:root {
    --bg-base: #0E1512;
    --bg-surface: #15201B;
    --bg-surface-raised: #1C2A24;
    --bg-surface-hover: #26362F;
    --bg-editor: #0B110F;
    
    --border-subtle: #26362F;
    --border-medium: rgba(255, 255, 255, 0.15);
    --border-focus: #F5B731;
    
    --text-main: #EEF2E6;
    --text-muted: #A9B8AE;
    --text-faint: #8A9B92;
    
    --brand-gradient: none;
    --accent-indigo: #F5B731;
    --accent-indigo-hover: #E0A21C;
    --accent-emerald: #9BDD74;
    --accent-amber: #FFA85E;
    --accent-rose: #FF7A73;
    --accent-cyan: #72C6F2;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-glow: none;
    
    --font-ui: 'Anek Bangla', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Atkinson Hyperlegible Mono', 'JetBrains Mono', 'Fira Code', monospace;

    /* Syntax highlighting token colors - Rickshaw Dhaka Night */
    --hl-comment: #8A9B92;
    --hl-string: #9BDD74;
    --hl-number: #FFA85E;
    --hl-type: #72C6F2;
    --hl-control: #FF85BF;
    --hl-logic: #C9A2FF;
    --hl-io: #F5B731;
    --hl-builtin: #5FD6C8;
    --hl-ident: #EEF2E6;
    --hl-punct: #A9B8AE;

    --editor-font-size: 0.88rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   Custom Scrollbars
   ============================================================ */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.22);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-ui);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-image: url('assets/bg-pattern.svg');
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

/* ============================================================
   Header
   ============================================================ */
header {
    position: relative;
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    height: 56px;
    padding: 0 16px;
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-right: 14px;
}

.brand-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-logo-img {
    display: block;
    width: auto;
    height: 36px;
    /* Constrain max width so the wordmark doesn't overflow on small screens */
    max-width: 180px;
    object-fit: contain;
}

.brand-title {
    margin: 0;
    padding: 0;
    font-size: 1rem;
    font-weight: normal;
    display: flex;
    align-items: center;
}

