/* =========================================================================
   Codash — Design System  ·  iOS "glass window" edition
   Light default · animated aurora · frosted materials · spring motion.
   ========================================================================= */

:root {
    /* ---- Light palette ---- */
    --bg-a:        #eef1fb;
    --bg-b:        #f6f4fd;
    --bg-c:        #fdf2f8;
    --surface:     #ffffff;
    --surface-2:   #fbfbfe;
    --surface-3:   #eef0f7;
    --border:      #e5e7f0;
    --border-soft: #eef0f6;
    --text:        #454b5e;
    --text-strong: #10131c;
    --muted:       #8b90a4;
    --accent:      #6366f1;
    --accent-2:    #a855f7;
    --accent-3:    #ec4899;
    --accent-fg:   #ffffff;
    --green:       #16a34a;
    --red:         #ef4444;

    --shadow-sm:   0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
    --shadow:      0 12px 34px -14px rgba(16,24,40,.22), 0 4px 12px -6px rgba(16,24,40,.12);
    --shadow-win:  0 40px 90px -30px rgba(49,46,129,.35), 0 16px 40px -20px rgba(16,24,40,.22);
    --glow:        0 8px 22px -6px rgba(99,102,241,.55);
    --glass:       color-mix(in srgb, var(--surface) 72%, transparent);

    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
    --ease-out:    cubic-bezier(.16, 1, .3, 1);
    --ease-smooth: cubic-bezier(.4, 0, .2, 1);
    --dur:         .3s;

    --r-sm: 10px;
    --r:    14px;
    --r-lg: 20px;

    /* Syntax tokens (light) */
    --tok-comment:  #9aa3b8;
    --tok-keyword:  #7c3aed;
    --tok-string:   #15803d;
    --tok-number:   #db2777;
    --tok-func:     #2563eb;
    --tok-tag:      #e11d48;
    --tok-attr:     #b45309;
    --tok-punct:    #7c8296;
    --tok-op:       #0891b2;
    --tok-var:      #ea580c;
}

