/* ==================================================================
   FxOS Docs — white, quiet, Apple-leaning
   ================================================================== */

:root {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-solid: #ffffff;
    --surface-translucent: rgba(255, 255, 255, 0.9);
    --surface-edge: rgba(255, 255, 255, 0.7);
    --header-bg: rgba(255, 255, 255, 0.72);
    --bg-soft: #f5f5f7;
    --bg-soft-2: #fafafa;
    --fill: rgba(0, 0, 0, 0.05);
    --fill-strong: #ebebef;
    --ink: #1d1d1f;
    --ink-2: #515154;
    --ink-3: #6e6e73;
    --ink-4: #86868b;
    --line: rgba(0, 0, 0, 0.075);
    --line-strong: rgba(0, 0, 0, 0.14);
    --line-input: rgba(0, 0, 0, 0.12);
    --line-faint: rgba(0, 0, 0, 0.035);
    --line-hover: rgba(0, 0, 0, 0.11);
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-soft: rgba(0, 113, 227, 0.085);
    --danger: #d70015;
    --danger-soft: rgba(215, 0, 21, 0.07);
    --success: #1a7f37;
    --success-soft: rgba(52, 199, 89, 0.12);
    --selection: rgba(0, 113, 227, 0.16);
    --scrim: rgba(0, 0, 0, 0.26);
    --scrim-soft: rgba(0, 0, 0, 0.2);
    --track: #d2d2d7;
    --knob: #ffffff;
    --placeholder: #a1a1a6;
    --code-bg: #fbfbfd;
    --code-head: #f5f5f7;
    --code-inline-bg: #f2f2f4;
    --code-inline-ink: #3a3a3c;
    --code-ink: #242426;
    --tok-com: #8a8a8f;
    --tok-kw: #a1309b;
    --tok-str: #c0392b;
    --tok-num: #2456c4;
    --tok-type: #6b4bb8;
    --alert-success-ink: #156d2f;
    --alert-danger-ink: #b00012;

    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 26px;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.035);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.045);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.05), 0 22px 60px rgba(0, 0, 0, 0.09);

    --spring: cubic-bezier(0.32, 0.72, 0, 1);
    --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);

    --header-h: 56px;
    --sidebar-w: 276px;
    --toc-w: 208px;

    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* 黑色调 · 带灰 */
html[data-theme="gray-dark"] {
    color-scheme: dark;
    --bg: #1c1c1e;
    --surface: #232326;
    --surface-solid: #232326;
    --surface-translucent: rgba(35, 35, 38, 0.92);
    --surface-edge: rgba(255, 255, 255, 0.08);
    --header-bg: rgba(28, 28, 30, 0.72);
    --bg-soft: #2c2c2e;
    --bg-soft-2: #242427;
    --fill: rgba(255, 255, 255, 0.07);
    --fill-strong: #3a3a3c;
    --ink: #f5f5f7;
    --ink-2: #d1d1d6;
    --ink-3: #a1a1a6;
    --ink-4: #8e8e93;
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.17);
    --line-input: rgba(255, 255, 255, 0.14);
    --line-faint: rgba(255, 255, 255, 0.05);
    --line-hover: rgba(255, 255, 255, 0.22);
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --accent-soft: rgba(10, 132, 255, 0.16);
    --danger: #ff453a;
    --danger-soft: rgba(255, 69, 58, 0.14);
    --success: #30d158;
    --success-soft: rgba(48, 209, 88, 0.14);
    --selection: rgba(10, 132, 255, 0.32);
    --scrim: rgba(0, 0, 0, 0.5);
    --scrim-soft: rgba(0, 0, 0, 0.45);
    --track: #48484a;
    --knob: #f5f5f7;
    --placeholder: #7c7c81;
    --code-bg: #18181a;
    --code-head: #242427;
    --code-inline-bg: rgba(255, 255, 255, 0.09);
    --code-inline-ink: #e5e5ea;
    --code-ink: #e8e8ed;
    --tok-com: #8e8e93;
    --tok-kw: #d98fd4;
    --tok-str: #ff8177;
    --tok-num: #82b1ff;
    --tok-type: #b8a1e3;
    --alert-success-ink: #6fdc8c;
    --alert-danger-ink: #ff6961;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.4), 0 26px 70px rgba(0, 0, 0, 0.5);
}

/* 白色简约 */
html[data-theme="minimal-white"] {
    --surface-translucent: #ffffff;
    --surface-edge: rgba(0, 0, 0, 0.12);
    --header-bg: rgba(255, 255, 255, 0.85);
    --bg-soft: #fafafa;
    --bg-soft-2: #ffffff;
    --fill: rgba(0, 0, 0, 0.035);
    --fill-strong: #f0f0f0;
    --line: rgba(0, 0, 0, 0.12);
    --line-strong: rgba(0, 0, 0, 0.24);
    --line-input: rgba(0, 0, 0, 0.2);
    --line-faint: rgba(0, 0, 0, 0.08);
    --line-hover: rgba(0, 0, 0, 0.28);
    --shadow-xs: none;
    --shadow-sm: none;
    --shadow-md: 0 18px 50px rgba(0, 0, 0, 0.06);
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --code-bg: #fafafa;
    --code-head: #f2f2f2;
}

