/* ============================================================
   SunFlightMap — v151-based layout
   ============================================================ */

/* --- Accessibility / SEO utilities --- */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* --- Global --- */
*, *::before, *::after { box-sizing: border-box; }

body, html {
    margin: 0; padding: 0;
    height: 100%; width: 100%;
    font-family: "Segoe UI", "Microsoft JhengHei", sans-serif;
    overflow-x: hidden;
    background-color: #f4f6f9;
}

/* --- App Container --- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    padding: 12px;
    gap: 8px;
    box-sizing: border-box;
}

/* ============================================================
   TOP DECK
   ============================================================ */
.top-deck {
    height: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    padding: 6px 16px;
    gap: 12px;
    flex-shrink: 0;
    z-index: 2000;
    border: 1px solid #f0f0f0;
}

/* --- Brand --- */
.brand-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 65px;
    margin-right: 8px;
}
.brand-icon {
    color: #007bff;
    font-size: 22px;
    margin-bottom: 5px;
}
.brand-name {
    font-size: 18px;
    font-weight: 800;
    color: #2c3e50;
    line-height: 1;
}
.brand-sub {
    font-size: 9px;
    color: #aaa;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 4px;
    font-weight: 600;
}
.brand-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

/* --- Matrix (input grid) --- */
.matrix-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.input-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 200px;
}

/* Primary input cell */
.stack-cell {
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border: 1.5px solid #e9ecef;
    border-radius: 10px;
    padding: 5px 10px;
    min-height: 46px;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    position: relative;
    cursor: text;
}
.stack-cell:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stack-cell:focus-within {
    background: #fff;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
    z-index: 10;
}

/* To field first-visit persistent glow */
input.dest-hint {
    border-radius: 6px;
    outline: 2px solid rgba(0,123,255,0.5);
    outline-offset: 2px;
}

