.transfer-container {
    max-width: 48rem;
    margin: 2rem auto;
    padding: 1.5rem;
    font-family: inherit;
    color: #0f172a;
}

/* Without this, width: 100% + padding pushes buttons out of their cards on themes that don't reset box-sizing. */
.transfer-container *,
.transfer-container *::before,
.transfer-container *::after {
    box-sizing: border-box;
}

.transfer-route {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.transfer-input {
    flex: 1;
    max-width: 300px;
    padding: 0.75rem;
    border: 2px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    text-align: center;
    background: #f9fafb;
    cursor: default;
}

.transfer-input:focus {
    outline: none;
    border-color: #000;
}

.transfer-swap {
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    background: #f3f4f6;
    border-radius: 50%;
    transition: all 0.2s;
    user-select: none;
}

.transfer-swap:hover {
    background: #e5e7eb;
    transform: rotate(180deg);
}

.transfer-trip-type {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.transfer-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #fff;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.transfer-checkbox-label:hover {
    border-color: #cbd5e1;
}

.transfer-checkbox-label:has(input:checked) {
    border-color: #0f172a;
    color: #0f172a;
}

.transfer-checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: #0f172a;
    cursor: pointer;
}

.transfer-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.transfer-option-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    text-align: left;
    transition: border-color 0.2s ease;
}

.transfer-option-card:hover {
    border-color: #cbd5e1;
}

.transfer-option-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.transfer-option-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.75rem;
    background: #f1f5f9;
    color: #0f172a;
}

.transfer-option-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

.transfer-option-title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0;
    text-transform: none;
    color: #0f172a;
}

.transfer-option-price {
    margin: 1.25rem 0 0;
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: #0f172a;
}

.transfer-option-price small {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0;
    color: #64748b;
}

.transfer-disabled {
    color: #94a3b8;
}

/* Keeps the button pinned to the bottom so side-by-side cards line up. */
.transfer-button-oneway,
.transfer-button-roundtrip {
    margin-top: auto;
    padding-top: 1.25rem;
}

.transfer-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin: 0;
    padding: 0.8125rem 1.25rem;
    background: #0f172a;
    color: #fff !important;
    text-decoration: none !important;
    border: 1px solid #0f172a;
    border-radius: 0.75rem;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.transfer-button:hover {
    background: #1e293b;
    border-color: #1e293b;
}

.transfer-button:visited {
    color: #fff;
}

.transfer-button:focus-visible {
    outline: 2px solid #0f172a;
    outline-offset: 2px;
}

.transfer-button svg {
    width: 1rem;
    height: 1rem;
    transition: transform 0.2s ease;
}

.transfer-button:hover svg {
    transform: translateX(2px);
}

.transfer-button-disabled,
.transfer-button-disabled:hover {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #94a3b8 !important;
    cursor: not-allowed;
}

.transfer-button-text {
    display: inline;
    color: inherit;
}

.transfer-no-data-card {
    grid-column: 1 / -1;
    align-items: center;
    padding: 3rem 2rem;
    text-align: center;
}

.transfer-no-data-message {
    margin: 0.75rem 0 0;
    font-size: 1rem;
    color: #64748b;
}

.transfer-destinations-button {
    width: auto;
    margin-top: 1.5rem;
}

@media (max-width: 768px) {
    .transfer-container {
        padding: 1rem;
        margin: 1rem auto;
    }

    .transfer-route {
        flex-direction: column;
        gap: 0.75rem;
    }

    .transfer-input {
        max-width: 100%;
    }

    .transfer-swap {
        transform: rotate(90deg);
    }

    .transfer-swap:hover {
        transform: rotate(270deg);
    }

    .transfer-options {
        grid-template-columns: 1fr;
    }

    .transfer-option-card {
        padding: 1.25rem;
    }

    .transfer-option-price {
        font-size: 1.75rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .transfer-container {
        max-width: 42rem;
    }
}

/* Route search (empty route_id) */
.transfer-search {
    --tm-ink: #0f172a;
    --tm-text: #334155;
    --tm-muted: #64748b;
    --tm-faint: #94a3b8;
    --tm-line: #e2e8f0;
    --tm-soft: #f1f5f9;
    --tm-surface: #fff;
    --tm-radius: 1rem;
    font-family: inherit;
}

.transfer-search.tm-has-results {
    margin-bottom: 0;
    padding-bottom: 0;
}

.transfer-search.tm-has-results + .transfer-container {
    margin-top: 0;
    padding-top: 1.25rem;
}

.tm-bar {
    position: relative;
    display: flex;
    background: var(--tm-surface);
    border: 1px solid var(--tm-line);
    border-radius: var(--tm-radius);
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.tm-bar:focus-within {
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
}

.tm-field-chevron {
    flex: 0 0 auto;
    width: 1.125rem;
    height: 1.125rem;
    color: var(--tm-faint);
    transition: transform 0.2s ease, color 0.2s ease;
}

.tm-field:hover .tm-field-chevron,
.tm-field.is-open .tm-field-chevron {
    color: var(--tm-ink);
}

.tm-field.is-open .tm-field-chevron {
    transform: rotate(180deg);
}

.tm-field:has(.tm-field-input:disabled) .tm-field-chevron {
    color: #cbd5e1;
}

/* Divider between the two fields; the swap button sits on top of it. */
.tm-bar::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 22%;
    bottom: 22%;
    width: 1px;
    background: var(--tm-line);
}

.tm-field {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.75rem 0.875rem 1rem;
    border-radius: var(--tm-radius);
    cursor: text;
    transition: background-color 0.2s ease;
}

.tm-field[data-role="destination"] {
    padding: 0.875rem 1rem 0.875rem 1.75rem;
}

.tm-field:hover,
.tm-field.is-open {
    background: #f8fafc;
}

.tm-field-icon {
    position: relative;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.625rem;
    background: var(--tm-soft);
    color: var(--tm-ink);
}

.tm-field-icon svg {
    width: 1.1rem;
    height: 1.1rem;
}

.tm-field-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    margin: 0;
    cursor: text;
}

