/* ═══════════════════════════════════════════════════════════════════════════
   OpenTuwa Studio — authentic Apple ecosystem design system.
   Three dedicated platform shells, one physics model:

     · macOS  — pointer shell  @media (hover:hover)(pointer:fine)
     · iPadOS — touch shell    @media (hover:none)(any-hover:hover) / hybrids
     · iOS    — phone shell    @media (hover:none)(any-hover:none)

   No shared breakpoint plumbing: every platform re-tunes its own tokens,
   chrome, touch targets, motion and overflow policy. Hover rules are
   gated to hover-capable devices so touch never sees stuck states.
   SF typefaces are resolved from the visitor's own Apple OS install;
   nothing is self-hosted, per Apple's font license.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── SF maximum-force, zero-host font strategy ── */
@supports (font: -apple-system-body) {
    body {
        font: -apple-system-body;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   1 · DESIGN TOKENS
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
    /* ── HIG semantic system colors · light ── */
    --system-bg: #ffffff;
    --system-bg-2: #f2f2f7;
    --system-bg-3: #ffffff;
    --system-grouped: #f2f2f7;
    --label: #000000;
    --label-2: rgba(60, 60, 67, 0.6);
    --label-3: rgba(60, 60, 67, 0.3);
    --label-4: rgba(60, 60, 67, 0.18);
    --separator: rgba(60, 60, 67, 0.29);
    --separator-opaque: #c6c6c8;

    --blue: #007aff;
    --green: #34c759;
    --red: #ff3b30;
    --orange: #ff9500;
    --yellow: #ffcc00;
    --indigo: #5856d6;
    --gray: #8e8e93;

    /* ── Apple.com "fog" canvas + Marketing Blue ramp ── */
    --bg-base: #f5f5f7;
    --apple-link: #0066cc;
    --apple-link-hover: #004999;
    --apple-blue: #0071e3;
    --apple-blue-hover: #0077ed;

    /* ── Fill / separator / shadow scale (light) ── */
    --fill-01: rgba(0, 0, 0, 0.01);
    --fill-03: rgba(0, 0, 0, 0.03);
    --fill-08: rgba(0, 0, 0, 0.08);
    --fill-10: rgba(0, 0, 0, 0.1);
    --fill-20: rgba(0, 0, 0, 0.2);
    --fill-35: rgba(0, 0, 0, 0.35);
    --hairline: rgba(0, 0, 0, 0.08);
    --border-subtle: rgba(0, 0, 0, 0.14);
    --border-medium: rgba(0, 0, 0, 0.16);
    --border-strong: rgba(0, 0, 0, 0.28);
    --border-stronger: rgba(0, 0, 0, 0.32);
    --glass-nav: rgba(251, 251, 253, 0.8);
    --glass-bg: rgba(252, 252, 252, 0.62);
    --glass-bg-strong: rgba(252, 252, 252, 0.86);
    --glass-fore: rgba(255, 255, 255, 0.96);
    --glass-edge: rgba(255, 255, 255, 0.62);
    --glass-fog: rgba(0, 0, 0, 0.04);
    --glass-hair: rgba(0, 0, 0, 0.09);
    --glass-shade: rgba(60, 60, 67, 0.32);
    --text-tertiary: #86868b;

    /* ── macOS-style shadow tones (light) ── */
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.1);
    --shadow-dropdown: 0 12px 32px rgba(0, 0, 0, 0.18);
    --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.32), 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-danger-ring: 0 8px 40px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(255, 59, 48, 0.1);

    /* ── Focus / selection rings ── */
    --ring-focus: 0 0 0 4px rgba(0, 113, 227, 0.35);
    --ring-danger: 0 0 0 4px rgba(255, 59, 48, 0.22);
    --ring-blue: rgba(0, 113, 227, 0.35);

    /* ── Apple physics ──
       --spring is a single-curve fallback (older Safari without linear()).
       --spring-fluid/--spring-snappy are multi-stage linear() springs that
       actually settle-with-micro-overshoot the way UIKit/AppKit springs do,
       rather than one smooth bezier hump. Feature-detected below. */
    --ease-apple: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-out-apple: cubic-bezier(0.32, 0.72, 0, 1);
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-fluid: var(--spring);
    --spring-snappy: var(--spring);
    --press-scale: 0.96;
    --press-scale-icon: 0.9;

    /* ── Type ── */
    --font-ui:
        -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
        "SF Pro Icons", "SF Arabic", "SF Hebrew", "SF Pro SC", "SF Pro TC",
        system-ui, "Segoe UI", Roboto, "Helvetica Neue", "Helvetica", Arial,
        sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --font-mono:
        "SF Mono", SFMono-Regular, ui-monospace, "Cascadia Code",
        "JetBrains Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

    /* ── Chrome metrics · macOS defaults (overridden per shell) ── */
    --nav-h: 48px;
    --nav-skin: rgba(251, 251, 253, 0.8);
    --tab-bar-h: 0px;
    --tap-min: 30px;
    --body-fs: 15px;
    --input-fs: 15px;
    --ui-fs: 13px;
    --label-fs: 11px;
    --radius-xs: 9px;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 18px;
    --radius-sheet: 14px;
    --radius-spot: 24px;
    --panel-gap: 24px;
    --content-x: 1.1rem;
    --cell-pad: 0.85rem 0.95rem 0.8rem;
    --bg-input: #ffffff;
    --bg-panel: #ffffff;
    --bg-card: #ffffff;
    --bg-side: #f2f2f7;
    --bg-sunken: rgba(0, 0, 0, 0.04);
    --bg-hover: rgba(0, 0, 0, 0.05);
    --accent: #0071e3;
    --accent-bg: #0071e3;
    --accent-hover: #0077ed;
    --accent-text: #ffffff;
    --accent-tint: rgba(0, 113, 227, 0.1);
    --accent-tint-border: rgba(0, 113, 227, 0.3);
    --danger: #ff3b30;
    --success: #34c759;
    --warning: #ff9500;
    --warning-tint: rgba(255, 204, 0, 0.12);
    --warning-border: rgba(255, 204, 0, 0.45);
    --warning-text: #8a6300;
    --text-main: #1d1d1f;
    --text-muted: #6e6e73;
    --tab-active: #ffffff;
    --scrollbar-w: 8px;
    --dock-shell: none;
    --z-nav: 100;
    --z-tabs: 500;
    --z-pop: 600;
    --z-modal: 1000;
    --z-spot: 1500;
    --z-ctx: 1600;
    --z-toast: 2000;
    --z-undo: 99999;
}

/* ── Real spring physics where the engine supports linear() ──
   Two tunings: "fluid" (sheets, modals, spotlight — a slower settle with a
   soft rebound) and "snappy" (toggles, tab selection, press feedback — a
   fast, tight settle). Values trace an actual damped-oscillator curve. */
@supports (transition-timing-function: linear(0, 1)) {
    :root {
        --spring-fluid: linear(
            0, 0.304 6.7%, 0.774 14.9%, 0.949 18.4%, 1.086 22.1%,
            1.136 24.2%, 1.169 26.4%, 1.185 28.5%, 1.191 30.7%,
            1.183 33.6%, 1.14 39.9%, 1.032 51%, 0.996 57.7%,
            0.976 65.6%, 0.976 82.4%, 1
        );
        --spring-snappy: linear(
            0, 0.522 9.7%, 0.813 16.5%, 0.942 20.6%, 1.036 25.2%,
            1.058 28.1%, 1.06 31.4%, 1.04 36.4%, 1.001 46.1%,
            0.988 53.4%, 0.993 68.7%, 1
        );
    }
}

/* ── Dark · macOS Tahoe / iOS semantic colors ── */
@media (prefers-color-scheme: dark) {
    :root {
        --system-bg: #000000;
        --system-bg-2: #1c1c1e;
        --system-bg-3: #2c2c2e;
        --system-grouped: #000000;
        --label: #ffffff;
        --label-2: rgba(235, 235, 245, 0.6);
        --label-3: rgba(235, 235, 245, 0.3);
        --label-4: rgba(235, 235, 245, 0.18);
        --separator: rgba(84, 84, 88, 0.6);
        --separator-opaque: #48484a;
        --blue: #0a84ff;
        --green: #30d158;
        --red: #ff453a;
        --orange: #ff9f0a;
        --yellow: #ffd60a;
        --indigo: #5e5ce6;
        --gray: #8e8e93;

        --bg-base: #000000;
        --apple-link: #2997ff;
        --apple-link-hover: #6cb6ff;
        --apple-blue-hover: #3aa0ff;

        --fill-01: rgba(255, 255, 255, 0.01);
        --fill-03: rgba(255, 255, 255, 0.03);
        --fill-08: rgba(255, 255, 255, 0.08);
        --fill-10: rgba(255, 255, 255, 0.1);
        --fill-20: rgba(255, 255, 255, 0.2);
        --fill-35: rgba(255, 255, 255, 0.35);
        --hairline: rgba(255, 255, 255, 0.08);
        --border-subtle: rgba(255, 255, 255, 0.16);
        --border-medium: rgba(255, 255, 255, 0.2);
        --border-strong: rgba(255, 255, 255, 0.32);
        --border-stronger: rgba(255, 255, 255, 0.4);
        --glass-nav: rgba(22, 22, 23, 0.8);
        --glass-bg: rgba(28, 28, 30, 0.6);
        --glass-bg-strong: rgba(28, 28, 30, 0.84);
        --glass-fore: rgba(30, 30, 32, 0.96);
        --glass-edge: rgba(255, 255, 255, 0.16);
        --glass-fog: rgba(255, 255, 255, 0.06);
        --glass-hair: rgba(255, 255, 255, 0.11);
        --glass-shade: rgba(0, 0, 0, 0.5);
        --text-tertiary: #98989d;

        --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.5);
        --shadow-dropdown: 0 12px 32px rgba(0, 0, 0, 0.55);
        --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
        --shadow-danger-ring: 0 8px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 69, 58, 0.16);
        --ring-focus: 0 0 0 4px rgba(10, 132, 255, 0.35);
        --ring-danger: 0 0 0 4px rgba(255, 69, 58, 0.22);
        --ring-blue: rgba(10, 132, 255, 0.35);

        --accent: #0a84ff;
        --accent-bg: #0a84ff;
        --accent-hover: #3aa0ff;
        --accent-tint: rgba(10, 132, 255, 0.16);
        --accent-tint-border: rgba(10, 132, 255, 0.4);
        --danger: #ff453a;
        --success: #32d74b;
        --warning: #ff9f0a;
        --warning-tint: rgba(255, 214, 10, 0.14);
        --warning-border: rgba(255, 214, 10, 0.4);
        --warning-text: #ffd60a;
        --text-main: #f5f5f7;
        --text-muted: #98989d;
        --tab-active: #2c2c2e;

        --bg-input: #1c1c1e;
        --bg-panel: #1c1c1e;
        --bg-card: #1c1c1e;
        --bg-side: #17171a;
        --bg-sunken: rgba(255, 255, 255, 0.04);
        --bg-hover: rgba(255, 255, 255, 0.08);
        --nav-skin: rgba(22, 22, 23, 0.8);
    }
    body {
        color-scheme: dark;
    }
}

