* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
--edge: 20px;
    --dock-space: 88px;
    --inspector-width: 352px;
    --surface: color-mix(in srgb, var(--bg-card) 88%, var(--accent) 12%);
    --surface-deep: var(--bg-base);
    --line: color-mix(in srgb, var(--text-muted) 24%, var(--bg-base));
    --sweep: polygon(0 0, 100% 0, 100% calc(100% - 16px), calc(100% - 9px) 100%, 0 100%);
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: "Bahnschrift", "Aptos", "Segoe UI", sans-serif;
    line-height: 1.45;
    overflow: hidden;
    width: 100%;
    height: 100dvh;
    color-scheme: dark;
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
button, input { font: inherit; }
button:focus-visible, a:focus-visible, .flight-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -4px;
}

::selection {
    background: var(--accent);
    color: var(--bg-base);
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Map Canvas */
#map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: auto;
    background: #090a0f;
}

.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-top-right,
.maplibregl-ctrl-top-left {
    display: none !important;
}

/* Common UI Box Primitives */
.box-ui {
background: var(--surface-deep);
    border: 1px solid var(--line);
    border-radius: 2px;
}

/* Swept control dock */
.imgui-bar {
position: absolute;
    bottom: var(--edge);
    left: var(--edge);
    height: 56px;
    display: flex;
    align-items: center;
    background: var(--surface-deep);
    border: 1px solid var(--line);
    border-radius: 2px;
    padding: 4px;
    gap: 2px;
    z-index: 30;
}

.imgui-tab {
position: relative;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 16px;
    background: transparent;
    color: var(--text-muted);
    border: 0;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 160ms ease;
    white-space: nowrap;
    user-select: none;
}

.imgui-tab:last-child {
    border-right: none;
}

.imgui-tab:hover {
background: transparent;
    color: var(--text-primary);
}

.imgui-tab.active {
color: var(--bg-base);
}


.flight-drawer {
position: absolute;
    left: var(--edge);
    right: var(--edge);
    bottom: var(--dock-space);
    height: 232px;
    display: flex;
    flex-direction: column;
    z-index: 25;
    visibility: hidden;
    transform: translateY(calc(100% + var(--dock-space)));
    transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}

.flight-drawer.open {
visibility: visible;
    transform: translateY(0);
}
body.inspector-open .flight-drawer { right: calc(var(--edge) + var(--inspector-width) + 16px); }

.drawer-header {
position: relative;
    min-height: 64px;
    padding: 8px 12px 8px 24px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
}