/* 黑色简约 */
html[data-theme="minimal-black"] {
    color-scheme: dark;
    --bg: #000000;
    --surface: #000000;
    --surface-solid: #000000;
    --surface-translucent: rgba(0, 0, 0, 0.94);
    --surface-edge: rgba(255, 255, 255, 0.14);
    --header-bg: rgba(0, 0, 0, 0.78);
    --bg-soft: #0a0a0a;
    --bg-soft-2: #000000;
    --fill: rgba(255, 255, 255, 0.08);
    --fill-strong: #1c1c1e;
    --ink: #f5f5f7;
    --ink-2: #d1d1d6;
    --ink-3: #a1a1a6;
    --ink-4: #8e8e93;
    --line: rgba(255, 255, 255, 0.16);
    --line-strong: rgba(255, 255, 255, 0.3);
    --line-input: rgba(255, 255, 255, 0.24);
    --line-faint: rgba(255, 255, 255, 0.1);
    --line-hover: rgba(255, 255, 255, 0.36);
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --danger: #ff453a;
    --danger-soft: rgba(255, 69, 58, 0.16);
    --success: #30d158;
    --success-soft: rgba(48, 209, 88, 0.16);
    --selection: rgba(10, 132, 255, 0.35);
    --scrim: rgba(0, 0, 0, 0.6);
    --scrim-soft: rgba(0, 0, 0, 0.55);
    --track: #3a3a3c;
    --knob: #ffffff;
    --placeholder: #7c7c81;
    --code-bg: #080808;
    --code-head: #141414;
    --code-inline-bg: rgba(255, 255, 255, 0.1);
    --code-inline-ink: #e5e5ea;
    --code-ink: #e8e8ed;
    --tok-com: #8e8e93;
    --tok-kw: #d98fd4;
    --tok-str: #ff8177;
    --tok-num: #82b1ff;
    --tok-type: #b8a1e3;
    --alert-success-ink: #6fdc8c;
    --alert-danger-ink: #ff6961;
    --shadow-xs: none;
    --shadow-sm: none;
    --shadow-md: 0 24px 70px rgba(0, 0, 0, 0.8);
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
}

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

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body.modal-open,
body.nav-open {
    overflow: hidden;
}

::selection {
    background: var(--selection);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 6px;
}

img,
svg {
    display: block;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

button,
input,
textarea,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

.skip-link {
    position: absolute;
    left: 16px;
    top: -48px;
    z-index: 200;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--ink);
    color: var(--bg);
    font-size: 13px;
    transition: top 0.2s var(--ease-out);
}

.skip-link:focus {
    top: 12px;
    color: var(--bg);
}

/* ------------------------------------------------------------------
   Chrome
   ------------------------------------------------------------------ */

@view-transition {
    navigation: auto;
}

::view-transition-old(root) {
    animation: vt-out 0.22s ease both;
}

::view-transition-new(root) {
    animation: vt-in 0.32s ease both;
}

@keyframes vt-out {
    to {
        opacity: 0;
    }
}

@keyframes vt-in {
    from {
        opacity: 0;
    }
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 60;
    height: var(--header-h);
    background: var(--header-bg);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--line);
    view-transition-name: site-header;
}

.header-inner {
    max-width: 1440px;
    height: 100%;
    margin: 0 auto;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 600;
    letter-spacing: -0.015em;
    font-size: 14.5px;
}

.brand:hover {
    color: var(--ink);
}

.brand-name {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 2px;
}

.nav-link {
    padding: 6px 13px;
    border-radius: 999px;
    font-size: 13.5px;
    color: var(--ink-3);
    transition: color 0.2s ease, background-color 0.28s var(--spring);
}

.nav-link:hover {
    color: var(--ink);
    background: var(--bg-soft);
}

.nav-link.is-active {
    color: var(--ink);
    background: var(--bg-soft);
    font-weight: 500;
}

/* ------------------------------------------------------------------
   Home
   ------------------------------------------------------------------ */

.home {
    position: relative;
    min-height: calc(100vh - var(--header-h));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 84px 24px 36px;
    overflow: hidden;
}

.home::before {
    content: "";
    position: absolute;
    inset: -18% -12% auto -12%;
    height: 72vh;
    background:
        radial-gradient(52% 48% at 50% 32%, rgba(0, 113, 227, 0.075), transparent 72%),
        radial-gradient(38% 38% at 74% 12%, rgba(120, 90, 255, 0.055), transparent 72%);
    pointer-events: none;
}

.hero {
    position: relative;
    width: 100%;
    max-width: 780px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.11em;
    color: var(--ink-4);
    text-transform: uppercase;
}

.eyebrow-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.hero-title {
    margin: 22px 0 0;
    font-size: clamp(2.6rem, 6.4vw, 4.5rem);
    line-height: 1.06;
    font-weight: 600;
    letter-spacing: -0.04em;
    color: var(--ink);
}

.choices {
    width: 100%;
    max-width: 720px;
    margin-top: 54px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    text-align: left;
}

.choice {
    position: relative;
    min-height: 132px;
    padding: 24px;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
}

.choice-disabled {
    background: var(--bg-soft);
    border: 1px solid var(--line-faint);
    color: var(--ink-4);
    cursor: default;
    user-select: none;
}

.choice-live {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    box-shadow: var(--shadow-xs);
    transition:
        transform 0.5s var(--spring),
        box-shadow 0.45s var(--ease-out),
        border-color 0.3s ease;
}

.choice-live:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--line-hover);
    color: var(--ink);
}

.choice-live:active {
    transform: scale(0.985);
    transition-duration: 0.12s;
}

.choice-body {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.choice-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: inherit;
}

.choice-live .choice-title {
    color: var(--ink);
}

.badge {
    position: absolute;
    top: 22px;
    right: 22px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--fill);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--ink-4);
}

.reveal {
    animation: rise 0.85s var(--spring) both;
}

[data-reveal="1"] {
    animation-delay: 0.02s;
}

[data-reveal="2"] {
    animation-delay: 0.08s;
}

[data-reveal="3"] {
    animation-delay: 0.16s;
}

[data-reveal="4"] {
    animation-delay: 0.24s;
}

[data-reveal="5"] {
    animation-delay: 0.31s;
}