/* ── Manual theme override (JS data-theme) ── */
html[data-theme="light"] {
    color-scheme: light;
    --bg-base: #f5f5f7;
    --label: #000000;
    --label-2: rgba(60, 60, 67, 0.6);
    --label-3: rgba(60, 60, 67, 0.3);
    --label-4: rgba(60, 60, 67, 0.18);
    --separator: rgba(60, 60, 67, 0.29);
    --separator-opaque: #c6c6c8;
    --blue: #007aff;
    --green: #34c759;
    --red: #ff3b30;
    --orange: #ff9500;
    --yellow: #ffcc00;
    --indigo: #5856d6;
    --gray: #8e8e93;
    --apple-link: #0066cc;
    --apple-link-hover: #004999;
    --apple-blue-hover: #0077ed;
    --fill-01: rgba(0, 0, 0, 0.01);
    --fill-03: rgba(0, 0, 0, 0.03);
    --fill-08: rgba(0, 0, 0, 0.08);
    --fill-10: rgba(0, 0, 0, 0.1);
    --fill-20: rgba(0, 0, 0, 0.2);
    --fill-35: rgba(0, 0, 0, 0.35);
    --hairline: rgba(0, 0, 0, 0.08);
    --border-subtle: rgba(0, 0, 0, 0.14);
    --border-medium: rgba(0, 0, 0, 0.16);
    --border-strong: rgba(0, 0, 0, 0.28);
    --border-stronger: rgba(0, 0, 0, 0.32);
    --glass-nav: rgba(251, 251, 253, 0.8);
    --glass-bg: rgba(252, 252, 252, 0.62);
    --glass-bg-strong: rgba(252, 252, 252, 0.86);
    --glass-fore: rgba(255, 255, 255, 0.96);
    --glass-edge: rgba(255, 255, 255, 0.62);
    --glass-fog: rgba(0, 0, 0, 0.04);
    --glass-hair: rgba(0, 0, 0, 0.09);
    --glass-shade: rgba(60, 60, 67, 0.32);
    --text-tertiary: #86868b;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.1);
    --shadow-dropdown: 0 12px 32px rgba(0, 0, 0, 0.18);
    --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.32), 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-danger-ring: 0 8px 40px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(255, 59, 48, 0.1);
    --ring-focus: 0 0 0 4px rgba(0, 113, 227, 0.35);
    --ring-danger: 0 0 0 4px rgba(255, 59, 48, 0.22);
    --ring-blue: rgba(0, 113, 227, 0.35);
    --accent: #0071e3;
    --accent-bg: #0071e3;
    --accent-hover: #0077ed;
    --accent-tint: rgba(0, 113, 227, 0.1);
    --accent-tint-border: rgba(0, 113, 227, 0.3);
    --danger: #ff3b30;
    --success: #34c759;
    --warning: #ff9500;
    --warning-tint: rgba(255, 204, 0, 0.12);
    --warning-border: rgba(255, 204, 0, 0.45);
    --warning-text: #8a6300;
    --text-main: #1d1d1f;
    --text-muted: #6e6e73;
    --tab-active: #ffffff;
    --bg-input: #ffffff;
    --bg-panel: #ffffff;
    --bg-card: #ffffff;
    --bg-side: #f2f2f7;
    --bg-sunken: rgba(0, 0, 0, 0.04);
    --bg-hover: rgba(0, 0, 0, 0.05);
    --nav-skin: rgba(251, 251, 253, 0.8);
}
html[data-theme="dark"] {
    color-scheme: dark;
    --system-bg: #000000;
    --system-bg-2: #1c1c1e;
    --system-bg-3: #2c2c2e;
    --system-grouped: #000000;
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --label-4: rgba(235, 235, 245, 0.18);
    --separator: rgba(84, 84, 88, 0.6);
    --separator-opaque: #48484a;
    --blue: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --yellow: #ffd60a;
    --indigo: #5e5ce6;
    --gray: #8e8e93;
    --bg-base: #000000;
    --apple-link: #2997ff;
    --apple-link-hover: #6cb6ff;
    --apple-blue-hover: #3aa0ff;
    --fill-01: rgba(255, 255, 255, 0.01);
    --fill-03: rgba(255, 255, 255, 0.03);
    --fill-08: rgba(255, 255, 255, 0.08);
    --fill-10: rgba(255, 255, 255, 0.1);
    --fill-20: rgba(255, 255, 255, 0.2);
    --fill-35: rgba(255, 255, 255, 0.35);
    --hairline: rgba(255, 255, 255, 0.08);
    --border-subtle: rgba(255, 255, 255, 0.16);
    --border-medium: rgba(255, 255, 255, 0.2);
    --border-strong: rgba(255, 255, 255, 0.32);
    --border-stronger: rgba(255, 255, 255, 0.4);
    --glass-nav: rgba(22, 22, 23, 0.8);
    --glass-bg: rgba(28, 28, 30, 0.6);
    --glass-bg-strong: rgba(28, 28, 30, 0.84);
    --glass-fore: rgba(30, 30, 32, 0.96);
    --glass-edge: rgba(255, 255, 255, 0.16);
    --glass-fog: rgba(255, 255, 255, 0.06);
    --glass-hair: rgba(255, 255, 255, 0.11);
    --glass-shade: rgba(0, 0, 0, 0.5);
    --text-tertiary: #98989d;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-dropdown: 0 12px 32px rgba(0, 0, 0, 0.55);
    --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-danger-ring: 0 8px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 69, 58, 0.16);
    --ring-focus: 0 0 0 4px rgba(10, 132, 255, 0.35);
    --ring-danger: 0 0 0 4px rgba(255, 69, 58, 0.22);
    --ring-blue: rgba(10, 132, 255, 0.35);
    --accent: #0a84ff;
    --accent-bg: #0a84ff;
    --accent-hover: #3aa0ff;
    --accent-tint: rgba(10, 132, 255, 0.16);
    --accent-tint-border: rgba(10, 132, 255, 0.4);
    --danger: #ff453a;
    --success: #32d74b;
    --warning: #ff9f0a;
    --warning-tint: rgba(255, 214, 10, 0.14);
    --warning-border: rgba(255, 214, 10, 0.4);
    --warning-text: #ffd60a;
    --text-main: #f5f5f7;
    --text-muted: #98989d;
    --tab-active: #2c2c2e;
    --bg-input: #1c1c1e;
    --bg-panel: #1c1c1e;
    --bg-card: #1c1c1e;
    --bg-side: #17171a;
    --bg-sunken: rgba(255, 255, 255, 0.04);
    --bg-hover: rgba(255, 255, 255, 0.08);
    --nav-skin: rgba(22, 22, 23, 0.8);
}

/* ═══════════════════════════════════════════════════════════════════════════
   2 · RESET + BASE
   ═══════════════════════════════════════════════════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-ui);
    font-size: var(--body-fs);
    line-height: 1.470588235;
    letter-spacing: -0.01em;
    background-color: var(--bg-base);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior-y: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1;
    -webkit-tap-highlight-color: transparent;
}

img,
video,
iframe,
svg {
    max-width: 100%;
}

::selection {
    background: color-mix(in srgb, var(--accent) 25%, transparent);
}

:focus-visible {
    outline: none;
    box-shadow: var(--ring-focus);
    border-radius: 6px;
}

/* Minimum legible hit target, tuned per shell */
button,
select,
[role="button"],
label[for] {
    min-height: var(--tap-min);
}

/* Long pasted payloads must fold, never explode the layout */
input,
textarea,
select,
#live_preview_container,
.editor-statusbar,
.combobox-display {
    overflow-wrap: break-word;
}
textarea,
pre {
    overflow-wrap: anywhere;
}

/* Layout-stable scroll regions — no thumb-jump when content grows */
.article-list,
.panel-body,
.combobox-options,
.spot-body,
.modal-content,
.advisory-list,
.adv-list {
    scrollbar-gutter: stable;
}

/* ── Scrollbar chrome · macOS overlay (per-shell overrides follow) ── */
::-webkit-scrollbar {
    width: var(--scrollbar-w);
    height: var(--scrollbar-w);
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
    min-height: 36px;
}
@media (prefers-color-scheme: dark) {
    ::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.22);
        background-clip: content-box;
    }
}
@media (hover: hover) and (pointer: fine) {
    ::-webkit-scrollbar-thumb:hover {
        background: rgba(0, 0, 0, 0.32);
        background-clip: content-box;
    }
    @media (prefers-color-scheme: dark) {
        ::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.35);
            background-clip: content-box;
        }
    }
}

svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   3 · GLOBALNAV
   ═══════════════════════════════════════════════════════════════════════════ */
nav {
    background-color: var(--glass-nav);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--hairline);
    padding: 0;
    height: var(--nav-h);
    min-height: var(--nav-h);
    display: flex;
    align-items: center;
    position: relative;
    z-index: var(--z-nav);
    flex-shrink: 0;
}

.globalnav-inner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 1.1rem;
}

.nav-brand {
    font-weight: 600;
    letter-spacing: -0.015em;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 13px;
    color: var(--text-main);
    padding: 0;
    white-space: nowrap;
    flex-shrink: 0;
}
.nav-brand svg {
    width: 16px;
    height: 16px;
}
.nav-brand .brand-name {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.022em;
}

.badge-outline {
    border: 1px solid var(--border-medium);
    padding: 2px 9px;
    border-radius: 980px;
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.nav-actions-wrap {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.nav-actions-wrap::-webkit-scrollbar {
    display: none;
}
.nav-actions {
    display: flex;
    gap: 0.15rem;
    align-items: center;
    width: max-content;
    padding: 2px 0;
}
.nav-actions > * {
    flex-shrink: 0;
}
.nav-actions button.btn-outline {
    background: transparent;
    border: none;
    border-radius: 980px;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: -0.01em;
    padding: 0.42rem 0.75rem;
    box-shadow: none;
}
.nav-actions button.btn-outline svg {
    width: 13px;
    height: 13px;
}
@media (hover: hover) and (pointer: fine) {
    .nav-actions button.btn-outline:hover {
        background: var(--bg-hover);
        color: var(--text-main);
    }
}
.nav-actions button.btn-outline:active {
    background: var(--fill-10);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-shrink: 0;
}

#draft-status {
    font-size: 11.5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.dot {
    width: 7px;
    height: 7px;
    background: var(--accent);
    border-radius: 50%;
    flex-shrink: 0;
}
.dot.saved {
    background: var(--success);
}

/* Glass pill buttons (Spotlight / Help) */
#btn-spotlight,
#btn-help {
    background: var(--glass-bg);
    border: 1px solid var(--glass-edge);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
@media (hover: hover) and (pointer: fine) {
    #btn-spotlight:hover,
    #btn-help:hover {
        background: var(--glass-bg-strong);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   4 · WORKSPACE SHELL — three-pane, overflow-proof grid
   ═══════════════════════════════════════════════════════════════════════════ */
main {
    flex-grow: 1;
    min-height: 0;
    display: grid;
    grid-template-columns:
        var(--col-side, clamp(236px, 23vw, 300px))
        minmax(400px, 1fr)
        minmax(0, 1fr);
    background-color: var(--bg-base);
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    border-right: 1px solid var(--hairline);
    background-color: var(--bg-panel);
}
.panel:first-child {
    background-color: var(--bg-side);
}
.panel:first-child .panel-header {
    background-color: transparent;
}
.panel:last-child {
    border-right: none;
}

/* Tab bar is owned by the iPadOS/iOS shells; never visible on desktop */
.mobile-tab-bar {
    display: none;
}

.panel-header {
    padding: 0.85rem 1.1rem 0.7rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 0.5rem;
    background-color: transparent;
}
.panel-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.015em;
    text-transform: none;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}
.panel-header h2 svg {
    width: 17px;
    height: 17px;
    color: var(--text-muted);
    stroke-width: 1.8;
    flex-shrink: 0;
}

.panel-body {
    flex-grow: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0.25rem 1.1rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* ── Grouped cell (form field) ── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: var(--cell-pad);
    min-width: 0;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group:focus-within {
    border-color: var(--accent);
    box-shadow: var(--ring-focus);
}
.row .form-group,
.row-3 .form-group {
    padding: 0.75rem 0.85rem 0.7rem;
}

/* Overflow-proof row grids: minmax(0,1fr), never bare 1fr */
.row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.6rem;
    align-items: start;
}
.row-3 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.6rem;
    align-items: start;
}

label {
    font-size: var(--label-fs);
    color: var(--text-muted);
    font-weight: 600;
    line-height: 1.4;
}
.form-group label[style*="display:flex"],
label[style*="display: flex"] {
    text-transform: none;
    font-size: 13px;
    letter-spacing: -0.01em;
    font-weight: 500;
}

input,
textarea,
select {
    width: 100%;
    min-width: 0;
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    padding: 0.42rem 0.25rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: var(--input-fs);
    letter-spacing: -0.011em;
    caret-color: var(--accent);
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}
.form-group > input,
.form-group > textarea,
.form-group > select {
    margin-top: 0.1rem;
}
@media (hover: hover) and (pointer: fine) {
    input:hover,
    textarea:hover,
    select:hover {
        border-color: var(--border-subtle);
    }
}
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring-focus);
}

/* SF-style chevron on bare selects */
select:not([size]) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='6' viewBox='0 0 9 6'%3E%3Cpath d='M1 1l3.5 3.5L8 1' stroke='%236e6e73' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    padding-right: 1.7rem;
}
select option,
select optgroup {
    background-color: var(--bg-panel);
    color: var(--text-main);
}
input[readonly] {
    background-color: var(--bg-sunken);
    color: var(--text-muted);
    cursor: default;
    border-radius: var(--radius-xs);
    padding-left: 0.55rem;
    padding-right: 0.55rem;
}
input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    -webkit-appearance: auto;
    appearance: auto;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: none;
    border: none;
}
input[type="date"],
input[type="time"],
input[type="number"] {
    -webkit-appearance: auto;
    appearance: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    padding: 0.42rem 0.6rem;
    background-color: var(--bg-input);
}
::placeholder {
    color: var(--text-muted);
    opacity: 0.65;
}
textarea {
    resize: vertical;
    min-height: 76px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   5 · BUTTONS — capsule language
   ═══════════════════════════════════════════════════════════════════════════ */
button {
    background: var(--bg-hover);
    border: 1px solid transparent;
    color: var(--text-main);
    padding: 0.42rem 1rem;
    border-radius: 980px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    letter-spacing: -0.011em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.34rem;
    min-height: var(--tap-min);
    white-space: nowrap;
    box-shadow: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    transition:
        background 0.15s,
        border-color 0.15s,
        color 0.15s,
        box-shadow 0.15s,
        opacity 0.15s,
        transform 0.18s var(--spring-snappy);
}
@media (hover: hover) and (pointer: fine) {
    button:hover {
        background-color: var(--fill-10);
    }
}
button:active:not(:disabled) {
    transform: scale(var(--press-scale));
}
button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
button:disabled:hover {
    background: var(--bg-hover);
}

button.btn-primary {
    background-color: var(--accent-bg);
    color: var(--accent-text);
    border: 1px solid var(--accent-bg);
    font-weight: 600;
}
@media (hover: hover) and (pointer: fine) {
    button.btn-primary:hover {
        background-color: var(--accent-hover);
        border-color: var(--accent-hover);
    }
}
button.btn-primary:active {
    background-color: var(--accent-hover);
    filter: brightness(0.92);
}
button.btn-outline {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-main);
}
@media (hover: hover) and (pointer: fine) {
    button.btn-outline:hover {
        border-color: var(--border-stronger);
        background-color: var(--bg-hover);
    }
}
button.btn-outline:active {
    background-color: var(--fill-10);
}
button.btn-danger {
    background: transparent;
    color: var(--danger);
}
@media (hover: hover) and (pointer: fine) {
    button.btn-danger:hover {
        background-color: color-mix(in srgb, var(--danger) 9%, transparent);
        border-color: color-mix(in srgb, var(--danger) 35%, transparent);
        color: var(--danger);
    }
}
button.btn-danger:active {
    background-color: color-mix(in srgb, var(--danger) 16%, transparent);
}
button.btn-icon {
    background: transparent;
    padding: 0.42rem 0.55rem;
}
@media (hover: hover) and (pointer: fine) {
    button.btn-icon:hover {
        background-color: var(--bg-hover);
    }
}
button.btn-icon svg {
    width: 15px;
    height: 15px;
}
button.btn-publish {
    padding: 0.44rem 1.15rem;
    font-size: 13.5px;
}