.drawer-title {
flex-shrink: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.drawer-count {
font-size: 0.75rem;
    font-family: var(--mono-font);
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.drawer-close {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    transition: color 0.15s ease;
}

.drawer-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.drawer-close:hover {
    color: var(--accent);
}

.drawer-search {
margin-left: auto;
    min-width: 0;
    width: min(260px, 35%);
}
.shelf-paging { display: flex; }

.search-input {
width: 100%;
    background: var(--surface-deep);
    border: 1px solid var(--line);
    border-radius: 2px;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-family: inherit;
    caret-color: var(--accent);
    color: var(--text-primary);
    outline: none;
    transition: border-color 160ms ease;
}

.search-input:focus {
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.drawer-list {
flex: 1;
    min-height: 0;
    min-width: 0;
    padding: 0;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-color: var(--line) transparent;
    scrollbar-width: thin;
}

.flight-item {
position: relative;
    isolation: isolate;
    padding: 20px 24px;
    background: transparent;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    cursor: pointer;
    transition: color 160ms ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    flex: 0 0 288px;
    min-width: 0;
    scroll-snap-align: start;
}

.flight-item:hover {
background: var(--surface);
}

.flight-item.selected {
background: transparent;
    color: var(--bg-base);
}
.flight-item.selected :is(.flight-item-route, .route-arrow, .flight-item-model, .flight-item-meta, .flight-item-name, strong) { color: var(--bg-base); }

.flight-item-top {
display: flex;
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
    width: 100%;
}

.flight-item-name {
display: block;
    min-width: 0;
    width: 100%;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (prefers-reduced-motion: no-preference) {
    .flight-item:is(:hover, :focus-visible) .flight-item-name.is-overflowing {
        text-overflow: clip;
    }
    .flight-item:is(:hover, :focus-visible) .flight-item-name.is-overflowing .flight-item-name-text {
        display: inline-block;
        animation: flightTitleScroll var(--title-scroll-duration) linear infinite alternate;
    }
}

@keyframes flightTitleScroll {
    0%, 20% { transform: translateX(0); }
    80%, 100% { transform: translateX(var(--title-scroll-distance)); }
}

.flight-item-route {
display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.625rem;
    line-height: 1.2;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--mono-font);
    white-space: nowrap;
}

.flight-item-route .route-arrow {
    color: var(--accent);
    font-weight: 400;
}

.flight-item-model {
font-size: 0.6875rem;
    font-weight: 600;
    font-family: var(--mono-font);
    color: var(--accent);
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: left;
}

.flight-item-meta {
display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.6875rem;
    font-family: var(--mono-font);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.flight-item-stats {
display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
}

.flight-item-stats span strong {
    color: var(--text-primary);
    font-weight: 600;
}

.drawer-empty {
width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 6px;
    padding: 24px;
    line-height: 1.6;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Aircraft inspector */
.fr24-sidebar {
position: absolute;
    top: var(--edge);
    right: var(--edge);
    bottom: var(--dock-space);
    width: var(--inspector-width);
    display: flex;
    flex-direction: column;
    z-index: 28;
    visibility: hidden;
    transform: translateX(calc(100% + var(--edge)));
    transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-color: var(--line) transparent;
    scrollbar-width: thin;
}

.fr24-sidebar.open {
visibility: visible;
    transform: none;
}

.fr24-header {
padding: 16px 16px 16px 24px;
    min-height: 88px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    background: var(--surface);
}

.fr24-callsign-wrap {
display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
}

.fr24-callsign {
font-size: 1.5rem;
    line-height: 1.2;
    font-weight: 600;
    overflow-wrap: anywhere;
    color: var(--text-primary);
}

.fr24-status-badge {
display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.625rem;
    font-weight: 600;
    font-family: var(--mono-font);
    color: var(--accent-secondary);
    text-transform: uppercase;
}

/* Aircraft Hero Photo */
.fr24-photo-container {
    position: relative;
    width: 100%;
    height: 180px;
    background: #000;
    overflow: hidden;
    flex-shrink: 0;
}

.fr24-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.fr24-photo-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.65) 100%);
    pointer-events: none;
}

/* Carousel Overlay Controls */
.fr24-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    color: #ffffff;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.2s ease, background 0.15s ease, color 0.15s ease, transform 0.15s ease;
    padding: 0;
    user-select: none;
}

.fr24-carousel-btn.prev {
    left: 8px;
}

.fr24-carousel-btn.next {
    right: 8px;
}

.fr24-photo-container:hover .fr24-carousel-btn {
    opacity: 1;
}

.fr24-carousel-btn:hover {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    transform: translateY(-50%) scale(1.1);
}

.fr24-carousel-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.fr24-carousel-dots {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10;
    pointer-events: auto;
}

.fr24-carousel-dot {
position: relative;
    width: 24px;
    height: 24px;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.fr24-carousel-dot:hover {
background: transparent;
}

.fr24-carousel-dot.active {
background: transparent;
}

.fr24-photo-badge {
    position: absolute;
    bottom: 6px;
    left: 8px;
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.68rem;
    font-family: var(--mono-font);
    color: var(--text-primary);
    font-weight: 600;
}

.fr24-photo-credit {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.6rem;
    font-family: var(--mono-font);
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 5;
    pointer-events: none;
}

/* Route Strip */
.fr24-route-strip {
    padding: 20px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fr24-airports {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
}

.fr24-apt {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.fr24-apt-code {
    font-size: 1.625rem;
    font-weight: 800;
    font-family: var(--mono-font);
    color: var(--text-primary);
}

.fr24-apt-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    max-width: 110px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fr24-route-mid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding-top: 16px;
}

.fr24-route-icon {
width: 32px;
    height: 24px;
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.5;
}

.fr24-route-cruise {
    font-size: 0.68rem;
    font-family: var(--mono-font);
    color: var(--accent);
    font-weight: 700;
}

.fr24-route-string {
    font-size: 0.75rem;
    font-family: var(--mono-font);
    color: var(--text-muted);
    overflow-wrap: anywhere;
    line-height: 1.6;
}

/* Sidebar Scrollable Body */
.fr24-body {
    flex: 1 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 20px;
}

.detail-box {
border-bottom: 1px solid var(--line);
    padding: 18px 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.detail-box.span-2 {
    grid-column: span 2;
}

.detail-lbl {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-val {
font-size: 0.9375rem;
    font-weight: 500;
    font-family: var(--mono-font);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.fr24-actions {
    position: sticky;
    bottom: 0;
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-base);
}

.btn-mini {
flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 6px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--line);
    border-radius: 2px;
    font-size: 0.8125rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: color 160ms ease, background 160ms ease;
    white-space: nowrap;
}

.btn-mini:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(255, 255, 255, 0.08);
}

.btn-mini.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-base);
    font-weight: 700;
}

/* Markers */
.plane-marker {
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    will-change: transform;
}

.plane-pulse {
    position: absolute;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-secondary-glow);
    border: 1.5px solid var(--accent-secondary);
    animation: planeRadarPulse 2.2s cubic-bezier(0.2, 0.8, 0.4, 1) infinite;
    pointer-events: none;
}