[data-reveal="6"] {
    animation-delay: 0.42s;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ------------------------------------------------------------------
   Announcement modal
   ------------------------------------------------------------------ */

.announce-scrim {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--scrim);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    backdrop-filter: blur(10px) saturate(120%);
    opacity: 0;
    transition: opacity 0.32s ease;
}

.announce-scrim.is-open {
    opacity: 1;
}

.announce-card {
    width: min(560px, 100%);
    max-height: min(80vh, 720px);
    display: flex;
    flex-direction: column;
    padding: 24px;
    border-radius: var(--radius-lg);
    background: var(--surface-translucent);
    border: 1px solid var(--surface-edge);
    box-shadow: var(--shadow-md);
    transform: translateY(14px) scale(0.972);
    opacity: 0;
    transition: transform 0.5s var(--spring), opacity 0.28s ease;
}

.announce-scrim.is-open .announce-card {
    transform: none;
    opacity: 1;
}

.announce-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.announce-tag {
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.announce-meta {
    font-size: 11.5px;
    color: var(--ink-4);
}

.text-button {
    margin-left: auto;
    padding: 4px 10px;
    border: 0;
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--ink-3);
    font-size: 11.5px;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.text-button:hover {
    background: var(--fill-strong);
    color: var(--ink);
}

.text-button:active {
    transform: scale(0.95);
}

.announce-title {
    margin: 16px 0 0;
    font-size: 22px;
    line-height: 1.28;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.announce-body {
    margin-top: 12px;
    overflow: auto;
    padding-right: 6px;
}

.announce-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------------
   Docs shell / sidebar
   ------------------------------------------------------------------ */

.docs-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    max-width: 1440px;
    margin: 0 auto;
    align-items: start;
}

.docs-shell.with-toc {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
}

.docs-sidebar {
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    border-right: 1px solid var(--line);
    background: var(--surface);
    z-index: 45;
}

.sidebar-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 16px 14px 12px;
}

.sidebar-head {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: none;
}

.sidebar-search {
    position: relative;
    flex: 1;
}

.doc-filter {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: var(--bg-soft);
    font-size: 12.5px;
    color: var(--ink);
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.doc-filter::placeholder {
    color: var(--ink-4);
}

.doc-filter:focus {
    outline: none;
    background: var(--surface);
    border-color: rgba(0, 113, 227, 0.35);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.sidebar-close {
    display: none;
    height: 30px;
    padding: 0 10px;
    flex: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--ink-3);
    font-size: 11.5px;
    place-items: center;
}

.doc-nav {
    flex: 1;
    overflow-y: auto;
    margin-top: 16px;
    padding: 0 2px 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--line-input) transparent;
}

.nav-group {
    margin-bottom: 20px;
}

.nav-group[hidden] {
    display: none;
}

.nav-label {
    margin: 0 0 6px;
    padding: 0 10px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-4);
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--ink-3);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-item:hover {
    background: var(--bg-soft);
    color: var(--ink);
}

.nav-item.is-active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 500;
}

.nav-item.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 2px;
    height: 14px;
    border-radius: 2px;
    background: var(--accent);
    transform: translateY(-50%);
}

.nav-num {
    flex: none;
    width: 18px;
    font-family: var(--mono);
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    color: var(--ink-4);
    transition: color 0.2s ease;
}

.nav-item.is-active .nav-num {
    color: var(--accent);
}

.nav-dot {
    flex: none;
    width: 4px;
    height: 4px;
    margin: 0 7px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.35;
}

.nav-text {
    min-width: 0;
    flex: 1;
}

.nav-empty {
    margin: 12px 10px;
    font-size: 12px;
    color: var(--ink-4);
}

.sidebar-foot {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px 2px;
    border-top: 1px solid var(--line);
}

.sidebar-back {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    color: var(--ink-3);
    padding: 4px 6px;
    border-radius: 6px;
}

.sidebar-back:hover {
    color: var(--ink);
    background: var(--bg-soft);
}

.sidebar-version {
    font-size: 10.5px;
    font-family: var(--mono);
    color: var(--ink-4);
}

.sidebar-scrim {
    display: none;
}

/* ------------------------------------------------------------------
   Doc page
   ------------------------------------------------------------------ */

.doc-main {
    min-width: 0;
    padding: 40px 56px 96px;
}

.reading-progress {
    position: fixed;
    top: var(--header-h);
    left: 0;
    height: 2px;
    width: 0;
    background: var(--accent);
    z-index: 65;
    transition: width 0.08s linear;
    pointer-events: none;
}

.doc-topbar {
    max-width: 780px;
    margin: 0 auto 26px;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 28px;
}

.sidebar-toggle {
    display: none;
    align-items: center;
    height: 30px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: 12.5px;
    box-shadow: var(--shadow-xs);
}

.crumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--ink-4);
}

.crumbs a {
    color: var(--ink-3);
}

.crumbs a:hover {
    color: var(--ink);
}

.crumb-sep {
    color: var(--ink-4);
}

.doc-time {
    margin-left: auto;
    font-size: 11.5px;
    color: var(--ink-4);
    white-space: nowrap;
}

.doc-toc {
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
    padding: 42px 20px 40px 4px;
    scrollbar-width: thin;
}

.toc-inner {
    border-left: 1px solid var(--line);
    padding-left: 14px;
}

.toc-inner .nav-label {
    padding: 0;
    margin-bottom: 8px;
}