.toolbar button {
    background: transparent;
    padding: 0.34rem 0.62rem;
    color: var(--text-muted);
    font-size: 12px;
    border-radius: 980px;
}
@media (hover: hover) and (pointer: fine) {
    .toolbar button:hover {
        color: var(--text-main);
        background-color: var(--bg-hover);
    }
}
.toolbar button:active {
    background-color: var(--fill-10);
}
.toolbar button b {
    font-weight: 700;
    font-size: 13px;
}

#btn-clear.arming {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 35%, transparent);
    background-color: transparent;
}
@media (hover: hover) and (pointer: fine) {
    #btn-clear.arming:hover {
        background-color: color-mix(in srgb, var(--danger) 10%, transparent);
    }
}

/* ── Segmented control (iOS Settings chrome) ── */
.seg {
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 13px;
    background: var(--bg-sunken);
    border: 1px solid var(--glass-hair);
}
.seg-btn {
    flex: 1;
    min-width: 0;
    padding: 0.48rem 0.6rem;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition:
        background 0.18s var(--ease-apple),
        color 0.18s var(--ease-apple),
        box-shadow 0.18s var(--ease-apple);
}
@media (hover: hover) and (pointer: fine) {
    .seg-btn:hover {
        color: var(--text-main);
    }
}
.seg-btn.active {
    background: var(--bg-panel);
    color: var(--accent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14), inset 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

/* ── Draft status pill ── */
.pill-status {
    background: var(--glass-bg);
    border: 1px solid var(--glass-edge);
    border-radius: 999px;
    padding: 0.32rem 0.75rem;
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    font-variant-numeric: tabular-nums;
}
.pill-status .dot.saved {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 45%, transparent);
    animation: dot-breathe 2.4s var(--ease-apple) infinite;
}
@keyframes dot-breathe {
    0%,
    100% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 45%, transparent);
    }
    55% {
        box-shadow: 0 0 0 7px transparent;
    }
}

/* ── iOS switch (Liquid Glass) ── */
input[type="checkbox"].ios-switch {
    -webkit-appearance: none;
    appearance: none;
    width: 51px;
    height: 31px;
    border-radius: 999px;
    background: var(--fill-20);
    border: none;
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
    margin: 0;
    box-shadow: none;
    transition: background 0.2s var(--ease-apple);
}
input[type="checkbox"].ios-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.28), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
    transition: transform 0.22s var(--spring-snappy);
}
input[type="checkbox"].ios-switch:checked {
    background: var(--accent);
}
input[type="checkbox"].ios-switch:checked::after {
    transform: translateX(20px);
}
input[type="checkbox"].ios-switch:active::after {
    width: 31px;
}
input[type="checkbox"].ios-switch:disabled {
    opacity: 0.4;
    cursor: default;
}
input[type="checkbox"].ios-switch:focus-visible {
    box-shadow: var(--ring-focus);
}

/* ═══════════════════════════════════════════════════════════════════════════
   6 · COLUMN 1 — ARTICLE LIBRARY
   ═══════════════════════════════════════════════════════════════════════════ */
.list-filters {
    padding: 0.35rem 1.1rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    flex-shrink: 0;
    background-color: transparent;
}
.list-filters input[type="search"] {
    font-size: var(--input-fs);
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-input);
    padding: 0.55rem 0.8rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
@media (hover: hover) and (pointer: fine) {
    .list-filters input[type="search"]:hover {
        border-color: var(--border-strong);
    }
}
.list-filters input[type="search"]:focus {
    border-color: var(--accent);
    box-shadow: var(--ring-focus);
    background-color: var(--bg-input);
}
.filter-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.5rem;
}
.filter-row select {
    font-size: 13px;
    padding: 0.44rem 1.5rem 0.44rem 0.6rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    background-color: var(--bg-input);
    color: var(--text-main);
    min-width: 0;
    text-overflow: ellipsis;
}
@media (hover: hover) and (pointer: fine) {
    .filter-row select:hover {
        border-color: var(--border-strong);
    }
}
.filter-row select:focus {
    border-color: var(--accent);
    box-shadow: var(--ring-focus);
}

.lib-count {
    padding: 0.15rem 1.15rem 0.55rem;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    flex-shrink: 0;
}

.article-list {
    flex-grow: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 0.25rem 0.65rem 1rem;
}

.article-card {
    padding: 0.7rem 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--bg-panel);
    border: 1px solid var(--glass-hair);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.025);
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    min-width: 0;
    content-visibility: auto;
    contain-intrinsic-size: auto 96px;
    transition:
        background-color 0.12s,
        border-color 0.15s,
        box-shadow 0.18s var(--ease-apple),
        transform 0.18s var(--spring-snappy);
}
@media (hover: hover) and (pointer: fine) {
    .article-card:hover {
        background-color: var(--bg-hover);
        border-color: var(--border-medium);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
        transform: translateY(-1px);
    }
}
.article-card:active {
    transform: scale(0.985);
}
.article-card.active {
    background-color: var(--accent-bg);
    border-color: transparent;
    box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent);
}
.article-card.active .card-title {
    color: #ffffff;
}
.article-card.active .card-date,
.article-card.active .card-slug {
    color: rgba(255, 255, 255, 0.75);
}
.article-card.active .card-tag {
    background-color: rgba(255, 255, 255, 0.22);
    border-color: transparent;
    color: #ffffff;
}
/* Selection dims to neutral gray once the list isn't the focused region —
   the same "remembered selection" behavior as Finder, Mail, Notes, Xcode.
   Since focus typically lands in the editor right after picking an
   article, this is the state visitors will see most of the time. */
.article-list:not(:focus-within) .article-card.active {
    background-color: var(--bg-sunken);
    border-color: var(--border-medium);
    box-shadow: none;
}
.article-list:not(:focus-within) .article-card.active .card-title {
    color: var(--text-main);
}
.article-list:not(:focus-within) .article-card.active .card-date,
.article-list:not(:focus-within) .article-card.active .card-slug {
    color: var(--text-muted);
}
.article-list:not(:focus-within) .article-card.active .card-tag {
    background-color: var(--bg-panel);
    border-color: var(--border-subtle);
    color: var(--text-muted);
}
.article-list:not(:focus-within) .article-card.active .card-actions button {
    background: var(--bg-panel);
    color: var(--text-main);
    border-color: var(--border-subtle);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.012em;
    color: var(--text-main);
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.card-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin-top: 0.05rem;
    min-width: 0;
}
.card-date {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.card-slug {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.card-tag {
    font-size: 10.5px;
    padding: 1px 7px;
    border-radius: 980px;
    background-color: var(--bg-sunken);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    font-weight: 600;
    min-width: 0;
}
.card-actions {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}
.card-actions button {
    font-size: 12px;
    padding: 0.28rem 0.75rem;
    border-radius: 980px;
}
.card-actions button.btn-outline {
    background-color: var(--bg-sunken);
    border-color: transparent;
}
@media (hover: hover) and (pointer: fine) {
    .card-actions button.btn-outline:hover {
        background-color: var(--fill-10);
    }
}
.article-card .card-actions {
    opacity: 0.6;
    transition: opacity 0.15s;
}
@media (hover: hover) and (pointer: fine) {
    .article-card:hover .card-actions,
    .article-card.active .card-actions {
        opacity: 1;
    }
}
.article-card .card-actions button {
    -webkit-backdrop-filter: saturate(140%) blur(8px);
    backdrop-filter: saturate(140%) blur(8px);
}
.article-card.active .card-actions button {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-color: transparent;
}
@media (hover: hover) and (pointer: fine) {
    .article-card.active .card-actions button:hover {
        background: rgba(255, 255, 255, 0.32);
    }
}

.list-empty {
    padding: 2.4rem 1.25rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════════════════════
   7 · COLUMN 2 — EDITOR
   ═══════════════════════════════════════════════════════════════════════════ */
.editor-container {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-input);
    min-width: 0;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.editor-container:focus-within {
    border-color: var(--accent);
    box-shadow: var(--ring-focus);
}

.toolbar {
    background-color: var(--bg-sunken);
    padding: 0.42rem 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    border-bottom: 1px solid var(--border-subtle);
    align-items: center;
}
.toolbar-divider {
    width: 1px;
    height: 18px;
    background-color: var(--border-subtle);
    margin: 0 0.3rem;
    flex-shrink: 0;
}

#content_html {
    min-height: 380px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.65;
    background-color: var(--bg-input);
    color: var(--text-main);
    caret-color: var(--accent);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: none;
    padding: 0.85rem;
    resize: vertical;
    overflow-wrap: anywhere;
}
#content_html:focus {
    box-shadow: none;
    border-color: transparent;
}

/* ── Find / Replace bar ── */
.find-bar {
    display: none;
    flex-direction: column;
    gap: 0;
    background-color: var(--bg-sunken);
    border-bottom: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
}
.find-bar.active {
    display: flex;
}
.find-bar-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.55rem;
    flex-wrap: nowrap;
    min-width: 0;
}
.find-bar input[type="text"] {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 0.28rem 0.55rem;
    width: 200px;
    min-width: 0;
    flex: 1 1 auto;
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    color: var(--text-main);
}
.find-bar input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring-focus);
}
.find-bar input.find-no-result {
    border-color: rgba(255, 59, 48, 0.55) !important;
    background-color: rgba(255, 59, 48, 0.07);
}
.find-toggle {
    padding: 0.24rem 0.5rem;
    font-size: 11px;
    font-family: var(--font-mono);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    transition: all 0.1s;
    white-space: nowrap;
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
}
@media (hover: hover) and (pointer: fine) {
    .find-toggle:hover {
        color: var(--text-main);
        background: var(--bg-hover);
    }
}
.find-toggle.on {
    background: var(--fill-10);
    color: var(--text-main);
    border-color: var(--accent);
}
.find-count {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 72px;
    padding: 0 0.1rem;
    font-variant-numeric: tabular-nums;
}
.find-count.no-match {
    color: var(--danger);
}
.find-bar-nav {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    margin-left: auto;
    flex-shrink: 0;
}
.find-bar-nav button {
    padding: 0.22rem 0.45rem;
    font-size: 13px;
    font-family: inherit;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    border-radius: var(--radius-xs);
    cursor: pointer;
    line-height: 1;
    transition: all 0.1s;
}
@media (hover: hover) and (pointer: fine) {
    .find-bar-nav button:hover {
        background: var(--bg-hover);
        color: var(--text-main);
        border-color: var(--border-subtle);
    }
}
.find-bar-sep {
    width: 1px;
    height: 16px;
    background: var(--border-subtle);
    margin: 0 0.25rem;
    flex-shrink: 0;
}
.find-replace-row {
    display: none;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.55rem;
    border-top: 1px solid var(--border-subtle);
    background-color: var(--bg-sunken);
    flex-wrap: nowrap;
    min-width: 0;
}
.find-replace-row.active {
    display: flex;
}
.find-replace-row button {
    padding: 0.24rem 0.7rem;
    font-size: 11.5px;
    font-family: inherit;
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    border-radius: 980px;
    cursor: pointer;
    transition: all 0.1s;
    white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) {
    .find-replace-row button:hover {
        background: var(--bg-hover);
        color: var(--text-main);
    }
}

/* ── Editor status bar ── */
.editor-statusbar {
    background: var(--bg-sunken);
    border-top: 1px solid var(--border-subtle);
    padding: 0;
    display: flex;
    align-items: stretch;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    user-select: none;
    flex-shrink: 0;
    overflow-x: auto;
    white-space: nowrap;
    min-height: 22px;
    overscroll-behavior-x: contain;
}
.status-item {
    padding: 0 0.65rem;
    display: flex;
    align-items: center;
    border-right: 1px solid var(--border-subtle);
    white-space: nowrap;
    height: 22px;
    cursor: default;
    transition: background 0.1s;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.status-item.clickable {
    cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
    .status-item.clickable:hover {
        background: var(--bg-hover);
        color: var(--text-main);
    }
}
.status-item:last-child {
    border-right: none;
}
.status-item .status-icon {
    margin-right: 3px;
    font-size: 10px;
    opacity: 0.65;
}

/* ── Related / combobox ── */
.related-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.related-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.related-placeholder {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    padding: 0.25rem 0;
}
.related-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 0.3rem;
    line-height: 1.55;
}
.related-hint code {
    font-family: var(--font-mono);
    background: var(--bg-sunken);
    padding: 1px 5px;
    border-radius: var(--radius-xs);
    font-size: 10.5px;
}