.badge-version {
    background: rgba(245, 183, 49, 0.15);
    border: 1px solid rgba(245, 183, 49, 0.35);
    color: #F5B731;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

/* Visually Hidden Utility for Search Engine Crawlers & Screen Readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================================
   Dhaka Cityscape: Full-Width, Full-Height Looping Animation
   ============================================================ */
.dhaka-city-bar {
    flex: 1;
    height: 100%;
    margin: 0;
    position: relative;
    overflow: hidden;
    background: #070e17;
    border-left: 1px solid rgba(245, 183, 49, 0.22);
    border-right: 1px solid rgba(245, 183, 49, 0.22);
    box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    user-select: none;
}

.city-svg {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

/* ============================================================
   METRO RAIL REVERSING LOOP:
   - Starts at West terminus (x = -130px)
   - Travels East across the city to the Station at x = 740px
   - Stops and dwells at the Station for passenger boarding
   - Headlight switches and train departs West back to the terminus
   - Dwells at terminus, then repeats the loop!
   ============================================================ */
.metro-train-track {
    width: 100%;
    height: 100%;
}

.metro-train-loop {
    animation: metroStationLoop 20s cubic-bezier(0.42, 0.08, 0.58, 0.92) infinite;
}

@keyframes metroStationLoop {
    /* 0% - 35%: Eastbound trip towards station */
    0% {
        transform: translateX(-130px);
    }
    35% {
        transform: translateX(740px); /* Arrived at station platform */
    }
    /* 35% - 48%: Stopped at Station (dwell / passenger boarding) */
    48% {
        transform: translateX(740px);
    }
    /* 48% - 83%: Westbound trip back to terminal */
    83% {
        transform: translateX(-130px); /* Arrived back at west terminal */
    }
    /* 83% - 97%: Stopped at west terminal */
    97%, 100% {
        transform: translateX(-130px);
    }
}


/* ============================================================
   TWO-WAY VEHICLE TRAFFIC (রিকশা ও সিএনজি)
   ============================================================ */

/* Westbound Green CNG (Upper lane, right to left) */
.traffic-west-cng {
    animation: cngWestTraffic 11s linear infinite;
}
@keyframes cngWestTraffic {
    0% { transform: translateX(1050px); opacity: 0; }
    3% { opacity: 1; }
    97% { opacity: 1; }
    100% { transform: translateX(-60px); opacity: 0; }
}

/* Westbound Dhaka Rickshaw (Upper lane, right to left) */
.traffic-west-rickshaw {
    animation: rickshawWestTraffic 18s linear infinite 3.5s;
}
@keyframes rickshawWestTraffic {
    0% { transform: translateX(1050px); opacity: 0; }
    3% { opacity: 1; }
    97% { opacity: 1; }
    100% { transform: translateX(-50px); opacity: 0; }
}

.rickshaw-wheel-west {
    transform-box: fill-box;
    transform-origin: center;
    animation: spinWheelCounterClockwise 0.7s linear infinite;
}
@keyframes spinWheelCounterClockwise {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

/* Eastbound Colorful Dhaka Rickshaw (Lower lane, left to right) */
.traffic-east-rickshaw {
    animation: rickshawEastTraffic 17s linear infinite 1s;
}
@keyframes rickshawEastTraffic {
    0% { transform: translateX(-60px); opacity: 0; }
    3% { opacity: 1; }
    97% { opacity: 1; }
    100% { transform: translateX(1050px); opacity: 0; }
}

.rickshaw-wheel-east {
    transform-box: fill-box;
    transform-origin: center;
    animation: spinWheelClockwise 0.7s linear infinite;
}
@keyframes spinWheelClockwise {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Eastbound Green CNG (Lower lane, left to right) */
.traffic-east-cng {
    animation: cngEastTraffic 12s linear infinite 5s;
}
@keyframes cngEastTraffic {
    0% { transform: translateX(-70px); opacity: 0; }
    3% { opacity: 1; }
    97% { opacity: 1; }
    100% { transform: translateX(1060px); opacity: 0; }
}

/* Twinkling Stars & Aviation Beacon */
.star-1 { animation: starTwinkle 2.5s ease-in-out infinite; }
.star-2 { animation: starTwinkle 3.2s ease-in-out infinite 0.8s; }
.star-3 { animation: starTwinkle 4s ease-in-out infinite 1.5s; }

@keyframes starTwinkle {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}

.antenna-beacon {
    animation: beaconBlink 1.4s steps(1) infinite;
}
@keyframes beaconBlink {
    0%, 100% { opacity: 1; fill: #ff4d4d; }
    50% { opacity: 0.15; fill: #5c1818; }
}

.controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 14px;
    flex-wrap: nowrap;
}

select, input, button {
    font-family: var(--font-ui);
    font-size: 0.86rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-surface-raised);
    color: var(--text-main);
    padding: 7px 12px;
    outline: none;
    transition: all 0.18s ease;
}

select {
    cursor: pointer;
    min-width: 170px;
    max-width: 240px;
    text-overflow: ellipsis;
}

select:hover {
    border-color: var(--border-medium);
}

button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 2px solid #F5B731;
    outline-offset: 2px;
}

button {
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    user-select: none;
}

button:active {
    transform: scale(0.97);
}

button.btn-primary {
    background: #F5B731;
    border: 1px solid #E0A21C;
    color: #1B1403;
    box-shadow: none;
    padding: 8px 16px;
    font-weight: 700;
}

button.btn-primary:hover {
    background: #E0A21C;
    box-shadow: none;
}

button.btn-secondary {
    background-color: var(--bg-surface-raised);
    color: var(--text-main);
    border-color: var(--border-subtle);
}

button.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-main);
    border-color: var(--border-medium);
}

.btn-game {
    font-family: var(--font-ui);
    font-size: 0.86rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(245, 183, 49, 0.3);
    background: rgba(245, 183, 49, 0.08);
    color: var(--text-main);
    padding: 7px 12px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    user-select: none;
    transition: all 0.18s ease;
    cursor: pointer;
    white-space: nowrap;
}

.btn-game svg {
    color: #F5B731;
    transition: transform 0.22s ease, color 0.22s ease;
}

.btn-game:hover {
    background: rgba(245, 183, 49, 0.18);
    border-color: rgba(245, 183, 49, 0.6);
    color: #F5B731;
    box-shadow: none;
}

.btn-game:hover svg {
    transform: rotate(-12deg) scale(1.15);
}

.btn-game:active {
    transform: scale(0.97);
}


/* ============================================================
   Mobile View Switcher
   ============================================================ */
.mobile-nav-segmented {
    display: none;
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 3px;
}

.segment-btn {
    flex: 1;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.segment-btn.active {
    background: #1C2A24;
    color: #F5B731;
    box-shadow: inset 0 -2px 0 #F5B731;
}

/* ============================================================
   Main Layout
   ============================================================ */
main {
    flex: 1;
    display: flex;
    gap: 0;
    padding: 12px 16px;
    min-height: 0;
    position: relative;
}

/* ============================================================
   Card Panels (Editor & Output/C)
   ============================================================ */
.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    min-width: 0;
    position: relative;
    z-index: 1;
    transition: border-color 0.2s ease;
}

.panel:hover {
    border-color: var(--border-medium);
}

.panel:focus-within {
    border-color: rgba(245, 183, 49, 0.4);
}

/* ============================================================
   Panel Divider (Resizable)
   ============================================================ */
.panel-divider {
    width: 12px;
    flex-shrink: 0;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 5;
    user-select: none;
    -webkit-user-select: none;
}

.panel-divider::before {
    content: '';
    width: 4px;
    height: 40px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    transition: background 0.2s, height 0.2s;
}

.panel-divider:hover::before,
.panel-divider.dragging::before {
    background: var(--accent-indigo);
    height: 60px;
    box-shadow: none;
}

.panel-divider.dragging {
    cursor: col-resize;
}

/* ============================================================
   Panel Header & Liquid Glass Toolbar
   ============================================================ */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-surface-raised);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    min-height: 44px;
    position: relative;
    z-index: 3;
}