.toc-link {
    display: block;
    padding: 4px 0 4px 10px;
    margin-left: -15px;
    border-left: 2px solid transparent;
    font-size: 12px;
    line-height: 1.45;
    color: var(--ink-4);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.toc-link:hover {
    color: var(--ink);
}

.toc-link.is-sub {
    padding-left: 24px;
    font-size: 11.5px;
}

.toc-link.is-active {
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
}

/* ------------------------------------------------------------------
   Markdown typography
   ------------------------------------------------------------------ */

.md {
    font-size: 15.5px;
    line-height: 1.78;
    color: var(--ink-2);
    overflow-wrap: break-word;
}

.md > *:first-child {
    margin-top: 0;
}

.md > *:last-child {
    margin-bottom: 0;
}

.md h1 {
    margin: 0 0 24px;
    font-size: clamp(2rem, 3.4vw, 2.45rem);
    line-height: 1.16;
    font-weight: 600;
    letter-spacing: -0.032em;
    color: var(--ink);
    scroll-margin-top: calc(var(--header-h) + 28px);
}

.md h2 {
    margin: 48px 0 14px;
    font-size: 1.45rem;
    line-height: 1.3;
    font-weight: 600;
    letter-spacing: -0.018em;
    color: var(--ink);
    scroll-margin-top: calc(var(--header-h) + 24px);
}

.md h3 {
    margin: 32px 0 10px;
    font-size: 1.08rem;
    line-height: 1.4;
    font-weight: 600;
    letter-spacing: -0.008em;
    color: var(--ink);
    scroll-margin-top: calc(var(--header-h) + 24px);
}

.md h4,
.md h5,
.md h6 {
    margin: 26px 0 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
}

.md p {
    margin: 0 0 17px;
}

.md strong {
    font-weight: 600;
    color: var(--ink);
}

.md em {
    font-style: italic;
}

.md a {
    color: var(--accent);
    text-decoration: none;
    border-radius: 2px;
}

.md a:hover {
    text-decoration: underline;
    text-underline-offset: 2.5px;
    text-decoration-thickness: 1px;
}

.md .anchor {
    margin-left: 7px;
    color: transparent;
    font-weight: 400;
    text-decoration: none;
    transition: color 0.2s ease;
}

.md h2:hover .anchor,
.md h3:hover .anchor {
    color: var(--ink-4);
}

.md ul,
.md ol {
    margin: 0 0 18px;
    padding-left: 1.35em;
}

.md li {
    margin: 5px 0;
    padding-left: 2px;
}

.md li::marker {
    color: var(--ink-4);
}

.md blockquote {
    margin: 0 0 22px;
    padding: 15px 19px;
    border-radius: 14px;
    background: var(--bg-soft);
    color: var(--ink-2);
    font-size: 14.5px;
    line-height: 1.65;
}

.md blockquote p {
    margin: 0;
}

.md blockquote p + p {
    margin-top: 10px;
}

.md hr {
    height: 1px;
    margin: 36px 0;
    border: 0;
    background: var(--line);
}

.md code {
    font-family: var(--mono);
    font-size: 0.88em;
}

.md :not(pre) > code {
    padding: 0.12em 0.38em;
    border-radius: 5px;
    background: var(--code-inline-bg);
    color: var(--code-inline-ink);
    white-space: break-spaces;
}

.md .code-block {
    margin: 0 0 24px;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    background: var(--code-bg);
}

.md .code-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px;
    background: var(--code-head);
    border-bottom: 1px solid var(--line);
}

.md .code-lang {
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 0.04em;
    color: var(--ink-4);
}

.md .copy-btn {
    border: 0;
    background: transparent;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10.5px;
    color: var(--ink-4);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.md .copy-btn:hover {
    background: var(--fill);
    color: var(--ink);
}

.md pre {
    margin: 0;
    padding: 16px 18px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 12.8px;
    line-height: 1.68;
    color: var(--code-ink);
    tab-size: 4;
}

.md pre code {
    font-size: inherit;
}

.md .tok-com {
    color: var(--tok-com);
}

.md .tok-kw {
    color: var(--tok-kw);
}

.md .tok-str {
    color: var(--tok-str);
}

.md .tok-num {
    color: var(--tok-num);
}

.md .tok-type {
    color: var(--tok-type);
}

.md .table-wrap {
    margin: 0 0 24px;
    border: 1px solid var(--line);
    border-radius: 13px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.md table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    line-height: 1.55;
}

.md th {
    padding: 10px 14px;
    background: var(--bg-soft);
    font-weight: 600;
    color: var(--ink);
    text-align: left;
    white-space: nowrap;
}

.md td {
    padding: 10px 14px;
    border-top: 1px solid var(--line);
    vertical-align: top;
}

.md tbody tr:hover {
    background: var(--bg-soft-2);
}

.md .align-center {
    text-align: center;
}

.md .align-right {
    text-align: right;
}

/* ------------------------------------------------------------------
   Pager / overview
   ------------------------------------------------------------------ */

.article {
    max-width: 780px;
    margin: 0 auto;
}

.pager {
    max-width: 780px;
    margin: 64px auto 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.pager-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 78px;
    padding: 16px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    transition: transform 0.4s var(--spring), box-shadow 0.35s ease, border-color 0.25s ease;
}

.pager-card:not(.pager-empty):hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-sm);
    border-color: var(--line-strong);
    color: var(--ink);
}

.pager-card.pager-empty {
    border-color: transparent;
    background: transparent;
}

.pager-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ink-4);
}

.pager-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
}

.pager-next {
    text-align: right;
}

.doc-footer {
    max-width: 780px;
    margin: 52px auto 0;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    color: var(--ink-4);
}

.doc-footer .dot {
    color: var(--ink-4);
}

.overview {
    min-width: 0;
    width: 100%;
    max-width: 1000px;
    padding: 40px 56px 100px;
}

.overview .doc-topbar {
    max-width: none;
    margin-bottom: 46px;
}

.overview-hero {
    max-width: 760px;
}