.tm-field-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tm-muted);
    line-height: 1.2;
}

/* Higher specificity than typical theme `input[type="text"]` rules. */
.transfer-search input.tm-field-input {
    width: 100%;
    margin: 0;
    padding: 0;
    height: auto;
    min-height: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    outline: none;
    font: inherit;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--tm-ink);
    text-overflow: ellipsis;
}

.transfer-search input.tm-field-input::placeholder {
    color: var(--tm-faint);
    font-weight: 400;
    opacity: 1;
}

.transfer-search input.tm-field-input:disabled {
    background: transparent;
    cursor: not-allowed;
}

.tm-field:has(.tm-field-input:disabled) {
    cursor: not-allowed;
}

.tm-field:has(.tm-field-input:disabled):hover {
    background: transparent;
}

.tm-field:has(.tm-field-input:disabled) .tm-field-icon {
    color: var(--tm-faint);
}

.transfer-search button.tm-swap {
    position: absolute;
    z-index: 2;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    margin: 0;
    padding: 0;
    border: 1px solid var(--tm-line);
    border-radius: 50%;
    background: var(--tm-surface);
    color: var(--tm-muted);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, transform 0.35s ease;
}

.transfer-search button.tm-swap:hover:not(:disabled) {
    color: var(--tm-ink);
    border-color: #cbd5e1;
    transform: translate(-50%, -50%) rotate(180deg);
}

.transfer-search button.tm-swap:disabled {
    color: #cbd5e1;
    box-shadow: none;
    cursor: default;
}

.transfer-search button.tm-swap:focus-visible {
    outline: 2px solid var(--tm-ink);
    outline-offset: 2px;
}

.tm-swap svg {
    width: 1rem;
    height: 1rem;
}

.tm-list {
    position: absolute;
    z-index: 30;
    top: calc(100% + 0.5rem);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: min(26rem, 90vw);
    max-height: 19rem;
    overflow-y: auto;
    margin: 0;
    padding: 0.375rem;
    list-style: none;
    background: var(--tm-surface);
    border: 1px solid var(--tm-line);
    border-radius: 0.875rem;
    box-shadow: 0 20px 45px -15px rgba(15, 23, 42, 0.28);
    animation: tm-pop 0.16s ease-out;
}

.tm-field[data-role="destination"] .tm-list {
    left: auto;
    right: 0;
}

@keyframes tm-pop {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.tm-list-caption {
    padding: 0.5rem 0.75rem 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tm-faint);
}

.tm-list-empty {
    padding: 0.75rem;
    font-size: 0.9375rem;
    color: var(--tm-muted);
}

.tm-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    padding: 0.625rem 0.75rem;
    border-radius: 0.625rem;
    font-size: 0.9375rem;
    color: var(--tm-text);
    cursor: pointer;
}

.tm-option.is-active {
    background: var(--tm-soft);
    color: var(--tm-ink);
}

.tm-option-icon {
    display: inline-flex;
    flex: 0 0 auto;
    color: var(--tm-faint);
}

.tm-option.is-active .tm-option-icon {
    color: var(--tm-ink);
}

.tm-option-icon svg {
    width: 1rem;
    height: 1rem;
}

.tm-option-label strong {
    font-weight: 600;
    color: var(--tm-ink);
}

/* Loading: the destination icon turns into a spinner while the page reloads. */
.tm-spinner {
    display: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--tm-line);
    border-top-color: var(--tm-ink);
    border-radius: 50%;
    animation: tm-spin 0.7s linear infinite;
}

.tm-bar.tm-loading [data-role="destination"] .tm-field-icon svg {
    display: none;
}

.tm-bar.tm-loading .tm-spinner {
    display: block;
}

.tm-bar.tm-loading {
    pointer-events: none;
}

@keyframes tm-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 640px) {
    .tm-bar {
        flex-direction: column;
    }

    .tm-bar::before {
        left: 1rem;
        right: 1rem;
        top: 50%;
        bottom: auto;
        width: auto;
        height: 1px;
    }

    .tm-field,
    .tm-field[data-role="destination"] {
        padding: 0.875rem 3.75rem 0.875rem 1rem;
    }

    .transfer-search button.tm-swap {
        left: auto;
        right: 1rem;
        transform: translateY(-50%) rotate(90deg);
    }

    .transfer-search button.tm-swap:hover:not(:disabled) {
        transform: translateY(-50%) rotate(270deg);
    }

    .tm-list,
    .tm-field[data-role="destination"] .tm-list {
        left: 0;
        right: 0;
        width: auto;
        max-width: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tm-list,
    .transfer-search button.tm-swap,
    .tm-spinner {
        animation: none;
        transition: none;
    }
}