.panel-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 5px;
}

.toolbar-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 3px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 28px;
    min-height: 26px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font-mono);
}

.toolbar-btn:hover {
    color: var(--text-main);
    border-color: var(--border-subtle);
    background: var(--bg-surface-hover);
}

.toolbar-btn:active {
    transform: translateY(0);
}

.toolbar-btn.active {
    color: #F5B731;
    border-color: var(--border-subtle);
    background: var(--bg-surface-hover);
    box-shadow: none;
}

.toolbar-sep {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0 4px;
}

.panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
    background: transparent;
    z-index: 2;
}

/* ============================================================
   Editor Container, Line Numbers & Syntax Highlight Overlay
   ============================================================ */
.editor-container {
    flex: 1;
    display: flex;
    min-height: 0;
    position: relative;
    background: transparent;
}

.line-numbers {
    width: 44px;
    padding: 12px 8px 12px 0;
    text-align: right;
    font-family: var(--font-mono);
    font-size: var(--editor-font-size);
    line-height: 1.55;
    color: var(--text-faint);
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid var(--border-subtle);
    user-select: none;
    overflow: hidden;
    flex-shrink: 0;
    transition: width 0.2s, opacity 0.2s;
}

.line-numbers.hidden {
    width: 0;
    opacity: 0;
    padding: 0;
    border-right: none;
    overflow: hidden;
}

/* The wrapper that holds both the highlight layer and the textarea */
.editor-scroll-wrapper {
    flex: 1;
    position: relative;
    min-width: 0;
    overflow: hidden;
}

/* Highlight layer: sits behind the textarea */
#highlight-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: var(--editor-font-size);
    line-height: 1.55;
    white-space: pre;
    color: var(--hl-ident);
    background: transparent;
    border: none;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
    word-break: normal;
    tab-size: 4;
    -moz-tab-size: 4;
}

#highlight-layer code {
    display: block;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    white-space: inherit;
    tab-size: inherit;
    -moz-tab-size: inherit;
    color: inherit;
}

textarea#src {
    position: relative;
    z-index: 2;
    flex: 1;
    width: 100%;
    height: 100%;
    display: block;
    background: transparent;
    color: transparent;
    caret-color: #e2e8f0;
    border: none;
    outline: none;
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: var(--editor-font-size);
    line-height: 1.55;
    resize: none;
    tab-size: 4;
    -moz-tab-size: 4;
    white-space: pre;
    overflow: auto;
}

textarea#src::placeholder {
    color: var(--text-faint);
}

textarea#src::selection {
    background: rgba(99, 102, 241, 0.35);
    color: transparent;
}

textarea#src::-moz-selection {
    background: rgba(99, 102, 241, 0.35);
    color: transparent;
}