.overview-title {
    margin: 20px 0 0;
    font-size: clamp(2.6rem, 5vw, 3.6rem);
    line-height: 1.08;
    font-weight: 600;
    letter-spacing: -0.04em;
}

.overview-lede {
    margin: 18px 0 0;
    font-size: 16.5px;
    line-height: 1.65;
    color: var(--ink-3);
    max-width: 620px;
}

.overview-stats {
    display: flex;
    gap: 10px;
    margin-top: 34px;
    flex-wrap: wrap;
}

.stat {
    flex: 1 1 0;
    min-width: 130px;
    padding: 15px 18px;
    border-radius: 16px;
    background: var(--bg-soft);
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--ink);
    transition: transform 0.4s var(--spring), background-color 0.25s ease;
}

.stat:hover {
    transform: translateY(-2px);
    background: var(--fill-strong);
    color: var(--ink);
}

.stat-value {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 11.5px;
    color: var(--ink-3);
}

.overview-section {
    margin-top: 54px;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-head h2 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.section-count {
    font-size: 11.5px;
    color: var(--ink-4);
}

.lesson-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 11px;
}

.lesson-card {
    display: flex;
    flex-direction: column;
    min-height: 152px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: var(--surface);
    color: var(--ink);
    transition: transform 0.42s var(--spring), box-shadow 0.35s ease, border-color 0.25s ease;
}

.lesson-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-sm);
    border-color: var(--line-strong);
    color: var(--ink);
}

.lesson-card:active {
    transform: scale(0.99);
    transition-duration: 0.12s;
}

.lesson-num {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--accent);
    letter-spacing: 0.04em;
}

.lesson-title {
    margin-top: 9px;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.35;
}

.lesson-desc {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--ink-3);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lesson-meta {
    margin-top: auto;
    padding-top: 14px;
    font-size: 10.5px;
    color: var(--ink-4);
}

.doc-list {
    border: 1px solid var(--line);
    border-radius: 17px;
    overflow: hidden;
    background: var(--surface);
}

.doc-row {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 16px 20px;
    color: var(--ink);
    border-top: 1px solid var(--line);
    transition: background-color 0.2s ease;
}

.doc-row:first-child {
    border-top: 0;
}

.doc-row:hover {
    background: var(--bg-soft-2);
    color: var(--ink);
}

.doc-row-main {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.doc-row-title {
    font-size: 14px;
    font-weight: 500;
}

.doc-row-desc {
    font-size: 12px;
    color: var(--ink-3);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-row-meta {
    font-size: 11px;
    color: var(--ink-4);
    white-space: nowrap;
}

.doc-row:hover .doc-row-meta {
    color: var(--ink-3);
}

/* ------------------------------------------------------------------
   Forms & buttons
   ------------------------------------------------------------------ */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition:
        transform 0.14s ease,
        background-color 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease;
}

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

.button-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(0, 113, 227, 0.22);
}

.button-primary:hover {
    background: var(--accent-hover);
    color: #fff;
}

.button-quiet {
    background: var(--bg-soft);
    color: var(--ink);
}

.button-quiet:hover {
    background: var(--fill-strong);
    color: var(--ink);
}

.button-danger-quiet {
    background: var(--danger-soft);
    color: var(--danger);
}

.button-danger-quiet:hover {
    background: rgba(215, 0, 21, 0.11);
    color: var(--danger);
}

.button-block {
    width: 100%;
    min-height: 44px;
    font-size: 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-3);
}

.input,
.editor-textarea {
    width: 100%;
    border: 1px solid var(--line-input);
    border-radius: 11px;
    background: var(--surface);
    color: var(--ink);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input {
    height: 42px;
    padding: 0 13px;
    font-size: 13.5px;
}

.input::placeholder,
.editor-textarea::placeholder {
    color: var(--placeholder);
}

.input:focus,
.editor-textarea:focus {
    outline: none;
    border-color: rgba(0, 113, 227, 0.55);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.mono {
    font-family: var(--mono);
}

.muted {
    color: var(--ink-4);
    font-size: 12.5px;
}

.alert {
    padding: 11px 15px;
    border-radius: 11px;
    font-size: 12.5px;
    line-height: 1.5;
    margin: 0 0 18px;
    animation: alert-in 0.4s var(--spring) both;
}

.alert-success {
    background: var(--success-soft);
    color: var(--alert-success-ink);
}

.alert-error {
    background: var(--danger-soft);
    color: var(--alert-danger-ink);
}

@keyframes alert-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
}

/* ------------------------------------------------------------------
   Auth
   ------------------------------------------------------------------ */

.auth {
    position: relative;
    min-height: calc(100vh - var(--header-h));
    display: grid;
    place-items: center;
    padding: 56px 24px 96px;
}

.auth::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(46% 42% at 50% 28%, rgba(0, 113, 227, 0.06), transparent 72%);
    pointer-events: none;
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 410px;
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-translucent);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    backdrop-filter: blur(24px) saturate(160%);
    box-shadow: var(--shadow-md);
    animation: rise 0.7s var(--spring) both;
}

.auth-back {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    color: var(--ink-3);
}

.auth-back:hover {
    color: var(--ink);
}

.auth-card .eyebrow {
    margin-top: 30px;
}