.combobox-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}
.combobox-display {
    width: 100%;
    min-width: 0;
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    padding: 0.5rem 1.9rem 0.5rem 0.7rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    line-height: 1.4;
    user-select: none;
}
.co-display-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}
.combobox-display:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring-focus);
}
.combobox-display.cb-open {
    border-color: var(--accent);
    box-shadow: var(--ring-focus);
}
.combobox-display.cb-empty {
    color: var(--text-muted);
}
.combobox-chevron {
    position: absolute;
    right: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: transform 0.2s var(--ease-apple);
}
.combobox-display.cb-open + .combobox-chevron {
    transform: translateY(-50%) rotate(180deg);
}
.combobox-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    min-width: 0;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    z-index: var(--z-pop);
    overflow: hidden;
    display: none;
    flex-direction: column;
    box-shadow: var(--shadow-dropdown);
    max-height: 240px;
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
}
.combobox-panel.cb-open {
    display: flex;
}
.combobox-search-wrap {
    padding: 0.4rem;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.combobox-search {
    width: 100%;
    min-width: 0;
    background: var(--bg-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    padding: 0.35rem 0.55rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 13px;
}
.combobox-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring-focus);
}
.combobox-options {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.combobox-option {
    padding: 0.5rem 0.7rem;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
    transition: background 0.08s;
    border-bottom: 1px solid var(--border-subtle);
}
.combobox-option:last-child {
    border-bottom: none;
}
.combobox-option:active {
    background: var(--fill-10);
}
@media (hover: hover) and (pointer: fine) {
    .combobox-option:hover,
    .combobox-option.cb-focused {
        background: var(--bg-hover);
    }
}
.combobox-option.cb-focused {
    background: var(--bg-hover);
}
.combobox-option.cb-selected {
    background: var(--accent-tint);
}
.co-title {
    color: var(--text-main);
    line-height: 1.3;
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.co-slug {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.co-locale {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--accent);
    background: var(--accent-tint);
    padding: 1px 6px;
    border-radius: 980px;
    margin-left: auto;
    flex-shrink: 0;
}
.combobox-empty {
    padding: 0.7rem 0.85rem;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   8 · COLUMN 3 — LIVE PREVIEW
   ═══════════════════════════════════════════════════════════════════════════ */
#live_preview_container {
    padding: 2.2rem 2rem 3.5rem;
    flex-grow: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    line-height: 1.6;
    font-size: 17px;
    letter-spacing: -0.011em;
    background-color: var(--bg-panel);
}
#live_preview_container > *:first-child {
    margin-top: 0;
}
#live_preview_container h1,
#live_preview_container h2,
#live_preview_container h3,
#live_preview_container h4 {
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.15;
    color: var(--text-main);
    overflow-wrap: anywhere;
}
#live_preview_container h1 {
    font-size: 40px;
    letter-spacing: -0.025em;
}
#live_preview_container h2 {
    font-size: 32px;
    letter-spacing: -0.02em;
    margin: 1.8rem 0 0.9rem;
}
#live_preview_container h3 {
    font-size: 24px;
    letter-spacing: -0.015em;
    margin: 1.5rem 0 0.7rem;
}
#live_preview_container h4 {
    font-size: 18px;
    letter-spacing: -0.01em;
    margin: 1.2rem 0 0.5rem;
}
#live_preview_container p {
    margin-top: 0;
    margin-bottom: 1.5em;
    color: var(--text-main);
    overflow-wrap: anywhere;
}
#live_preview_container a {
    color: var(--apple-link);
    text-decoration: none;
}
@media (hover: hover) and (pointer: fine) {
    #live_preview_container a:hover {
        text-decoration: underline;
    }
}
#live_preview_container blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.3rem;
    color: var(--text-main);
    margin: 2rem 0;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
#live_preview_container figure {
    margin: 2rem 0;
    min-width: 0;
}
#live_preview_container img,
#live_preview_container video,
#live_preview_container iframe {
    max-width: 100%;
    border-radius: var(--radius-sm);
    display: block;
    border: none;
    box-shadow: var(--shadow-1);
}
#live_preview_container figcaption {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 0.6rem;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.6rem;
    overflow-wrap: anywhere;
}
#live_preview_container .infobox {
    background: var(--bg-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 1.3rem;
    margin: 2rem 0;
    border-left: 4px solid var(--text-main);
    min-width: 0;
}
#live_preview_container .infobox h4 {
    margin-top: 0;
    color: var(--text-main);
    font-size: 13px;
}
#live_preview_container .tuwa-subtitle-box {
    background: var(--bg-sunken);
    border: 1px dashed var(--accent);
    padding: 0.4rem;
    margin-top: -1rem;
    margin-bottom: 1rem;
    border-radius: 0 0 var(--radius-xs) var(--radius-xs);
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    overflow-wrap: anywhere;
}
#live_preview_container .tuwa-subtitle-box::before {
    content: "Subtitle: " attr(data-vtt);
}
#live_preview_container .yt-short-wrap {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
}
#live_preview_container .yt-short-wrap iframe {
    width: 315px;
    max-width: 100%;
    aspect-ratio: 9/16;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    display: block;
    box-shadow: none;
}
#live_preview_container .pull-quote {
    margin: 1.8rem 0;
    padding: 0.6rem 0 0.6rem 1.1rem;
    border-left: 4px solid var(--accent);
    font-size: 1.45rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.35;
    color: var(--text-main);
}
#live_preview_container p.dropcap::first-letter {
    float: left;
    font-size: 3.4em;
    line-height: 0.82;
    font-weight: 700;
    letter-spacing: -0.03em;
    padding-right: 0.14em;
    color: var(--text-main);
}
#live_preview_container figcaption .credit {
    color: var(--text-muted);
    font-style: normal;
}

/* ═══════════════════════════════════════════════════════════════════════════
   9 · MODALS — Apple sheet language
   ═══════════════════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.36);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    backdrop-filter: saturate(180%) blur(24px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: var(--z-modal);
    padding: 1.5rem;
}
.modal-overlay.active {
    display: flex;
    animation: modal-fade 0.18s var(--ease-out-apple);
}
@keyframes modal-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
.modal-content {
    position: relative;
    background: linear-gradient(180deg, color-mix(in srgb, var(--glass-fore) 100%, #fff 8%) 0%, var(--glass-fore) 60%);
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius-sheet);
    box-shadow: inset 0 1px 0 var(--glass-edge), var(--shadow-modal);
    padding: 1.8rem;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    animation: sheet-up 0.28s var(--spring-fluid);
}
.modal-content::before {
    display: none;
}
@keyframes modal-pop {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}
@keyframes sheet-up {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.modal-content h2 {
    margin: 0 0 1.2rem;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.016em;
    color: var(--text-main);
}
.modal-content .form-group {
    border-radius: var(--radius-sm);
}

/* ── Delete triple-confirm ── */
.del-step {
    display: none;
    flex-direction: column;
    gap: 0.9rem;
}
.del-step.active {
    display: flex;
}
.del-progress {
    display: flex;
    gap: 0.3rem;
}
.del-pip {
    height: 4px;
    flex: 1;
    min-width: 0;
    border-radius: 2px;
    background: var(--border-subtle);
    transition: background 0.25s;
}
.del-pip.done {
    background: var(--danger);
}
.del-phrase {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 7%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    letter-spacing: 0.08em;
    text-align: center;
    user-select: none;
    overflow-wrap: anywhere;
}
.del-note {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.55;
    overflow-wrap: anywhere;
}
.del-note strong {
    color: var(--text-main);
}
.del-input-err {
    border-color: rgba(255, 59, 48, 0.6) !important;
    box-shadow: var(--ring-danger) !important;
}
.del-errmsg {
    font-size: 12px;
    color: var(--danger);
    display: none;
}

/* ── Advisory tabs ── */
.adv-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 1.1rem;
    gap: 0;
}
.adv-tab {
    padding: 0.55rem 1.1rem;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    transition: all 0.12s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    border-radius: 0;
    white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) {
    .adv-tab:hover {
        color: var(--text-main);
    }
}
.adv-tab.active {
    color: var(--text-main);
    border-bottom-color: var(--accent);
}
.adv-panel {
    display: none;
    flex-direction: column;
    gap: 0.8rem;
}
.adv-panel.active {
    display: flex;
}
.adv-search {
    padding: 0.55rem 0.7rem;
    background: var(--bg-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    color: var(--text-main);
    font-size: 14px;
    width: 100%;
    min-width: 0;
}
.adv-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring-focus);
}
.adv-bulk-textarea {
    min-height: 180px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    padding: 0.65rem;
    background: var(--bg-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    resize: vertical;
}
.adv-bulk-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring-focus);
}
.adv-list {
    max-height: 320px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-sunken);
}
.adv-list-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.08s;
    min-width: 0;
}
.adv-list-item:last-child {
    border-bottom: none;
}
.adv-list-item:active {
    background: var(--fill-10);
}
@media (hover: hover) and (pointer: fine) {
    .adv-list-item:hover {
        background: var(--bg-hover);
    }
}
.adv-list-item input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}
.adv-list-item .adv-title {
    flex: 1;
    min-width: 0;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.adv-list-item .adv-meta {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.adv-review-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
    min-width: 0;
}
.adv-review-item:last-child {
    border-bottom: none;
}
.adv-review-item .adv-title {
    flex: 1;
    min-width: 0;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.adv-review-item .adv-slug {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 0.5rem;
    flex-shrink: 0;
}
.state-badge {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 1;
    padding: 3px 7px;
    border-radius: 999px;
    margin-left: 0.5rem;
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    background: transparent;
    white-space: nowrap;
}
.state-badge-on {
    color: var(--success);
    border-color: var(--success);
    background: color-mix(in srgb, var(--success) 8%, transparent);
}
.adv-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.6rem;
    border-top: 1px solid var(--border-subtle);
    padding-top: 0.85rem;
    flex-wrap: wrap;
}
.adv-count {
    font-size: 12.5px;
    color: var(--text-muted);
    padding: 0.3rem 0;
}

/* ── Announcements ── */
.ann-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    transition: border-color 0.12s;
    min-width: 0;
}
@media (hover: hover) and (pointer: fine) {
    .ann-item:hover {
        border-color: var(--border-medium);
    }
}
.ann-item-info {
    flex: 1;
    min-width: 0;
}
.ann-item-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.011em;
    color: var(--text-main);
    overflow-wrap: anywhere;
}
.ann-item-meta {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 3px;
    overflow-wrap: anywhere;
}
.ann-item-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}
.ann-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
    padding: 0.75rem 0.9rem;
    background: var(--bg-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 13px;
}
.ann-toggle-switch {
    position: relative;
    width: 51px;
    height: 31px;
    background: var(--fill-20);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s var(--ease-apple);
    flex-shrink: 0;
    border: none;
    padding: 0;
}
.ann-toggle-switch.on {
    background: var(--accent);
}
.ann-toggle-switch:focus-visible {
    box-shadow: var(--ring-focus);
}
.ann-toggle-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.22s var(--spring-snappy);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.28), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
.ann-toggle-switch:active::after {
    width: 31px;
}
.ann-toggle-switch.on::after {
    transform: translateX(20px);
}