html.dark {
    /* ---- Dark palette ---- */
    --bg-a:        #090a12;
    --bg-b:        #0d0b18;
    --bg-c:        #120a17;
    --surface:     #14151f;
    --surface-2:   #12131c;
    --surface-3:   #262838;
    --border:      #262838;
    --border-soft: #1c1d29;
    --text:        #c7cbe0;
    --text-strong: #f4f5ff;
    --muted:       #757a94;
    --accent:      #818cf8;
    --accent-2:    #c084fc;
    --accent-3:    #f472b6;
    --accent-fg:   #0b0c14;
    --green:       #4ade80;
    --red:         #fb7185;

    --shadow-sm:   0 1px 2px rgba(0,0,0,.5);
    --shadow:      0 18px 44px -20px rgba(0,0,0,.75);
    --shadow-win:  0 50px 110px -30px rgba(0,0,0,.85), 0 0 0 1px rgba(255,255,255,.03);
    --glow:        0 10px 26px -6px rgba(129,140,248,.6);
    --glass:       color-mix(in srgb, var(--surface) 68%, transparent);

    /* Syntax tokens (dark) */
    --tok-comment:  #636880;
    --tok-keyword:  #c084fc;
    --tok-string:   #4ade80;
    --tok-number:   #f472b6;
    --tok-func:     #7dd3fc;
    --tok-tag:      #fb7185;
    --tok-attr:     #fbbf24;
    --tok-punct:    #8a90aa;
    --tok-op:       #67e8f9;
    --tok-var:      #fdba74;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* ---------- Icons (Lucide) ---------- */
svg.lucide { width: 16px; height: 16px; stroke-width: 2; flex: none; vertical-align: -2px; }
.btn-icon svg.lucide { width: 18px; height: 18px; }
.meta-chip svg.lucide { width: 14px; height: 14px; }
.status-item svg.lucide { width: 13px; height: 13px; }
.notfound .btn svg.lucide { width: 18px; height: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .9s linear infinite; }

body {
    margin: 0;
    padding: 18px;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
                 "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    letter-spacing: -0.011em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    display: flex;
    overflow: hidden;
    background:
        radial-gradient(1200px 700px at 12% -10%, var(--bg-b), transparent 60%),
        radial-gradient(1000px 800px at 110% 10%, var(--bg-c), transparent 55%),
        var(--bg-a);
    transition: background var(--dur) var(--ease-smooth), color var(--dur) var(--ease-smooth);
    /* Native-app feel */
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overscroll-behavior: none;
}
.code-scroll { -webkit-overflow-scrolling: touch; }

/* Shown only on the native-style mobile layout */
.mobile-only { display: none; }

[x-cloak] { display: none !important; }
.mono { font-family: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, "JetBrains Mono", monospace; }

/* ---------- Ambient aurora ---------- */
.aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.aurora .blob {
    position: absolute;
    width: 46vw; height: 46vw;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .55;
    mix-blend-mode: multiply;
}
html.dark .aurora .blob { opacity: .5; mix-blend-mode: screen; filter: blur(110px); }
.aurora .b1 { background: radial-gradient(circle, var(--accent), transparent 68%);   top: -14vw; left: -8vw;  animation: float1 20s var(--ease-smooth) infinite; }
.aurora .b2 { background: radial-gradient(circle, var(--accent-2), transparent 68%); top: -6vw;  right: -10vw; animation: float2 24s var(--ease-smooth) infinite; }
.aurora .b3 { background: radial-gradient(circle, var(--accent-3), transparent 68%); bottom: -18vw; left: 40%; animation: float3 28s var(--ease-smooth) infinite; }
.aurora .grid-overlay {
    position: absolute; inset: 0;
    background-image:
        linear-gradient(color-mix(in srgb, var(--text-strong) 5%, transparent) 1px, transparent 1px),
        linear-gradient(90deg, color-mix(in srgb, var(--text-strong) 5%, transparent) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(circle at 50% 40%, #000, transparent 75%);
    mask-image: radial-gradient(circle at 50% 40%, #000, transparent 75%);
    opacity: .5;
}
@keyframes float1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(6vw, 5vw) scale(1.12); } }
@keyframes float2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-5vw, 7vw) scale(1.08); } }
@keyframes float3 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-4vw, -6vw) scale(1.15); } }

/* ---------- Window ---------- */
.window {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-radius: var(--r-lg);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-win);
    animation: window-in .6s var(--ease-out) both;
}
@keyframes window-in { from { opacity: 0; transform: translateY(16px) scale(.99); } to { opacity: 1; transform: none; } }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border: 3px solid var(--surface); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---------- Keyframes ---------- */
@keyframes ios-in   { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes ios-drop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes pop-in   { 0% { opacity: 0; transform: scale(.8); } 60% { opacity: 1; transform: scale(1.06); } 100% { transform: scale(1); } }

/* ---------- Header ---------- */
.app-header {
    height: 60px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    background: var(--glass);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 30;
}
.header-left, .header-right { display: flex; align-items: center; gap: 14px; }

.traffic { display: flex; gap: 8px; padding-right: 4px; }
.traffic span { width: 12px; height: 12px; border-radius: 50%; transition: transform .3s var(--ease-spring); }
.traffic span:nth-child(1) { background: #ff5f57; }
.traffic span:nth-child(2) { background: #febc2e; }
.traffic span:nth-child(3) { background: #28c840; }
.window:hover .traffic span { transform: scale(1.05); }

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text-strong); }
.brand .codash-mark { filter: drop-shadow(0 4px 12px color-mix(in srgb, var(--accent) 50%, transparent)); transition: transform .5s var(--ease-spring); }
.brand:hover .codash-mark { transform: rotate(-8deg) scale(1.1); }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.03em; line-height: 1; }
.brand-name .accent-dot { color: var(--accent); }
.brand-tag { font-size: 11.5px; color: var(--muted); margin-top: 3px; letter-spacing: -0.01em; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 600;
    padding: 9px 16px; border-radius: var(--r-sm);
    border: 1px solid transparent; cursor: pointer;
    transition: transform .22s var(--ease-spring), background .2s, box-shadow .25s, filter .2s, color .2s;
    white-space: nowrap; font-family: inherit; letter-spacing: -0.01em; line-height: 1; text-decoration: none;
    position: relative; overflow: hidden;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.95); }