.auth-title {
    margin: 12px 0 0;
    font-size: 2rem;
    line-height: 1.15;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.auth-sub {
    margin: 10px 0 0;
    font-size: 13.5px;
    color: var(--ink-3);
}

.auth-form {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.auth-form .field {
    gap: 5px;
}

.auth-note {
    margin: 18px 0 0;
    text-align: center;
    font-size: 11px;
    color: var(--ink-4);
}

/* ------------------------------------------------------------------
   Admin
   ------------------------------------------------------------------ */

.admin {
    max-width: 1080px;
    margin: 0 auto;
    padding: 54px 32px 100px;
}

.admin-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.admin-title {
    margin: 12px 0 0;
    font-size: clamp(2rem, 4vw, 2.6rem);
    line-height: 1.1;
    font-weight: 600;
    letter-spacing: -0.035em;
}

.admin-sub {
    margin: 8px 0 0;
    font-size: 13.5px;
    color: var(--ink-3);
}

.admin-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--bg-soft);
    font-size: 12px;
    color: var(--ink-2);
}

.user-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.12);
}

.segmented {
    display: inline-flex;
    gap: 2px;
    margin: 34px 0 22px;
    padding: 3px;
    border-radius: 999px;
    background: var(--bg-soft);
}

.segmented-item {
    padding: 7px 19px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-3);
    font-size: 13px;
    transition: background-color 0.28s var(--spring), color 0.2s ease, box-shadow 0.28s ease;
}

.segmented-item:hover {
    color: var(--ink);
}

.segmented-item.is-active {
    background: var(--surface);
    color: var(--ink);
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 0.5px rgba(0, 0, 0, 0.02);
}

.panel {
    display: none;
}

.panel.is-active {
    display: block;
    animation: panel-in 0.45s var(--spring) both;
}

@keyframes panel-in {
    from {
        opacity: 0;
        transform: translateY(9px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.card {
    margin-bottom: 18px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.card-title {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.card-sub {
    margin: 5px 0 0;
    font-size: 12px;
    line-height: 1.55;
    color: var(--ink-3);
}

.empty-state {
    margin: 0;
    padding: 30px 20px;
    border-radius: 13px;
    background: var(--bg-soft-2);
    text-align: center;
    font-size: 12.5px;
    color: var(--ink-3);
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.field-wide {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Editor */

.editor-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.editor-shell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    background: var(--surface);
}

.editor-pane {
    min-width: 0;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-soft);
}

.tool {
    min-width: 29px;
    height: 27px;
    padding: 0 7px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.tool:hover {
    background: var(--fill);
    color: var(--ink);
}

.tool:active {
    transform: scale(0.95);
}

.tool-italic {
    font-style: italic;
}

.tool-fence {
    margin-left: auto;
    font-size: 11px;
}

.editor-textarea {
    min-height: 330px;
    padding: 15px 16px;
    border: 0;
    border-radius: 0;
    font-family: var(--mono);
    font-size: 12.8px;
    line-height: 1.72;
    resize: vertical;
    background: var(--surface);
}

.editor-textarea:focus {
    box-shadow: inset 0 0 0 2px rgba(0, 113, 227, 0.16);
}

.preview-pane {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

.preview-head {
    padding: 7px 15px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-soft);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ink-4);
}

.preview {
    padding: 15px 18px;
    overflow: auto;
    max-height: 520px;
    font-size: 13.5px;
}

.preview h1 {
    font-size: 1.5rem;
    margin-bottom: 14px;
}

.preview h2 {
    font-size: 1.2rem;
    margin-top: 26px;
}

.preview h3 {
    font-size: 1rem;
    margin-top: 20px;
}

.preview p {
    margin-bottom: 12px;
}

.preview ul,
.preview ol {
    margin-bottom: 12px;
}

.preview pre {
    font-size: 11.5px;
    padding: 12px;
}

.preview .code-head {
    padding: 5px 12px;
}

.preview table {
    font-size: 12px;
}

.editor-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.toggle-field {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    user-select: none;
}

.toggle-field input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.toggle-track {
    position: relative;
    width: 40px;
    height: 24px;
    border-radius: 999px;
    background: var(--track);
    transition: background-color 0.25s ease;
}

.toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: var(--knob);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s var(--spring);
}

.toggle-field input:checked + .toggle-track {
    background: var(--accent);
}

.toggle-field input:checked + .toggle-track .toggle-knob {
    transform: translateX(16px);
}

.toggle-field input:focus-visible + .toggle-track {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.toggle-text {
    font-size: 12.5px;
    color: var(--ink-2);
}

/* Announcement list */

.announce-list {
    display: flex;
    flex-direction: column;
}

.announce-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 15px 0;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}

.announce-row:first-child {
    border-top: 0;
    padding-top: 2px;
}

.announce-row-main {
    min-width: 0;
    flex: 1;
}

.announce-row-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 500;
    flex-wrap: wrap;
}

.announce-row-meta {
    margin-top: 3px;
    font-size: 11.5px;
    color: var(--ink-4);
}

.announce-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.announce-row-actions form {
    margin: 0;
}

.status-pill,
.source-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
}

.status-pill {
    background: var(--bg-soft);
    color: var(--ink-3);
}

.status-pill.is-on {
    background: var(--success-soft);
    color: var(--success);
}

.status-pill.is-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.source-pill {
    background: var(--bg-soft);
    color: var(--ink-3);
}

.source-pill.is-manual {
    background: var(--accent-soft);
    color: var(--accent);
}

/* Switch */

.switch-form {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.switch {
    position: relative;
    width: 46px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--track);
    transition: background-color 0.28s ease;
}

.switch.is-on {
    background: var(--accent);
}

.switch-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--knob);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
    transition: transform 0.34s var(--spring);
}

.switch.is-on .switch-knob {
    transform: translateX(18px);
}

.switch-state {
    font-size: 12px;
    color: var(--ink-3);
    white-space: nowrap;
}

/* API box */

.api-box {
    padding: 16px 18px;
    border-radius: 13px;
    background: var(--bg-soft-2);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 11px;
}

.api-box.is-off {
    background: var(--bg-soft-2);
}

.api-row {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    font-size: 12.5px;
    line-height: 1.6;
}