/* Word-wrap mode */
.editor-container.wrap-on textarea#src,
.editor-container.wrap-on #highlight-layer {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-all;
}

/* Syntax token classes */
.hl-comment { color: var(--hl-comment); font-style: italic; }
.hl-string  { color: var(--hl-string); }
.hl-number  { color: var(--hl-number); }
.hl-type    { color: var(--hl-type); }
.hl-control { color: var(--hl-control); }
.hl-logic   { color: var(--hl-logic); }
.hl-io      { color: var(--hl-io); }
.hl-builtin { color: var(--hl-builtin); }
.hl-ident   { color: var(--hl-ident); }
.hl-punct   { color: var(--hl-punct); }

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}
.tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.tab-btn:hover {
    color: var(--text-main);
    background: var(--bg-surface-hover);
}

.tab-btn.active {
    background: var(--bg-surface-hover);
    border: 1px solid var(--border-subtle);
    color: #F5B731;
    box-shadow: none;
}

/* ============================================================
   Status Bar
   ============================================================ */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--accent-emerald);
    box-shadow: none;
}

.status-dot.loading {
    background-color: var(--accent-amber);
    box-shadow: none;
    animation: pulse 1s infinite;
}

.status-dot.waiting {
    background-color: var(--accent-cyan);
    box-shadow: none;
    animation: pulse 1s infinite;
}

.status-dot.error {
    background-color: var(--accent-rose);
    box-shadow: none;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* ============================================================
   Interactive Terminal Prompt & Input
   ============================================================ */
.term-transcript {
    white-space: pre-wrap;
    word-break: break-word;
}

.term-user-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0;
}

.term-user-echo {
    color: #72C6F2;
    font-weight: 600;
}

.term-prompt {
    color: #F5B731;
    font-weight: 700;
    user-select: none;
}

.term-input-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 12px;
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
}

.term-input-field {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #72C6F2;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    padding: 2px 4px;
}

.term-input-field::placeholder {
    color: var(--text-faint);
    font-style: italic;
    font-size: 0.82rem;
}

.term-submit-btn {
    background: #F5B731;
    color: #1B1403;
    border: none;
    border-radius: 5px;
    padding: 5px 12px;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: none;
    transition: background 0.15s, transform 0.1s;
}

.term-submit-btn:hover {
    background: #E0A21C;
    box-shadow: none;
}

.term-submit-btn:active {
    transform: scale(0.96);
}

.term-stopped {
    color: var(--text-muted);
    font-style: italic;
    display: block;
    margin-top: 4px;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 4px 9px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.icon-btn:hover {
    color: var(--text-main);
    border-color: var(--border-medium);
    background: var(--bg-surface-hover);
    box-shadow: none;
}

.icon-btn:active {
    transform: translateY(0);
}

/* ============================================================
   Code Viewers & Output Placeholder
   ============================================================ */
.code-view {
    flex: 1;
    background: transparent;
    color: #cbd5e1;
    padding: 14px;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.5;
    overflow: auto;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    display: none;
    position: relative;
    z-index: 2;
    transition: opacity 0.2s ease, filter 0.2s ease;
}

.code-view.active {
    display: block;
}

.code-view.outdated-output {
    opacity: 0.55;
    filter: grayscale(0.4);
}

.outdated-banner {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    background: rgba(245, 183, 49, 0.15);
    border: 1px solid #F5B731;
    color: #F5B731;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
}

/* Empty-state placeholder for output */
.code-view.active:empty::before {
    content: attr(data-placeholder);
    color: var(--text-faint);
    font-style: italic;
    pointer-events: none;
}

/* ============================================================
   Error Console
   ============================================================ */
#err {
    display: none;
    max-height: 180px;
    overflow-y: auto;
    background: #150a0e;
    border-top: 1px solid rgba(255, 122, 115, 0.35);
    padding: 8px 16px;
    flex-shrink: 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}

#err.has-errors {
    display: block;
}