@keyframes planeRadarPulse {
    0% { transform: scale(0.6); opacity: 0.9; }
    100% { transform: scale(2.2); opacity: 0; }
}

.plane-svg {
    width: 24px;
    height: 24px;
    fill: var(--accent);
    position: relative;
    z-index: 2;
}

.waypoint-badge {
    --procedure-tone: #b8c1ca;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: fit-content;
    max-width: min(196px, calc(100vw - 24px));
    padding: 6px;
    background: rgba(15, 19, 25, 0.97);
    border: 1px solid rgba(210, 220, 229, 0.26);
    color: #edf1f4;
    font-family: var(--mono-font);
    line-height: 1.2;
    border-radius: 2px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.48);
}

.waypoint-badge-main {
    display: flex;
    align-items: baseline;
    gap: 6px;
    max-width: 100%;
    min-width: 0;
}

.waypoint-badge.sid,
.fr24-rwy-pill.sid {
    --procedure-tone: #a8b9c5;
}

.waypoint-badge.star,
.fr24-rwy-pill.star {
    --procedure-tone: #cfb5aa;
}

.waypoint-badge.ils,
.fr24-rwy-pill.ils {
    --procedure-tone: #b8c8bf;
}

.waypoint-badge-role {
    color: var(--procedure-tone);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.waypoint-badge-code {
    min-width: 0;
    overflow: hidden;
    color: #f0f3f5;
    font-size: 12px;
    font-weight: 700;
    text-overflow: ellipsis;
}

.waypoint-badge-meta {
    flex: 0 0 auto;
    color: #b8c3cb;
    font-size: 11px;
}

.waypoint-badge-detail {
    max-width: 100%;
    overflow: hidden;
    color: #cbd3d8;
    font-size: 11px;
    font-weight: 600;
    text-overflow: ellipsis;
}

.fr24-rwy-pill {
    --procedure-tone: #b8c1ca;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    font-size: 11px;
    font-family: var(--mono-font);
    font-weight: 600;
    line-height: 1.25;
    padding: 5px 7px;
    border-radius: 2px;
    margin-top: 5px;
    border: 1px solid var(--line);
    color: var(--text-primary);
    background: var(--surface-deep);
}

.fr24-apt:last-child .fr24-rwy-pill {
    align-items: flex-end;
}

.fr24-rwy-pill-runway,
.fr24-rwy-pill-procedure {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fr24-rwy-pill-procedure {
    color: var(--procedure-tone);
}


/* The eye and separated cheek are kept intact in the compact brand mark. */
html { width: 100%; height: 100%; overflow: hidden; }
/* Minimal floating home logo */
.sphinx-brand {
    position: absolute;
    top: var(--edge);
    left: var(--edge);
    z-index: 30;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: transparent;
    border: none;
    text-decoration: none;
    cursor: pointer;
    /* Keeps the mark legible regardless of whatever map terrain is beneath it */
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.75));
    transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1), filter 180ms ease;
    -webkit-tap-highlight-color: transparent;
}