.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2) 60%, var(--accent-3)); color: var(--accent-fg); box-shadow: var(--glow); }
.btn-primary::after { content:""; position:absolute; inset:0; background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%); transform: translateX(-120%); }
.btn-primary:hover::after { transform: translateX(120%); transition: transform .8s var(--ease-out); }
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 12px 30px -6px color-mix(in srgb, var(--accent) 60%, transparent); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; box-shadow: none; }

.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text-strong); border-color: var(--muted); }

.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: var(--r-sm);
    color: var(--muted); background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow-sm); cursor: pointer;
    transition: transform .3s var(--ease-spring), background .2s, color .2s;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text-strong); }
.btn-icon:active { transform: scale(.9); }
.btn-icon i { transition: transform .5s var(--ease-spring); }
.btn-icon:hover i { transform: rotate(-15deg) scale(1.12); }

/* ---------- Toolbar ---------- */
.toolbar {
    min-height: 54px; flex: none;
    display: flex; align-items: center; gap: 9px;
    padding: 0 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    overflow-x: auto; scrollbar-width: none;
    animation: ios-in .5s var(--ease-out) .05s both;
}
.toolbar::-webkit-scrollbar { display: none; }
.tool-group { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.tool-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }

.select {
    appearance: none; background: var(--surface); color: var(--text-strong);
    border: 1px solid var(--border); border-radius: var(--r-sm);
    padding: 9px 34px 9px 13px; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
    box-shadow: var(--shadow-sm);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b90a4' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    transition: border-color .2s, box-shadow .25s var(--ease-out);
}
.select:hover { border-color: var(--muted); }
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }

.toggle-chip {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 600; padding: 9px 15px; border-radius: var(--r-sm);
    border: 1px solid var(--border); background: var(--surface); color: var(--muted);
    box-shadow: var(--shadow-sm); cursor: pointer; font-family: inherit;
    transition: all .28s var(--ease-spring);
}
.toggle-chip:hover { border-color: var(--muted); transform: translateY(-1px); }
.toggle-chip:active { transform: scale(.95); }
.toggle-chip.active {
    background: linear-gradient(135deg, color-mix(in srgb, var(--red) 18%, transparent), color-mix(in srgb, var(--accent-3) 14%, transparent));
    border-color: color-mix(in srgb, var(--red) 45%, transparent); color: var(--red);
}
.toggle-chip.active i { animation: pop-in .45s var(--ease-spring); }
.spacer { flex: 1; }

/* ---------- Workspace ---------- */
.workspace { flex: 1; display: flex; overflow: hidden; position: relative; background: var(--surface); animation: ios-in .55s var(--ease-out) .1s both; }

/* Gutter markup is unused now — inline .cl numbers replace it everywhere,
   so the code wraps and never needs horizontal scrolling. */
.gutter { display: none; }

.code-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; }

/* Overlay editor: highlighted <pre> beneath a transparent <textarea>.
   Both wrap identically so the caret aligns with the highlighted text. */
.code-stack { position: relative; width: 100%; min-width: 0; min-height: 100%; }
.code-layer {
    margin: 0; padding: 16px 16px 16px 8px; border: 0;
    font-family: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, "JetBrains Mono", monospace;
    font-size: 13.5px; line-height: 22px; letter-spacing: 0; tab-size: 4;
    white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
    font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0;
}
pre.code-layer { position: relative; z-index: 1; margin: 0; background: none; pointer-events: none; min-height: 100%; }
pre.code-layer code { font-family: inherit; background: none; color: var(--text-strong); }
textarea.code-input {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 2;
    resize: none; outline: none; overflow: hidden;
    background: transparent; color: transparent; caret-color: var(--accent);
    padding: 16px 16px 16px calc(8px + 3.3em);   /* left = base pad + number gutter */
    white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}