.error-card {
    background: rgba(255, 122, 115, 0.08);
    border: 1px solid rgba(255, 122, 115, 0.2);
    border-left: 3px solid var(--accent-rose);
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: 0 6px 6px 0;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.error-card:hover {
    background: rgba(255, 122, 115, 0.14);
    border-color: rgba(255, 122, 115, 0.4);
    transform: translateX(2px);
}

.error-card:last-child {
    margin-bottom: 0;
}

.error-header {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 3px;
}

.error-badge {
    background: #FF7A73;
    color: #2A0806;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.error-loc {
    color: #FF85BF;
    font-weight: 600;
}

.error-jump-hint {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.8;
}

.error-card:hover .error-jump-hint {
    opacity: 1;
    color: var(--accent-indigo);
}

.error-msg {
    color: #fecdd3;
    white-space: pre-wrap;
}

.error-sug {
    color: #9BDD74;
    font-size: 0.78rem;
    margin-top: 3px;
    font-style: italic;
}

.errors-fold-toggle {
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 0.76rem;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    margin-top: 6px;
    width: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.errors-fold-toggle:hover {
    color: var(--text-main);
    border-color: var(--border-medium);
}

.folded-errors-list {
    display: none;
    margin-top: 6px;
    flex-direction: column;
    gap: 6px;
}

.folded-errors-list.open {
    display: flex;
}

/* ============================================================
   Footer / Timing
   ============================================================ */
footer.timing-bar {
    background: rgba(18, 21, 31, 0.9);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border-subtle);
    padding: 6px 16px;
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    font-size: 0.74rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.shortcut-hint {
    color: var(--text-faint);
}

kbd {
    background: rgba(255, 255, 255, 0.1);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-link {
    color: var(--text-faint);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    transition: color 0.15s ease;
}

.footer-link:hover {
    color: var(--accent-indigo);
}

/* ============================================================
   Cheatsheet Modal
   ============================================================ */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 100;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal-backdrop.open {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    width: 820px;
    max-width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface-raised);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-body {
    padding: 18px 20px;
    overflow-y: auto;
    font-size: 0.86rem;
}

.sheet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.sheet-card {
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.sheet-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.sheet-card h3 {
    font-size: 0.84rem;
    font-weight: 700;
    color: #F5B731;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sheet-card > code {
    display: block;
    background: var(--bg-editor);
    padding: 6px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    margin-top: 4px;
    color: #EEF2E6;
    border-left: 2px solid var(--accent-indigo);
}

.sheet-card p code {
    display: inline;
    background: var(--bg-editor);
    padding: 2px 5px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--hl-type);
    border-left: none;
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.close-btn:hover {
    color: #fff;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}


/* ============================================================
   Drag-select prevention while resizing
   ============================================================ */
body.resizing-panels {
    cursor: col-resize !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

body.resizing-panels * {
    cursor: col-resize !important;
}

/* ============================================================
   Mobile Symbol Helper Bar (above keyboard on touch devices)
   ============================================================ */
.mobile-symbols-bar {
    display: none;
}

/* ============================================================
   Mobile Optimization (Screens <= 768px)
   ========================================================================= */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    header {
        height: auto;
        padding: 8px 12px;
        padding-top: calc(8px + env(safe-area-inset-top, 0px));
        padding-left: calc(12px + env(safe-area-inset-left, 0px));
        padding-right: calc(12px + env(safe-area-inset-right, 0px));
        flex-wrap: wrap;
        gap: 8px;
    }

    .brand {
        margin-right: 0;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
    }

    .brand-logo-img {
        height: 28px;
    }

    .badge-version {
        display: none;
    }

    .dhaka-city-bar {
        display: none;
    }

    .controls {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    select#sel {
        flex: 1;
        min-width: 0;
        font-size: 0.82rem;
        padding: 6px 8px;
        height: 38px;
    }

    button#btn-cheat,
    a#btn-games {
        padding: 0;
        font-size: 0.8rem;
        min-height: 38px;
        min-width: 38px;
        width: 38px;
        height: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    button#run {
        padding: 0 12px;
        font-size: 0.82rem;
        min-height: 38px;
        min-width: 42px;
        height: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    /* Hide text labels on small buttons, keep icons */
    button#btn-cheat > span,
    a#btn-games > span,
    button#run > span,
    .icon-btn > span {
        display: none;
    }

    /* Bigger tap targets */
    .icon-btn {
        min-width: 38px;
        min-height: 38px;
        padding: 6px;
        justify-content: center;
    }

    .mobile-nav-segmented {
        display: flex;
        margin: 8px 12px 6px 12px;
        margin-left: calc(12px + env(safe-area-inset-left, 0px));
        margin-right: calc(12px + env(safe-area-inset-right, 0px));
        padding: 3px;
        gap: 4px;
        border-radius: var(--radius-sm);
    }

    .segment-btn {
        min-height: 36px;
        padding: 5px 10px;
        font-size: 0.8rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    main {
        flex-direction: column;
        padding: 0 12px 8px 12px;
        padding-left: calc(12px + env(safe-area-inset-left, 0px));
        padding-right: calc(12px + env(safe-area-inset-right, 0px));
        gap: 0;
    }

    /* Mobile Symbol Toolbar */
    .mobile-symbols-bar {
        display: flex;
        align-items: center;
        gap: 5px;
        padding: 5px 8px;
        background: var(--bg-surface-raised);
        border-top: 1px solid var(--border-subtle);
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        flex-shrink: 0;
        z-index: 15;
    }

    .mobile-symbols-bar::-webkit-scrollbar {
        display: none;
    }

    .sym-btn {
        background: var(--bg-surface);
        border: 1px solid var(--border-subtle);
        color: var(--text-main);
        font-family: var(--font-mono);
        font-size: 0.85rem;
        font-weight: 600;
        padding: 4px 9px;
        border-radius: 4px;
        min-height: 30px;
        min-width: 30px;
        cursor: pointer;
        flex-shrink: 0;
        user-select: none;
        transition: all 0.15s ease;
    }

    .sym-btn:active {
        background: var(--accent-indigo);
        color: #1B1403;
        border-color: var(--accent-indigo);
    }

    /* Hide the panel divider on mobile */
    .panel-divider {
        display: none;
    }

    /* Mobile tabbed switching between Editor & Output */
    .panel {
        display: none;
        height: 100%;
    }

    .panel.mobile-active {
        display: flex;
    }

    .panel-header {
        padding: 6px 10px;
        min-height: 36px;
    }

    .tabs {
        max-width: calc(100vw - 110px);
    }

    .sheet-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        max-height: 94vh;
    }

    .modal-body {
        padding: 12px 14px;
    }

    footer.timing-bar {
        padding: 4px 10px;
        padding-left: calc(10px + env(safe-area-inset-left, 0px));
        padding-right: calc(10px + env(safe-area-inset-right, 0px));
        padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
        font-size: 0.7rem;
    }

    .shortcut-hint {
        display: none;
    }

    /* Toolbar adjustments on mobile */
    .editor-toolbar {
        gap: 2px;
    }

    .toolbar-btn {
        min-width: 28px;
        min-height: 28px;
        padding: 3px 5px;
    }
}

/* ============================================================ */
/* Autocomplete / Intellisense Dropdown                         */
/* ============================================================ */
.autocomplete-dropdown {
    position: fixed;
    z-index: 9999;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65), 0 2px 8px rgba(0, 0, 0, 0.4);
    min-width: 260px;
    max-width: 380px;
    max-height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0;
    font-family: var(--font-mono);
    font-size: 13px;
    display: none;
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
}
.autocomplete-dropdown::-webkit-scrollbar { width: 6px; }
.autocomplete-dropdown::-webkit-scrollbar-track { background: transparent; }
.autocomplete-dropdown::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 3px; }

.ac-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    border-left: 2px solid transparent;
    transition: background 0.08s ease;
}
.ac-item:hover,
.ac-item.ac-selected {
    background: var(--bg-surface-raised);
    border-left-color: #F5B731;
}

.ac-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    font-family: var(--font-ui);
    letter-spacing: 0;
}
.ac-icon.kw  { background: #2C2640; color: #C9A2FF; }
.ac-icon.fn  { background: #18382B; color: #9BDD74; }
.ac-icon.sn  { background: #3B2E17; color: #FFA85E; }

.ac-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ac-label-main {
    color: #EEF2E6;
    font-weight: 500;
}
.ac-label-match {
    color: #F5B731;
    font-weight: 700;
}
.ac-detail {
    color: #8A9B92;
    font-size: 11px;
    font-family: var(--font-ui);
    margin-left: auto;
    padding-left: 8px;
    flex-shrink: 0;
}

/* Small "TAB" badge shown on selected item */
.ac-tab-hint {
    display: none;
    font-size: 10px;
    background: #26362F;
    color: #F5B731;
    border-radius: 3px;
    padding: 1px 5px;
    font-family: var(--font-ui);
    flex-shrink: 0;
}
.ac-item.ac-selected .ac-tab-hint { display: block; }