.api-label {
    flex: none;
    width: 40px;
    padding-top: 1px;
    font-size: 11.5px;
    color: var(--ink-4);
}

.api-value {
    min-width: 0;
    color: var(--ink-2);
}

.api-value code,
.api-url {
    font-family: var(--mono);
    font-size: 11.5px;
    background: var(--fill);
    padding: 1px 5px;
    border-radius: 4px;
}

.api-url {
    display: block;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    word-break: break-all;
    line-height: 1.55;
    color: var(--ink-2);
}

.hash-details summary {
    cursor: pointer;
    font-size: 11.5px;
    color: var(--accent);
    width: fit-content;
}

.hash {
    display: block;
    margin-top: 8px;
    padding: 9px 11px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 10.5px;
    word-break: break-all;
    color: var(--ink-3);
}

.api-note {
    margin: 0;
    font-size: 11px;
    color: var(--ink-4);
}

/* Admin tables */

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.admin-table th {
    padding: 8px 10px;
    text-align: left;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-4);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.admin-table td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.admin-table tbody tr:last-child td {
    border-bottom: 0;
}

.admin-table .align-right {
    text-align: right;
}

.inline-form {
    display: inline;
    margin: 0;
}

/* Events */

.event-list {
    display: flex;
    flex-direction: column;
}

.event-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 13px 0;
    border-top: 1px solid var(--line);
}

.event-row:first-child {
    border-top: 0;
    padding-top: 0;
}

.event-type {
    flex: none;
    margin-top: 1px;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--danger-soft);
    color: var(--alert-danger-ink);
    font-size: 10.5px;
    font-weight: 500;
    white-space: nowrap;
}

.event-main {
    min-width: 0;
    flex: 1;
}

.event-detail {
    font-size: 12.5px;
    color: var(--ink);
    line-height: 1.5;
}

.event-meta {
    margin-top: 3px;
    display: flex;
    gap: 12px;
    font-size: 10.5px;
    color: var(--ink-4);
    flex-wrap: wrap;
}

.event-path {
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-side {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    font-size: 10.5px;
    color: var(--ink-4);
    white-space: nowrap;
}

.list-note {
    margin: 14px 0 0;
    text-align: center;
}

/* 主题选择 */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.theme-option {
    position: relative;
}

.theme-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s var(--ease-out);
}

.theme-option:hover .theme-card {
    border-color: var(--line-strong);
}