textarea.code-input::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
textarea.code-input::placeholder { color: var(--muted); }

/* Static viewer */
.code-view { display: block; width: 100%; min-height: 100%; margin: 0; padding: 16px 16px 16px 8px; background: transparent; color: var(--text-strong);
    font-family: ui-monospace, "SF Mono", Menlo, "JetBrains Mono", monospace; font-size: 13.5px; line-height: 22px;
    white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; overflow: visible;
    font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.code-view code { font-family: inherit; background: none; }

/* Per-line wrappers (added by JS): wrap-aware line numbers via CSS counter.
   Hanging indent keeps wrapped text aligned; the number sits in the margin. */
.code-view code, pre.code-layer code { counter-reset: ln; }
.cl { display: block; counter-increment: ln; position: relative; padding-left: 3.3em; min-height: 1.375rem; }
.cl::before {
    content: counter(ln);
    position: absolute; left: 0; top: 0; width: 2.5em;
    text-align: right; color: var(--muted); opacity: .45;
    font-variant-ligatures: none; pointer-events: none;
}

/* Empty-state hint */
@keyframes hint-fade { from { opacity: 0; } to { opacity: 1; } }
.hero-hint { position: absolute; top: 44%; left: 50%; transform: translate(-50%, -50%); width: min(90%, 460px); text-align: center; pointer-events: none; color: var(--muted); z-index: 3; animation: hint-fade .6s var(--ease-out) .2s both; }
.hero-hint .big { font-size: 16px; font-weight: 600; color: var(--text-strong); margin-bottom: 10px; letter-spacing: -0.02em; }
.hero-hint .kbd { display: inline-block; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; padding: 3px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); color: var(--text-strong); margin: 0 2px; }

/* ---------- Status bar ---------- */
.status-bar {
    height: 34px; flex: none; display: flex; align-items: center; gap: 18px; padding: 0 18px;
    background: var(--glass); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border);
    font-family: ui-monospace, "SF Mono", Menlo, "JetBrains Mono", monospace; font-size: 11.5px; color: var(--muted);
    z-index: 20; animation: ios-drop .5s var(--ease-out) .15s both;
}
.status-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2.4s var(--ease-smooth) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 55%, transparent); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.status-accent { color: var(--accent); font-weight: 600; }

/* ---------- Meta chips ---------- */
.meta-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.meta-chip {
    display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--text);
    padding: 7px 13px; border-radius: 30px; border: 1px solid var(--border); background: var(--surface);
    box-shadow: var(--shadow-sm); white-space: nowrap; animation: pop-in .5s var(--ease-spring) both;
}
.meta-chip:nth-child(1){animation-delay:.05s} .meta-chip:nth-child(2){animation-delay:.1s} .meta-chip:nth-child(3){animation-delay:.15s} .meta-chip:nth-child(4){animation-delay:.2s} .meta-chip:nth-child(5){animation-delay:.25s}
.meta-chip i { color: var(--accent); }
.meta-chip.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); background: color-mix(in srgb, var(--red) 10%, transparent); }
.meta-chip.danger i { color: var(--red); }