/* Dur/Arr toggle rows */
.dur-arr-toggle {
    display: flex;
    flex-direction: column;
    border: 1.5px solid #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fa;
    position: relative;
}
.arr-cal-icon {
    position: absolute !important;
    right: 8px;
    bottom: 0;
    height: 38px !important;
    transform: none !important;
    top: auto !important;
}
.dar-row {
    display: flex;
    align-items: center;
    padding: 0 10px;
    height: 32px;
    gap: 7px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
    background: #fff;
    position: relative;
}
.dar-row + .dar-row { border-top: 1px solid #e9ecef; }
.dar-row.dar-active { background: #eaf3ff; }

/* Radio dot indicator */
.dar-row::before {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ccc;
    flex-shrink: 0;
    transition: border-color 0.15s, background 0.15s;
    box-sizing: border-box;
}
.dar-row.dar-active::before {
    border-color: #007bff;
    background: #007bff;
    box-shadow: inset 0 0 0 2px #fff;
}

.dar-icon {
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #ccc;
    flex-shrink: 0;
}
.dar-row.dar-active .dar-icon { color: #007bff; }

/* Custom SVG icons via CSS mask (inherit parent color) */
.icon-takeoff,
.icon-landing,
.icon-hourglass {
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    flex-shrink: 0;
}
.icon-takeoff {
    -webkit-mask: url('../assets/icons/plane-takeoff.svg') no-repeat center / contain;
    mask: url('../assets/icons/plane-takeoff.svg') no-repeat center / contain;
}
.icon-landing {
    -webkit-mask: url('../assets/icons/plane-landing.svg') no-repeat center / contain;
    mask: url('../assets/icons/plane-landing.svg') no-repeat center / contain;
}
.icon-hourglass {
    -webkit-mask: url('../assets/icons/hourglass.svg') no-repeat center / contain;
    mask: url('../assets/icons/hourglass.svg') no-repeat center / contain;
}
.dar-label {
    font-size: 13px;
    font-weight: 700;
    color: #adb5bd;
    flex-shrink: 0;
    padding-right: 6px;
    border-right: 1.5px solid #e9ecef;
    margin-right: 6px;
    white-space: nowrap;
}
.dar-row.dar-active .dar-label { color: #007bff; border-right-color: #007bff; }
.dar-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px !important;
    font-weight: 600;
    color: #000;
    font-family: inherit;
    outline: none;
    min-width: 0;
    padding: 0;
    line-height: 1;
    -moz-appearance: textfield;
}
.dar-input::placeholder { color: #ccc; font-weight: 400; font-size: 13px; }
.dar-input::-webkit-outer-spin-button,
.dar-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.dar-unit { font-size: 16px; font-weight: 600; color: #2c3e50; flex-shrink: 0; visibility: hidden; }
.dar-auto { font-size: 16px; color: #bbb; flex: 1; display: none; }

/* Duration value row: input + unit hugged together */
.dur-value-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex: 1;
    min-width: 0;
    position: relative;
}
.dur-value-row .dar-input { flex: 0 0 auto; min-width: 0; }
.dur-mirror {
    position: absolute;
    visibility: hidden;
    white-space: pre;
    pointer-events: none;
}

/* Inactive row: read-only display, calendar hidden */
.dar-row:not(.dar-active) .dar-input {
    color: #2c3e50;
    pointer-events: none;
}
.dar-row:not(.dar-active) .dar-unit { color: #2c3e50; }
#darDur:not(.dar-active) .cal-icon { display: none; }

.mini-cell {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1.5px solid #e9ecef;
    border-radius: 10px;
    padding: 0 8px;
    height: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
    position: relative;
    min-width: 0;
}
.mini-cell:focus-within {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
    z-index: 10;
}
.mini-cell.readonly {
    background: #f5f6f7;
    border-color: #eee;
}
.mini-cell.readonly .clean-input { color: #bbb; pointer-events: none; }

#arrBox { flex: 1; }

/* Cell body: vertical stack of label + input */
.cell-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

/* Cell internals */
.cell-label {
    font-size: 11px;
    font-weight: 700;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
    line-height: 1;
}
.stack-cell:focus-within .cell-label { color: #007bff; }

.cell-icon {
    width: 22px;
    flex-shrink: 0;
    text-align: center;
    color: #bbb;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
}
/* Cell icon sizes */
.cell-icon i { font-size: 20px; }
.cell-icon .fa-circle { font-size: 12px; }

.clean-input {
    border: none;
    background: transparent;
    font-size: 16px;
    font-weight: 600;
    color: #000;
    width: 100%;
    outline: none;
    line-height: 1;
    padding: 0;
    min-width: 0;
    transition: font-size 0.2s ease;
    font-family: inherit;
}
.clean-input::placeholder {
    color: #ccc;
    font-weight: 400;
    font-size: 13px;
}
/* Override flatpickr's font-size on depTime/arrTime */
#depTime, #arrTime { font-size: 16px !important; }
/* Smooth font-size transition for fitBannerFonts() — arrTime only (#depTime inherits from .clean-input) */
#arrTime { transition: font-size 0.2s ease; }

.clean-input:disabled {
    color: #bbb;
    cursor: default;
}

.unit-label {
    font-size: 9px;
    color: #aaa;
    font-weight: 700;
    margin-left: 3px;
    flex-shrink: 0;
}

/* Clear button */
.clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background-color: #ccc;
    -webkit-mask: url('../assets/icons/delete.svg') no-repeat center / contain;
    mask: url('../assets/icons/delete.svg') no-repeat center / contain;
    cursor: pointer;
    display: none;
    z-index: 5;
    transition: background-color 0.15s;
}
.clear-btn.visible { display: block; }
.clear-btn:hover { background-color: #888; }

.globe-icon {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    opacity: 0.35;
    cursor: pointer;
    z-index: 5;
    transition: opacity 0.15s;
}
.globe-icon:hover { opacity: 0.65; }
.globe-icon.hidden { display: none; }

/* Airport flag shown inside origin/dest cell after selection */
.input-flag {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    display: none;
    z-index: 4;
    line-height: 1;
    border-radius: 2px;
    overflow: hidden;
}

/* Calendar icon (inside depTime / arrTime cells) */
.cal-icon {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    display: block;
    background-color: #bbb;
    -webkit-mask: url('../assets/icons/calendar.svg') no-repeat center / contain;
    mask: url('../assets/icons/calendar.svg') no-repeat center / contain;
    cursor: pointer;
    z-index: 5;
    transition: background-color 0.15s;
    pointer-events: auto;
    flex-shrink: 0;
}
.cal-icon:hover { background-color: #555; }

/* Prevent input text from going under the cal-icon */
#depTime, #arrTime { padding-right: 30px; }

/* Timezone badge */
.tz-badge-float {
    position: absolute;
    right: 6px;
    top: 5px;
    font-size: 11px;
    font-weight: 700;
    background: #007bff;
    color: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 20;
}

/* Suggestions dropdown */
.suggestions-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 9999;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.suggestion-item {
    padding: 8px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #f8f8f8;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:nth-child(even) { background: #f6f8fb; }
.suggestion-item:hover { background: #e8f1ff; }
.suggestion-current { border-bottom: 2px double #bbb !important; background: #f0f4ff !important; }
.suggestion-current:hover { background: #e2eaff !important; }

.row-codes { display: flex; align-items: baseline; gap: 5px; flex-shrink: 0; min-width: 70px; }
.code-iata { font-size: 14px; font-weight: 800; color: #007bff; }
.code-icao { font-size: 10px; color: #aaa; font-weight: 600; }
.row-name { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.city-text { font-size: 12px; font-weight: 600; color: #444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flag-icon { flex-shrink: 0; font-size: 14px; border: 1px solid #e0e0e0; border-radius: 2px; }
.match-highlight { color: #007bff; }

/* --- Swap button --- */
.swap-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0 2px;
}
.swap-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #ddd;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.3s;
    font-size: 12px;
}
.swap-btn:hover {
    color: #007bff;
    border-color: #007bff;
    background: #f0f7ff;
    transform: rotate(180deg);
}

/* --- Controls group (simulate + fun) --- */
.controls-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
    padding-left: 16px;
    border-left: 1px solid #eee;
    flex-shrink: 0;
}

/* Hidden radio (used inside dar-row labels) */
.hidden-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

/* Simulate button */
.btn-simulate {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: #fff;
    border: none;
    padding: 0 20px;
    height: 40px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    white-space: nowrap;
    letter-spacing: 0.3px;
    animation: sim-pulse 2.4s ease-in-out infinite;
}
.btn-simulate:hover {
    transform: translateY(-2px);
    animation: none;
    box-shadow: 0 8px 24px rgba(0,123,255,0.6);
}
.btn-simulate .fa-paper-plane { transition: transform 0.2s; }
.btn-simulate:hover .fa-paper-plane { transform: translateX(3px); }
@keyframes sim-pulse {
    0%   { box-shadow: 0 4px 16px rgba(0,123,255,0.4), 0 0 0 0   rgba(0,123,255,0.4); }
    60%  { box-shadow: 0 4px 16px rgba(0,123,255,0.25), 0 0 0 9px rgba(0,123,255,0); }
    100% { box-shadow: 0 4px 16px rgba(0,123,255,0.4), 0 0 0 0   rgba(0,123,255,0); }
}

.sim-share-wrap {
    display: flex;
    flex-direction: row;
    gap: 6px;
    align-items: center;
}
.btn-simulate { flex: 1; }

.btn-icon-share {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    border: 1.5px solid #dee2e6;
    background: #fff;
    color: #666;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.btn-icon-share:hover {
    border-color: #007bff;
    color: #007bff;
    background: #f0f7ff;
}

.btn-share {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #555;
    border: 1.5px solid #ccc;
    border-radius: 10px;
    padding: 0 14px;
    height: 42px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s, color 0.2s, transform 0.2s;
}
.btn-share:hover {
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-1px);
}

.btn-recommend:hover {
    border-color: #f5a623;
    color: #f5a623;
}

/* ============================================================
   RECOMMEND MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: #fff;
    border-radius: 16px;
    padding: 28px 28px 24px;
    width: 360px;
    max-width: calc(100vw - 32px);
    position: relative;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    font-size: 16px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
}
.modal-close:hover { color: #333; }

.modal-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
}

.modal-route-info {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-route-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-route-label {
    font-size: 11px;
    color: #999;
    min-width: 52px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.modal-route-value {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

.modal-share-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
}
.modal-share-url {
    flex: 1;
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: monospace;
}
.modal-copy-btn {
    flex-shrink: 0;
    background: #fff;
    border: 1.5px solid #dee2e6;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s, color 0.2s;
}
.modal-copy-btn:hover { border-color: #007bff; color: #007bff; }

.modal-textarea {
    width: 100%;
    height: 80px;
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.modal-textarea:focus { border-color: #007bff; }

.modal-msg {
    font-size: 13px;
    margin: 10px 0 0;
    line-height: 1.5;
}

.modal-submit-btn {
    margin-top: 14px;
    width: 100%;
    height: 42px;
    background: #2c3e50;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.modal-submit-btn:hover:not(:disabled) { background: #34495e; }
.modal-submit-btn:disabled { background: #aaa; cursor: not-allowed; }
.modal-close-btn { background: #6c757d; margin-top: 8px; }
.modal-close-btn:hover { background: #5a6268; }

/* --- Try Something Fun dropdown --- */
.fun-menu-wrap {
    position: relative;
}
.btn-fun {
    width: 100%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 0 20px;
    height: 40px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    white-space: nowrap;
    letter-spacing: 0.3px;
    transition: transform 0.15s, box-shadow 0.15s;
    animation: fun-pulse 2.4s ease-in-out infinite;
}
.btn-fun:hover {
    transform: translateY(-2px);
    animation: none;
    box-shadow: 0 8px 24px rgba(102,126,234,0.6);
}
.btn-fun .fa-compass { transition: transform 0.5s ease; }
.btn-fun:hover .fa-compass { transform: rotate(180deg); }
@keyframes fun-pulse {
    0%   { box-shadow: 0 4px 16px rgba(102,126,234,0.4), 0 0 0 0   rgba(102,126,234,0.4); }
    60%  { box-shadow: 0 4px 16px rgba(102,126,234,0.25), 0 0 0 9px rgba(102,126,234,0); }
    100% { box-shadow: 0 4px 16px rgba(102,126,234,0.4), 0 0 0 0   rgba(102,126,234,0); }
}

/* --- Fun Modal --- */
.fun-modal-box {
    width: 520px;
    max-width: calc(100vw - 32px);
    padding: 24px 24px 20px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.fun-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid #f0f0f0;
}

.fun-tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}
.fun-tab-btn.active { color: #667eea; border-bottom-color: #667eea; }
.fun-tab-btn:hover:not(.active) { color: #555; }

.fun-tab-content { display: none; flex-direction: column; gap: 10px; }
.fun-tab-content.active { display: flex; }

.fun-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1.5px solid #eee;
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    background: #fff;
}
.fun-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 16px rgba(102,126,234,0.12);
    background: #f8f7ff;
}

.fun-card-emoji {
    font-size: 26px;
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}

.fun-card-model {
    flex-shrink: 0;
    width: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 14px;
    font-weight: 800;
    color: #2c3e50;
    line-height: 1.25;
    border-right: 1.5px solid #e0e0e0;
    padding-right: 14px;
    margin-right: 2px;
}

.fun-card-body { flex: 1; min-width: 0; }

.fun-card-title {
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 3px;
}

.fun-card-route {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 3px;
    font-family: monospace;
    letter-spacing: 0.04em;
}

.fun-card-desc {
    font-size: 12px;
    color: #888;
    line-height: 1.4;
}
/* When accordion has no label, tagline becomes the primary text */
.fun-card-title--tagline {
    font-size: 13px;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1.4;
    margin-bottom: 0; /* override fun-card-title margin so it centers properly */
}

.fun-card-arrow {
    color: #ccc;
    font-size: 18px;
    flex-shrink: 0;
    transition: color 0.15s, transform 0.15s;
}
.fun-card:hover .fun-card-arrow { color: #667eea; transform: translateX(3px); }

/* --- Accordion (family variants) --- */
.fun-accordion { /* container only */ }

.fun-acc-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    cursor: pointer;
    background: #fff;
    border: 1.5px solid #eee;
    border-radius: 12px;
    transition: background 0.15s, border-color 0.15s;
}
.fun-acc-header:hover { background: #fafafa; border-color: #d0d0e8; }
/* When open: right side connects to body → remove bottom-right radius */
.fun-accordion:has(.fun-acc-body.open) .fun-acc-header {
    border-bottom-right-radius: 0;
}

.fun-acc-arrow {
    color: #999;
    font-size: 22px;
    flex-shrink: 0;
    transition: transform 0.2s;
    user-select: none;
}
.fun-acc-arrow.open { transform: rotate(180deg); }

/* Body drops from | position: header-left-pad(16) + badge total width(52, border-box) = 68px
   Measured via CDP: badge.right - accordion.left = 69px */
.fun-acc-body {
    display: none;
    position: relative;
    margin-left: 69px;
    margin-top: -1.5px;          /* overlap header bottom border → visually attached */
    border: 1.5px solid #eee;
    border-radius: 0 0 10px 10px; /* top corners square; bottom corners rounded */
    overflow: hidden;
    background: #fff;
}
.fun-acc-body.open { display: block; }

.fun-variant-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    transition: background 0.12s;
}
.fun-variant-row:last-child { border-bottom: none; }
.fun-variant-row:nth-child(even) { background: #f6f5ff; }  /* zebra stripe */
.fun-variant-row:hover { background: #eeecff !important; }

.fun-variant-submodel {
    font-size: 12px;
    font-weight: 700;
    color: #2c3e50;
    min-width: 62px;
    flex-shrink: 0;
}
.fun-variant-info { flex: 1; min-width: 0; }
.fun-variant-main {
    font-size: 12px;
    font-weight: 600;
    color: #444;
    margin-bottom: 2px;
}
.fun-variant-iata {
    color: #667eea;
    font-family: monospace;
    font-weight: 700;
}
.fun-variant-stats { font-size: 11px; color: #aaa; }
.fun-variant-arrow {
    color: #ccc;
    font-size: 15px;
    flex-shrink: 0;
    transition: color 0.15s;
}
.fun-variant-row:hover .fun-variant-arrow { color: #667eea; }

/* --- Fun Modal Sub-tabs --- */
.fun-subtabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.fun-subtab-btn {
    background: #f4f4f6;
    border: none;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.fun-subtab-btn.active {
    background: #667eea;
    color: #fff;
}
.fun-subtab-btn:hover:not(.active) { background: #e8e8f0; color: #555; }

.fun-subtab-content-wrap { flex: 1; }
.fun-subtab-content { display: none; flex-direction: column; gap: 10px; }
.fun-subtab-content.active { display: flex; }

/* ============================================================
   MAIN STAGE
   ============================================================ */
.main-stage {
    flex: 1;
    display: flex;
    gap: 12px;
    overflow: hidden;
    min-height: 0;
}

/* ============================================================
   SIDEBAR PANEL
   ============================================================ */
.sidebar-panel {
    flex: 4 4 0;
    min-width: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #f0f0f0;
}

.sb-header-slim {
    padding: 10px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-size: 10px;
    font-weight: 800;
    color: #aaa;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.sb-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Section headers */
.section-header {
    font-size: 12px;
    font-weight: 800;
    color: #adb5bd;
    margin-bottom: 4px;
    margin-top: 8px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.section-header:first-child { margin-top: 0; }


/* FlightAware route textarea */
.route-textarea {
    width: 100%;
    height: 75px;
    border: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 8px 10px;
    font-family: monospace;
    font-size: 11px;
    resize: none;
    box-sizing: border-box;
    color: #444;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}
.route-textarea:focus { background: #fff; border-color: #007bff; }

.status-msg {
    font-size: 11px;
    color: #888;
    margin: 4px 0;
    min-height: 14px;
}

.btn-parse {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
}
.btn-parse:hover { background: #007bff; color: #fff; border-color: #007bff; }

/* Analysis content toggle */
#drawerContent { display: none; }
#drawerContent.open {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.collapse-btn {
    background: none;
    border: none;
    font-size: 10px;
    color: #bbb;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
}
.collapse-btn:hover { background: #f0f0f0; color: #666; }

/* Flight progress slider */
.slider-wrap { margin-bottom: 2px; flex-shrink: 0; }
.slider-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    font-weight: 700;
    color: #555;
    margin-bottom: 2px;
}
.slider-top-row {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
}
.slider-top-row > span {
    flex: 1;
    min-width: min-content;
}
.slider-top-row > span:empty {
    flex: 0;
    min-width: 0;
}
#distanceRow {
    overflow: visible;
    white-space: nowrap;
}
.slider-stats-row {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}
.slider-stats-row > span {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 3px;
    min-width: min-content;
}
.stat-lbl {
    font-size: 13px;
    color: #aaa;
    font-weight: 600;
    white-space: nowrap;
}

.play-btn-group {
    display: flex;
    align-items: center;
    gap: 5px;
}
.play-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: #007bff;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.15s;
}
.play-btn:hover:not(:disabled) { background: #0056b3; }
.play-btn:disabled { background: #ccc; cursor: not-allowed; }
.play-label {
    font-size: 13px;
    color: #888;
    white-space: nowrap;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
}
input[type=range]::-webkit-slider-thumb {
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: #007bff;
    margin-top: -5px;
    -webkit-appearance: none;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input[type=range]:disabled::-webkit-slider-thumb { background: #ccc; }

/* Seat exposure bars */
.seats-col-inner {
    position: relative;
    padding: 0;
    flex-shrink: 0;
}
.seat-section + .seat-section { margin-top: 4px; }
.seat-section { }
.seat-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}
.seat-label {
    font-size: 13px;
    font-weight: 700;
    color: #888;
}
.stats-inline {
    font-size: 13px;
    color: #666;
    display: flex;
    gap: 6px;
    align-items: center;
}
.stat-item {
    display: flex;
    align-items: center;
    gap: 3px;
}
.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.bar-track {
    display: flex;
    background: #f1f3f5;
    border-radius: 4px;
    height: 12px;
    overflow: hidden;
    position: relative;
    --cursor-pct: 100%;
}
.bar-track::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: var(--cursor-pct);
    right: 0;
    background: rgba(255,255,255,0.6);
    pointer-events: none;
    transition: none;
}
.bar-seg    { border-radius: 0; }
.bg-glare   { background: #ffc107; }
.bg-backlit { background: #87ceeb; }
.bg-night   { background: #2c3e50; }

.seat-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: #ffc107;
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 6px;
    vertical-align: middle;
    line-height: 1.4;
}

/* Solar profile chart header */
#solarChartHeader { flex-shrink: 0; }

/* Solar profile chart */
.chart-col-inner {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}
.chart-box {
    flex: 1;
    height: auto;
    min-height: 120px;
    background: #fff;
    border-radius: 8px;
    position: relative;
    border: 1px solid #f0f0f0;
    overflow: hidden;
}

/* Drag-sync cursor overlay */
.cursor-track-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    cursor: crosshair;
    z-index: 100;
}
.sync-cursor { display: none; }

/* ============================================================
   MAP CARD
   ============================================================ */
.map-card {
    flex: 6 6 0;
    min-width: 0;
    background: #aad3df;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    overflow: hidden;
    position: relative;
    border: 4px solid #fff;
    opacity: 0;
    transition: opacity 0.4s ease;
}
#map {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
}

.copyright-tag {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: 10px;
    color: #555;
    z-index: 500;
    background: rgba(255,255,255,0.8);
    padding: 2px 7px;
    border-radius: 4px;
    backdrop-filter: blur(2px);
}
.copyright-tag a { color: #444; text-decoration: none; }
.copyright-tag a:hover { color: #007bff; }

/* ============================================================
   LIVE BADGE & HUD OVERLAY
   ============================================================ */
.live-badge {
    position: absolute;
    top: 14px;
    left: 14px;
    background: rgba(255,255,255,0.95);
    padding: 5px 12px 5px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1500;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.5s ease;
    cursor: default;
}
.live-label {
    font-size: 12px;
    font-weight: 700;
    color: #e74c3c;
}
.live-divider {
    width: 1px;
    height: 26px;
    background: rgba(0,0,0,0.1);
    flex-shrink: 0;
}
.live-info {
    display: block;
    white-space: nowrap;
}
.lt-main {
    font-size: 11px;
    font-weight: 600;
    color: #1e2733;
}
.lt-country {
    font-size: 10px;
    font-weight: 400;
    color: rgba(0,0,0,0.45);
    margin-top: 1px;
}
.live-dot {
    width: 8px;
    height: 8px;
    background: #e74c3c;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0%   { opacity: 1; transform: scale(1); }
    50%  { opacity: 0.4; transform: scale(1.3); }
    100% { opacity: 1; transform: scale(1); }
}

.hud-overlay {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    gap: 8px;
    z-index: 1500;
}
.hud-box {
    background: #1e2733;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    min-width: 54px;
}
.hud-accent-cyan   { border-left: 3px solid #00e5ff; }
.hud-accent-white  { border-left: 3px solid #ffffff; }
.hud-accent-yellow { border-left: 3px solid #FFD700; }
.hud-label {
    font-size: 9px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.hud-value {
    font-family: "Consolas", "Courier New", monospace;
    font-size: 15px;
    font-weight: 700;
}
.val-cyan  { color: #00e5ff; }
.val-white { color: #fff; }

/* ============================================================
   LEAFLET OVERRIDES
   ============================================================ */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    border-radius: 8px !important;
}
.leaflet-control-zoom a {
    border-radius: 6px !important;
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
}
.leaflet-control-layers {
    border: none !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
}
.leaflet-control-layers-toggle {
    width: 30px !important;
    height: 30px !important;
    background-size: 16px 16px !important;
}
.leaflet-control-custom {
    background: #fff;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-size: 13px;
    color: #555;
    border: none !important;
}
.leaflet-control-custom:hover { color: #007bff; }
.zoom-level-display {
    background: #fff;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    color: #555;
    letter-spacing: 0.5px;
    cursor: default;
    user-select: none;
    min-width: 30px;
    text-align: center;
}

/* ============================================================
   MAP MARKERS
   ============================================================ */
.plane-emoji {
    font-size: 26px;
    display: block;
    transition: transform 0.1s linear;
}
.sun-icon { font-size: 28px; filter: drop-shadow(0 0 8px gold); }

.airport-wrapper { display: flex; flex-direction: column; align-items: center; }
.airport-icon-inner {
    font-size: 20px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.airport-label {
    font-size: 10px;
    font-weight: 700;
    background: rgba(255,255,255,0.92);
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: -2px;
    color: #333;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.airport-marker       { background: transparent !important; border: none !important; pointer-events: none !important; }
.airport-label-marker { background: transparent !important; border: none !important; }
.marker-origin .airport-icon-inner { color: #2ecc71; }
.marker-dest   .airport-icon-inner { color: #e74c3c; }
.push-down { margin-top: 24px; }
.push-up   { margin-top: -28px; }

.wpt-popup-title  { font-size: 12px; font-weight: 700; color: #333; }
.wpt-popup-coords { font-size: 10px; color: #888; }

/* Airport label hover tooltip (FR24-style) */
.leaflet-tooltip.ap-tip {
    background: #1c1c2e;
    border: 1px solid #3a3a5c;
    border-radius: 7px;
    color: #fff;
    padding: 7px 11px;
    font-family: inherit;
    font-size: 12px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.65);
    white-space: normal;
    pointer-events: none;
}
.leaflet-tooltip-top.ap-tip::before {
    border-top-color: #3a3a5c;
}
.ap-tip-name {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 4px;
    white-space: pre;
}
.ap-tip-codes { display: flex; align-items: center; gap: 4px; margin-top: 5px; }
.ap-iata {
    font-weight: 700;
    font-size: 13px;
    color: #4fc3f7;
    letter-spacing: 0.04em;
}
.ap-sep { color: #666; font-size: 12px; }
.ap-icao {
    font-size: 12px;
    color: #9e9e9e;
    letter-spacing: 0.04em;
}

/* ============================================================
   MISC
   ============================================================ */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   RESPONSIVE — MOBILE (< 768px)
   ============================================================ */
@media (max-width: 950px) {

    /* Allow vertical scroll on mobile, block horizontal overflow */
    body, html {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
    }

    /* App container: full-page scrollable block
       用 width:100% 而非 100vw，避免 Windows scrollbar(15px) 把右側邊框裁掉 */
    .app-container {
        width: 100%;
        height: auto;
        min-height: 100vh;
        padding: 8px;
        gap: 8px;
        overflow-x: hidden;
        overflow-y: visible;
    }

    /* ── TOP DECK ── */
    .top-deck {
        height: auto;
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
        gap: 8px;
        border-radius: 12px;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Brand: compact horizontal row */
    .brand-area {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        min-width: unset;
        margin-right: 0;
        gap: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid #f0f0f0;
    }
    .brand-icon { margin-bottom: 0; font-size: 18px; }
    .brand-name { font-size: 16px; }
    .brand-sub  { display: none; }

    /* Matrix: 2×2 grid — [左欄 45%] [swap 10%] [右欄 45%] */
    .matrix-container {
        flex-direction: row;
        align-items: center;
        gap: 4px;
    }

    .input-stack {
        flex: 1;
        min-width: 0;
        width: auto;
        gap: 4px;
    }

    /* Swap zone: fixed width, centered vertically */
    .swap-zone {
        flex-shrink: 0;
        padding: 0 2px;
    }

    /* Compact cells on mobile */
    .stack-cell {
        min-height: 44px;
        padding: 4px 8px;
    }
    .mini-cell {
        height: 38px;
        padding: 0 6px;
    }
    .split-row { height: 38px; gap: 4px; }
    #arrBox { flex: 1; }

    /* Slightly smaller text to fit narrow cells */
    .stack-cell .clean-input,
    .mini-cell  .clean-input { font-size: 16px; }
    .cell-icon { width: 18px; margin-right: 4px; }
    .cell-icon i { font-size: 13px; }
    .cal-icon { width: 18px; height: 18px; }
    #depTime, #arrTime { padding-right: 26px; }

    .controls-group {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding-left: 0;
        border-left: none;
        padding-top: 8px;
        border-top: 1px solid #eee;
        gap: 8px;
    }

    /* Simulate button: fill col 2 */
    .btn-simulate {
        width: 100%;
        justify-content: center;
    }

    .fun-menu-wrap { flex: unset; width: 100%; }
    .btn-fun {
        width: 100%;
        justify-content: center;
    }
    /* ── MAIN STAGE ── */
    .main-stage {
        flex-direction: column;
        overflow: visible;
        overflow-x: hidden;
        min-height: unset;
        gap: 8px;
        max-width: 100%;
    }

    /* Map: full width, 50vh — appears FIRST on mobile */
    .map-card {
        order: 1;
        width: 100%;
        height: 50vh;
        min-height: 250px;
        flex: unset;
        border-radius: 10px;
    }

    /* Sidebar: full width, appears BELOW map on mobile */
    .sidebar-panel {
        order: 2;
        width: 100%;
        flex-shrink: unset;
        border-radius: 10px;
        overflow: visible;
        height: auto;
    }

    .sb-scroll {
        overflow: visible;
        padding: 10px 12px;
    }

    /* Drawer always open on mobile */
    #drawerContent { display: block !important; }

    /* Collapse button hidden on mobile */
    .collapse-btn { display: none; }

    /* Suggestions list: ensure full width on mobile */
    .suggestions-list { max-height: 220px; }

    /* Seat bars / chart: ensure no horizontal overflow */
    .seats-col-inner { overflow: hidden; }

    /* Chart: fixed height on mobile (flex:1 無法在 block 容器生效) */
    .chart-col-inner { overflow: hidden; height: auto; min-height: unset; }
    .chart-box { height: 280px; min-height: unset; flex: unset; }


}

@media (max-width: 75em) {
    /* slider：≤1200px (含 mobile/zoom) 統一 — 自動播放獨佔一行，其他 2×2 */
    .slider-top-row { flex-wrap: wrap; gap: 4px; }
    .slider-top-row > span:first-child  { flex: 0 0 100%; }   /* 自動播放：整行 */
    .slider-top-row > span:nth-child(3) { display: none; }    /* 空佔位：隱藏 */
    .slider-top-row > span:nth-child(2),
    .slider-top-row > span:nth-child(4) { flex: 1 1 45%; }   /* 大圓距離 / 航程進度：各半 */

    /* slider-stats-row：2×2 */
    .slider-stats-row { flex-wrap: wrap; gap: 4px; }
    .slider-stats-row > span { flex: 1 1 45%; align-items: flex-start; }
}

/* ============================================================
   BANNER DESIGN2 — 5欄橫排，swap 圓圈騎邊界
   ============================================================ */

/* top-deck: 子元素撐滿高度 */
body.banner-design2 .top-deck { align-items: stretch; padding: 8px 16px; }
body.banner-design2 .brand-area,
body.banner-design2 .controls-group { align-self: center; }
/* 固定 controls-group 為 EN 自然寬度，讓 ZH 輸入欄位與 EN 等寬 */
body.banner-design2 .controls-group { flex: 0 0 185px; width: 185px; }

/* matrix-container: flex，各欄用固定百分比強制等寬，不依賴 flex-grow */
body.banner-design2 .matrix-container {
    gap: 0;
    align-items: stretch;
    border: 1.5px solid #e0e3e8;
    border-radius: 14px;
    background: #fff;
    overflow: visible;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

/* .input-stack 透明包裝，子元素直接成為 flex items */
body.banner-design2 .input-stack { display: contents; }

/* 欄位順序 + 固定寬度：3個 stack-cell 各佔 20%，dur-arr 佔 40%，swap 佔 0 */
body.banner-design2 #origin-cell    { order: 1; flex: 0 0 20%; min-width: 0; max-width: 20%; }
body.banner-design2 .swap-zone      { order: 2; flex: 0 0 0; }
body.banner-design2 #dest-cell      { order: 3; flex: 0 0 20%; min-width: 0; max-width: 20%; padding-left: 24px; }
body.banner-design2 #deptime-cell   { order: 4; flex: 0 0 20%; min-width: 0; max-width: 20%; }
body.banner-design2 .dur-arr-toggle { order: 5; flex: 0 0 40%; min-width: 0; max-width: 40%; }

/* Stack-cells: grid 佈局，icon + label 同行，input 在第二行 */
body.banner-design2 .stack-cell {
    display: grid;
    grid-template-columns: 20px 1fr;
    align-content: center;
    row-gap: 2px; column-gap: 3px;
    border: none;
    border-right: 1px solid #e9ecef;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    min-height: 68px;
    min-width: 0;
    padding: 6px 14px;
}
body.banner-design2 #origin-cell { border-radius: 12px 0 0 12px; }
body.banner-design2 .stack-cell:hover { background: #f9fbff; }
body.banner-design2 .stack-cell:focus-within { background: #f0f6ff; box-shadow: none; }
/* dest-cell hover/focus：z-index 確保在 origin-cell 之上；box-shadow 往左蓋住 border-right 白縫 */
body.banner-design2 #dest-cell:hover {
    position: relative; z-index: 5;
    box-shadow: -4px 0 0 0 #f9fbff;
}
body.banner-design2 #dest-cell:focus-within {
    box-shadow: -4px 0 0 0 #f0f6ff;
}
/* cell-body 透明包裝，子元素直接成為 grid items */
body.banner-design2 .cell-body { display: contents; }
body.banner-design2 .stack-cell .cell-icon {
    grid-column: 1; grid-row: 1;
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    align-self: center; justify-self: center;
}
body.banner-design2 .stack-cell .cell-icon i { font-size: 18px; }
body.banner-design2 .stack-cell .cell-icon .icon-takeoff { width: 18px; height: 18px; }
body.banner-design2 #deptime-cell { column-gap: 8px; }
body.banner-design2 .stack-cell .cell-icon { color: #555; }
body.banner-design2 .stack-cell .cell-label {
    grid-column: 2; grid-row: 1;
    font-size: 14px; font-weight: 900;
    font-family: 'Noto Sans TC', "Segoe UI", "Microsoft JhengHei", sans-serif;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: #999;
}
body.banner-design2 .stack-cell:focus-within .cell-label { color: #007bff; }
body.banner-design2 .stack-cell:focus-within .cell-icon  { color: #007bff; }
body.banner-design2 .stack-cell .clean-input {
    grid-column: 1 / 3; grid-row: 2;
}
/* Globe icon: 暫時隱藏 */
body.banner-design2 #origin-cell .globe-icon,
body.banner-design2 #dest-cell .globe-icon { display: none; }
/* Cal icon: 恢復顯示（position absolute 不影響 grid 佈局） */

/* Swap zone: 寬度 0，圓圈 absolute 騎在邊界上 */
/* z-index: 20 確保永遠在 focus-within 的 z-index:10 之上 */
body.banner-design2 .swap-zone {
    width: 0; flex: 0 0 0;
    position: relative; z-index: 20;
    align-self: center;
}
body.banner-design2 .swap-btn {
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 2px solid #d0d5dd;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: #555;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    cursor: pointer; padding: 0;
    transition: box-shadow 0.2s, border-color 0.2s, color 0.2s;
}
body.banner-design2 .swap-btn:hover {
    border-color: #007bff; color: #007bff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.2);
}

/* Origin clear-btn：往左移，避開 swap 按鈕（swap 半徑 16px + 視覺間距 8px = 24px） */
body.banner-design2 #origin-cell .clear-btn { right: 24px; }

/* Dur-Arr toggle: 左右並排 */
body.banner-design2 .dur-arr-toggle {
    flex-direction: row;
    border: none;
    border-radius: 0 12px 12px 0;
    background: transparent;
    overflow: visible;
    min-height: 68px;
}
body.banner-design2 .arr-cal-icon { display: none; }
body.banner-design2 #arrTime { padding-right: 4px; }
body.banner-design2 #depTime { padding-right: 4px; }
body.banner-design2 .cal-icon { background-color: #666; }
body.banner-design2 .dar-row {
    flex: 1; flex-direction: row; flex-wrap: wrap;
    align-items: center; align-content: center;
    justify-content: flex-start;
    height: 100%; min-height: 68px;
    min-width: 0;
    padding: 8px 14px 6px 14px;
    gap: 0; position: relative;
    background: transparent;
}
body.banner-design2 .dar-row.dar-active { background: #f0f6ff; }
/* 飛行時長(darDur)和抵達時間(darArr)左右互換：arr 在左，dur 在右 */
body.banner-design2 #darArr { order: 1; border-right: 1px solid #e9ecef; }
body.banner-design2 #darDur { order: 2; border-radius: 0 12px 12px 0; }
body.banner-design2 .dar-row:last-child { border-radius: 0; }
body.banner-design2 .dar-row + .dar-row { border-top: none; border-left: 1px solid #e9ecef; }
body.banner-design2 .dar-row::before { display: none; }
body.banner-design2 .dar-icon {
    flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; margin-right: 6px;
    color: #555;
}
body.banner-design2 .dar-icon .icon-landing  { width: 18px; height: 18px; }
body.banner-design2 #darArr .dar-icon { margin-right: 9px; }
body.banner-design2 #darDur .dar-icon { margin-right: 4px; }
body.banner-design2 .dar-icon .icon-hourglass { width: 18px; height: 18px; }
body.banner-design2 .dar-label {
    flex: 1;
    font-size: 14px; font-weight: 900; color: #999;
    font-family: 'Noto Sans TC', "Segoe UI", "Microsoft JhengHei", sans-serif;
    border-right: none; padding-right: 0; margin-right: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    line-height: 1; min-width: 0;
    user-select: text; /* 允許滑鼠反白選取，覆蓋 .dar-row 的 user-select: none */
}
body.banner-design2 .dar-row.dar-active .dar-label { color: #007bff; }
body.banner-design2 .dar-input {
    flex: 0 0 100%;
    font-size: 16px !important; font-weight: 600;
    color: #2c3e50; pointer-events: auto;
    margin-top: 2px;
}
body.banner-design2 .dar-row:not(.dar-active) .dar-input { color: #2c3e50; }
body.banner-design2 .dar-auto { display: none !important; }

/* Duration value row in design2: wrapper takes the full line, input auto-sizes */
body.banner-design2 .dur-value-row {
    flex: 0 0 100%;
    margin-top: 2px;
    align-items: baseline;
}
body.banner-design2 .dur-value-row .dar-input {
    flex: 0 0 auto;
    margin-top: 0;
}
body.banner-design2 .dar-row:not(.dar-active) .dar-unit { color: #2c3e50; }

/* Font scaling is handled by JS fitBannerFonts() via ResizeObserver + scrollWidth detection */

/* ============================================================
   Banner Design2 — Responsive overrides
   ============================================================ */

/* Mid-range: 951px–1200px — label 字級已由 clamp(11px,1vw,14px) 平滑處理，無需步進規則 */

/* Mobile: ≤1050px (design2 banner only) — top-deck 轉直排 + 兩行 matrix + 修正 controls-group */
@media (max-width: 1050px) {
    /* top-deck 切成 column（讓 matrix 2-row 有空間展開） */
    body.banner-design2 .top-deck {
        flex-direction: column;
        align-items: stretch;
        padding: 10px 12px;
        gap: 8px;
    }
    body.banner-design2 .brand-area {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        min-width: unset;
        margin-right: 0;
        gap: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid #f0f0f0;
    }
    body.banner-design2 .brand-icon { margin-bottom: 0; font-size: 18px; }
    body.banner-design2 .brand-name { font-size: 16px; }
    body.banner-design2 .brand-sub  { display: none; }
    /* 修正: controls-group 在 column flex 裡 flex:0 0 185px 會變成 185px 高度 → 大空白 */
    body.banner-design2 .controls-group {
        flex: none !important; width: 100%;
        border-left: none; padding-left: 0;
        border-top: 1px solid #eee; padding-top: 8px;
    }

    /* Matrix: 允許換行 */
    body.banner-design2 .matrix-container { flex-wrap: wrap; }

    /* Row 1: Origin + swap + Dest (各 flex:1) */
    body.banner-design2 #origin-cell {
        flex: 1 1 0; max-width: none;
        border-right: none;
        border-radius: 12px 0 0 0;
        border-bottom: 1px solid #e9ecef;
    }
    body.banner-design2 .swap-zone {
        flex: 0 0 44px;
        border-bottom: 1px solid transparent;
        align-self: stretch; display: flex; align-items: center; justify-content: center;
    }
    body.banner-design2 #dest-cell {
        flex: 1 1 0; max-width: none;
        padding-left: 12px;
        border-right: none;
        border-radius: 0 12px 0 0;
        border-bottom: 1px solid #e9ecef;
    }

    /* Row 2: Departure (40%) + Arrival+Duration (60%) */
    body.banner-design2 #deptime-cell {
        flex: 0 0 40%; max-width: 40%;
        border-right: 1px solid #e9ecef;
        border-radius: 0 0 0 12px;
    }
    body.banner-design2 .dur-arr-toggle {
        flex: 0 0 60%; max-width: 60%;
        border-radius: 0 0 12px 0;
        min-height: 60px;
    }
    body.banner-design2 .dar-row { min-height: 60px; padding: 6px 10px 4px 10px; }
    body.banner-design2 .dar-input { font-size: 14px !important; }
}

/* Very narrow: ≤600px (design2 banner only) — Departure 獨佔一行 */
@media (max-width: 600px) {
    body.banner-design2 #deptime-cell {
        flex: 0 0 100%; max-width: 100%;
        border-right: none;
        border-radius: 0;
        border-bottom: 1px solid #e9ecef;
    }
    body.banner-design2 .dur-arr-toggle {
        flex: 0 0 100%; max-width: 100%;
        border-radius: 0 0 12px 12px;
    }
}

/* Very very narrow: ≤480px — Arrival+Duration 垂直堆疊，避免時間截斷 */
@media (max-width: 480px) {
    body.banner-design2 .dur-arr-toggle { flex-direction: column !important; }
    body.banner-design2 .dar-row { min-height: 52px; }
    body.banner-design2 #darArr { border-right: none !important; border-bottom: 1px solid #e9ecef; }
}

/* ============================================================
   Language Trigger Button
   ============================================================ */
.lang-trigger {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 2px 7px 2px 5px;
    cursor: pointer;
    color: #666;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.4;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
}
.lang-trigger:hover {
    border-color: #007bff;
    color: #007bff;
    background: rgba(0,123,255,0.05);
}
.lang-trigger-icon {
    font-size: 11px;
    opacity: 0.7;
}

/* ============================================================
   Language Picker Modal
   ============================================================ */
.lang-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.lang-modal-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.22);
    padding: 24px 28px 28px;
    min-width: 320px;
    max-width: 480px;
    width: 90%;
    animation: langModalIn 0.18s ease;
}
@keyframes langModalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.lang-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.lang-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #222;
    letter-spacing: 0.2px;
}
.lang-modal-close {
    background: none;
    border: none;
    font-size: 16px;
    color: #999;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.lang-modal-close:hover { color: #333; background: #f0f0f0; }
.lang-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}
.lang-option {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 32px 10px 12px;
    border: 1.5px solid #e8e8e8;
    border-radius: 8px;
    background: #fafafa;
    cursor: pointer;
    position: relative;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.lang-option:hover {
    border-color: #007bff;
    background: #f0f6ff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.12);
}
.lang-option.active {
    border-color: #007bff;
    background: #e8f2ff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.15);
}
.lang-option.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    font-size: 18px;
    font-weight: 700;
    color: #007bff;
}
.lang-option-flag {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    flex-shrink: 0;
}
.lang-option-native {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    line-height: 1.3;
}

/* Non-ZH mode: cancel uppercase; fix descender clipping */
body:not(.lang-zh).banner-design2 .stack-cell .cell-label,
body:not(.lang-zh).banner-design2 .dar-label {
    text-transform: none;
    letter-spacing: 0;
    font-size: 14px;
    font-weight: 900;
    line-height: 1.4;
    overflow: visible;
}
/* banner-design2 placeholder：顏色加深、字體略大於標籤（14px → 15px）
   font-size 改用 CSS 變數，由 fitBannerFonts() / fitPlaceholder() 動態縮小 */
body.banner-design2 .stack-cell .clean-input::placeholder,
body.banner-design2 .dar-input::placeholder {
    font-size: var(--ph-size, 15px);
    color: #aaa;
}
/* Non-ZH placeholder：font-family 同步標籤字型 */
body:not(.lang-zh).banner-design2 .stack-cell .clean-input::placeholder,
body:not(.lang-zh).banner-design2 .dar-input::placeholder {
    font-size: var(--ph-size, 15px);
    font-family: inherit;
    color: #aaa;
}