/* ── Media insert modal ── */
.media-modal-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}
.media-modal-field label {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}
.media-modal-field input {
    background-color: var(--bg-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    padding: 0.5rem 0.7rem;
    font-size: 14px;
    min-width: 0;
}
.media-modal-field input:focus {
    border-color: var(--accent);
    box-shadow: var(--ring-focus);
}
.media-modal-field .field-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* ── Generic tables (bulk modals) — fixed layout, wraps, never blows out ── */
.modal-content table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
    font-variant-numeric: tabular-nums;
}
.modal-content thead th {
    padding: 0.6rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-sunken);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    overflow-wrap: anywhere;
}
.modal-content tbody td {
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: top;
    overflow-wrap: anywhere;
    word-break: break-word;
}
@media (hover: hover) and (pointer: fine) {
    .modal-content tbody tr:hover {
        background: var(--bg-hover);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   10 · TOASTS — notification banners
   ═══════════════════════════════════════════════════════════════════════════ */
#toast-container {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 60px);
    right: 1rem;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 13px;
    min-width: 220px;
    max-width: 340px;
    border-radius: 17px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--glass-fore) 100%, #fff 8%) 0%, var(--glass-fore) 60%);
    border: 1px solid var(--glass-edge);
    box-shadow: inset 0 1px 0 var(--glass-edge), var(--shadow-modal);
    padding: 0.55rem 0.9rem;
    transform: translateX(calc(100% + 1.5rem));
    opacity: 0;
    transition:
        transform 0.24s var(--ease-apple),
        opacity 0.24s var(--ease-apple);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    pointer-events: auto;
}
.toast.toast-show {
    transform: translateX(0);
    opacity: 1;
}
.toast-success,
.toast-error,
.toast-info {
    border-left: none;
}
.toast-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: var(--glass-fog);
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.toast-icon svg {
    width: 15px;
    height: 15px;
}
.toast-success .toast-icon {
    background: color-mix(in srgb, var(--success) 14%, transparent);
    color: var(--success);
}
.toast-error .toast-icon {
    background: color-mix(in srgb, var(--danger) 14%, transparent);
    color: var(--danger);
}
.toast-info .toast-icon {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent);
}
.toast-msg {
    color: var(--text-main);
    line-height: 1.4;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* ── Loading skeleton ── */
.skel {
    background: linear-gradient(
        90deg,
        var(--bg-sunken) 25%,
        var(--bg-hover) 50%,
        var(--bg-sunken) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
    border-radius: var(--radius-xs);
}
@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   11 · OVERLAYS — Spotlight / Context menu / Help
   ═══════════════════════════════════════════════════════════════════════════ */
.spot-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-spot);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 11vh 0.8rem 1.5rem;
    background: rgba(0, 0, 0, 0.16);
    -webkit-backdrop-filter: blur(6px) saturate(160%);
    backdrop-filter: blur(6px) saturate(160%);
}
.spot-overlay.open {
    display: flex;
    animation: spot-fade 0.16s var(--ease-apple);
}
@keyframes spot-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
.spot-panel {
    position: relative;
    width: 100%;
    max-width: 620px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--glass-bg-strong) 100%, #fff 8%) 0%, var(--glass-bg-strong) 60%);
    -webkit-backdrop-filter: saturate(200%) blur(40px);
    backdrop-filter: saturate(200%) blur(40px);
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius-spot);
    box-shadow: inset 0 1px 0 var(--glass-edge), 0 28px 64px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: spot-in 0.26s var(--spring-fluid);
}
.spot-search-ico {
    position: absolute;
    left: 1.15rem;
    top: 1.12rem;
    color: var(--text-muted);
    pointer-events: none;
}
.spot-kbd {
    position: absolute;
    top: 1.05rem;
    right: 1.1rem;
    pointer-events: none;
}
@keyframes spot-in {
    from {
        opacity: 0;
        transform: translateY(-14px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.spot-search {
    width: 100%;
    min-width: 0;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    font: inherit;
    font-size: 19px;
    letter-spacing: -0.015em;
    padding: 1.05rem 1.2rem 1.05rem 2.7rem;
    color: var(--text-main);
    caret-color: var(--accent);
    border-radius: 0 !important;
}
.spot-search:focus,
.spot-search:focus-visible {
    outline: none;
    box-shadow: none !important;
    border-color: transparent !important;
}
.spot-search::placeholder {
    color: var(--text-muted);
    opacity: 0.75;
}
.spot-body {
    max-height: min(380px, 46vh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0.2rem 0.6rem 0.65rem;
}
.spot-group {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    padding: 0.75rem 0.85rem 0.25rem;
}
.spot-empty {
    display: none;
    padding: 1.6rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
}
.spot-empty.visible {
    display: block;
}
.sl-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.55rem 0.7rem;
    border-radius: 13px;
    cursor: pointer;
    min-width: 0;
    transition: background 0.08s;
}
.sl-row.active,
.sl-row:active {
    background: var(--accent);
}
@media (hover: hover) and (pointer: fine) {
    .sl-row:hover {
        background: var(--accent);
    }
}
.sl-ico {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: var(--glass-fog);
    color: var(--text-muted);
    flex-shrink: 0;
}
.sl-ico svg {
    width: 15px;
    height: 15px;
}
.sl-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.sl-head {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sl-sub {
    font-size: 11.5px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sl-row.active .sl-head,
.sl-row.active .sl-sub,
.sl-row.active .sl-kbd .kbd,
.sl-row.active .sl-ico,
.sl-row:active .sl-head,
.sl-row:active .sl-sub,
.sl-row:active .sl-kbd .kbd,
.sl-row:active .sl-ico {
    color: #ffffff;
}
.sl-row.active .sl-sub,
.sl-row:active .sl-sub {
    color: rgba(255, 255, 255, 0.75);
}
.sl-row.active .sl-ico,
.sl-row.active .sl-kbd .kbd,
.sl-row:active .sl-ico,
.sl-row:active .sl-kbd .kbd {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.3);
}
@media (hover: hover) and (pointer: fine) {
    .sl-row:hover .sl-head,
    .sl-row:hover .sl-sub,
    .sl-row:hover .sl-kbd .kbd,
    .sl-row:hover .sl-ico {
        color: #ffffff;
    }
    .sl-row:hover .sl-sub {
        color: rgba(255, 255, 255, 0.75);
    }
    .sl-row:hover .sl-ico,
    .sl-row:hover .sl-kbd .kbd {
        background: rgba(255, 255, 255, 0.22);
        border-color: rgba(255, 255, 255, 0.3);
    }
}
.sl-kbd {
    margin-left: auto;
    flex-shrink: 0;
}
.spot-footer,
.spot-panel-foot {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 0.55rem 0.95rem;
    border-top: 1px solid var(--glass-hair);
    background: var(--glass-fog);
    font-size: 11.5px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.spot-tip kbd {
    font-family: var(--font-mono);
    font-size: 10.5px;
    border: 1px solid var(--glass-hair);
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: 1px 5px;
    background: var(--glass-fog);
    color: var(--text-muted);
}
.kbd {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    border: 1px solid var(--glass-hair);
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: 1px 5px;
    background: var(--glass-fog);
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Context menu ── */
.ctx-root {
    position: fixed;
    inset: 0;
    z-index: var(--z-ctx);
    display: none;
}
.ctx-root.open {
    display: block;
}
.ctx-menu {
    position: absolute;
    min-width: 224px;
    max-width: min(320px, calc(100vw - 16px));
    padding: 5px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--glass-fore) 100%, #fff 8%) 0%, var(--glass-fore) 60%);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
    backdrop-filter: saturate(180%) blur(28px);
    border: 1px solid var(--glass-edge);
    border-radius: 15px;
    box-shadow: inset 0 1px 0 var(--glass-edge), 0 24px 50px rgba(0, 0, 0, 0.24);
    animation: ctx-in 0.18s var(--spring-snappy);
    transform-origin: left top;
}
@keyframes ctx-in {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.ctx-label {
    padding: 0.5rem 0.75rem 0.35rem;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 280px;
}
.ctx-item {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-main);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: -0.01em;
    text-align: left;
    padding: 0.55rem 0.65rem;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: none;
}
.ctx-item:active {
    background: var(--accent);
    color: #ffffff;
}
@media (hover: hover) and (pointer: fine) {
    .ctx-item:hover {
        background: var(--accent);
        color: #ffffff;
        transform: none;
    }
}
.ctx-item svg {
    width: 15px;
    height: 15px;
    opacity: 0.85;
}
.ctx-ico {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: var(--glass-fog);
    color: var(--text-muted);
    flex-shrink: 0;
}
.ctx-item:active .ctx-ico {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}
@media (hover: hover) and (pointer: fine) {
    .ctx-item:hover .ctx-ico {
        background: rgba(255, 255, 255, 0.18);
        color: #ffffff;
    }
}
.ctx-item.ctx-destructive {
    color: var(--danger);
}
.ctx-item.ctx-destructive:active {
    background: var(--danger);
    color: #ffffff;
}
@media (hover: hover) and (pointer: fine) {
    .ctx-item.ctx-destructive:hover {
        background: var(--danger);
        color: #ffffff;
    }
}
.ctx-kbd {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
}
.ctx-item:active .ctx-kbd {
    color: rgba(255, 255, 255, 0.85);
}
@media (hover: hover) and (pointer: fine) {
    .ctx-item:hover .ctx-kbd {
        color: rgba(255, 255, 255, 0.85);
    }
}

/* ── Help sheet ── */
.help-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-spot);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.24);
    -webkit-backdrop-filter: blur(8px) saturate(160%);
    backdrop-filter: blur(8px) saturate(160%);
}
.help-overlay.open {
    display: flex;
}
.help-card {
    width: 100%;
    max-width: 520px;
    max-height: 82vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: linear-gradient(180deg, color-mix(in srgb, var(--glass-fore) 100%, #fff 8%) 0%, var(--glass-fore) 60%);
    -webkit-backdrop-filter: saturate(180%) blur(32px);
    backdrop-filter: saturate(180%) blur(32px);
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius-sheet);
    box-shadow: inset 0 1px 0 var(--glass-edge), var(--shadow-modal);
    padding: 1.6rem 1.7rem 1.4rem;
    animation: sheet-up 0.32s var(--spring-fluid);
}
.help-card h2,
.help-title {
    margin: 0 0 0.3rem;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.016em;
    color: var(--text-main);
}
.help-card .help-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 1.1rem;
    line-height: 1.5;
}
.help-rows {
    display: flex;
    flex-direction: column;
}
.help-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--glass-hair);
    font-size: 13.5px;
    color: var(--text-main);
}
.help-row .kbd {
    min-width: 104px;
    text-align: center;
    flex-shrink: 0;
}
.help-row > span:last-child {
    flex: 1;
}
.help-row:last-child {
    border-bottom: none;
}
.help-row .kbd-stack {
    min-width: 96px;
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.help-row .help-desc {
    flex: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   12 · JS-INJECTED COMPONENTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Bulk Serial Assignment tabs ── */
.bsa-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}
.bsa-tab {
    appearance: none;
    border: none;
    background: none;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.5rem 0.85rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    border-radius: 0;
    transition: color 0.08s;
    white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) {
    .bsa-tab:hover {
        color: var(--text-main);
    }
}
.bsa-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.bsa-panel {
    display: none;
}
.bsa-panel.active {
    display: block;
}

/* ── YouTube VTT undo banner (glass notification) ── */
#ytvtt-undo-banner {
    display: none;
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
    right: 22px;
    z-index: var(--z-undo);
    width: 310px;
    max-width: calc(100vw - 44px);
    background: linear-gradient(180deg, color-mix(in srgb, var(--glass-fore) 100%, #fff 8%) 0%, var(--glass-fore) 60%);
    border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
    border-radius: 16px;
    box-shadow: inset 0 1px 0 var(--glass-edge), var(--shadow-danger-ring);
    padding: 1rem 1.1rem;
    font-family: var(--font-ui);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
    backdrop-filter: saturate(180%) blur(28px);
    animation: undoBannerIn 0.28s cubic-bezier(0.2, 0.8, 0.4, 1) both;
    pointer-events: all;
}
@keyframes undoBannerIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
#ytvtt-undo-banner .ub-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--danger);
    margin-bottom: 0.35rem;
}
#ytvtt-undo-banner .ub-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 0.75rem;
    overflow-wrap: anywhere;
}
#ytvtt-undo-banner .ub-desc strong {
    color: var(--text-main);
}
#ytvtt-undo-banner .ub-countdown-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}
#ytvtt-undo-banner .ub-bar-track {
    flex: 1;
    min-width: 0;
    height: 4px;
    background: var(--fill-10);
    border-radius: 2px;
    overflow: hidden;
}
#ytvtt-undo-banner .ub-bar-fill {
    height: 100%;
    background: var(--danger);
    border-radius: 2px;
    transition: width 1s linear;
    width: 100%;
}
#ytvtt-undo-banner .ub-timer {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--danger);
    white-space: nowrap;
    min-width: 38px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
#ytvtt-undo-banner .ub-articles {
    font-size: 0.62rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-bottom: 0.85rem;
    max-height: 54px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
#ytvtt-undo-btn {
    width: 100%;
    background: color-mix(in srgb, var(--danger) 8%, transparent);
    border: 1.5px solid color-mix(in srgb, var(--danger) 35%, transparent);
    color: var(--danger);
    border-radius: 12px;
    padding: 0.52rem 0;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
    letter-spacing: 0.01em;
}
@media (hover: hover) and (pointer: fine) {
    #ytvtt-undo-btn:hover {
        background: color-mix(in srgb, var(--danger) 16%, transparent);
        border-color: color-mix(in srgb, var(--danger) 60%, transparent);
    }
}
#ytvtt-undo-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
#ytvtt-undo-banner .ub-expired {
    display: none;
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: center;
    padding-top: 0.35rem;
}