/* ---------- iOS-style notification banners ---------- */
#toast-container {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    z-index: 200; display: flex; flex-direction: column; gap: 10px;
    width: min(400px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
    position: relative; overflow: hidden;
    pointer-events: auto; cursor: pointer;
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    border-radius: 22px;
    /* Liquid Glass material */
    background: color-mix(in srgb, var(--surface) 55%, transparent);
    backdrop-filter: saturate(210%) blur(28px) brightness(1.06);
    -webkit-backdrop-filter: saturate(210%) blur(28px) brightness(1.06);
    border: 1px solid transparent;
    box-shadow:
        0 20px 54px -14px rgba(16,24,40,.4),
        0 3px 10px rgba(16,24,40,.12),
        inset 0 1px 0 0 rgba(255,255,255,.65),
        inset 0 0 0 1px rgba(255,255,255,.22),
        inset 0 -10px 24px -14px rgba(255,255,255,.18);
    transform: translateY(-140%) scale(.94); opacity: 0;
    transition: transform .6s var(--ease-spring), opacity .35s var(--ease-out);
    will-change: transform, opacity;
}
/* Specular sheen + refraction highlight */
.toast::before {
    content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 1;
    background:
        linear-gradient(135deg, rgba(255,255,255,.4), rgba(255,255,255,0) 42%),
        radial-gradient(130% 90% at 50% -30%, rgba(255,255,255,.3), transparent 60%);
    mix-blend-mode: screen;
}
/* Light streak that sweeps once on appear */
.toast::after {
    content: ""; position: absolute; top: 0; left: -70%; width: 60%; height: 100%; z-index: 1;
    pointer-events: none; transform: skewX(-16deg);
    background: linear-gradient(105deg, transparent, rgba(255,255,255,.35), transparent);
}
.toast.show::after { animation: glass-sweep 1.25s var(--ease-out) .18s; }
@keyframes glass-sweep { from { left: -70%; } to { left: 140%; } }

.toast-icon, .toast-body, .toast-time { position: relative; z-index: 2; }

html.dark .toast {
    background: color-mix(in srgb, var(--surface) 52%, transparent);
    box-shadow:
        0 24px 64px -14px rgba(0,0,0,.75),
        inset 0 1px 0 0 rgba(255,255,255,.22),
        inset 0 0 0 1px rgba(255,255,255,.08),
        inset 0 -10px 26px -16px rgba(255,255,255,.08);
}
html.dark .toast::before {
    background:
        linear-gradient(135deg, rgba(255,255,255,.16), rgba(255,255,255,0) 44%),
        radial-gradient(130% 90% at 50% -30%, rgba(255,255,255,.14), transparent 60%);
}
html.dark .toast::after { background: linear-gradient(105deg, transparent, rgba(255,255,255,.16), transparent); }

.toast.show { transform: translateY(0) scale(1); opacity: 1; }
.toast.hide { transform: translateY(-140%) scale(.94); opacity: 0; }