.sphinx-mark {
    width: 44px;
    height: 39px;
    fill: var(--accent);
    flex-shrink: 0;
    display: block;
    transition: fill 180ms ease;
}

.sphinx-brand:hover {
    transform: scale(1.08);
    filter: drop-shadow(0 0 12px var(--accent-glow)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.85));
}

.sphinx-brand:active {
    transform: scale(0.95);
}

.sphinx-brand:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 4px;
}
.imgui-tab svg, .fr24-carousel-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; flex-shrink: 0; }
.imgui-tab::before { content: ''; position: absolute; inset: 0; z-index: -1; background: transparent; clip-path: var(--sweep); transition: background 160ms ease; }
.imgui-tab:hover::before { background: var(--surface); }
.imgui-tab.active::before { background: var(--accent); }
.flight-item.selected::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--accent); clip-path: var(--sweep); }
.fr24-status-badge::before { content: ''; width: 9px; height: 5px; background: currentColor; clip-path: polygon(35% 0, 100% 0, 65% 100%, 0 100%); }
.fr24-carousel-dot::before { content: ''; position: absolute; inset: 10px 5px; background: #c4c7d0; transform: skewX(-28deg); }
.fr24-carousel-dot.active::before { background: var(--accent); inset-inline: 1px; }
.fr24-carousel-dot:hover::before { background: #ffffff; }
.fr24-carousel-dots { bottom: 4px; gap: 0; }
.drawer-empty strong { color: var(--text-primary); font-size: 1rem; font-weight: 600; }
.search-input:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
button:disabled { opacity: 0.45; cursor: default; }
button:disabled:hover { background: transparent; color: var(--text-muted); }

@media (min-width: 801px) and (max-width: 1100px) {
    body.inspector-open .shelf-paging { display: none; }
    body.inspector-open .drawer-search { width: auto; flex: 1; }
}

/* Responsive */
@media (max-width: 800px) {
    body {
        --edge: 12px;
        --dock-space: calc(86px + env(safe-area-inset-bottom, 0px));
    }
    .flight-drawer { height: 232px; }
    body.inspector-open .flight-drawer { right: var(--edge); }
    .drawer-header { flex-wrap: wrap; gap: 4px; padding: 8px 8px 8px 16px; }
    .drawer-search { width: auto; flex: 1; min-width: 100px; }
    .drawer-title { margin-right: 4px; }
    .shelf-paging { display: none; }
    .search-input { padding: 8px; font-size: 1rem; }
    .flight-item { flex-basis: 256px; padding: 18px 20px; }
    .fr24-sidebar {
        top: auto;
        left: var(--edge);
        right: var(--edge);
        bottom: var(--dock-space);
        width: auto;
        max-height: 62dvh;
        transform: translateY(110%);
    }
    .fr24-sidebar.open {
        transform: none;
    }
    .imgui-bar {
        bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px));
        right: var(--edge);
        padding: 0 2px;
        gap: 0;
        overflow-x: auto;
    }
    .imgui-tab {
        flex: 1 1 0;
        flex-direction: column;
        gap: 4px;
        padding: 0 3px;
        min-width: 0;
        font-size: 0.6875rem;
    }
    .fr24-photo-container { height: 150px; }
    .sphinx-mark { width: 36px; height: 32px; }
    .imgui-bar { height: 62px; }
    .imgui-tab { height: 52px; }
    .drawer-title { font-size: 0.875rem; gap: 6px; }
    .drawer-header { min-height: 60px; }
    .drawer-search { min-width: 80px; }
    .fr24-header { min-height: 80px; }
    .fr24-callsign { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