/* ── D1 Terminal (macOS Terminal.app chrome) ── */
#d1-terminal-modal {
    --term-bg: #0d0d0d;
    --term-text: #00ff41;
    --term-dim: #107a2a;
    --term-error: #ff6b6b;
    --term-accent: #ffffff;
    --term-font: "SF Mono", SFMono-Regular, ui-monospace, Menlo, monospace;
}
#d1-terminal-modal .modal-content {
    max-width: 820px;
    width: 95%;
    max-height: 88vh;
    padding: 0;
    background: var(--term-bg);
    border: 1px solid #1a1a1a;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: sheet-up 0.24s var(--spring-fluid);
}
#d1-terminal-modal .modal-content::before {
    display: none;
}
.term-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
    flex-shrink: 0;
    user-select: none;
    gap: 0.5rem;
}
.term-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}
.term-dots {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
@media (hover: hover) and (pointer: fine) {
    .term-dots:hover .term-dot::after {
        opacity: 1;
    }
}
.term-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: relative;
    box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.15);
}
.term-dot::after {
    content: "";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0;
    transition: opacity 0.1s var(--ease-apple);
}
.term-dot.red {
    background: #ff5f56;
}
.term-dot.red::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6' viewBox='0 0 6 6'%3E%3Cpath d='M1 1l4 4M5 1L1 5' stroke='%23730000' stroke-width='1.1' stroke-linecap='round'/%3E%3C/svg%3E");
}
.term-dot.yellow {
    background: #ffbd2e;
}
.term-dot.yellow::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='2' viewBox='0 0 6 2'%3E%3Cpath d='M1 1h4' stroke='%23985700' stroke-width='1.1' stroke-linecap='round'/%3E%3C/svg%3E");
}
.term-dot.green {
    background: #27c93f;
}
.term-dot.green::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6' viewBox='0 0 6 6'%3E%3Cpath d='M1 3.6L2.4 5M1 5V3.4M1 5h1.6M5 2.4L3.6 1M5 1H3.4M5 1v1.6' stroke='%23006500' stroke-width='1' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.term-title {
    font-family: var(--term-font);
    font-size: 0.72rem;
    color: #888;
    letter-spacing: 0.03em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.term-header-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.15rem 0.4rem;
    font-family: var(--term-font);
    font-size: 0.9rem;
    border-radius: 10px;
}
@media (hover: hover) and (pointer: fine) {
    .term-header-close:hover {
        background: #333;
        color: #fff;
    }
}
.term-output {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0.75rem 1rem;
    font-family: var(--term-font);
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--term-text);
    background: var(--term-bg);
    min-height: 280px;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-wrap: anywhere;
}
.term-output .err {
    color: var(--term-error);
}
.term-output .dim {
    color: var(--term-dim);
}
.term-output .white {
    color: var(--term-accent);
}
.term-output .info {
    color: #88bbff;
}
.term-input-row {
    display: flex;
    align-items: center;
    padding: 0.4rem 1rem 0.6rem;
    background: #0a0a0a;
    border-top: 1px solid #1a1a1a;
    flex-shrink: 0;
    gap: 0.3rem;
}
.term-prompt {
    font-family: var(--term-font);
    font-size: 0.82rem;
    color: var(--term-text);
    flex-shrink: 0;
    white-space: nowrap;
}
.term-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--term-font);
    font-size: 0.82rem;
    color: var(--term-accent);
    caret-color: var(--term-text);
}
.term-input::placeholder {
    color: #333;
}
.term-table {
    display: inline-block;
    font-family: var(--term-font);
    font-size: 0.74rem;
    line-height: 1.4;
    color: var(--term-text);
    margin: 2px 0;
}
.term-table .sep {
    color: var(--term-dim);
}
.term-table .hdr {
    color: var(--term-accent);
    font-weight: bold;
}
.term-table .row {
    color: var(--term-text);
}

/* ═══════════════════════════════════════════════════════════════════════════
   13 · MOTION SAFETY
   ═══════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SHELL 1 · macOS — pointer shell
   Hover chrome, overlay scrollbars, ⌘ shortcuts, hover-reveal actions.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (hover: hover) and (pointer: fine) and (not (any-pointer: coarse)) {
    :root {
        --nav-h: 48px;
        --tap-min: 28px;
        --body-fs: 15px;
        --input-fs: 15px;
        --ui-fs: 13px;
        --label-fs: 11px;
        --radius-xs: 9px;
        --radius-sm: 12px;
        --radius-md: 16px;
        --radius-sheet: 14px;
        --radius-spot: 24px;
        --scrollbar-w: 8px;
        --col-side: clamp(236px, 23vw, 300px);
    }

    body {
        cursor: default;
    }
    body,
    button,
    input,
    textarea,
    select,
    .article-card,
    .combobox-display {
        cursor: default;
    }

    /* Overlay, inset scrollbars */
    .article-list,
    .panel-body,
    .combobox-options,
    .spot-body,
    .modal-content,
    .adv-list,
    .editor-statusbar {
        scrollbar-gutter: stable;
    }
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    /* Mac-style sidebar: inset list cells, 8px margins */
    .article-list {
        padding: 0.3rem 0.65rem 1rem;
    }

    .panel-header h2 {
        font-size: 16px;
        font-weight: 700;
        letter-spacing: -0.015em;
    }

    /* Hover-reveal only on hover-capable pointers */
    .card-actions {
        opacity: 0;
    }
    .article-card:hover .card-actions,
    .article-card:focus-within .card-actions,
    .article-card.active .card-actions {
        opacity: 1;
    }

    /* Nested media for narrow desktop windows — compress, never overflow */
    @media (max-width: 979px) {
        main {
            grid-template-columns:
                clamp(176px, 24vw, 232px)
                minmax(300px, 1fr)
                minmax(0, 1fr);
        }
    }

    @media (max-width: 719px) {
        main {
            display: flex;
            flex-direction: column;
            overflow-y: auto;
        }
        .panel {
            border-right: none;
            border-bottom: 1px solid var(--hairline);
            height: max(460px, 70vh);
            flex: none;
        }
        .panel:last-child {
            border-bottom: none;
        }
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SHELL 2 · iPadOS — touch shell (coarse primary, hover capability)
   Split-view columns, 44pt targets, floating dock, no sticky hovers.
   Hybrid pointers (trackpad / touchscreen laptop) land here too.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (hover: none) and (any-hover: hover) and (pointer: coarse),
    (hover: on-demand) and (pointer: coarse),
    (pointer: fine) and (any-pointer: coarse) {
    :root {
        --nav-h: 52px;
        --tap-min: 44px;
        --body-fs: 15px;
        --input-fs: 16px;
        --ui-fs: 14px;
        --label-fs: 12px;
        --radius-xs: 11px;
        --radius-sm: 16px;
        --radius-md: 18px;
        --radius-sheet: 24px;
        --radius-spot: 26px;
        --content-x: 1.25rem;
        --cell-pad: 0.9rem 1rem 0.85rem;
        --col-side: clamp(220px, 24vw, 288px);
        --panel-gap: 28px;
        --scrollbar-w: 6px;
        --bg-side: var(--system-grouped);
        --bg-base: var(--system-grouped);
    }

    body {
        -webkit-touch-callout: none;
        cursor: default;
    }

    /* Native touch scrolling with momentum */
    .article-list,
    .panel-body,
    .combobox-options,
    .spot-body,
    .modal-content,
    .adv-list,
    #live_preview_container,
    #content_html {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .editor-statusbar {
        overscroll-behavior-x: contain;
    }

    /* Hide web scrollbars — momentum indicators only */
    ::-webkit-scrollbar {
        display: none;
    }
    .article-list,
    .panel-body,
    .combobox-options,
    .spot-body,
    .modal-content,
    .adv-list {
        scrollbar-width: none;
    }

    /* Fat touch targets everywhere */
    .panel-header {
        padding: 1rem 1.25rem 0.85rem;
    }
    .panel-header h2 {
        font-size: 22px;
    }
    .article-card {
        padding: 1rem 1rem;
        border-radius: 18px;
        margin-bottom: 0;
        transform: none !important;
    }
    .card-actions button {
        padding: 0.42rem 0.95rem;
    }
    .article-card .card-actions {
        opacity: 1;
        background: transparent;
    }
    .toolbar button,
    .nav-actions button.btn-outline,
    .find-toggle,
    .find-bar-nav button,
    .find-replace-row button,
    .seg-btn {
        min-height: 44px;
        padding-top: 0.55rem;
        padding-bottom: 0.55rem;
    }
    .find-bar input[type="text"] {
        min-height: 40px;
    }
    input,
    textarea,
    select {
        font-size: 16px;
    }

    /* Landscape split-view columns */
    @media (min-width: 801px) {
        main {
            grid-template-columns:
                var(--col-side)
                minmax(380px, 1fr)
                minmax(0, 1fr);
        }
    }

    /* Portrait: single pane + floating dock (JS .mobile-active pattern) */
    @media (max-width: 800px) {
        main {
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        .panel {
            display: none;
            width: 100%;
            border-right: none;
            flex: 1;
            min-height: 0;
        }
        .panel.mobile-active {
            display: flex;
        }
        .mobile-tab-bar {
            display: flex;
        }
        .row,
        .row-3 {
            grid-template-columns: minmax(0, 1fr);
            gap: 0.5rem;
        }
        #toast-container {
            top: 1rem;
            right: 50%;
            transform: translateX(50%);
            align-items: center;
            width: calc(100vw - 2rem);
        }
        .toast {
            min-width: 0;
            width: 100%;
        }
        .modal-overlay {
            padding: 0.75rem;
        }
        .modal-content {
            width: 100%;
            max-width: 640px;
            max-height: 88vh;
            padding: 1.5rem;
        }
    }

    /* Floating dock bar */
    .mobile-tab-bar {
        display: none;
        position: fixed;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
        width: calc(100% - 32px);
        max-width: 520px;
        height: 64px;
        padding-bottom: 0;
        border-radius: 34px;
        background: linear-gradient(180deg, color-mix(in srgb, var(--glass-bg-strong) 100%, #fff 8%) 0%, var(--glass-bg-strong) 60%);
        border: 1px solid var(--glass-edge);
        box-shadow: inset 0 1px 0 var(--glass-edge), 0 14px 36px rgba(0, 0, 0, 0.22);
        -webkit-backdrop-filter: saturate(180%) blur(30px);
        backdrop-filter: saturate(180%) blur(30px);
        overflow: hidden;
        z-index: var(--z-tabs);
    }
    .tab-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-size: 10px;
        color: var(--text-muted);
        cursor: pointer;
        gap: 3px;
        letter-spacing: -0.01em;
        font-weight: 600;
        margin: 3px 2px;
        border-radius: 999px;
        padding: 5px 4px;
        min-height: 0;
        transition:
            background 0.2s var(--ease-apple),
            color 0.2s var(--ease-apple);
        -webkit-tap-highlight-color: transparent;
    }
    .tab-btn.active {
        background: var(--tab-active);
        color: var(--accent);
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
    }
    .tab-btn:active {
        transform: scale(0.9);
        transition-duration: 0.1s;
    }
    .tab-btn svg {
        width: 22px;
        height: 22px;
        stroke-width: 1.9;
        transition: transform 0.3s var(--spring-snappy);
    }
    .tab-btn.active svg {
        transform: translateY(-1px);
    }

    /* Sheets read as Liquid Glass panels, grab handle present */
    .modal-content::before {
        content: "";
        display: block;
        width: 40px;
        height: 5px;
        border-radius: 999px;
        background: var(--glass-shade);
        opacity: 0.45;
        margin: -0.15rem auto 0.85rem;
        flex-shrink: 0;
    }

    .form-group {
        border-radius: var(--radius-sm);
    }

    .lib-count,
    .list-empty {
        font-size: 14px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SHELL 3 · iOS — phone shell (no hover, no hover capability)
   Single pane, large-title chrome, bottom sheets, safe-area full routing.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (hover: none) and (any-hover: none) {
    :root {
        --nav-h: 44px;
        --tap-min: 44px;
        --body-fs: 17px;
        --input-fs: 16px;
        --ui-fs: 15px;
        --label-fs: 13px;
        --radius-xs: 12px;
        --radius-sm: 16px;
        --radius-md: 18px;
        --radius-sheet: 26px;
        --radius-spot: 28px;
        --content-x: 1rem;
        --cell-pad: 1rem 1.05rem 0.9rem;
        --scrollbar-w: 0px;
        --bg-base: var(--system-grouped);
        --bg-side: var(--system-grouped);
        --bg-panel: var(--system-bg);
        --bg-card: var(--system-bg);
        --bg-input: rgba(118, 118, 128, 0.12);
        --press-scale: 0.97;
    }

    body {
        -webkit-touch-callout: none;
        cursor: default;
        background-color: var(--system-grouped);
    }

    /* Full safe-area routing on the nav */
    nav {
        height: auto;
        min-height: calc(max(var(--nav-h), 44px) + env(safe-area-inset-top, 0px));
        padding: 0;
    }
    nav > .globalnav-inner {
        min-height: 44px;
    }
    .globalnav-inner {
        padding-right: max(1rem, env(safe-area-inset-right, 0px));
        padding-left: max(1rem, env(safe-area-inset-left, 0px));
        padding-top: env(safe-area-inset-top, 0px);
    }
    .nav-brand .brand-name {
        font-size: 17px;
        font-weight: 700;
    }
    .nav-actions-wrap {
        display: none;
    }
    .badge-outline {
        display: none;
    }
    .nav-right {
        margin-left: auto;
    }

    /* Single pane stack — content scrolls beneath the dock */
    main {
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .panel {
        display: none;
        width: 100%;
        border-right: none;
        flex: 1;
        min-height: 0;
        background-color: var(--system-grouped);
    }
    .panel.mobile-active {
        display: flex;
    }
    .panel:first-child {
        background-color: var(--system-grouped);
    }
    .panel-body {
        padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
        font-size: 17px;
    }
    .article-list {
        padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
    }
    #live_preview_container {
        padding: 1.5rem 1.25rem 4.5rem;
    }

    .panel-header {
        padding: 0.9rem 1.15rem 0.75rem;
    }
    .panel-header h2 {
        font-size: 28px;
        font-weight: 700;
        letter-spacing: -0.021em;
    }

    /* Momentum scroll everywhere, no web scrollbars */
    .article-list,
    .panel-body,
    .combobox-options,
    .spot-body,
    .modal-content,
    .adv-list,
    #live_preview_container {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scrollbar-width: none;
    }
    ::-webkit-scrollbar {
        display: none;
    }

    /* Grouped inset cells */
    .article-card {
        border-radius: 18px;
        padding: 1rem 1.05rem;
        margin-bottom: 0;
        transform: none !important;
        box-shadow: var(--shadow-1);
    }
    .form-group {
        border-radius: 16px;
        background: var(--system-bg);
    }
    .row,
    .row-3 {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.75rem;
    }
    .card-actions {
        opacity: 1;
        flex-wrap: wrap;
    }
    .card-actions button {
        min-height: 44px;
        padding: 0.45rem 1rem;
    }

    /* 44pt controls — no pixel-hunt regions anywhere */
    button,
    .seg-btn,
    .toolbar button,
    .nav-actions button.btn-outline,
    .find-toggle,
    .find-bar-nav button,
    .ctx-item,
    .tab-btn {
        min-height: 44px;
    }
    .find-bar input[type="text"] {
        min-height: 42px;
    }
    input,
    textarea,
    select {
        font-size: 16px !important; /* no iOS auto-zoom on focus */
    }

    /* Bottom sheet modals (JS .active) */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
        background: rgba(0, 0, 0, 0.3);
        -webkit-backdrop-filter: saturate(180%) blur(12px);
        backdrop-filter: saturate(180%) blur(12px);
    }
    .modal-content {
        width: 100%;
        max-width: none;
        max-height: 92dvh;
        border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
        padding: 1.5rem 1.25rem 2rem;
        animation: sheet-up 0.34s var(--spring-fluid);
    }
    .modal-content::before {
        content: "";
        display: block;
        width: 42px;
        height: 5px;
        border-radius: 999px;
        background: var(--glass-shade);
        opacity: 0.45;
        margin: -0.1rem auto 1rem;
        flex-shrink: 0;
    }
    #d1-terminal-modal .modal-content {
        border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    }

    /* Floating capsule tab bar (Liquid Glass) */
    .mobile-tab-bar {
        display: flex;
        position: fixed;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
        width: calc(100% - 24px);
        max-width: 440px;
        height: 64px;
        padding-bottom: 0;
        border-radius: 32px;
        background: linear-gradient(180deg, color-mix(in srgb, var(--glass-bg-strong) 100%, #fff 8%) 0%, var(--glass-bg-strong) 60%);
        border: 1px solid var(--glass-edge);
        box-shadow: inset 0 1px 0 var(--glass-edge), 0 14px 36px rgba(0, 0, 0, 0.22);
        -webkit-backdrop-filter: saturate(180%) blur(30px);
        backdrop-filter: saturate(180%) blur(30px);
        overflow: hidden;
        z-index: var(--z-tabs);
    }
    .tab-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-size: 10px;
        color: var(--text-muted);
        cursor: pointer;
        gap: 3px;
        letter-spacing: -0.01em;
        font-weight: 600;
        margin: 3px 2px;
        border-radius: 999px;
        padding: 5px 4px;
        transition:
            background 0.2s var(--ease-apple),
            color 0.2s var(--ease-apple);
        -webkit-tap-highlight-color: transparent;
    }
    .tab-btn.active {
        background: var(--tab-active);
        color: var(--accent);
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
    }
    .tab-btn:active {
        transform: scale(0.9);
        transition-duration: 0.1s;
    }
    .tab-btn svg {
        width: 22px;
        height: 22px;
        stroke-width: 1.9;
        transition: transform 0.3s var(--spring-snappy);
    }
    .tab-btn.active svg {
        transform: translateY(-1px);
    }

    /* Toasts read top-center under the Dynamic Island */
    #toast-container {
        top: calc(env(safe-area-inset-top, 0px) + 8px);
        right: 50%;
        transform: translateX(50%);
        align-items: center;
        width: min(96vw, 420px);
    }
    .toast {
        min-width: 0;
        width: 100%;
        padding: 0.85rem 1rem;
    }

    /* Spotlight / help: near-full sheets */
    .spot-overlay {
        padding: calc(env(safe-area-inset-top, 0px) + 1.25rem) 0.75rem 1.5rem;
    }
    .spot-panel {
        border-radius: 28px;
    }
    .help-overlay {
        padding: 0.75rem;
    }
    .help-card {
        border-radius: 26px;
        max-height: 86vh;
    }

    /* Undo banner becomes a bottom toast on iOS */
    #ytvtt-undo-banner {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: min(92vw, 420px);
        max-width: 420px;
        border-radius: 18px;
    }

    #draft-status {
        font-size: 12px;
    }

    .editor-statusbar {
        min-height: 28px;
    }
    .status-item {
        height: 28px;
    }

    #content_html {
        min-height: 320px;
    }

    /* Landscape phone: without a dock, everything stacks as one page */
    @media (min-width: 801px) and (max-width: 979px) {
        main {
            display: flex;
            flex-direction: column;
            overflow-y: auto;
        }
        .panel {
            display: flex;
            flex: none;
            height: max(420px, 72vh);
            border-bottom: 1px solid var(--separator);
        }
        .panel:last-child {
            border-bottom: none;
        }
        .mobile-tab-bar {
            display: none;
        }
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   FALLBACK · touch without modern hover reporting — treat as phone
   ═══════════════════════════════════════════════════════════════════════════ */
@media (hover: on-demand) and (any-hover: none) {
    :root {
        --tap-min: 44px;
        --input-fs: 16px;
    }
    input,
    textarea,
    select {
        font-size: 16px !important;
    }
    .article-list,
    .panel-body,
    .combobox-options,
    .spot-body,
    .modal-content,
    .adv-list,
    #live_preview_container {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    ::-webkit-scrollbar {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   17 · LIVE PREVIEW — Production article surface
   Mirrors src/components/ArticleView.jsx + ArticleContent + LyricsBlock +
   PhotoCredit + ContentAdvisoryBanner + VerifiedBadge + AudioImplantArticle
   + MediaCuratorNote. The live site is LIGHT-FORCED, so the surface is
   always light regardless of Studio appearance.
   ═══════════════════════════════════════════════════════════════════════════ */
#live_preview_container.has-surface {
    padding: 0;
    background: #fff;
}

#live_preview_container .ap-surface {
    background: #fff;
    color: rgb(29, 29, 31);
    color-scheme: light;
    font-size: 17px;
    line-height: 1.4705882353;
    font-weight: 400;
    letter-spacing: -0.022em;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "SF Arabic", "SF Hebrew", "SF Pro SC", "SF Pro TC", "PingFang SC", "PingFang TC", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-width: 0;
}
#live_preview_container .ap-surface *,
#live_preview_container .ap-surface *::before,
#live_preview_container .ap-surface *::after {
    box-sizing: border-box;
}
#live_preview_container .ap-surface a {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.ap-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    color: rgb(134, 134, 139);
    font-size: 0.82rem;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}