.theme-option input:checked + .theme-card {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.theme-option input:focus-visible + .theme-card {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.theme-swatch {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr;
    gap: 4px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.theme-swatch span {
    display: block;
}

.theme-swatch-gray-white span:nth-child(1) { background: #ffffff; }
.theme-swatch-gray-white span:nth-child(2) { background: #f5f5f7; }
.theme-swatch-gray-white span:nth-child(3) { background: #1d1d1f; }

.theme-swatch-gray-dark span:nth-child(1) { background: #1c1c1e; }
.theme-swatch-gray-dark span:nth-child(2) { background: #2c2c2e; }
.theme-swatch-gray-dark span:nth-child(3) { background: #f5f5f7; }

.theme-swatch-minimal-white span:nth-child(1) { background: #ffffff; }
.theme-swatch-minimal-white span:nth-child(2) { background: #fafafa; }
.theme-swatch-minimal-white span:nth-child(3) { background: #1d1d1f; }

.theme-swatch-minimal-black span:nth-child(1) { background: #000000; }
.theme-swatch-minimal-black span:nth-child(2) { background: #0a0a0a; }
.theme-swatch-minimal-black span:nth-child(3) { background: #f5f5f7; }

.theme-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.theme-desc {
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--ink-3);
}

.theme-current {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 10.5px;
    color: var(--accent);
}

.theme-option input:checked + .theme-card .theme-current {
    display: block;
}

/* ------------------------------------------------------------------
   Error page
   ------------------------------------------------------------------ */

.error-shell {
    min-height: calc(100vh - var(--header-h));
    display: grid;
    place-items: center;
    padding: 64px 24px;
}

.error-card {
    width: 100%;
    max-width: 480px;
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    text-align: center;
    animation: rise 0.6s var(--spring) both;
}

.error-code {
    margin: 0;
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: 0.16em;
    color: var(--ink-4);
}

.error-title {
    margin: 12px 0 0;
    font-size: 1.9rem;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.error-message {
    margin: 12px 0 0;
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--ink-3);
}

.error-actions {
    margin-top: 26px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */

@media (max-width: 1180px) {
    .docs-shell.with-toc {
        grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    }

    .doc-toc {
        display: none;
    }
}

@media (max-width: 900px) {
    .docs-shell,
    .docs-shell.with-toc {
        grid-template-columns: minmax(0, 1fr);
    }

    .docs-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        width: min(86vw, 326px);
        z-index: 90;
        transform: translateX(-102%);
        transition: transform 0.44s var(--spring);
        box-shadow: 0 0 0 1px var(--line), 24px 0 60px rgba(0, 0, 0, 0.08);
        border-right: 1px solid var(--line);
    }

    .docs-shell.sidebar-open .docs-sidebar {
        transform: translateX(0);
    }

    .sidebar-inner {
        padding-top: 14px;
    }

    .sidebar-close {
        display: grid;
    }

    .sidebar-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 80;
        background: var(--scrim-soft);
        -webkit-backdrop-filter: blur(3px);
        backdrop-filter: blur(3px);
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .docs-shell.sidebar-open .sidebar-scrim {
        opacity: 1;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .doc-main,
    .overview {
        padding: 26px 24px 80px;
    }

    .doc-topbar {
        margin-bottom: 22px;
    }

    .overview .doc-topbar {
        margin-bottom: 32px;
    }

    .article,
    .pager,
    .doc-footer,
    .doc-topbar {
        max-width: none;
    }

    .lesson-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin {
        padding: 40px 22px 80px;
    }
}

@media (max-width: 720px) {
    .header-inner {
        padding: 0 18px;
    }

    .brand-name {
        max-width: 150px;
    }

    .site-nav {
        gap: 0;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 12.5px;
    }

    .home {
        padding: 60px 18px 28px;
        justify-content: flex-start;
    }

    .hero {
        padding-top: 26px;
    }

    .hero-title {
        margin-top: 18px;
    }

    .choices {
        grid-template-columns: 1fr;
        margin-top: 38px;
    }

    .choice {
        min-height: 112px;
        padding: 22px;
    }

    .overview-stats {
        gap: 8px;
    }

    .stat {
        min-width: calc(50% - 4px);
    }

    .lesson-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .doc-row {
        flex-wrap: wrap;
        gap: 4px 12px;
        padding: 14px 16px;
    }

    .doc-row-meta {
        width: 100%;
        padding-left: 0;
    }

    .pager {
        grid-template-columns: 1fr;
        margin-top: 46px;
    }

    .pager-card.pager-empty {
        display: none;
    }

    .admin-head-actions {
        width: 100%;
        justify-content: space-between;
    }

    .segmented {
        display: flex;
        width: 100%;
    }

    .segmented-item {
        flex: 1;
    }

    .form-grid,
    .editor-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .editor-pane {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .editor-textarea {
        min-height: 240px;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions .button {
        flex: 1;
    }

    .card {
        padding: 20px;
    }

    .announce-row-actions {
        width: 100%;
    }

    .announce-row-actions .button {
        padding: 0 12px;
    }

    .api-row {
        flex-direction: column;
        gap: 3px;
    }

    .api-label {
        width: auto;
    }

    .event-row {
        flex-wrap: wrap;
    }

    .event-side {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        padding-left: 0;
    }

    .event-path {
        max-width: 100%;
    }

    .announce-card {
        padding: 20px;
        max-height: 86vh;
    }

    .announce-title {
        font-size: 19px;
    }

    .auth-card {
        padding: 26px 22px;
    }

    .error-card {
        padding: 28px 22px;
    }
}

@media (max-width: 480px) {
    .brand-name {
        max-width: 108px;
    }

    .nav-link {
        padding: 6px 8px;
    }

    .doc-main,
    .overview {
        padding: 20px 17px 70px;
    }

    .md {
        font-size: 15px;
    }

    .md h2 {
        margin-top: 38px;
        font-size: 1.32rem;
    }

    .md pre {
        font-size: 11.8px;
        padding: 14px;
    }

    .admin {
        padding: 32px 16px 70px;
    }

    .admin-title {
        font-size: 1.9rem;
    }
}

/* ------------------------------------------------------------------
   Preferences
   ------------------------------------------------------------------ */

@media (prefers-reduced-transparency: reduce) {
    .site-header,
    .auth-card,
    .announce-card {
        background: var(--surface-solid);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .announce-scrim {
        background: var(--scrim);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }

    .reveal {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .choice-live:hover,
    .lesson-card:hover,
    .doc-row:hover,
    .pager-card:hover {
        transform: none;
    }

    @view-transition {
        navigation: none;
    }
}

@media (max-width: 720px) {
    .theme-grid {
        grid-template-columns: 1fr;
    }
}

.forbidden-page .site-nav {
    display: none;
}

/* ------------------------------------------------------------------
   Human verification
   ------------------------------------------------------------------ */

.captcha {
    min-height: calc(100vh - var(--header-h));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
}

.captcha-card {
    width: min(480px, 100%);
    padding: 42px 36px 32px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.captcha-title {
    margin: 12px 0 10px;
    font-size: clamp(26px, 4vw, 34px);
    letter-spacing: -0.02em;
    font-weight: 600;
}

.captcha-sub {
    margin: 0 auto;
    max-width: 34em;
    color: var(--ink-3);
    font-size: 14.5px;
}

.captcha-widget {
    display: flex;
    justify-content: center;
    margin: 26px 0 8px;
}

.captcha-status {
    margin: 10px 0 0;
    color: var(--danger);
    font-size: 13.5px;
}

.captcha-foot {
    margin: 22px 0 0;
    color: var(--ink-4);
    font-size: 12px;
}

cap-widget {
    --cap-background: var(--surface);
    --cap-color: var(--ink);
    --cap-border-color: var(--line-strong);
    --cap-border-radius: var(--radius-sm);
    --cap-font: var(--font);
    /* 宽度必须由宿主给出确定值；百分比在 Shadow DOM 内会形成循环计算。 */
    --cap-widget-width: 100%;
    --cap-checkbox-background: var(--bg-soft);
    --cap-checkbox-border: 1px solid var(--line-input);
    --cap-checkbox-border-radius: 6px;
    --cap-focus-ring: var(--accent);
    --cap-troubleshoot-color: var(--accent);
    --cap-invalid-border-color: var(--danger);
    display: block;
    width: 280px;
    max-width: 100%;
}

.captcha-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.captcha-stat {
    padding: 16px 18px;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
}

.captcha-stat-value {
    display: block;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.captcha-stat-label {
    display: block;
    margin-top: 2px;
    color: var(--ink-3);
    font-size: 12.5px;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    margin: 6px 0 2px;
}

.radio-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--ink-2);
}

.radio-option input {
    accent-color: var(--accent);
}

.captcha-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

@media (max-width: 720px) {
    .captcha {
        padding: 40px 18px;
    }

    .captcha-card {
        padding: 32px 22px 26px;
    }

    .captcha-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .captcha-settings-grid {
        grid-template-columns: 1fr;
    }
}