.toast-icon {
    flex: none; width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; box-shadow: 0 4px 12px -2px rgba(16,24,40,.3);
}
.toast-icon.success { background: linear-gradient(135deg, var(--accent), var(--accent-2) 60%, var(--accent-3)); }
.toast-icon.error   { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.toast-icon svg.lucide { width: 22px; height: 22px; stroke-width: 2.5; }

.toast-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.toast-title { font-size: 14px; font-weight: 700; color: var(--text-strong); letter-spacing: -0.01em; line-height: 1.25; }
.toast-msg { font-size: 13px; font-weight: 500; color: var(--muted); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-time { flex: none; align-self: flex-start; font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }

/* ---------- 404 ---------- */
.notfound { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 16px; padding: 30px; animation: ios-in .6s var(--ease-out) both; }
.notfound .code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: clamp(72px, 15vw, 130px); font-weight: 800; line-height: 1; letter-spacing: -0.04em;
    background: linear-gradient(135deg, var(--accent), var(--accent-2), var(--accent-3)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: pop-in .7s var(--ease-spring) both; }
.notfound h1 { color: var(--text-strong); font-size: 23px; margin: 0; letter-spacing: -0.02em; }
.notfound p { color: var(--muted); margin: 0; max-width: 440px; line-height: 1.6; }

/* ---------- Syntax tokens ---------- */
code[class*="language-"], pre[class*="language-"] { color: var(--text-strong); font-family: ui-monospace, "SF Mono", Menlo, "JetBrains Mono", monospace; text-shadow: none; background: none; }
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--tok-comment); font-style: italic; }
.token.punctuation { color: var(--tok-punct); }
.token.property, .token.tag, .token.deleted, .token.selector { color: var(--tok-tag); }
.token.boolean, .token.number, .token.constant, .token.symbol { color: var(--tok-number); }
.token.string, .token.char, .token.inserted, .token.attr-value { color: var(--tok-string); }
.token.attr-name, .token.class-name, .token.builtin { color: var(--tok-attr); }
.token.operator, .token.entity, .token.url { color: var(--tok-op); }
.token.keyword, .token.atrule, .token.important, .token.rule { color: var(--tok-keyword); font-weight: 600; }
.token.function { color: var(--tok-func); }
.token.regex { color: var(--tok-number); }
.token.variable { color: var(--tok-var); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- Native-style mobile bottom bar ---------- */
.mobile-bar {
    flex: none;
    align-items: center; gap: 8px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--glass);
    backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
    border-top: 1px solid var(--border);
}
.mobile-bar .mobile-save { flex: 1; justify-content: center; padding: 15px; font-size: 15px; border-radius: 15px; }
.mobile-bar.tabbar { justify-content: space-around; gap: 4px; padding-top: 8px; }
.tabitem {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: none; border: none; cursor: pointer; text-decoration: none;
    color: var(--muted); font-family: inherit; font-size: 10.5px; font-weight: 600; padding: 5px 2px;
    border-radius: 12px; transition: transform .25s var(--ease-spring), color .2s;
}
.tabitem svg.lucide { width: 23px; height: 23px; stroke-width: 2; }
.tabitem:active { transform: scale(.88); }
.tabitem-primary { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
    body { padding: 0; }
    .window { border-radius: 0; border: none; box-shadow: none; }

    .mobile-only { display: flex; }
    .desktop-only { display: none !important; }
    .status-bar { display: none; }              /* hide dev status bar on mobile */

    .app-header {
        height: calc(54px + env(safe-area-inset-top, 0px));
        padding: env(safe-area-inset-top, 0px) calc(14px + env(safe-area-inset-right, 0px)) 0 calc(14px + env(safe-area-inset-left, 0px));
    }
    .brand-tag { display: none; }
    .traffic { display: none; }
    .brand-name { font-size: 16px; }
    .header-left, .header-right { gap: 10px; }

    /* Toolbar wraps into rows so the primary action is never off-screen */
    .toolbar {
        flex-wrap: wrap; height: auto; min-height: 0;
        padding: 10px 12px; gap: 8px; overflow: visible;
    }
    .toolbar .spacer { display: none; }
    .tool-label { display: none; }
    .tool-group { flex: 1 1 calc(50% - 5px); min-width: 0; }
    .tool-group .select { width: 100%; }
    .toggle-chip { flex: 1 1 auto; justify-content: center; }
    .toolbar .btn-primary { flex: 2 1 auto; justify-content: center; padding: 12px 16px; font-size: 14px; }
    .toolbar .btn-ghost { flex: 1 1 auto; justify-content: center; }
    .meta-row { flex: 1 1 100%; }

    /* Status bar: keep it readable, drop the least useful bits */
    .status-bar { gap: 12px; height: 32px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
    .status-bar::-webkit-scrollbar { display: none; }
    .hide-sm { display: none !important; }

    /* Code already wraps with inline line numbers at every size (see base
       rules); on phones just nudge the font down a touch. */
    .code-layer, .code-view { font-size: 13px; }

    .hero-hint { left: 16px; right: 16px; width: auto; transform: translateY(-50%); padding: 0 8px; }
    .hero-hint .big { font-size: 15px; }

    /* Notification banners span the width on small screens */
    #toast-container { top: 10px; width: calc(100vw - 20px); }
}

@media (max-width: 330px) {
    .tool-group { flex: 1 1 100%; }
}