/* ── Hero banner (ArticleView) ── */
#live_preview_container .ap-surface .ap-hero {
    position: relative;
    width: 100%;
    height: 50vh;
    overflow: hidden;
    background: #f5f5f7;
}
@media (min-width: 768px) {
    #live_preview_container .ap-surface .ap-hero {
        height: 60vh;
    }
}
#live_preview_container .ap-surface .ap-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
}
#live_preview_container .ap-surface .ap-hero-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.25), transparent 25%);
    pointer-events: none;
}
#live_preview_container .ap-surface .ap-photo-credit {
    position: absolute;
    bottom: 12px;
    left: 16px;
    font-size: 12px;
    line-height: 1.3333733333;
    letter-spacing: -0.01em;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.75);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    background: none;
    padding: 0;
    border-radius: 0;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
    z-index: 10;
    max-width: min(320px, 60vw);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Title block (ArticleView) ── */
#live_preview_container .ap-surface .ap-title-sec {
    padding: 48px 0 16px;
    text-align: left;
}
@media (min-width: 768px) {
    #live_preview_container .ap-surface .ap-title-sec {
        padding: 64px 0 16px;
    }
}
#live_preview_container .ap-surface .ap-title-inner {
    max-width: 1068px;
    margin: 0 auto;
    width: 100%;
    padding: 0 22px;
    min-width: 0;
}
#live_preview_container .ap-surface .ap-title-cat-wrap {
    margin-bottom: 12px;
}
#live_preview_container .ap-surface .ap-category-label {
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
    color: rgb(0, 102, 204);
    text-decoration: none;
    transition: color 0.32s cubic-bezier(0.4, 0, 0.6, 1);
}
#live_preview_container .ap-surface .ap-category-label:hover {
    color: rgb(0, 102, 204);
    text-decoration: underline;
}
#live_preview_container .ap-surface .ap-h1 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.12;
    color: rgb(29, 29, 31);
    margin: 0;
    overflow-wrap: anywhere;
}
@media (min-width: 640px) {
    #live_preview_container .ap-surface .ap-h1 {
        font-size: 36px;
    }
}
@media (min-width: 768px) {
    #live_preview_container .ap-surface .ap-h1 {
        font-size: 48px;
    }
}
#live_preview_container .ap-surface .ap-subtitle {
    margin: 12px 0 0;
    font-size: 17px;
    line-height: 1.38;
    font-weight: 400;
    color: rgb(81, 81, 84);
    letter-spacing: -0.011em;
    max-width: 680px;
    overflow-wrap: anywhere;
}
@media (min-width: 640px) {
    #live_preview_container .ap-surface .ap-subtitle {
        font-size: 19px;
    }
}
@media (min-width: 768px) {
    #live_preview_container .ap-surface .ap-subtitle {
        font-size: 21px;
    }
}

/* ── Content Advisory banner (ContentAdvisoryBanner.jsx) ── */
#live_preview_container .ap-surface .ap-advisory {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 0;
    margin: 0 0 20px;
    border-top: 0.5px solid rgb(232, 232, 237);
    border-bottom: 0.5px solid rgb(232, 232, 237);
    background: transparent;
    border-radius: 0;
}
#live_preview_container .ap-surface .ap-advisory svg {
    color: rgb(255, 59, 48);
}
#live_preview_container .ap-surface .ap-advisory p {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.625;
    color: rgb(134, 134, 139);
    overflow-wrap: anywhere;
}

/* ── Byline / metadata (ArticleView) ── */
#live_preview_container .ap-surface .ap-byline {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin: 32px 0 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
#live_preview_container .ap-surface .ap-avatar {
    width: 40px;
    height: 40px;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 0, 0, 0.48);
    font-size: 14px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
    overflow: hidden;
}
#live_preview_container .ap-surface .ap-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
}
#live_preview_container .ap-surface .ap-byline-main {
    min-width: 0;
    text-align: left;
}
#live_preview_container .ap-surface .ap-authors {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: #000;
}
#live_preview_container .ap-surface .ap-author {
    font-weight: 600;
    color: #000;
    text-decoration: none;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
    transition: color 0.32s cubic-bezier(0.4, 0, 0.6, 1);
}
#live_preview_container .ap-surface .ap-author:hover {
    color: rgb(0, 113, 227);
    text-decoration: none;
}
#live_preview_container .ap-surface .ap-author-sep {
    color: rgba(0, 0, 0, 0.24);
}
#live_preview_container .ap-surface .ap-tuwa-media {
    font-weight: 600;
    color: #000;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}
#live_preview_container .ap-surface .ap-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: 12px;
    color: rgb(110, 110, 115);
    letter-spacing: -0.01em;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}
#live_preview_container .ap-surface .ap-meta-sep {
    color: rgba(0, 0, 0, 0.12);
}
#live_preview_container .ap-surface .ap-meta time {
    display: inline;
}

/* ── Verified badge (VerifiedBadge.jsx) ── */
#live_preview_container .ap-surface .ap-verified {
    position: relative;
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: 0;
    padding: 0;
    margin-left: 2px;
    cursor: pointer;
    color: rgb(0, 113, 227);
    border-radius: 9999px;
}
#live_preview_container .ap-surface .ap-verified .ap-vtip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    z-index: 50;
    width: 220px;
    border-radius: 12px;
    background: rgba(250, 250, 252, 0.85);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border: 0.5px solid rgba(0, 0, 0, 0.16);
    padding: 10px 12px;
    text-align: left;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.32s cubic-bezier(0.4, 0, 0.6, 1), transform 0.32s cubic-bezier(0.4, 0, 0.6, 1), visibility 0.32s;
    pointer-events: none;
}
#live_preview_container .ap-surface .ap-verified:hover .ap-vtip,
#live_preview_container .ap-surface .ap-verified:focus-visible .ap-vtip,
#live_preview_container .ap-surface .ap-verified .ap-vtip-open {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
#live_preview_container .ap-surface .ap-vtip-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: rgb(29, 29, 31);
    font-size: 11px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}
#live_preview_container .ap-surface .ap-vtip-body {
    color: rgb(110, 110, 115);
    font-size: 11px;
    line-height: 1.45;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}

/* ── Credits row (ArticleView) ── */
#live_preview_container .ap-surface .ap-credits {
    margin: 16px 0 40px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgb(110, 110, 115);
    line-height: 1.625;
    letter-spacing: -0.01em;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
    min-width: 0;
    overflow-wrap: anywhere;
}
#live_preview_container .ap-surface .ap-credits-label {
    font-weight: 600;
    color: rgb(29, 29, 31);
}
#live_preview_container .ap-surface .ap-credits a {
    color: rgb(0, 102, 204);
    text-decoration: none;
}
#live_preview_container .ap-surface .ap-credits a:hover {
    text-decoration: underline;
}
#live_preview_container .ap-surface .ap-credit-role {
    color: rgb(134, 134, 139);
}
#live_preview_container .ap-surface .ap-credits-sep {
    color: rgba(0, 0, 0, 0.12);
}

/* ── Audio implant (AudioImplantArticle.jsx) ── */
#live_preview_container .ap-surface .ap-audio-implant {
    width: 100%;
    border-top: 0.5px solid rgb(232, 232, 237);
    border-bottom: 0.5px solid rgb(232, 232, 237);
    background: rgb(245, 245, 247);
    padding: 12px 0;
    margin: 32px 0;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: background-color 0.32s cubic-bezier(0.4, 0, 0.6, 1);
}
@media (min-width: 640px) {
    #live_preview_container .ap-surface .ap-audio-implant {
        padding: 16px 0;
    }
}
#live_preview_container .ap-surface .ap-audio-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 9999px;
    background: rgb(0, 113, 227);
    border: 0;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.32s cubic-bezier(0.4, 0, 0.6, 1);
    padding: 0;
}
@media (min-width: 640px) {
    #live_preview_container .ap-surface .ap-audio-btn {
        width: 48px;
        height: 48px;
    }
}
#live_preview_container .ap-surface .ap-audio-btn:hover {
    background: #0076df;
}
#live_preview_container .ap-surface .ap-audio-btn:active {
    background: #006edb;
}
#live_preview_container .ap-surface .ap-audio-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding-right: 8px;
}
#live_preview_container .ap-surface .ap-audio-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    min-width: 0;
}
#live_preview_container .ap-surface .ap-audio-labels {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}
#live_preview_container .ap-surface .ap-audio-listen {
    font-size: 12px;
    font-weight: 600;
    color: rgb(29, 29, 31);
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}
@media (min-width: 640px) {
    #live_preview_container .ap-surface .ap-audio-listen {
        font-size: 14px;
    }
}
#live_preview_container .ap-surface .ap-audio-dot {
    color: rgb(232, 232, 237);
}
#live_preview_container .ap-surface .ap-audio-owner {
    font-size: 12px;
    color: rgb(110, 110, 115);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}
#live_preview_container .ap-surface .ap-audio-time {
    font-size: 11px;
    flex-shrink: 0;
    color: rgb(110, 110, 115);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}
@media (min-width: 640px) {
    #live_preview_container .ap-surface .ap-audio-time {
        font-size: 12px;
    }
}
#live_preview_container .ap-surface .ap-audio-track {
    position: relative;
    width: 100%;
    height: 8px;
    background: rgb(232, 232, 237);
    border-radius: 9999px;
    overflow: hidden;
}
#live_preview_container .ap-surface .ap-audio-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: rgb(0, 113, 227);
    transition: width 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}
#live_preview_container .ap-surface .ap-audio-range {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
    margin: 0;
    display: block;
    box-shadow: none;
    border-radius: 0;
}

/* ── Article body (ArticleView inline body CSS) ── */
#live_preview_container .ap-surface .ap-article {
    margin: 0 auto;
    padding: 32px 22px;
    width: 100%;
    max-width: 680px;
    min-width: 0;
}
@media (min-width: 768px) {
    #live_preview_container .ap-surface .ap-article {
        padding: 48px 22px;
    }
}
#live_preview_container .ap-surface .ap-article .article-body {
    text-align: left;
}
#live_preview_container .ap-surface .ap-article .article-body p {
    margin-bottom: 1.25em;
    font-size: 17px;
    line-height: 1.47059;
    letter-spacing: -0.022em;
    color: rgb(29, 29, 31);
    overflow-wrap: anywhere;
}
#live_preview_container .ap-surface .ap-article .article-body a {
    color: rgb(0, 102, 204);
    text-decoration: none;
    transition: color 0.2s cubic-bezier(0.4, 0, 0.6, 1);
    overflow-wrap: anywhere;
}
#live_preview_container .ap-surface .ap-article .article-body a:hover {
    color: rgb(0, 113, 227);
    text-decoration: underline;
}
#live_preview_container .ap-surface .ap-article .article-body h2 {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.16667;
    letter-spacing: -0.022em;
    color: rgb(29, 29, 31);
    margin-top: 1.8em;
    margin-bottom: 0.6em;
    overflow-wrap: anywhere;
}
#live_preview_container .ap-surface .ap-article .article-body h3 {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.022em;
    color: rgb(29, 29, 31);
    margin-top: 1.6em;
    margin-bottom: 0.5em;
    overflow-wrap: anywhere;
}
#live_preview_container .ap-surface .ap-article .article-body img {
    margin: 1.5em 0;
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: none;
    display: block;
}
#live_preview_container .ap-surface .ap-article .article-body blockquote {
    border-left: 2px solid rgb(210, 210, 215);
    padding: 2px 0 2px 20px;
    margin: 40px 0;
    overflow-wrap: anywhere;
}
#live_preview_container .ap-surface .ap-article .article-body blockquote p {
    font-size: 19px;
    font-weight: 600;
    line-height: 1.47059;
    letter-spacing: -0.022em;
    color: rgb(29, 29, 31);
    margin-bottom: 0;
}
#live_preview_container .ap-surface .ap-article .article-body blockquote cite {
    display: block;
    margin-top: 6px;
    font-size: 14px;
    font-weight: 400;
    color: rgb(110, 110, 115);
    font-style: normal;
}
#live_preview_container .ap-surface .ap-article .article-body ul,
#live_preview_container .ap-surface .ap-article .article-body ol {
    margin: 1em 0;
    padding-left: 1.5em;
}
#live_preview_container .ap-surface .ap-article .article-body li {
    margin-bottom: 0.4em;
    font-size: 17px;
    line-height: 1.47059;
    letter-spacing: -0.022em;
    color: rgb(29, 29, 31);
}
#live_preview_container .ap-surface .ap-article .article-body hr {
    border: none;
    border-top: 0.5px solid rgb(232, 232, 237);
    margin: 2.5em 0;
}
#live_preview_container .ap-surface .ap-article .article-body figure {
    margin: 1.5em 0;
    min-width: 0;
}
#live_preview_container .ap-surface .ap-article .article-body figcaption {
    font-size: 12px;
    color: rgb(110, 110, 115);
    margin-top: 6px;
    letter-spacing: -0.01em;
    border-bottom: 0;
    padding-bottom: 0;
    overflow-wrap: anywhere;
}
#live_preview_container .ap-surface .ap-article .article-body video,
#live_preview_container .ap-surface .ap-article .article-body iframe {
    max-width: 100%;
    border-radius: 12px;
    display: block;
    border: 0;
    box-shadow: none;
}
#live_preview_container .ap-surface .ap-article .article-body .yt-short-wrap {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
}
#live_preview_container .ap-surface .ap-article .article-body .yt-short-wrap iframe {
    width: 315px;
    max-width: 100%;
    aspect-ratio: 9/16;
    border-radius: 12px;
    border: 0;
    display: block;
}

/* ── CMS authoring helpers, light-theme carry-over ── */
#live_preview_container .ap-surface .ap-article .article-body .pull-quote {
    margin: 1.8rem 0;
    padding: 0.6rem 0 0.6rem 1.1rem;
    border-left: 4px solid rgb(210, 210, 215);
    font-size: 1.45rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.35;
    color: rgb(29, 29, 31);
    overflow-wrap: anywhere;
}
#live_preview_container .ap-surface .ap-article .article-body .infobox {
    background: rgb(245, 245, 247);
    border: 1px solid rgb(232, 232, 237);
    border-radius: 12px;
    padding: 1.3rem;
    margin: 2rem 0;
    border-left: 4px solid rgb(29, 29, 31);
    min-width: 0;
}
#live_preview_container .ap-surface .ap-article .article-body .infobox h4 {
    margin-top: 0;
    color: rgb(29, 29, 31);
    font-size: 13px;
    letter-spacing: 0;
}
#live_preview_container .ap-surface .ap-article .article-body p.dropcap::first-letter {
    float: left;
    font-size: 3.4em;
    line-height: 0.82;
    font-weight: 700;
    letter-spacing: -0.03em;
    padding-right: 0.14em;
    color: rgb(29, 29, 31);
}
#live_preview_container .ap-surface .ap-article .article-body figcaption .credit {
    color: rgb(134, 134, 139);
    font-style: normal;
}

/* ── Subtitle boxes — production appearance (VttEngine) ── */
#live_preview_container .ap-surface .tuwa-subtitle-box {
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    border-radius: 0;
    font-size: inherit;
    color: inherit;
    font-family: inherit;
    overflow-wrap: anywhere;
}
#live_preview_container .ap-surface .tuwa-subtitle-box::before {
    content: none;
}

/* ── Curator note (MediaCuratorNote.jsx) ── */
#live_preview_container .ap-surface .ap-curator-note {
    margin-top: 48px;
    padding-top: 16px;
    border-top: 0.5px solid rgba(0, 0, 0, 0.12);
    font-size: 12px;
    line-height: 1.47;
    letter-spacing: -0.01em;
    color: rgb(134, 134, 139);
    overflow-wrap: anywhere;
}
#live_preview_container .ap-surface .ap-curator-note-label {
    font-weight: 600;
    color: rgb(29, 29, 31);
}

/* ── Lyrics block (LyricsBlock.jsx desktop) ── */
#live_preview_container .ap-surface .ap-lyrics-wrap {
    margin: 0 auto;
    width: 100%;
    max-width: 680px;
    padding: 0 22px;
}
#live_preview_container .ap-surface .lyrics-block-native {
    margin: 2rem 0;
    max-width: 672px;
    margin-left: auto;
    margin-right: auto;
}
#live_preview_container .ap-surface .lyrics-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    border: 0;
    border-radius: 980px;
    background: rgba(250, 250, 252, 0.92);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    color: rgb(29, 29, 31);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: -0.016em;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    transition: color 0.32s cubic-bezier(0.4, 0, 0.6, 1), background-color 0.32s cubic-bezier(0.4, 0, 0.6, 1);
}
#live_preview_container .ap-surface .lyrics-hint:hover {
    color: rgb(29, 29, 31);
    background: rgb(250, 250, 252);
}
#live_preview_container .ap-surface .lyrics-hint svg:last-child {
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.6, 1);
}
#live_preview_container .ap-surface .lyrics-hint:hover svg:last-child {
    transform: translateX(2px);
}
#live_preview_container .ap-surface .lyrics-panel {
    margin-top: 8px;
    border: 0.5px solid rgba(0, 0, 0, 0.16);
    border-radius: 18px;
    overflow: hidden;
    background: rgba(250, 250, 252, 0.92);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    opacity: 0;
    max-height: 0;
    transform: translateY(-8px);
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.6, 1), max-height 0.5s cubic-bezier(0.4, 0, 0.6, 1), transform 0.5s cubic-bezier(0.4, 0, 0.6, 1);
}
#live_preview_container .ap-surface .lyrics-panel--open {
    opacity: 1;
    max-height: 600px;
    transform: translateY(0);
}
#live_preview_container .ap-surface .lyrics-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.16);
}
#live_preview_container .ap-surface .lyrics-panel-title {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: rgb(110, 110, 115);
    text-transform: uppercase;
}
#live_preview_container .ap-surface .lyrics-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 980px;
    background: transparent;
    color: rgb(110, 110, 115);
    cursor: pointer;
    transition: color 0.32s cubic-bezier(0.4, 0, 0.6, 1), background-color 0.32s cubic-bezier(0.4, 0, 0.6, 1);
    padding: 0;
}
#live_preview_container .ap-surface .lyrics-close-btn:hover {
    background: rgb(250, 250, 252);
    color: rgb(29, 29, 31);
}
#live_preview_container .ap-surface .lyrics-panel-body {
    padding: 16px 20px;
    max-height: 440px;
    overflow-y: auto;
    overscroll-behavior: contain;
}
#live_preview_container .ap-surface .lyrics-line {
    margin: 0;
    padding: 4px 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
    font-size: 14px;
    line-height: 1.7;
    color: rgb(29, 29, 31);
    white-space: pre-wrap;
    letter-spacing: -0.022em;
}

/* ── Related (further-reading style) ── */
#live_preview_container .ap-surface .ap-related {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 22px 48px;
    min-width: 0;
}
@media (min-width: 768px) {
    #live_preview_container .ap-surface .ap-related {
        padding-bottom: 64px;
    }
}
#live_preview_container .ap-surface .ap-related-title {
    font-size: 12px;
    font-weight: 600;
    color: rgb(134, 134, 139);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
#live_preview_container .ap-surface .ap-related-list {
    list-style: none;
    margin: 0;
    padding: 8px 0 0;
}
#live_preview_container .ap-surface .ap-related-item {
    margin-bottom: 16px;
}
#live_preview_container .ap-surface .ap-related-link {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    text-decoration: none;
    color: #000;
}
#live_preview_container .ap-surface .ap-related-text {
    font-size: 15px;
    line-height: 1.375;
    color: #000;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.32s cubic-bezier(0.4, 0, 0.6, 1);
    overflow-wrap: anywhere;
}
#live_preview_container .ap-surface .ap-related-link:hover .ap-related-text {
    color: rgb(0, 102, 204);
}

/* -- Localized surface  RTL mirrors ArticleView "rtl:text-right" -- */
#live_preview_container .ap-surface[dir="rtl"] .ap-title-sec,
#live_preview_container .ap-surface[dir="rtl"] .ap-title-inner,
#live_preview_container .ap-surface[dir="rtl"] .ap-byline-main {
    text-align: right;
}
#live_preview_container .ap-surface[dir="rtl"] .article-body blockquote {
    border-left: none;
    border-right: 2px solid rgba(0, 0, 0, 0.16);
    padding: 2px 20px 2px 0;
}
#live_preview_container .ap-surface[dir="rtl"] .article-body blockquote cite {
    text-align: right;
}
