@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&display=swap');

:root {
    --bg: #0f181b;
    --panel: #172226;
    --panel-strong: #1c2b30;
    --text: #1d1d1f;
    --muted: #5f6368;
    --accent: #19d1ff;
    --accent-soft: rgba(25, 209, 255, 0.12);
    --line: rgba(29, 29, 31, 0.08);
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
    --danger: #a54242;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Source Han Sans SC", "Source Han Sans CN", "Source Han Sans",
        "Noto Sans SC", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #111b1f, #111f24 40%, #0f181b);
    color: var(--text);
}

body {
    min-height: 100vh;
}

button,
input,
textarea {
    font: inherit;
}

.page-shell {
    max-width: 1480px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr) 240px;
    gap: 28px;
    min-height: 100vh;
    padding: 28px;
}

.sidebar {
    background: rgba(255, 255, 255, 0.52);
    border: 1px solid var(--line);
    border-radius: 0;
    box-shadow: var(--shadow);
    padding: 22px 18px;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 10px 22px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 0;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), #087b98);
    color: white;
    font-size: 1.4rem;
    font-weight: 700;
}

.brand-kicker,
.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    font-size: 0.72rem;
}

.brand-wrap h1,
.topbar h2 {
    margin: 6px 0 0;
    font-weight: 700;
}

.nav-header {
    color: var(--muted);
    font-size: 0.8rem;
    margin: 12px 10px 8px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.note-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.note-item {
    position: relative;
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.5);
    border-radius: 0;
    padding: 12px 12px 10px;
    color: var(--text);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.note-item:hover,
.note-item.active {
    background: var(--accent-soft);
    border-color: rgba(24, 209, 255, 0.34);
    transform: translateX(2px);
}

.note-item h4 {
    margin: 0 0 6px;
    font-size: 1rem;
}

.note-item p {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.note-preview {
    max-height: 78px;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.note-preview> :first-child {
    margin-top: 0;
}

.note-preview p,
.note-preview ul,
.note-preview ol,
.note-preview blockquote {
    margin: 0.25em 0;
}

.note-preview h1,
.note-preview h2,
.note-preview h3,
.note-preview h4,
.note-preview pre,
.note-preview table,
.note-preview .math-block {
    margin: 0.25em 0;
    font-size: 0.9em;
}

.note-preview pre,
.note-preview table,
.note-preview img {
    display: none;
}

.note-preview .math-block {
    overflow: hidden;
    max-height: 2.2em;
}

.note-item:hover {
    z-index: 12;
    width: min(420px, calc(100% + 150px));
    max-width: calc(100vw - 48px);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.24);
}

.note-item:hover .note-preview {
    max-height: 230px;
}

.sidebar,
.note-list {
    overflow: visible;
}

.note-item {
    transform-origin: center center;
    transition: transform 220ms cubic-bezier(.2, .75, .25, 1),
        box-shadow 220ms ease,
        background-color 220ms ease,
        border-color 220ms ease;
}

.note-item:hover,
.note-item.active:hover {
    width: 100%;
    max-width: none;
    transform: scale(1.045);
    background: #1a1b1b;
    border-color: var(--accent);
    box-shadow: 0 18px 34px rgba(0, 0, 0, .34);
}

.note-item:hover .note-preview {
    max-height: 300px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.note-item:hover .note-preview::-webkit-scrollbar {
    width: 5px;
}

.note-item:hover .note-preview::-webkit-scrollbar-thumb {
    background: var(--accent);
}

.note-item-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--muted);
}

.content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 8px 6px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-btn {
    padding: 8px 12px;
    border-radius: 0;
    background: rgba(24, 209, 255, 0.08);
    color: var(--accent);
    font-weight: 600;
}

.auth-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(180deg, #111b1f, #0f181b);
}

.auth-card {
    width: min(100%, 460px);
    padding: 30px;
}

.publish-card {
    width: min(100%, 720px);
    padding: 30px;
}

.auth-card h1 {
    margin: 8px 0 6px;
}

.auth-hint {
    margin: 0 0 22px;
    color: var(--muted);
}

.back-btn {
    padding: 7px 10px;
    margin-bottom: 28px;
    background: rgba(29, 29, 31, 0.08);
    color: var(--text);
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.auth-tab {
    padding: 10px 4px;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    border-bottom: 2px solid transparent;
}

.auth-tab:hover,
.auth-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    transform: none;
}

.card {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--line);
    border-radius: 0;
    box-shadow: var(--shadow);

    .note-item:hover,
    .note-item.active {
        background: #1a1b1b;
        border-color: var(--line);
        transform: none;
    }
}

.stack-form {
    display: grid;
    gap: 14px;

    .note-item {
        transform-origin: center center;
        transition: transform 220ms cubic-bezier(.2, .75, .25, 1), box-shadow 220ms ease, background-color 220ms ease, border-color 220ms ease;
    }

    .note-item:hover,
    .note-item.active:hover {
        z-index: 12;
        background: #1a1b1b;
        border-color: var(--accent);
        transform: scale(1.045);
        box-shadow: 0 18px 34px rgba(0, 0, 0, .34);
    }

    .note-item:hover .note-preview {
        max-height: 300px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

.stack-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
}

.stack-form input,
.stack-form textarea {
    width: 100%;
    border: 1px solid rgba(29, 29, 31, 0.14);
    background: #fff;
    border-radius: 0;
    padding: 12px 14px;
    color: var(--text);
    outline: none;
    resize: vertical;
}

.stack-form input:focus,
.stack-form textarea:focus {
    border-color: rgba(24, 209, 255, 0.7);
    box-shadow: 0 0 0 4px rgba(24, 209, 255, 0.08);
}

button {
    border: none;
    border-radius: 0;
    background: var(--accent);
    color: white;
    padding: 11px 16px;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

button:hover {
    opacity: 0.96;
    transform: translateY(-1px);
}

button:disabled {
    cursor: wait;
    opacity: 0.58;
    transform: none;
}

.secondary-btn {
    background: rgba(29, 29, 31, 0.08);
    color: var(--text);
}

.delete-btn {
    background: rgba(165, 66, 66, 0.12);
    color: var(--danger);
    padding: 7px 10px;
    font-size: 0.8rem;
}

.article {
    min-height: 520px;
    padding: clamp(24px, 4vw, 58px) clamp(22px, 7vw, 92px);
    background: #172226;
}

.article.is-loading {
    opacity: 0.56;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#appMessage {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 20;
    max-width: min(360px, calc(100vw - 32px));
    padding: 12px 16px;
    border: 1px solid rgba(29, 29, 31, 0.1);
    border-radius: 0;
    background: var(--panel-strong);
    box-shadow: var(--shadow);
    color: var(--text);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#appMessage.visible {
    opacity: 1;
    transform: translateY(0);
}

#appMessage[data-type="success"] {
    border-color: rgba(24, 209, 255, 0.3);
    color: var(--accent);
}

.article-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 26px;
    border-bottom: 1px solid var(--line);
}

.article-kicker {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.article-title {
    margin: 0;
    color: var(--text);
    font-size: clamp(1.9rem, 4vw, 3rem);
    line-height: 1.12;
    letter-spacing: -0.02em;
}

.article-toc-panel {
    position: sticky;
    top: 14px;
    z-index: 5;
    align-self: start;
    max-height: calc(100vh - 28px);
    overflow-y: auto;
    padding: 0;
}

.markdown-toc {
    max-width: none;
    margin: 0;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 0;
    background: rgba(24, 209, 255, 0.045);
}

.markdown-toc-title {
    margin-bottom: 7px;
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.markdown-toc ul {
    margin: 0;
    padding-left: 1.15em;
    list-style: none;
}

.markdown-toc ul ul {
    margin-top: 2px;
}

.markdown-toc li {
    margin: 0;
    line-height: 1.55;
}

.markdown-toc a {
    display: block;
    padding: 2px 0;
    color: var(--muted);
    font-size: 0.88rem;
    text-decoration: none;
}

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

.markdown-body {
    max-width: 76ch;
    margin: 34px auto 0;
    color: #292a28;
    font-size: 1rem;
    line-height: 1.82;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    scroll-margin-top: 24px;
    color: #20221f;
    font-weight: 700;
    line-height: 1.3;
    margin: 2em 0 0.65em;
}

.markdown-body h1 {
    font-size: 1.9rem;
}

.markdown-body h2 {
    padding-bottom: 0.35em;
    border-bottom: 1px solid var(--line);
    font-size: 1.55rem;
}

.markdown-body h3 {
    font-size: 1.25rem;
}

.markdown-body h4 {
    font-size: 1.08rem;
}

.markdown-body> :first-child {
    margin-top: 0;
}

.markdown-body p,
.markdown-body li {
    color: #3a3c38;
}

.markdown-body p {
    margin: 1em 0;
    white-space: pre-wrap;
    tab-size: 4;
}

.markdown-body li {
    tab-size: 4;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.6em;
    margin: 1em 0;
}

.markdown-body li+li {
    margin-top: 0.35em;
}

.markdown-body a {
    color: #18d1ff;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.markdown-body a:hover {
    color: #9aeaff;
}

.markdown-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.6em auto;
    border: 1px solid var(--line);
    border-radius: 0;
}

.markdown-body hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 2.4em 0;
}

.markdown-body pre {
    overflow-x: auto;
    margin: 1.5em 0;
    background: #252823;
    color: #f2f4ec;
    padding: 18px 20px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 0;
    font-size: 0.92rem;
    line-height: 1.65;
}

.markdown-body code {
    font-family: "Cascadia Code", "Consolas", monospace;
}

.markdown-body :not(pre)>code {
    padding: 0.15em 0.35em;
    border: 1px solid rgba(24, 209, 255, 0.16);
    border-radius: 0;
    background: rgba(24, 209, 255, 0.08);
    color: #8be8ff;
    font-size: 0.9em;
}

.markdown-body blockquote {
    margin: 1.3em 0;
    border-left: 3px solid #7dd8e8;
    background: #15282d;
    padding: 10px 18px;
    color: #b3cbd0;
}

.markdown-body blockquote p {
    margin: 0.45em 0;
    color: inherit;
}

.markdown-body blockquote.callout {
    border-left-width: 4px;
    border-left-color: #18d1ff;
    background: rgba(24, 209, 255, 0.09);
    padding: 13px 18px;
}

.markdown-body .callout-title {
    margin-bottom: 6px;
    color: #9aeaff;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.markdown-body blockquote.callout-warning,
.markdown-body blockquote.callout-danger,
.markdown-body blockquote.callout-failure,
.markdown-body blockquote.callout-bug {
    border-left-color: #18d1ff;
    background: rgba(24, 209, 255, 0.09);
}

.markdown-body .callout-warning .callout-title,
.markdown-body .callout-danger .callout-title,
.markdown-body .callout-failure .callout-title,
.markdown-body .callout-bug .callout-title {
    color: #9aeaff;
}

.markdown-body blockquote.callout-tip,
.markdown-body blockquote.callout-success {
    border-left-color: #18d1ff;
    background: rgba(24, 209, 255, 0.1);
}

.markdown-body blockquote.callout-info,
.markdown-body blockquote.callout-abstract,
.markdown-body blockquote.callout-example {
    border-left-color: #18d1ff;
    background: rgba(24, 209, 255, 0.09);
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
    overflow: hidden;
    border-radius: 0;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
}

.markdown-body th {
    background: #17282d;
    color: #d8f3f7;
    font-weight: 700;
}

.markdown-body tr:nth-child(even) td {
    background: rgba(24, 209, 255, 0.025);
}

.markdown-body input[type="checkbox"] {
    width: 1em;
    height: 1em;
    margin: 0 0.45em 0 0;
    accent-color: var(--accent);
    vertical-align: -0.12em;
}

.markdown-body li:has(input[type="checkbox"]) {
    list-style: none;
    margin-left: -1.35em;
}

.markdown-body mjx-container {
    color: #242923;
}

.markdown-body .math-block {
    display: block;
    width: 100%;
    clear: both;
    margin: 1.35em 0;
    min-height: 1.5em;
    text-align: center;
}

.markdown-body mjx-container[display="true"] {
    display: block;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.45em 0.2em;
    margin: 0;
    text-align: center;
}

.markdown-body mjx-container:not([display="true"]) {
    padding: 0 0.08em;
}

.empty-state {
    margin: 0;
    color: var(--muted);
    text-align: center;
    padding: 120px 18px;
    letter-spacing: 0.03em;
}

.hidden {
    display: none !important;
}

@media (max-width: 960px) {
    .page-shell {
        grid-template-columns: 1fr;
        padding: 18px;
    }

    .article-toc-panel {
        grid-row: 3;
        max-height: none;
        position: static;
    }

    .content {
        grid-row: 2;
    }

    .sidebar {
        max-height: none;
    }

    .article {
        padding: 26px 20px;
    }

    .markdown-body {
        font-size: 0.98rem;
    }

    .markdown-body table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Archive terminal skin — original styling inspired by industrial sci-fi interfaces. */
:root {
    --bg: #111213;
    --panel: #1a1b1b;
    --panel-strong: #202121;
    --text: #f0f0ea;
    --muted: #969a98;
    --accent: #19d1ff;
    --accent-soft: rgba(25, 209, 255, .14);
    --line: rgba(239, 239, 232, .14);
    --shadow: 0 18px 40px rgba(0, 0, 0, .28);
    --danger: #e66d5a;
}

html,
body {
    background: #111213;
    color: var(--text);
}

body {
    position: relative;
    overflow-x: hidden;
}

.ambient-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 76% 12%, rgba(24, 209, 255, .08), transparent 46%),
        linear-gradient(90deg, rgba(159, 192, 200, .045) 1px, transparent 1px) 0 0 / 96px 96px,
        linear-gradient(rgba(159, 192, 200, .045) 1px, transparent 1px) 0 0 / 96px 96px,
        #101719;
}

.ambient-grid::before,
.ambient-grid::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
}

.ambient-grid::before {
    right: auto;
    left: calc(100% - var(--workspace-edge) - var(--rail-right) - var(--workspace-gap));
    width: calc(var(--rail-right) + var(--workspace-gap));
    background:
        repeating-linear-gradient(135deg, transparent 0 22px, rgba(24, 209, 255, .07) 22px 23px),
        #142f37;
    clip-path: polygon(30% 0, 100% 0, 100% 100%, 0 100%, 0 54%, 30% 38%);
    border: 0;
}

.ambient-grid::after {
    top: 68px;
    bottom: 0;
    left: calc(var(--workspace-edge) + var(--rail-left) + 6px);
    width: 7px;
    background:
        repeating-linear-gradient(to bottom, rgba(24, 209, 255, .45) 0 1px, transparent 1px 16px);
    border-left: 1px solid rgba(24, 209, 255, .18);
    border-right: 0;
}

.page-shell {
    position: relative;
    z-index: 1;
    max-width: 1660px;
    grid-template-columns: 288px minmax(0, 1fr) 300px;
    gap: 18px;
    padding: 18px;
}

.sidebar,
.card {
    border-radius: 0;
    border: 1px solid var(--line);
    box-shadow: none;
    background: rgba(26, 27, 27, .9);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.sidebar {
    position: relative;
    padding: 16px 12px;
    border-top: 3px solid var(--accent);
}

.sidebar::after {
    content: "ARCHIVE NODE // A-01";
    position: absolute;
    right: -1px;
    bottom: 10px;
    color: rgba(240, 240, 234, .3);
    font: 600 9px/1 "Cascadia Code", monospace;
    letter-spacing: .12em;
    writing-mode: vertical-rl;
}

.brand-wrap {
    padding: 8px 8px 20px;
    border-bottom-color: var(--line);
}

.brand-wrap h1,
.topbar h2 {
    color: var(--text);
    letter-spacing: .02em;
}

.brand-kicker,
.eyebrow {
    color: var(--accent);
    font: 700 .63rem/1.4 "Cascadia Code", "Source Han Sans SC", "Source Han Sans CN", "Microsoft YaHei", monospace;
    letter-spacing: .15em;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 0;
    background: var(--accent);
    color: #151515;
    clip-path: polygon(0 0, 100% 0, 100% 68%, 68% 100%, 0 100%);
    font-family: "Arial Black", sans-serif;
}

.brand-mark span {
    transform: translate(-1px, -1px);
}

.nav-header {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    margin: 16px 8px 10px;
    font: 700 .65rem/1 "Cascadia Code", monospace;
}

.nav-header::before {
    content: "";
    display: block;
    width: 6px;
    height: 6px;
    background: var(--accent);
}

.nav-header::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
}

.note-list {
    gap: 5px;
}

.note-item {
    position: relative;
    border: 1px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    padding: 13px 12px 11px 17px;
}

.note-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: transparent;
}

.note-item:hover,
.note-item.active {
    background: rgba(255, 255, 255, .055);
    border-color: var(--line);
    transform: none;
}

.note-item:hover::before,
.note-item.active::before {
    background: var(--accent);
}

.note-item h4 {
    font-size: .94rem;
    font-weight: 650;
    letter-spacing: .015em;
}

.note-item p,
.note-item-meta {
    color: var(--muted);
}

.note-item-meta {
    font: .68rem "Cascadia Code", monospace;
}

.content {
    gap: 14px;
    min-width: 0;
}

.topbar {
    min-height: 72px;
    padding: 10px 4px 12px 16px;
    border-bottom: 1px solid var(--line);
}

.topbar h2 {
    margin-top: 7px;
    font-size: clamp(1.25rem, 2.2vw, 1.8rem);
}

.topbar-actions {
    gap: 8px;
}

button {
    border-radius: 0;
    background: var(--accent);
    color: #151515;
    font-weight: 750;
    padding: 10px 14px;
    letter-spacing: .04em;
}

button:hover {
    opacity: 1;
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.profile-btn,
.secondary-btn,
.back-btn {
    border: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    color: var(--text);
}

.profile-btn {
    padding: 8px 12px;
}

.publish-btn {
    clip-path: polygon(0 0, 100% 0, 100% 72%, 92% 100%, 0 100%);
}

.article {
    min-height: calc(100vh - 108px);
    padding: clamp(26px, 4vw, 56px) clamp(24px, 6vw, 82px);
    background: rgba(24, 25, 25, .93);
}

.article-header {
    position: relative;
    padding: 0 0 28px;
    border-bottom-color: var(--line);
}

.article-header::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 86px;
    height: 3px;
    background: var(--accent);
}

.article-kicker {
    color: var(--accent);
    font: 700 .67rem "Cascadia Code", monospace;
    letter-spacing: .16em;
}

.article-title {
    color: var(--text);
    font-size: clamp(2rem, 4vw, 3.6rem);
    letter-spacing: .01em;
}

.delete-btn {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(230, 109, 90, .55);
}

.markdown-body {
    max-width: 72ch;
    margin-left: auto;
    margin-right: auto;
    color: #c9e1e6;
    font-size: 1.04rem;
    line-height: 1.85;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    color: #eaf7fa;
    line-height: 1.3;
    scroll-margin-top: 28px;
}

.markdown-body h1 {
    font-size: 2rem;
}

.markdown-body h2 {
    font-size: 1.55rem;
    margin-top: 2.2em;
}

.markdown-body h3 {
    font-size: 1.25rem;
    margin-top: 1.9em;
}

.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    font-size: 1.08rem;
    margin-top: 1.7em;
}

.markdown-body p {
    margin: 1.1em 0;
}

.markdown-body ul,
.markdown-body ol {
    margin-top: 1.1em;
    margin-bottom: 1.1em;
}

.markdown-body h2 {
    border-bottom-color: var(--line);
}

.markdown-body h2::before {
    content: none;
}

.markdown-body p,
.markdown-body li {
    color: #c2dce1;
}

.markdown-body a {
    color: #19d1ff;
}

.markdown-body a:hover {
    color: #8be8ff;
}

.markdown-body pre {
    border-radius: 0;
    background: #0d0e0e;
    border-left: 3px solid var(--accent);
    color: #e2f2f5;
}

.markdown-body :not(pre)>code {
    border-radius: 0;
    border-color: rgba(25, 209, 255, .3);
    background: rgba(25, 209, 255, .11);
    color: #79e5ff;
}

.markdown-body blockquote {
    border-left-color: var(--accent);
    background: rgba(25, 209, 255, .07);
    color: #c2f4ff;
}

.markdown-body th {
    background: #252625;
    color: var(--text);
}

.markdown-body th,
.markdown-body td {
    border-color: var(--line);
}

.markdown-body tr:nth-child(even) td {
    background: rgba(255, 255, 255, .025);
}

.markdown-body mjx-container {
    color: #e6f5f8;
}

.article-toc-panel {
    top: 18px;
    max-height: none;
    overflow: visible;
}

.markdown-toc {
    min-height: 120px;
    border-radius: 0;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    background: rgba(26, 27, 27, .86);
    padding: 20px 18px;
    overflow: visible;
}

.markdown-toc-title {
    color: var(--accent);
    margin-bottom: 12px;
    font: 700 .78rem "Cascadia Code", monospace;
}

.markdown-toc a {
    position: relative;
    z-index: 0;
    isolation: isolate;
    color: var(--muted);
    padding: 7px 10px;
    font-size: .94rem;
    line-height: 1.55;
    transition: color 160ms ease, transform 160ms ease;
}

.markdown-toc a::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 1px -14px;
    background: transparent;
    box-shadow: none;
    transition: background-color 160ms ease, box-shadow 160ms ease;
}

.markdown-toc a:hover {
    z-index: 1;
    color: #151515;
    transform: translateX(3px);
}

.markdown-toc a:hover::before,
.markdown-toc a:focus-visible::before {
    background: #19d1ff;
    box-shadow: 0 0 0 1px #19d1ff, 0 8px 20px rgba(0, 0, 0, .34);
}

.markdown-toc a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.markdown-toc li {
    position: relative;
}

.markdown-toc li::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 0.8em;
    width: 5px;
    height: 5px;
    background: var(--muted);
    transform: rotate(45deg);
}

.markdown-toc .toc-level-1>a {
    font-weight: 750;
}

.markdown-toc .toc-level-2 {
    margin-left: 12px;
}

.markdown-toc .toc-level-3 {
    margin-left: 24px;
}

.markdown-toc .toc-level-4 {
    margin-left: 36px;
}

.markdown-toc .toc-level-5 {
    margin-left: 48px;
}

.markdown-toc .toc-level-6 {
    margin-left: 60px;
}

.markdown-toc .toc-level-1::before {
    background: var(--accent);
}

.markdown-toc .toc-level-2::before {
    width: 4px;
    height: 4px;
}

.markdown-toc .toc-level-3::before,
.markdown-toc .toc-level-4::before,
.markdown-toc .toc-level-5::before,
.markdown-toc .toc-level-6::before {
    width: 3px;
    height: 3px;
}

.auth-screen {
    position: relative;
    z-index: 1;
    background: transparent;
}

.auth-screen::before {
    content: "ACCESS / A-01";
    position: fixed;
    top: 24px;
    left: 28px;
    color: var(--accent);
    font: 700 .68rem "Cascadia Code", monospace;
    letter-spacing: .16em;
}

.auth-card,
.publish-card {
    border-top: 3px solid var(--accent);
}

.auth-card h1,
.publish-card h1 {
    color: var(--text);
}

.auth-hint,
.stack-form label {
    color: var(--muted);
}

.auth-tabs {
    border-bottom-color: var(--line);
}

.auth-tab {
    color: var(--muted);
}

.auth-tab:hover,
.auth-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.stack-form input,
.stack-form textarea {
    border-radius: 0;
    border: 0;
    border-bottom: 1px solid rgba(24, 209, 255, .24);
    background: rgba(255, 255, 255, .018);
    padding: 11px 2px 10px;
    color: var(--text);
}

.stack-form input:focus,
.stack-form textarea:focus {
    border-color: var(--accent);
    border-bottom-color: var(--accent);
    box-shadow: none;
}

#appMessage {
    border-radius: 0;
    border-left: 3px solid var(--accent);
    background: var(--panel-strong);
    color: var(--text);
}

@media (max-width: 960px) {
    .page-shell {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 12px;
    }

    .content {
        grid-row: 2;
    }

    .article-toc-panel {
        grid-row: 3;
        position: static;
        max-height: none;
    }

    .markdown-toc {
        width: 100%;
    }

    .sidebar {
        padding-bottom: 20px;
    }

    .sidebar::after {
        display: none;
    }

    .article {
        min-height: 0;
    }
}

@media (max-width: 560px) {
    .topbar {
        align-items: flex-start;
        padding-left: 4px;
    }

    .topbar-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .article-title {
        font-size: 2rem;
    }

    .article {
        padding: 28px 20px;
    }

    .profile-btn {
        max-width: 142px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Top archive banner and layered atmospheric background. */
body::before,
body::after {
    content: "";
    position: fixed;
    z-index: -1;
    pointer-events: none;
}

body::before {
    width: min(68vw, 900px);
    height: min(68vw, 900px);
    top: -34vw;
    right: -14vw;
    background: radial-gradient(circle, rgba(24, 209, 255, .1), transparent 68%);
    filter: blur(4px);
}

body::after {
    inset: 0;
    opacity: .18;
    background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, .12) 3px 4px);
    mix-blend-mode: soft-light;
}

.archive-banner {
    position: relative;
    isolation: isolate;
    min-height: 288px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid var(--line);
    background:
        linear-gradient(104deg, rgba(21, 22, 22, .96) 0%, rgba(25, 26, 25, .93) 58%, rgba(18, 57, 68, .62) 100%),
        linear-gradient(90deg, transparent 64%, rgba(24, 209, 255, .1) 64%);
}

.archive-banner::before {
    content: "A";
    position: absolute;
    z-index: -1;
    right: 176px;
    bottom: -102px;
    color: rgba(239, 239, 231, .035);
    font: 900 390px/.7 Arial, sans-serif;
    letter-spacing: -.18em;
}

.archive-banner::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 46%;
    height: 3px;
    background: var(--accent);
}

.banner-noise {
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: .48;
    background:
        linear-gradient(120deg, transparent 0 62%, rgba(255, 255, 255, .035) 62% 62.3%, transparent 62.3%),
        repeating-linear-gradient(90deg, transparent 0 33px, rgba(255, 255, 255, .027) 33px 34px);
}

.banner-copy {
    padding: clamp(26px, 4vw, 46px);
    align-self: center;
}

.banner-kicker {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 13px;
    color: var(--accent);
    font: 700 .66rem/1 "Cascadia Code", monospace;
    letter-spacing: .16em;
}

.status-dot {
    width: 7px;
    height: 7px;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(24, 209, 255, .14);
    animation: status-pulse 2.2s ease-in-out infinite;
}

.banner-copy h2 {
    max-width: 680px;
    margin: 0;
    color: var(--text);
    font-size: clamp(2rem, 4.3vw, 4.4rem);
    font-weight: 750;
    line-height: 1.04;
    letter-spacing: -.045em;
}

.banner-copy h2 em {
    color: var(--accent);
    font-style: normal;
}

.banner-description {
    max-width: 510px;
    margin: 16px 0 24px;
    color: #adb0aa;
    font-size: .92rem;
    line-height: 1.8;
}

.banner-read-btn {
    padding: 11px 15px;
    font-size: .76rem;
}

.banner-read-btn span {
    display: inline-block;
    margin-left: 14px;
    font-size: 1rem;
    transition: transform .2s ease;
}

.banner-read-btn:hover span {
    transform: translate(3px, 3px);
}

.banner-data {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 18px;
    padding: 25px 20px;
    border-left: 1px solid rgba(239, 239, 232, .14);
    background: rgba(0, 0, 0, .12);
}

.banner-data div {
    display: grid;
    gap: 3px;
}

.banner-data span {
    color: var(--text);
    font: 700 2rem/1 "Cascadia Code", monospace;
    letter-spacing: -.08em;
}

.banner-data small,
.banner-data p {
    color: var(--muted);
    font: 600 .58rem/1.55 "Cascadia Code", monospace;
    letter-spacing: .12em;
}

.banner-data p {
    margin: 0;
    padding-top: 13px;
    border-top: 1px solid var(--line);
}

.markdown-toc a.active {
    color: var(--accent);
    padding-left: 7px;
    border-left: 2px solid var(--accent);
}

.markdown-toc a.active:hover,
.markdown-toc a.active:focus-visible {
    color: #151515;
}

.markdown-toc a.active:hover::before,
.markdown-toc a.active:focus-visible::before {
    background: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), 0 8px 20px rgba(0, 0, 0, .34);
}

@keyframes status-pulse {
    50% {
        opacity: .45;
        box-shadow: 0 0 0 7px rgba(24, 209, 255, 0);
    }
}

@media (max-width: 960px) {
    .archive-banner {
        min-height: 250px;
        grid-template-columns: minmax(0, 1fr) 170px;
    }

    .banner-data {
        padding: 20px 14px;
    }

    .archive-banner::before {
        right: 110px;
        font-size: 310px;
    }
}

/* Persistent, enlarged navigation rails for desktop reading. */
@media (min-width: 961px) {
    .page-shell {
        grid-template-columns: clamp(330px, 24vw, 400px) minmax(420px, 1fr) clamp(320px, 22vw, 390px);
        align-items: start;
    }

    .sidebar {
        position: sticky;
        top: 82px;
        max-height: calc(100vh - 100px);
        overflow: hidden auto;
        scrollbar-width: thin;
        scrollbar-color: rgba(24, 209, 255, .55) transparent;
    }

    .sidebar::-webkit-scrollbar,
    .article-toc-panel::-webkit-scrollbar {
        width: 5px;
    }

    .sidebar::-webkit-scrollbar-thumb,
    .article-toc-panel::-webkit-scrollbar-thumb {
        background: rgba(24, 209, 255, .55);
    }

    .note-list {
        gap: 8px;
    }

    .note-item {
        padding: 17px 16px 15px 21px;
    }

    .note-item h4 {
        font-size: 1.05rem;
    }

    .note-preview {
        max-height: 6.3em;
        overflow: hidden;
    }

    .article-toc-panel {
        position: fixed;
        top: 82px;
        right: clamp(18px, 2.4vw, 40px);
        bottom: 18px;
        width: clamp(320px, 22vw, 390px);
        max-height: none;
        overflow: hidden auto;
        padding: 0 4px 0 0;
        border-left: 1px solid rgba(240, 240, 234, .08);
        background: linear-gradient(90deg, rgba(17, 18, 18, .7), transparent);
        box-shadow: -18px 0 38px rgba(0, 0, 0, .14);
    }

    .markdown-toc {
        min-height: calc(100vh - 100px);
    }

    .markdown-toc a {
        font-size: .94rem;
    }
}

/* Main-stage composition: a restrained, archive-inspired reading layout. */
.page-shell::before {
    content: "ARCHIVE / READING NODE A-01";
    position: absolute;
    top: 5px;
    left: clamp(18px, 2.4vw, 40px);
    color: rgba(240, 240, 234, .32);
    font: 700 .56rem/1 "Cascadia Code", monospace;
    letter-spacing: .16em;
}

.page-shell::after {
    content: "";
    position: absolute;
    top: 16px;
    left: clamp(18px, 2.4vw, 40px);
    right: clamp(18px, 2.4vw, 40px);
    height: 1px;
    background: linear-gradient(90deg, var(--accent), rgba(240, 240, 234, .14) 19%, transparent 70%);
}

.sidebar {
    align-self: start;
    border-top-width: 2px;
    background: linear-gradient(145deg, rgba(35, 36, 35, .94), rgba(20, 21, 21, .86));
}

.sidebar nav {
    position: relative;
}

.sidebar nav::after {
    content: "INDEX // J · K TO NAVIGATE";
    display: block;
    margin: 22px 8px 2px;
    color: rgba(240, 240, 234, .32);
    font: 600 .55rem/1.5 "Cascadia Code", monospace;
    letter-spacing: .1em;
}

.content {
    position: relative;
}

.content::before {
    content: "01";
    position: absolute;
    top: 18px;
    right: 5px;
    color: rgba(240, 240, 234, .18);
    font: 700 .64rem "Cascadia Code", monospace;
    letter-spacing: .1em;
}

.topbar {
    position: relative;
    border-bottom: 0;
}

.topbar::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, var(--accent) 0 74px, var(--line) 74px 100%);
}

.article {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(240, 240, 234, .16);
    background:
        linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px) 0 0 / 24px 24px,
        linear-gradient(rgba(255, 255, 255, .015) 1px, transparent 1px) 0 0 / 24px 24px,
        rgba(25, 26, 26, .96);
}

.article::before,
.article::after {
    content: "";
    position: absolute;
    width: 28px;
    height: 28px;
    pointer-events: none;
}

.article::before {
    top: -1px;
    right: -1px;
    border-top: 3px solid var(--accent);
    border-right: 3px solid var(--accent);
}

.article::after {
    bottom: -1px;
    left: -1px;
    border-bottom: 2px solid rgba(24, 209, 255, .6);
    border-left: 2px solid rgba(24, 209, 255, .6);
}

.article-header {
    padding-bottom: 31px;
}

.article-title {
    font-weight: 750;
}

.markdown-body {
    position: relative;
}

.markdown-body::before {
    content: "CONTENT";
    position: absolute;
    top: -18px;
    left: 0;
    color: rgba(240, 240, 234, .3);
    font: 700 .52rem/1 "Cascadia Code", monospace;
    letter-spacing: .16em;
}

.article-toc-panel {
    position: sticky;
}

.markdown-toc {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 14px 30px rgba(0, 0, 0, .13);
}

.article-toc-panel::after {
    content: "SCROLL TO READ";
    display: block;
    flex-shrink: 0;
    margin: 16px 20px 20px;
    padding-top: 11px;
    border-top: 1px solid var(--line);
    color: rgba(240, 240, 234, .3);
    font: 600 .54rem/1 "Cascadia Code", monospace;
    letter-spacing: .12em;
}

.back-to-top {
    position: fixed;
    right: max(24px, calc((100vw - 1740px) / 2 + 8px));
    bottom: 18vh;
    z-index: 12;
    display: grid;
    width: 46px;
    height: 52px;
    place-items: center;
    padding: 5px;
    border: 1px solid rgba(240, 240, 234, .2);
    border-left: 3px solid var(--accent);
    border-right: 1px solid rgba(240, 240, 234, .2);
    background: rgba(22, 23, 23, .9);
    color: var(--text);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .24);
    opacity: 0;
    pointer-events: none;
    transform: translateX(12px);
    transition: opacity .18s ease, transform .18s ease, background .18s ease;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.back-to-top:hover {
    background: var(--accent);
    color: #151515;
    transform: translateX(-2px);
}

.back-to-top span {
    font: 500 1.15rem/1 "Cascadia Code", monospace;
}

.back-to-top small {
    font: 700 .48rem/1 "Cascadia Code", monospace;
    letter-spacing: .1em;
}

@media (max-width: 960px) {

    .page-shell::before,
    .page-shell::after,
    .content::before {
        display: none;
    }

    .sidebar nav::after {
        display: none;
    }

    .article {
        background: rgba(25, 26, 26, .96);
    }

    .back-to-top {
        right: 16px;
        bottom: 22px;
    }
}

@media (max-width: 620px) {
    .archive-banner {
        display: block;
        min-height: 0;
    }

    .banner-copy {
        padding: 29px 24px;
    }

    .banner-copy h2 {
        font-size: 2.35rem;
    }

    .banner-description {
        font-size: .84rem;
    }

    .banner-data {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        border-left: 0;
        border-top: 1px solid var(--line);
        padding: 15px 24px;
    }

    .banner-data p {
        grid-column: span 2;
        padding-top: 10px;
    }

    .archive-banner::before {
        right: 12px;
        bottom: -65px;
        font-size: 235px;
    }
}

/* Compact global navigation replaces the former hero banner. */
.top-navigation {
    position: sticky;
    top: 0;
    z-index: 30;
    width: 100%;
    max-width: none;
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 18px;
    margin: 0;
    padding: 13px clamp(18px, 3vw, 52px);
    border: 0;
    border-bottom: 1px solid var(--line);
    border-top: 0;
    background: rgba(18, 19, 19, .9);
    box-shadow: 0 10px 25px rgba(0, 0, 0, .16);
    backdrop-filter: blur(16px);
}

.top-navigation::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 92px;
    height: 2px;
    background: var(--accent);
}

.top-nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-size: .94rem;
    font-weight: 750;
    letter-spacing: .04em;
    text-decoration: none;
}

.top-nav-mark {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    clip-path: polygon(0 0, 100% 0, 100% 72%, 72% 100%, 0 100%);
    background: var(--accent);
    color: #151515;
    font: 900 .82rem Arial, sans-serif;
}

.top-nav-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 17px;
    border-left: 1px solid var(--line);
    color: var(--muted);
    font: 700 .61rem/1 "Cascadia Code", monospace;
    letter-spacing: .12em;
}

.top-nav-status .status-dot {
    width: 6px;
    height: 6px;
}

.top-nav-metrics {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

.top-nav-metrics span,
.top-nav-date {
    color: var(--muted);
    font: 600 .59rem/1 "Cascadia Code", monospace;
    letter-spacing: .08em;
    white-space: nowrap;
}

.top-nav-metrics b {
    margin-right: 4px;
    color: var(--text);
    font-size: .76rem;
}

.top-nav-date {
    padding-left: 16px;
    border-left: 1px solid var(--line);
}

.top-nav-user-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    padding-left: 14px;
    border-left: 1px solid var(--line);
}

.top-nav-user-actions button {
    padding: 8px 11px;
    font-size: .7rem;
    white-space: nowrap;
}

.top-nav-user-actions .profile-btn {
    color: var(--text);
}

.top-nav-user-actions .publish-btn {
    clip-path: polygon(0 0, 100% 0, 100% 70%, 92% 100%, 0 100%);
}

.topbar {
    min-height: 58px;
    padding-left: 4px;
}

.page-shell {
    padding-top: 18px;
}

@media (max-width: 760px) {
    .top-navigation {
        gap: 11px;
        padding: 8px 12px;
    }

    .top-nav-status,
    .top-nav-date {
        display: none;
    }

    .top-nav-metrics {
        gap: 10px;
    }

    .top-nav-user-actions {
        padding-left: 10px;
    }
}

@media (max-width: 650px) {
    .top-nav-metrics {
        display: none;
    }

    .top-nav-user-actions {
        margin-left: auto;
    }
}

@media (max-width: 500px) {
    .top-navigation {
        min-height: 52px;
    }

    .top-nav-brand {
        font-size: .82rem;
    }

    .top-nav-mark {
        width: 25px;
        height: 25px;
    }

    .top-nav-metrics span:last-child {
        display: none;
    }

    .top-nav-user-actions {
        gap: 5px;
        padding-left: 7px;
    }

    .top-nav-user-actions button {
        padding: 7px 8px;
        font-size: .62rem;
    }

    .top-nav-user-actions .profile-btn {
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Editorial sizing pass: strengthen the reading column and its two index rails. */
.page-shell {
    max-width: 1740px;
    grid-template-columns: 270px minmax(0, 1fr) 280px;
    gap: clamp(18px, 2vw, 32px);
    padding: 24px clamp(18px, 2.4vw, 40px) 42px;
}

.sidebar {
    padding: 20px 14px;
}

.brand-wrap {
    padding: 10px 8px 24px;
    margin-bottom: 18px;
}

.brand-wrap h1 {
    font-size: 1.32rem;
}

.note-item {
    padding: 14px 12px 12px 18px;
}

.note-item h4 {
    font-size: 1rem;
    line-height: 1.35;
}

.topbar {
    min-height: 68px;
    padding: 12px 4px 15px;
}

.topbar h2 {
    font-size: clamp(1.4rem, 2vw, 1.9rem);
}

.article {
    min-height: calc(100vh - 132px);
    padding: clamp(34px, 4.5vw, 72px) clamp(30px, 6vw, 106px);
}

.article-title {
    max-width: 17ch;
}

.markdown-body {
    max-width: 72ch;
    font-size: 1.04rem;
}

.article-toc-panel {
    top: 82px;
}

.markdown-toc {
    padding: 22px 18px 20px;
}

.markdown-toc-title {
    position: relative;
    overflow: hidden;
    max-width: 100%;
    margin: 0 0 16px;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    font: 700 .9rem/1.45 "Source Han Sans SC", "Source Han Sans CN", "Source Han Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
    letter-spacing: .015em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.markdown-toc-title::before {
    content: "CURRENT DOCUMENT";
    display: block;
    margin-bottom: 5px;
    color: var(--accent);
    font: 700 .57rem/1 "Cascadia Code", monospace;
    letter-spacing: .14em;
}

.markdown-toc a {
    padding-top: 8px;
    padding-bottom: 8px;
    font-size: .88rem;
}

@media (max-width: 1180px) {
    .page-shell {
        grid-template-columns: 240px minmax(0, 1fr) 240px;
        gap: 16px;
    }

    .article {
        padding-left: clamp(28px, 5vw, 58px);
        padding-right: clamp(28px, 5vw, 58px);
    }
}

@media (max-width: 960px) {
    .page-shell {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .article-toc-panel {
        top: auto;
    }

    .markdown-toc-title {
        white-space: normal;
    }
}

/* Unified workspace layout. Keep these rules after the legacy theme layers. */
:root {
    --workspace-gap: 20px;
    --workspace-edge: clamp(16px, 2vw, 36px);
    --rail-left: clamp(260px, 22vw, 370px);
    --rail-right: clamp(240px, 20vw, 330px);
    --workspace-top: 88px;
}

html {
    scroll-padding-top: 100px;
}

body {
    isolation: isolate;
}

.ambient-grid {
    opacity: 1;
}

button,
a,
input,
textarea {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

button:active:not(:disabled) {
    transform: translateY(1px);
}

::selection {
    background: #18d1ff;
    color: #161819;
}

.top-navigation {
    position: fixed;
    inset: 0 0 auto;
    height: 72px;
    padding-inline: var(--workspace-edge);
    gap: 20px;
    background: rgba(17, 19, 20, .96);
}

.top-nav-brand {
    font-size: 1.04rem;
    letter-spacing: -.025em;
}

.top-nav-mark {
    width: 34px;
    height: 34px;
}

.top-nav-user-actions button {
    min-height: 36px;
    font-size: .76rem;
}

.top-nav-user-actions .profile-btn {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-nav-metrics {
    gap: 22px;
}

.page-shell {
    max-width: none;
    min-height: 100vh;
    padding: var(--workspace-top) var(--workspace-edge) 32px;
    grid-template-columns: var(--rail-left) minmax(0, 1fr) var(--rail-right);
    gap: var(--workspace-gap);
    align-items: start;
}

.page-shell::before,
.page-shell::after,
.content::before,
.sidebar::after,
.sidebar nav::after {
    display: none;
}

.sidebar,
.article-toc-panel {
    position: fixed;
    top: var(--workspace-top);
    bottom: 20px;
    height: auto;
    max-height: none;
    min-width: 0;
    border: 1px solid rgba(240, 240, 234, .12);
    border-top: 2px solid var(--accent);
    background: #191c1d;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .16);
    scrollbar-width: thin;
    scrollbar-color: #545955 transparent;
    overscroll-behavior: contain;
}

.sidebar {
    left: var(--workspace-edge);
    width: var(--rail-left);
    padding: 20px 12px 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar .brand-wrap {
    flex: none;
    margin: 0 8px 16px;
    padding: 0 0 20px;
    gap: 12px;
}

.brand-wrap h1 {
    font-size: 1.3rem;
    letter-spacing: -.03em;
}

.brand-mark {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.sidebar>nav {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.nav-header {
    flex: none;
    margin: 0 8px 16px;
    font-size: .72rem;
}

.note-list {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding: 0 6px 8px;
    gap: 10px;
}

.note-item,
.note-item:hover,
.note-item.active,
.note-item.active:hover {
    flex-shrink: 0;
    width: 100%;
    transform: none;
    padding: 16px;
    border-radius: 0;
}

.note-item {
    border: 1px solid rgba(255, 255, 255, .06);
    background: rgba(255, 255, 255, .018);
    transition: border-color .18s, background .18s;
}

.note-item:hover {
    background: #252a2b;
    border-color: #626764;
    filter: none;
}

.note-item.active,
.note-item.active:hover {
    background: rgba(24, 209, 255, .075);
    border-color: rgba(24, 209, 255, .42);
}

.note-item h4 {
    font-size: .97rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.note-preview,
.note-item:hover .note-preview {
    height: 104px;
    max-height: 104px;
    overflow: auto;
    font-size: .8rem;
    line-height: 1.65;
    color: #abb2ae;
    scrollbar-width: thin;
}

.note-item-meta {
    border-top: 1px solid var(--line);
    padding-top: 10px;
    margin-top: 12px;
    font-size: .64rem;
}

.content {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    gap: 16px;
}

.topbar {
    min-height: 48px;
    padding: 0 2px 12px;
}

.topbar h2 {
    font-size: .94rem;
    font-weight: 500;
    color: #c2c8c4;
    overflow-wrap: anywhere;
}

.eyebrow {
    font-size: .58rem;
}

.article {
    padding: clamp(26px, 3vw, 56px);
    min-height: calc(100vh - 180px);
    background: #121313;
}

.article-header {
    gap: 12px;
    padding-bottom: 26px;
}

.article-header>div {
    min-width: 0;
}

.article-title {
    max-width: none;
    font-size: clamp(1.7rem, 2.5vw, 3rem);
    line-height: 1.25;
    letter-spacing: -.025em;
    overflow-wrap: anywhere;
}

.article-kicker {
    font-size: .62rem;
    margin-bottom: 14px;
}

.markdown-body {
    font-size: 1rem;
    line-height: 1.95;
    overflow-wrap: anywhere;
    margin-top: 40px;
}

.markdown-body :is(h1, h2, h3, h4, h5, h6) {
    scroll-margin-top: 100px;
}

.markdown-body table {
    display: block;
    overflow-x: auto;
}

.delete-btn {
    flex-shrink: 0;
}

.article-toc-panel {
    right: var(--workspace-edge);
    width: var(--rail-right);
    padding: 0;
    overflow: auto;
}

.markdown-toc {
    padding: 22px 20px;
    min-height: 100%;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.markdown-toc-title {
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 1rem;
    padding-bottom: 18px;
    margin-bottom: 18px;
}

.markdown-toc-title::before {
    margin-bottom: 12px;
}

.markdown-toc ul {
    padding-left: 12px;
}

.markdown-toc>ul {
    padding-left: 0;
}

.markdown-toc li::before {
    display: none;
}

.markdown-toc a,
.markdown-toc a.active {
    border-left: 2px solid transparent;
    padding: 8px 10px;
    font-size: .83rem;
    transition: color .16s, background .16s;
    border-radius: 0;
}

.markdown-toc a::before {
    display: none;
}

.markdown-toc a:hover,
.markdown-toc a:focus-visible {
    background: #303536;
    color: #fff;
    transform: none;
}

.markdown-toc a.active,
.markdown-toc a.active:hover,
.markdown-toc a.active:focus-visible {
    border-left-color: var(--accent);
    color: #9aeaff;
    background: rgba(24, 209, 255, .12);
}

.back-to-top {
    right: calc(var(--workspace-edge) + var(--rail-right) + var(--workspace-gap) + 12px);
    bottom: 32px;
    width: 40px;
    height: 48px;
    visibility: hidden;
}

.back-to-top.visible {
    visibility: visible;
}

.auth-screen {
    padding-top: 100px;
}

.auth-screen::before {
    display: none;
}

.auth-card,
.publish-card {
    padding: 32px;
}

@media (max-width: 1200px) {
    :root {
        --workspace-gap: 14px;
        --rail-left: 250px;
        --rail-right: 220px;
    }

    .top-nav-status,
    .top-nav-date {
        display: none;
    }

    .top-nav-user-actions {
        margin-left: auto;
    }

    .article {
        padding: 28px 24px;
    }
}

@media (max-width: 960px) {
    .page-shell {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .sidebar,
    .article-toc-panel {
        position: static;
        width: auto;
        height: auto;
        max-height: none;
    }

    .sidebar {
        grid-row: 1;
        padding: 16px;
    }

    .sidebar .brand-wrap {
        padding-bottom: 12px;
        margin-bottom: 12px;
    }

    .note-list {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 12px;
    }

    .note-item,
    .note-item:hover,
    .note-item.active {
        width: 250px;
    }

    .content {
        grid-row: 2;
        grid-column: 1;
    }

    .article-toc-panel {
        grid-row: 3;
        max-height: 420px;
    }

    .markdown-toc {
        min-height: 0;
    }

    .back-to-top {
        right: 24px;
        bottom: 24px;
    }
}

@media (max-width: 560px) {
    .top-navigation {
        gap: 8px;
        padding-inline: 12px;
    }

    .top-nav-brand {
        font-size: .83rem;
        gap: 6px;
    }

    .top-nav-mark {
        width: 26px;
        height: 26px;
    }

    .top-nav-user-actions {
        gap: 4px;
        padding-left: 6px;
    }

    .top-nav-user-actions button {
        padding: 7px;
        font-size: .65rem;
    }

    .top-nav-user-actions .profile-btn {
        max-width: 94px;
    }

    .article {
        padding: 26px 20px;
    }

    .article-title {
        font-size: 1.7rem;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

/* Edge-attached navigation: a continuous surface with quiet row selection. */
.sidebar {
    --sidebar-content-inset: 32px;
    padding: 22px 0 14px;
    border: 0;
    border-right: 1px solid #2a373e;
    border-radius: 0;
    background: #121313;
    box-shadow: none;
}

.sidebar::before,
.sidebar::after,
.sidebar .brand-wrap::after,
.sidebar .note-list::before {
    content: none;
}

.sidebar .brand-wrap {
    margin: 0 32px 20px var(--sidebar-content-inset);
    padding: 0 0 20px;
    gap: 12px;
    border-bottom: 1px solid #2a373e;
}

.sidebar .brand-kicker {
    color: #8ba2ac;
    font-size: .65rem;
    letter-spacing: .18em;
}

.sidebar .brand-wrap h1 {
    margin-top: 5px;
    font-size: 1.28rem;
    font-weight: 600;
    letter-spacing: -.035em;
}

.sidebar>nav {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.sidebar .nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 32px 8px var(--sidebar-content-inset);
    padding: 0 0 12px;
    border-bottom: 1px solid #2a373e;
    color: #9caeb7;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .08em;
}

.sidebar .nav-header::before,
.sidebar .nav-header::after {
    content: none;
}

.nav-header-caption {
    color: #8ba2ac;
    font: 500 .58rem/1 "Cascadia Code", monospace;
    letter-spacing: .16em;
}

.sidebar .note-list {
    position: relative;
    min-height: 0;
    gap: 0;
    padding: 4px 0 12px;
    scrollbar-width: thin;
    scrollbar-color: #40525c transparent;
    overflow-anchor: none;
}

.sidebar .note-item,
.sidebar .note-item:hover,
.sidebar .note-item.active,
.sidebar .note-item.active:hover {
    padding: 16px 32px 16px var(--sidebar-content-inset);
    border: 1px solid transparent;
    border-bottom-color: #26333a;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transform: none;
    filter: none;
    text-align: left;
    font-weight: 400;
    letter-spacing: 0;
    transition: background-color 180ms ease, border-color 180ms ease;
}

.sidebar .note-item:hover {
    border-bottom-color: #35464f;
    background: #1c2930;
}

.sidebar .note-item.active,
.sidebar .note-item.active:hover {
    border-color: transparent;
    border-bottom-color: #304650;
    background: #20343e;
    color: #b6cbd5;
}

/* Inset rules and short corner strokes frame content without covering it. */
.sidebar .note-list .note-item {
    background-image: linear-gradient(rgba(137, 199, 218, .3), rgba(137, 199, 218, .3));
    background-size: 16px 1px;
    background-position: right 14px top 16px;
    background-repeat: no-repeat;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .sidebar .note-list:not(.is-dragging):not(.is-sorting) .note-item {
        transition: background-color 180ms ease, border-color 180ms ease,
            background-size 260ms ease;
    }

    .sidebar .note-list:not(.is-dragging):not(.is-sorting) .note-item:is(:hover, :focus-visible) {
        background-size: 24px 1px;
    }
}

.sidebar .note-item::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    background: transparent;
    transition: width 180ms ease, background-color 180ms ease;
}

.sidebar .note-item.active::before {
    width: 5px;
    background: var(--accent);
}

.sidebar .note-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.sidebar .note-item h4 {
    margin: 0 0 10px;
    color: #e4edf0;
    font-size: .94rem;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.sidebar .note-item.active:focus-visible {
    outline-color: var(--accent);
}

.sidebar .note-item.active h4 {
    color: #9ee9fc;
}

.sidebar .note-preview,
.sidebar .note-item:hover .note-preview {
    height: 76px;
    max-height: 76px;
    overflow: hidden;
    /* Reserve scrollbar space even while collapsed to prevent text reflow. */
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    color: #9bafb7;
    font-size: .76rem;
    line-height: 1.65;
    mask-image: linear-gradient(#000 70%, transparent);
}

.sidebar .note-preview :is(p, h1, h2, h3, h4, h5, h6) {
    color: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* Center preview equations, including inline-delimited formulas, and allow
   wide equations to scroll without widening the navigation. */
.note-preview .math-block {
    max-height: none;
    text-align: center;
}

.note-preview mjx-container,
.note-preview mjx-container[display="true"] {
    display: block;
    max-width: 100%;
    margin: .5em 0;
    padding-block: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    text-align: center;
    scrollbar-width: thin;
}

.sidebar .note-item-meta {
    align-items: center;
    margin-top: 12px;
    padding-top: 0;
    border-top: 0;
    color: #91a6af;
    font: 400 .64rem/1.5 "Source Han Sans SC", "Source Han Sans CN", "Source Han Sans", "Segoe UI", "Microsoft YaHei", sans-serif;
    font-variant-numeric: tabular-nums;
}

.sidebar .note-item-meta>span:last-child {
    padding: 0 0 0 8px;
    border: 0;
    border-left: 1px solid #40525c;
    border-radius: 0;
    font-size: .6rem;
}

.sidebar .sort-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin: 0 0 10px;
    padding: 1px;
    border: 0;
    border-radius: 0;
    color: #9bafb7;
}

.sidebar .sort-handle:hover {
    color: var(--accent);
}

/* Selection keeps the same text hierarchy as the rest of the navigation. */
.sidebar .note-item.active :is(.note-preview, .note-preview *, .note-item-meta, .sort-handle) {
    color: #b6cbd5;
}

.sidebar .note-item.active :is(.note-item-meta, .note-item-meta>span:last-child, .sort-handle) {
    border-color: #4b6572;
}

.sidebar .note-list .note-item.active .note-preview {
    scrollbar-color: #6e99ad transparent;
}

@media (min-width: 961px) {
    .sidebar {
        --sidebar-content-inset: 44px;
        top: 72px;
        bottom: 0;
        left: 0;
        width: calc(var(--workspace-edge) + var(--rail-left));
        height: calc(100vh - 72px);
        height: calc(100dvh - 72px);
    }

    .sidebar .note-list {
        flex: 1 1 0;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: none;
        cursor: grab;
        user-select: none;
        touch-action: pan-y;
        scroll-snap-type: none;
    }

    .sidebar .note-list::-webkit-scrollbar {
        display: none;
    }

    .sidebar .note-preview {
        pointer-events: none;
    }

    .sidebar .note-list.is-dragging,
    .sidebar .note-list.is-dragging .note-item {
        cursor: grabbing;
    }
}

/* Keep expanded, independently scrollable previews for pointer and keyboard use. */
@media (min-width: 961px) and (hover: hover) {
    .sidebar .note-preview {
        transition: height 220ms ease, max-height 220ms ease;
    }

    .sidebar .note-list:not(.is-dragging):not(.is-sorting) .note-item:is(:hover, :focus-visible) .note-preview {
        height: 190px;
        max-height: 190px;
        mask-image: none;
    }

    .sidebar .note-list:not(.is-dragging):not(.is-sorting) :is(.preview-ready, :focus-visible) .note-preview {
        pointer-events: auto;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-color: #58717d transparent;
        cursor: auto;
    }
}

@media (max-width: 960px) {
    .sidebar {
        padding: 16px 0 10px;
        border: 1px solid #2a373e;
    }

    .sidebar .brand-wrap {
        margin-bottom: 16px;
        padding-bottom: 14px;
    }

    .sidebar .note-list {
        scroll-snap-type: x proximity;
        gap: 10px;
    }

    .sidebar .note-item,
    .sidebar .note-item:hover,
    .sidebar .note-item.active,
    .sidebar .note-item.active:hover {
        width: min(270px, 76vw);
        scroll-snap-align: start;
        border-color: #2a373e;
        background: transparent;
    }

    .sidebar .note-item.active,
    .sidebar .note-item.active:hover {
        border-color: #304650;
        background: #20343e;
    }

    .sidebar .note-preview,
    .sidebar .note-item:hover .note-preview {
        overflow: auto;
        mask-image: none;
    }
}

.article-stage {
    position: fixed !important;
    top: 0;
    left: -20000px;
    visibility: hidden;
    pointer-events: none;
}

.article[aria-busy="true"] {
    cursor: progress;
}

.article-toc-panel {
    border: 1px solid rgba(240, 240, 234, .12);
    border-left: 2px solid #18d1ff;
    background: #121313;
    box-shadow: none;
    overflow-x: hidden;
    scrollbar-color: #40525c transparent;
}

.markdown-toc {
    background: transparent;
    box-shadow: none;
}

.markdown-toc-title {
    border-bottom-color: rgba(240, 240, 234, .13);
}

.markdown-toc-title::before {
    color: #18d1ff;
}

/* Keep every highlight full-width; express hierarchy through text indentation. */
.markdown-toc ul {
    padding-left: 0;
}

.markdown-toc li[class] {
    margin-left: 0;
}

.markdown-toc a {
    border-radius: 0;
}

.markdown-toc a.toc-link-level-2 {
    padding-left: 20px;
}

.markdown-toc a.toc-link-level-3 {
    padding-left: 30px;
}

.markdown-toc a.toc-link-level-4 {
    padding-left: 40px;
}

.markdown-toc a.toc-link-level-5 {
    padding-left: 50px;
}

.markdown-toc a.toc-link-level-6 {
    padding-left: 60px;
}

.markdown-toc a.active,
.markdown-toc a.active:hover,
.markdown-toc a.active:focus-visible {
    position: relative;
    border-left: 2px solid transparent;
    border-radius: 0;
    background: #18d1ff;
    color: #08252d;
    font-weight: 700;
    box-shadow: none;
    padding-top: 11px;
    padding-bottom: 11px;
    padding-right: 12px;
    margin-left: -20px;
    margin-right: -20px;
    width: calc(100% + 40px);
    padding-left: 30px;
}

.markdown-toc a.toc-link-level-2.active {
    padding-left: 40px;
}

.markdown-toc a.toc-link-level-3.active {
    padding-left: 50px;
}

.markdown-toc a.toc-link-level-4.active {
    padding-left: 60px;
}

.markdown-toc a.toc-link-level-5.active {
    padding-left: 70px;
}

.markdown-toc a.toc-link-level-6.active {
    padding-left: 80px;
}

/* Background surfaces continue the cyan geometry without reducing text contrast. */
.reading-footer {
    padding: 34px 24px 28px;
    color: #91a9af;
    border-bottom: 1px solid rgba(24, 209, 255, .24);
}

.footer-rule {
    display: block;
    width: 56px;
    height: 3px;
    margin-bottom: 16px;
    background: #18d1ff;
}

.reading-footer p {
    font: 600 .65rem/1.7 "Cascadia Code", monospace;
    letter-spacing: .12em;
}

.reading-footer p span {
    color: #18d1ff;
    margin-inline: 8px;
}

.reading-footer>div {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    margin-top: 24px;
    font-size: .74rem;
}

.reading-footer strong {
    color: #d9e5e8;
}

.content {
    padding-bottom: 24px;
}

.sort-handle {
    display: inline-block;
    padding: 5px 8px;
    margin: 0 0 10px;
    color: #18d1ff;
    border: 1px solid rgba(24, 209, 255, .3);
    font: 600 .65rem/1.4 "Source Han Sans SC", "Source Han Sans CN", "Source Han Sans", sans-serif;
    cursor: grab;
}

.sidebar .note-list.is-sorting .note-item {
    transform: none;
    transition: none;
}

.sidebar .note-list.is-sorting .note-preview {
    height: 100px !important;
    max-height: 100px !important;
    transition: none;
}

.sidebar .note-item.is-sorting {
    opacity: .45;
    border-style: dashed;
}

.article-toc-panel {
    background: #121313;
}

.article {
    background: #121313;
}

@media (max-width: 960px) {
    .ambient-grid::after {
        display: none;
    }

    .ambient-grid::before {
        width: 42vw;
        opacity: .55;
    }
}

/* Live local clock and coordinated, non-layout-shifting motion. */
.top-navigation .top-nav-date {
    display: grid;
    gap: 5px;
    flex: 0 0 auto;
    padding-left: 18px;
    font-variant-numeric: tabular-nums;
    letter-spacing: .08em;
}

.nav-calendar {
    font-size: .57rem;
    color: #8fa7ac;
}

.nav-clock {
    font-size: .91rem;
    color: #c2f4ff;
    font-weight: 700;
}

.top-nav-brand,
.sort-handle {
    transition: color 180ms ease, border-color 180ms ease;
}

.top-nav-brand:hover {
    color: #18d1ff;
}

.top-nav-user-actions button {
    transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.top-nav-user-actions .profile-btn:hover,
.top-nav-user-actions .secondary-btn:hover {
    border-color: #18d1ff;
    background: rgba(24, 209, 255, .1);
    color: #c2f4ff;
}

.top-nav-user-actions #bgmToggleBtn[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.stack-form input,
.stack-form textarea {
    transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.reading-footer .footer-rule {
    transform-origin: left;
    transition: transform 400ms cubic-bezier(.2, .7, .3, 1);
}

.reading-footer:hover .footer-rule {
    transform: scaleX(1.8);
}

@keyframes workspace-reveal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes panel-reveal {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes frame-reveal {
    from {
        opacity: .3;
    }

    to {
        opacity: 1;
    }
}

@keyframes cyan-breathe {

    0%,
    100% {
        opacity: .5;
    }

    50% {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .page-shell {
        animation: workspace-reveal 420ms ease-out;
    }

    .sidebar {
        animation: workspace-reveal 500ms ease-out;
    }

    .markdown-toc {
        animation: panel-reveal 320ms cubic-bezier(.2, .7, .3, 1);
    }

    .auth-card,
    .publish-card {
        animation: panel-reveal 360ms cubic-bezier(.2, .7, .3, 1);
    }

    .top-navigation::before {
        animation: cyan-breathe 5s ease-in-out infinite;
    }

    .note-list.is-sorting .note-item {
        animation: none;
    }
}

@media (max-width: 1200px) {
    .top-nav-metrics {
        display: none;
    }

    .top-navigation .top-nav-date {
        margin-left: auto;
    }

    .top-nav-user-actions {
        margin-left: 0;
    }
}

@media (max-width: 560px) {
    .top-navigation {
        height: 96px;
        flex-wrap: wrap;
        align-content: center;
        gap: 8px 12px;
    }

    .top-navigation .top-nav-date {
        border: 0;
        padding-left: 0;
    }

    .nav-calendar {
        display: none;
    }

    .nav-clock {
        font-size: .8rem;
    }

    .top-nav-user-actions {
        width: 100%;
        justify-content: flex-end;
        border: 0;
        padding: 0;
    }

    .page-shell {
        padding-top: 112px;
    }

    .auth-screen {
        padding-top: 120px;
    }
}

/* Keep the return control directly below the independently scrolling contents. */
.reading-tools {
    position: fixed;
    top: 88px;
    right: var(--workspace-edge);
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: var(--rail-right);
    max-height: calc(100vh - 108px);
    max-height: calc(100dvh - 108px);
}

.reading-tools .article-toc-panel {
    position: static;
    display: flex;
    flex-direction: column;
    align-self: stretch;
    width: 100%;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    scrollbar-width: none;
}

.reading-tools .article-toc-panel::-webkit-scrollbar,
.reading-tools .markdown-toc>ul::-webkit-scrollbar {
    display: none;
}

.reading-tools .markdown-toc {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.reading-tools .markdown-toc-title {
    flex-shrink: 0;
    width: 100%;
    background: transparent;
    text-align: left;
    transform: none;
}

.reading-tools .markdown-toc-title:hover {
    color: #18d1ff;
}

.reading-tools .markdown-toc-title:focus-visible {
    outline-offset: -2px;
}

.reading-tools .markdown-toc>ul {
    min-width: 0;
    min-height: 0;
    margin-inline: -20px;
    padding-inline: 20px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    scrollbar-color: transparent transparent;
}

.reading-tools .toc-link {
    white-space: normal;
    overflow-wrap: anywhere;
}

.reading-tools .back-to-top {
    position: static;
    align-self: flex-start;
    flex-shrink: 0;
    margin: 0;
    transform: none;
}

/* Keep the theme block anchored beside the article on narrow layouts too. */
@media (max-width: 960px) {
    .ambient-grid::before {
        left: auto;
        right: 0;
        width: 42vw;
    }
}

@media (max-width: 960px) {
    .reading-tools {
        position: static;
        grid-column: 1;
        grid-row: 3;
        width: 100%;
        max-height: none;
    }

    .reading-tools .article-toc-panel {
        max-height: 420px;
    }
}

/* On small screens the contents slide out beneath the navigation. */
.toc-toggle,
.toc-backdrop {
    display: none;
}

@media (max-width: 960px) {
    .top-nav-user-actions .toc-toggle {
        display: inline-block;
        white-space: nowrap;
        padding-inline: 10px;
    }

    .toc-toggle[aria-expanded="true"] {
        border-color: #18d1ff;
        color: #18d1ff;
    }

    .reading-tools {
        display: contents;
    }

    .reading-tools .article-toc-panel {
        position: fixed;
        z-index: 25;
        top: var(--mobile-nav-bottom, 96px);
        right: 0;
        bottom: 0;
        width: min(86vw, 360px);
        max-height: none;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        visibility: hidden;
        transform: translateX(100%);
        transition: transform 220ms ease, visibility 220ms;
        box-shadow: -12px 0 32px rgba(0, 0, 0, .3);
    }

    .toc-open .article-toc-panel {
        visibility: visible;
        transform: translateX(0);
    }

    .toc-backdrop:not([hidden]) {
        display: block;
        position: fixed;
        z-index: 24;
        inset: var(--mobile-nav-bottom, 96px) 0 0;
        background: rgba(0, 0, 0, .42);
        touch-action: none;
    }

    .reading-tools .back-to-top {
        position: fixed;
        z-index: 12;
        right: calc(16px + env(safe-area-inset-right, 0px));
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        width: 44px;
        height: 48px;
    }

    .top-nav-user-actions {
        gap: 6px;
    }
}

@media (max-width: 560px) {
    .top-nav-user-actions button {
        padding-inline: 8px;
        font-size: .75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .reading-tools .article-toc-panel {
        transition: none;
    }
}

/* Lucide controls share a clear touch target and inherit the theme color. */
.ui-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    vertical-align: middle;
    pointer-events: none;
}

.top-nav-user-actions .icon-button,
.reading-tools .back-to-top,
.article-header .delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    flex-shrink: 0;
}

.top-nav-user-actions .toc-toggle {
    display: none;
}

/* Keep the return control larger than the shared icon-button baseline. */
.reading-tools .back-to-top {
    width: 56px;
    height: 56px;
    min-width: 56px;
}

.reading-tools .back-to-top .ui-icon {
    width: 24px;
    height: 24px;
}

.reading-tools .back-to-top[data-placement="above"] {
    border-left: 1px solid rgba(240, 240, 234, .2);
    border-right: 3px solid var(--accent);
}

/* In portrait mode, keep the accent strip on the button's outer right side. */
@media (orientation: portrait) {
    .reading-tools .back-to-top {
        border-left: 1px solid rgba(240, 240, 234, .2);
        border-right: 3px solid var(--accent);
    }
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sort-handle .ui-icon {
    width: 14px;
    height: 14px;
}

.external-arrow-icon {
    width: 18px;
    height: 18px;
    background: currentColor;
    -webkit-mask: url('/icons/arrow-left.svg') center / contain no-repeat;
    mask: url('/icons/arrow-left.svg') center / contain no-repeat;
}

/* Spacious single-column account form. */
#authScreen {
    min-height: 100dvh;
    padding: 84px 20px 24px;
    align-items: safe center;
}

#authScreen .auth-card {
    width: min(100%, 440px);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
    padding: 20px 28px 26px;
    border: 1px solid rgba(240, 240, 234, .13);
    border-top: 2px solid var(--accent);
    border-radius: 0;
    background: linear-gradient(180deg, rgba(25, 29, 30, .98), rgba(17, 19, 20, .98));
    box-shadow: 0 24px 64px rgba(0, 0, 0, .32);
}

.auth-toolbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.auth-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #b6cbd2;
    transform: none;
    transition: color 160ms ease, background-color 160ms ease;
}

.auth-back:hover {
    color: var(--accent);
    background: transparent;
}

.auth-back .ui-icon {
    width: 22px;
    height: 22px;
}

.publish-card .auth-back {
    margin-bottom: 18px;
}

.auth-wordmark {
    font: 600 .65rem/1.5 "Cascadia Code", monospace;
    letter-spacing: .1em;
    color: #c2c8c4;
}

.auth-wordmark span {
    color: #809fa8;
}

.auth-heading {
    margin: 0;
    padding: 0;
}

.auth-title-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.auth-form-panel {
    min-width: 0;
}

#authScreen .eyebrow {
    color: var(--accent);
    font-size: .65rem;
    letter-spacing: .16em;
}

#authScreen h1 {
    margin: 0;
    font-size: clamp(1.6rem, 4vw, 2rem);
    line-height: 1.25;
    letter-spacing: -.025em;
    color: #e4edf0;
}

#authScreen .auth-hint {
    margin: 0;
    font-size: .85rem;
    line-height: 1.7;
    color: #9db4bc;
}

#authScreen .auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin: 0 0 18px;
    border-bottom: 1px solid rgba(240, 240, 234, .13);
}

#authScreen .auth-tab {
    min-height: 44px;
    padding: 10px;
    font-size: .87rem;
    border: 0;
    border-bottom: 2px solid transparent;
    transition: color 160ms ease, border-color 160ms ease;
}

#authScreen .auth-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

#authScreen .stack-form {
    gap: 22px;
}

#authScreen .stack-form label {
    gap: 7px;
    min-width: 0;
    color: #abb2ae;
    font-size: .82rem;
}

#authScreen .stack-form input {
    min-width: 0;
    min-height: 42px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, .16);
    border: 1px solid rgba(240, 240, 234, .1);
    border-bottom: 1px solid rgba(240, 240, 234, .18);
    border-radius: 0;
    color: #e4edf0;
    font-size: 16px;
    caret-color: var(--accent);
}

#authScreen .stack-form input::placeholder {
    color: #7c959f;
    opacity: 1;
}

#authScreen .stack-form input:focus {
    border-color: var(--accent);
    background: rgba(24, 209, 255, .035);
    outline: none;
    box-shadow: none;
}

#authScreen .field-hint {
    color: #8fa7ac;
    font-size: .73rem;
    line-height: 1.5;
}

#authScreen .auth-submit {
    width: 100%;
    min-height: 46px;
    margin-top: 16px;
    padding: 10px 14px;
    border: 0;
    border-radius: 0;
    background: var(--accent);
    color: #08252d;
    font-weight: 700;
    font-size: .9rem;
    letter-spacing: .04em;
    clip-path: none;
}

#authScreen button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

#authScreen .auth-submit {
    background: var(--accent);
    transition: transform 200ms ease, box-shadow 240ms ease, filter 240ms ease;
}

#authScreen .auth-submit::after {
    content: none;
}

#authScreen .auth-submit:is(:hover, :focus-visible):not(:disabled) {
    filter: brightness(1.06);
    box-shadow: 0 6px 22px rgba(24, 209, 255, .18);
}

#authScreen .auth-submit:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: none;
}

#authScreen .auth-tab {
    transform: none;
    transition: color 200ms ease, border-color 200ms ease, background-color 200ms ease;
}

#authScreen .auth-tab:is(:hover, :focus-visible) {
    background: rgba(24, 209, 255, .045);
}

@keyframes auth-gradient-flow {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

@media (prefers-reduced-motion: no-preference) {
    #authScreen .auth-card {
        animation: panel-reveal 480ms cubic-bezier(.22, 1, .36, 1);
    }

}

@media (hover: hover) {
    #authScreen .auth-submit:hover:not(:disabled) {
        background: linear-gradient(110deg, #19d1ff, #66eedb, #75dfff, #19d1ff);
        background-size: 300% 100%;
        background-position: 0% 50%;
    }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    #authScreen .auth-submit:hover:not(:disabled) {
        animation: auth-gradient-flow 3s ease-in-out infinite;
        transform: translateY(-1px);
    }
}

@media (prefers-reduced-motion: reduce) {

    #authScreen *,
    #authScreen *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* All controls follow the square-edged page design. */
button,
input[type="button"],
input[type="submit"],
input[type="reset"],
input::file-selector-button {
    border-radius: 0 !important;
    clip-path: none !important;
}

@media (max-width: 700px) {
    #authScreen .auth-card {
        grid-template-columns: minmax(0, 1fr);
        width: min(100%, 440px);
        padding: 22px 24px 26px;
    }

    .auth-form-panel {
        padding: 0;
        border: 0;
    }

    .auth-heading {
        padding: 0;
    }
}

@media (max-width: 560px) {
    #authScreen {
        padding: 88px 16px 20px;
        align-items: start;
    }

    #authScreen .auth-card {
        padding: 20px 22px 28px;
    }

    .auth-toolbar {
        margin-bottom: 24px;
    }

    .auth-wordmark {
        font-size: .59rem;
    }
}

@media (max-width: 960px) {
    .top-nav-user-actions .toc-toggle {
        display: inline-flex;
    }
}

/* Theme-colored six-wing model; the wordmark remains the home link. */
.top-nav-brand .brand-home {
    color: inherit;
    text-decoration: none;
}

.top-navigation .top-nav-mark,
.sidebar .brand-mark.seraphim-mark {
    position: relative;
    display: grid;
    flex: 0 0 auto;
    width: 60px;
    height: 56px;
    min-height: 0;
    padding: 0;
    border: 0;
    clip-path: none;
    background: transparent;
    color: var(--accent);
    transform: none;
    filter: none;
    touch-action: pan-y;
}

.seraphim-mark canvas,
.seraphim-mark .seraphim-fallback {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.seraphim-mark .seraphim-fallback {
    padding: 5px;
    transition: opacity 160ms ease;
}

.seraphim-mark.seraphim-ready .seraphim-fallback {
    opacity: 0;
}

.seraphim-mark:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 0;
}

.sidebar .brand-mark.seraphim-mark {
    width: 76px;
    height: 76px;
    color: #72b8c8;
    cursor: grab;
    touch-action: none;
}

.seraphim-mark canvas {
    pointer-events: auto;
}

.seraphim-mark:active {
    cursor: grabbing;
}

@media (max-width: 560px) {
    .top-navigation .top-nav-mark {
        width: 44px;
        height: 40px;
    }
}

.top-navigation .flat-knight {
    width: 40px;
    height: 40px;
}

.flat-knight svg {
    display: block;
    width: 100%;
    height: 100%;
    padding: 4px;
    pointer-events: none;
}

/* Two small moving highlights share the static grid; no canvas or blur loop. */
.ambient-grid {
    overflow: hidden;
    contain: strict;
}

.ambient-beam {
    position: absolute;
    top: -160px;
    width: 1px;
    height: 160px;
    background: linear-gradient(transparent, rgba(24, 209, 255, .5), transparent);
    opacity: 0;
}

.ambient-beam-primary {
    right: 7%;
}

.ambient-beam-secondary {
    right: 19%;
    height: 100px;
}

@keyframes grid-signal {
    0% {
        transform: translateY(0);
        opacity: 0;
    }

    12%,
    65% {
        opacity: .7;
    }

    82%,
    100% {
        transform: translateY(calc(100vh + 180px));
        opacity: 0;
    }
}

/* Travel whole pattern periods so the loops join without a visible jump.
   Extra length stays clipped by the existing background containers. */
@keyframes ruler-flow {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-80px);
    }
}

@keyframes accent-breathe {

    0%,
    100% {
        opacity: .4;
    }

    50% {
        opacity: 1;
    }
}

/* Motion accents stay on decorative layers and never move the page layout. */
.ambient-glow {
    position: absolute;
    display: block;
    width: min(54vw, 720px);
    aspect-ratio: 1;
    border-radius: 0;
    pointer-events: none;
    contain: paint;
    background: radial-gradient(circle, rgba(24, 209, 255, .1), transparent 66%);
}

.ambient-glow-primary {
    top: -24%;
    left: 14%;
}

.ambient-glow-secondary {
    right: -24%;
    bottom: -28%;
    opacity: .65;
}

.top-navigation {
    transition: background-color 280ms ease, box-shadow 280ms ease, border-color 280ms ease;
}

.top-navigation.is-scrolled {
    background-color: rgba(16, 23, 26, .97);
    border-bottom-color: rgba(24, 209, 255, .22);
    box-shadow: 0 10px 32px rgba(0, 0, 0, .3);
}

.reading-progress-bar {
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    pointer-events: none;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(90deg, #087b98, var(--accent), #b8f4ff);
    box-shadow: 0 0 10px rgba(24, 209, 255, .4);
    transition: transform 160ms linear;
}

.auth-screen:not(.hidden)~.top-navigation .reading-progress-bar {
    visibility: hidden;
}

.top-nav-user-actions .icon-button,
.reading-tools .back-to-top,
.article-header .delete-btn {
    transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease,
        box-shadow 180ms ease, transform 180ms cubic-bezier(.22, 1, .36, 1), opacity 180ms ease;
}

.top-nav-user-actions .icon-button:focus-visible,
.reading-tools .back-to-top:focus-visible {
    box-shadow: 0 0 0 4px rgba(24, 209, 255, .12);
}

.top-nav-user-actions .icon-button:active:not(:disabled),
.reading-tools .back-to-top:active {
    transform: scale(.94);
}

.stack-form label {
    transition: color 180ms ease;
}

.stack-form label:focus-within {
    color: #9aeaff;
}

.stack-form :is(input, textarea):focus-visible {
    border-color: var(--accent);
    outline: none;
    box-shadow: none;
}

.article-toc-panel .toc-link {
    transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.markdown-body a {
    transition: color 180ms ease, text-decoration-color 180ms ease;
    text-underline-offset: .2em;
}

.markdown-body img {
    transition: border-color 260ms ease, box-shadow 260ms ease;
}

@keyframes ambient-drift {

    0%,
    100% {
        transform: translate3d(-2%, -1.5%, 0) scale(.98);
    }

    50% {
        transform: translate3d(3%, 2.5%, 0) scale(1.03);
    }
}

@keyframes article-loading {

    0%,
    100% {
        opacity: .45;
    }

    50% {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .ambient-grid::after {
        bottom: -80px;
        animation: ruler-flow 12s linear infinite;
    }

    .nav-header::before {
        animation: accent-breathe 5s ease-in-out infinite;
    }

    .article::before {
        animation: accent-breathe 7s ease-in-out -2s infinite;
    }

    .ambient-beam-primary {
        animation: grid-signal 16s linear infinite;
    }

    .ambient-beam-secondary {
        animation: grid-signal 22s linear -9s infinite;
    }

    .note-item::before {
        background: var(--accent);
        transform: scaleY(.15);
        transform-origin: center;
        opacity: 0;
        transition: transform 240ms cubic-bezier(.22, 1, .36, 1), opacity 180ms ease;
    }

    .note-item:is(:hover, :focus-visible, .active)::before {
        transform: scaleY(1);
        opacity: 1;
    }

    .auth-submit {
        position: relative;
        overflow: hidden;
    }

    .auth-submit::after {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(105deg, transparent 25%, rgba(215, 248, 255, .2), transparent 75%);
        transform: translateX(-120%);
        pointer-events: none;
    }

    .auth-submit:is(:hover, :focus-visible)::after {
        transform: translateX(120%);
        transition: transform 600ms ease;
    }

    .toc-backdrop:not([hidden]) {
        animation: workspace-reveal 200ms ease-out;
    }

    .ambient-glow-primary {
        animation: ambient-drift 34s ease-in-out infinite;
    }

    .ambient-glow-secondary {
        animation: ambient-drift 42s ease-in-out -14s infinite;
    }

    .article[aria-busy="true"] .article-kicker {
        animation: article-loading 1.4s ease-in-out infinite;
    }

    .topbar {
        animation: panel-reveal 480ms cubic-bezier(.22, 1, .36, 1);
    }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
    :is(.auth-card, .publish-card):hover {
        background-image: radial-gradient(260px circle at 20% 0%,
                rgba(24, 209, 255, .095), transparent 72%);
    }

    .top-nav-user-actions .icon-button:hover:not(:disabled),
    .reading-tools .back-to-top:hover {
        transform: translateY(-2px);
        box-shadow: 0 5px 16px rgba(24, 209, 255, .13);
    }

    .markdown-body img:hover {
        border-color: rgba(24, 209, 255, .45);
        box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
    }
}

.motion-paused *,
.motion-paused *::before,
.motion-paused *::after {
    animation-play-state: paused !important;
}

.motion-lite .ambient-glow,
.motion-lite .ambient-beam,
.motion-lite .top-navigation::before,
.motion-lite .article::before {
    animation: none;
}

/* Keep the two tiny signals alive in light mode; stop the larger accents. */
.motion-lite .ambient-grid::after {
    animation-duration: 24s;
}

.motion-lite .nav-header::before {
    animation-duration: 8s;
}

.motion-lite .ambient-beam {
    display: none;
}

/* Keep every native scrollbar square, including nested preview and TOC rails. */
* {
    scrollbar-width: thin;
    scrollbar-color: #40525c transparent;
}

*::-webkit-scrollbar,
*::-webkit-scrollbar-track,
*::-webkit-scrollbar-thumb {
    border-radius: 0 !important;
}

*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

*::-webkit-scrollbar-thumb {
    background: #40525c;
}

/* The article rail scrolls by wheel, touch, or drag without showing a bar. */
.sidebar .note-list {
    scrollbar-width: none;
}

.sidebar .note-list::-webkit-scrollbar {
    display: none;
}

/* Oswald gives the interface labels and controls the narrow editorial rhythm;
   long-form article copy keeps its existing reading font. */
.top-navigation,
.sidebar,
.article-toc-panel,
.topbar,
.reading-footer,
button,
input,
textarea,
select {
    font-family: "Oswald", "Source Han Sans SC", "Source Han Sans CN", "Source Han Sans",
        "Noto Sans SC", "Noto Sans CJK SC", "Arial Narrow", "Segoe UI", sans-serif;
}

.motion-lite .auth-submit::after {
    content: none;
}

@media (max-width: 960px) {
    .ambient-glow {
        animation: none;
        opacity: .4;
    }
}

@media (prefers-reduced-motion: reduce) {
    .reading-progress-bar {
        transition: none;
    }
}

/* Dragging a chapter gives the rail a clear insertion preview and lifts the
   active card above neighbouring cards while its order is being changed. */
.note-item[draggable="true"] {
    cursor: grab;
}

.note-item[draggable="true"]:active,
.note-list.is-sorting {
    cursor: grabbing;
}

.sidebar .note-list.is-sorting .note-item {
    opacity: .64;
    transform: scale(.985);
    transition: transform 180ms cubic-bezier(.2, .75, .25, 1), opacity 180ms ease,
        box-shadow 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.sidebar .note-list.is-sorting .note-item.is-sorting {
    position: relative;
    z-index: 20;
    opacity: .25;
    transform: scale(.96);
    border-color: var(--accent);
    border-style: dashed;
    background: #222627;
    box-shadow: none;
}

/* A body-level drag preview escapes both scrolling and clipped rail surfaces. */
.sort-floating-layer {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    pointer-events: none;
    will-change: transform;
}

.sort-floating-layer .sort-floating-card {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 17px 38px 15px 20px;
    overflow: hidden;
    border: 1px solid var(--accent);
    border-radius: 0;
    background: #12282e;
    color: var(--text);
    opacity: 1;
    transform: scale(1.06) rotate(2deg);
    box-shadow: none;
    animation: sort-card-lift 220ms cubic-bezier(.22, 1, .36, 1) both;
}

.sort-floating-card .note-preview {
    height: 100px;
    max-height: 100px;
    overflow: hidden;
}

.sort-floating-card h4 {
    overflow-wrap: anywhere;
}

@keyframes sort-card-lift {
    from {
        transform: scale(1) rotate(0);
        box-shadow: none;
    }

    to {
        transform: scale(1.06) rotate(2deg);
        box-shadow: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sort-floating-layer .sort-floating-card {
        animation: none;
        transform: none;
    }
}

.sidebar .note-list.is-sorting .note-item.drop-before {
    transform: translateY(8px) scale(.985);
}

.sidebar .note-list.is-sorting .note-item.drop-after {
    transform: translateY(-8px) scale(.985);
}

.sidebar .note-list.is-sorting .note-item.drop-before::after,
.sidebar .note-list.is-sorting .note-item.drop-after::after {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    height: 2px;
    background: var(--accent);
    box-shadow: 0 0 12px rgba(24, 209, 255, .7);
    pointer-events: none;
}

.sidebar .note-list.is-sorting .note-item.drop-before::after {
    top: -5px;
}

.sidebar .note-list.is-sorting .note-item.drop-after::after {
    bottom: -5px;
}

@media (prefers-reduced-motion: reduce) {
    .sidebar .note-list.is-sorting .note-item {
        transition: none;
    }
}

/* Shared industrial background for reading, account and publishing screens. */
body::before,
body::after {
    content: none;
}

.ambient-grid {
    --terrain-x: 0px;
    --terrain-y: 0px;
    --pointer-x: 50%;
    --pointer-y: 50%;
    --pointer-strength: 0;
    background:
        linear-gradient(90deg, rgba(145, 169, 176, .042) 1px, transparent 1px) 0 0 / 192px 192px,
        linear-gradient(rgba(145, 169, 176, .042) 1px, transparent 1px) 0 0 / 192px 192px,
        linear-gradient(90deg, rgba(145, 169, 176, .018) 1px, transparent 1px) 0 0 / 48px 48px,
        linear-gradient(rgba(145, 169, 176, .018) 1px, transparent 1px) 0 0 / 48px 48px,
        #090e10;
}

.ambient-grid::before {
    display: none;
}

.industrial-block,
.industrial-lines {
    display: none;
}

.ambient-grid::before {
    top: 0;
    bottom: 0;
    left: auto;
    right: 0;
    width: clamp(240px, 30vw, 620px);
    background:
        repeating-linear-gradient(135deg, transparent 0 23px, rgba(25, 209, 255, .036) 23px 24px),
        linear-gradient(160deg, #10272d, #0c1b20 72%);
    clip-path: polygon(44% 0, 100% 0, 100% 100%, 0 100%, 0 62%, 24% 48%, 24% 18%);
    opacity: .62;
}

/* Preserve the original scrolling ruler and its whole-period animation. */
.ambient-grid::after {
    z-index: 3;
    top: var(--mobile-nav-bottom, 72px);
    background:
        repeating-linear-gradient(to bottom, rgba(210, 239, 242, .64) 0 1px, transparent 1px 80px),
        repeating-linear-gradient(to bottom, rgba(154, 184, 190, .3) 0 1px, transparent 1px 16px);
    border-left: 1px solid rgba(210, 239, 242, .18);
}

.industrial-block,
.industrial-lines,
.terrain-light {
    position: absolute;
    pointer-events: none;
}

.industrial-block-secondary {
    left: 0;
    bottom: 0;
    width: clamp(180px, 36vw, 640px);
    height: 35%;
    background: linear-gradient(130deg, rgba(25, 209, 255, .055), rgba(25, 209, 255, .01));
    clip-path: polygon(0 0, 42% 0, 57% 24%, 100% 24%, 100% 100%, 0 100%);
}

.industrial-lines {
    inset: 0;
    opacity: .42;
    background:
        linear-gradient(90deg, var(--accent), transparent) left 35% top 22% / 140px 1px no-repeat,
        linear-gradient(var(--accent), transparent) right 7% top 15% / 1px 180px no-repeat,
        linear-gradient(90deg, transparent, #6f929c) right 4% bottom 17% / 220px 1px no-repeat,
        linear-gradient(#6f929c, transparent) left 9% bottom 9% / 1px 96px no-repeat;
}

.industrial-lines::before,
.industrial-lines::after {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    background:
        linear-gradient(#75a3b0, #75a3b0) center / 1px 100% no-repeat,
        linear-gradient(#75a3b0, #75a3b0) center / 100% 1px no-repeat;
}

.industrial-lines::before {
    right: calc(7% - 6px);
    top: 15%;
}

.industrial-lines::after {
    left: calc(9% - 6px);
    bottom: 9%;
}

.terrain-map {
    position: absolute;
    inset: -3%;
    width: 106%;
    height: 106%;
    overflow: hidden;
    transform: translate(var(--terrain-x), var(--terrain-y));
    pointer-events: none;
}

.terrain-field {
    transform-box: fill-box;
    transform-origin: center;
    stroke: #e7f0f1;
    stroke-width: .72;
    opacity: .3;
}

.terrain-field path {
    vector-effect: non-scaling-stroke;
}

.terrain-field .terrain-major {
    stroke: #ffffff;
    stroke-width: 1;
    opacity: .86;
}

.terrain-field-secondary {
    opacity: .2;
}

.terrain-light {
    inset: 0;
    opacity: var(--pointer-strength);
    background: radial-gradient(260px circle at var(--pointer-x) var(--pointer-y), rgba(255, 255, 255, .055), transparent 75%);
    transition: opacity 500ms ease;
}

/* A low horizontal measurement rail moves right-to-left across the lower field. */
.horizontal-ruler {
    position: absolute;
    z-index: 3;
    top: 78%;
    left: 0;
    right: 0;
    height: 7px;
    overflow: hidden;
    pointer-events: none;
    background:
        repeating-linear-gradient(to right, rgba(210, 239, 242, .64) 0 1px, transparent 1px 80px),
        repeating-linear-gradient(to right, rgba(154, 184, 190, .3) 0 1px, transparent 1px 16px);
    border-top: 1px solid rgba(210, 239, 242, .18);
}

@keyframes terrain-drift {
    from {
        transform: translate(-9px, 5px) rotate(-1deg);
    }

    to {
        transform: translate(9px, -5px) rotate(1deg);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .terrain-field {
        animation: terrain-drift 24s ease-in-out infinite alternate;
    }

    .terrain-field-secondary {
        animation: terrain-drift 32s ease-in-out -12s infinite alternate-reverse;
    }

    .horizontal-ruler {
        animation: horizontal-ruler-flow 9s linear infinite;
    }
}

@keyframes horizontal-ruler-flow {
    from {
        background-position: 0 0, 0 0;
    }

    to {
        background-position: -80px 0, -80px 0;
    }
}

.terrain-paused .terrain-field,
.motion-paused .terrain-field {
    animation-play-state: paused;
}

@media (max-width: 960px) {
    .ambient-grid::after {
        display: block;
        left: 5px;
        width: 4px;
    }

    .terrain-field {
        opacity: .18;
    }

    .terrain-field-secondary {
        display: none;
    }

    .industrial-lines {
        opacity: .4;
    }
}

.motion-lite .terrain-field {
    animation-duration: 48s;
}

.motion-lite .terrain-field-secondary {
    display: none;
}

@media (prefers-reduced-motion: reduce) {

    .terrain-field,
    .ambient-grid::after,
    .horizontal-ruler {
        animation: none;
    }

    .terrain-map {
        transform: none;
    }

    .terrain-light {
        display: none;
    }
}

/* Fluid workspace proportions: keep the reading column usable at every
   desktop viewport instead of switching abruptly to fixed rail widths. */
@media (min-width: 961px) {
    :root {
        --workspace-edge: clamp(14px, 2vw, 36px);
        --workspace-gap: clamp(12px, 1.4vw, 22px);
        --rail-left: clamp(220px, 21vw, 360px);
        --rail-right: clamp(200px, 18.5vw, 320px);
        --workspace-top: clamp(76px, 5.5vw, 88px);
    }

    .page-shell {
        grid-template-columns: var(--rail-left) minmax(0, 1fr) var(--rail-right);
        gap: var(--workspace-gap);
        padding: var(--workspace-top) var(--workspace-edge) 32px;
    }

    .top-navigation {
        gap: clamp(10px, 1.4vw, 20px);
    }

    .article {
        padding: clamp(24px, 3vw, 56px);
    }

    .sidebar {
        width: calc(var(--workspace-edge) + var(--rail-left));
    }

    .reading-tools {
        top: var(--workspace-top);
        right: var(--workspace-edge);
        width: var(--rail-right);
        max-height: calc(100dvh - var(--workspace-top) - 20px);
    }
}

/* Tablet layouts retain comfortable gutters before collapsing into one column. */
@media (max-width: 960px) {
    :root {
        --workspace-edge: clamp(12px, 3vw, 20px);
        --workspace-gap: clamp(12px, 2vw, 16px);
    }

    .page-shell {
        gap: var(--workspace-gap);
        padding-inline: var(--workspace-edge);
    }

    .sidebar,
    .content,
    .reading-tools {
        min-width: 0;
    }

    .article {
        padding: clamp(20px, 4vw, 30px) clamp(16px, 4.5vw, 32px);
    }
}

@media (max-width: 560px) {
    .page-shell {
        padding-inline: 12px;
    }

    .article {
        padding-inline: 16px;
    }
}

/* Give portrait navigation controls a real bottom safe area instead of
   letting the final button row sit against the fixed bar edge. */
@media (orientation: portrait) and (max-width: 960px) {
    .top-navigation {
        height: 92px;
        min-height: 92px;
        padding-block: 14px;
    }

    .page-shell {
        padding-top: 108px;
    }
}

@media (orientation: portrait) and (max-width: 560px) {
    .top-navigation {
        height: 116px;
        min-height: 116px;
        padding-block: 12px;
        align-content: flex-start;
        row-gap: 8px;
    }

    .page-shell {
        padding-top: 132px;
    }

    .auth-screen {
        padding-top: 140px;
    }
}

/* The account action opens as a small bubble below the profile control. */
.profile-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

.profile-btn[aria-expanded="true"] {
    border-color: #18d1ff;
    background: rgba(24, 209, 255, .1);
    color: #c2f4ff;
}

.profile-popover {
    position: absolute;
    z-index: 40;
    top: calc(100% + 12px);
    right: 0;
    display: flex;
    padding: 7px;
    border: 1px solid rgba(240, 240, 234, .16);
    border-top: 2px solid var(--accent);
    background: #121313;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .34);
}

.profile-popover::before {
    content: "";
    position: absolute;
    top: -6px;
    right: 16px;
    width: 9px;
    height: 9px;
    border-top: 1px solid var(--accent);
    border-left: 1px solid var(--accent);
    background: #121313;
    transform: rotate(45deg);
}

.profile-popover .icon-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
}

@media (prefers-reduced-motion: no-preference) {
    .profile-popover:not(.hidden) {
        animation: profile-popover-in 160ms ease-out;
    }
}

@keyframes profile-popover-in {
    from {
        opacity: 0;
        transform: translateY(-5px) scale(.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.background-particles {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: .62;
}

/* Desktop rail controls: either side can fold into the screen edge while the
   reading column takes back the released width. */
@media (min-width: 961px) {
    .page-shell {
        transition: grid-template-columns 360ms cubic-bezier(.22, 1, .36, 1);
    }

    .page-shell.left-rail-collapsed {
        grid-template-columns: var(--rail-left) minmax(0, 1fr) var(--rail-right);
    }

    .page-shell.right-rail-collapsed {
        grid-template-columns: var(--rail-left) minmax(0, 1fr) var(--rail-right);
    }

    .page-shell.left-rail-collapsed.right-rail-collapsed {
        grid-template-columns: var(--rail-left) minmax(0, 1fr) var(--rail-right);
    }

    .sidebar,
    .reading-tools {
        transition: transform 360ms cubic-bezier(.22, 1, .36, 1), opacity 220ms ease;
    }

    .page-shell.left-rail-collapsed .sidebar {
        transform: translateX(-100%);
        opacity: 0;
        pointer-events: none;
    }

    .page-shell.right-rail-collapsed .reading-tools {
        transform: translateX(100%);
        opacity: 0;
        pointer-events: none;
    }

    .rail-toggle {
        position: fixed;
        z-index: 30;
        top: calc(var(--workspace-top) + 8px);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 34px;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: #121313;
        color: #91a6af;
        box-shadow: none;
        transform: none;
        transition: left 360ms cubic-bezier(.22, 1, .36, 1),
            right 360ms cubic-bezier(.22, 1, .36, 1),
            color 180ms ease, background-color 180ms ease, border-color 180ms ease;
    }

    .rail-toggle:hover,
    .rail-toggle:focus-visible {
        background: #1c2930;
        color: #c2f4ff;
    }

    .rail-toggle:active:not(:disabled) {
        transform: none;
    }

    /* Leave a control row above the directory title so the handle cannot
       cover long titles or links. The archive already has an inset header. */
    .reading-tools .article-toc-panel {
        padding-top: 44px;
    }

    .rail-toggle .ui-icon {
        width: 18px;
        height: 18px;
    }

    .rail-toggle-left {
        left: calc(var(--workspace-edge) + var(--rail-left) - 42px);
    }

    .rail-toggle-right {
        right: calc(var(--workspace-edge) + var(--rail-right) - 42px);
    }

    .page-shell.left-rail-collapsed .rail-toggle-left {
        left: 0;
    }

    .page-shell.right-rail-collapsed .rail-toggle-right {
        right: 0;
    }
}

@media (max-width: 960px) {
    .rail-toggle {
        display: none;
    }
}

@media (min-width: 961px) and (prefers-reduced-motion: reduce) {

    .page-shell,
    .sidebar,
    .reading-tools,
    .rail-toggle {
        transition: none;
    }
}

/* Theme surfaces. Yellow is an accent fill; readable text stays dark. */
:root {
    color-scheme: dark;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #eeeee7;
    --panel: #f8f8f2;
    --panel-strong: #ffffff;
    --text: #25271e;
    --muted: #606354;
    --accent: #fffa00;
    --accent-soft: rgba(255, 250, 0, .18);
    --line: rgba(45, 48, 30, .18);
    --shadow: 0 12px 28px rgba(45, 48, 30, .08);
}

html[data-theme="light"],
[data-theme="light"] body {
    background: var(--bg);
    color: var(--text);
}

[data-theme="light"] .ambient-grid {
    background:
        linear-gradient(90deg, rgba(60, 65, 40, .05) 1px, transparent 1px) 0 0 / 96px 96px,
        linear-gradient(rgba(60, 65, 40, .05) 1px, transparent 1px) 0 0 / 96px 96px,
        #e5e5d9;
}

[data-theme="light"] .ambient-grid::after,
[data-theme="light"] .horizontal-ruler {
    border-color: #aaad91;
    filter: brightness(.55) sepia(.7);
}

[data-theme="light"] :is(.ambient-glow, .ambient-beam) {
    opacity: .15;
}

[data-theme="light"] .top-navigation,
[data-theme="light"] .top-navigation.is-scrolled {
    background: rgba(250, 250, 244, .97);
    border-color: var(--line);
    box-shadow: 0 6px 24px rgba(45, 48, 30, .06);
}

[data-theme="light"] :is(.sidebar, .article, .article-toc-panel, .profile-popover,
    .profile-popover::before, .rail-toggle, .sort-floating-layer .sort-floating-card) {
    background: var(--panel);
    border-color: var(--line);
    color: var(--text);
}

[data-theme="light"] :is(.article, .article-toc-panel) {
    background: #fff;
}

[data-theme="light"] :is(.auth-card, .publish-card),
[data-theme="light"] #authScreen .auth-card {
    background: #fafaf5;
    background-image: none;
    border-color: var(--line);
    box-shadow: var(--shadow);
}

[data-theme="light"] :is(.brand-kicker, .eyebrow, .nav-header, .nav-calendar,
    .nav-clock, .topbar h2, .article-title, .article-kicker, .article-meta,
    .top-nav-status, .top-nav-metrics, .top-nav-metrics b, .brand-home,
    .markdown-toc-title, .markdown-toc-title::before, .reading-footer,
    .reading-footer strong, .reading-footer span, .note-item h4, .note-item-meta,
    .note-preview, .empty-state, .auth-card h2, .auth-card p, .auth-card label,
    .publish-card h2, .publish-card p, .publish-card label, .auth-back,
    .sort-handle) {
    color: var(--text);
}

[data-theme="light"] .sidebar :is(.brand-wrap, .nav-header, .note-item-meta) {
    border-color: var(--line);
}

[data-theme="light"] .sidebar .note-item {
    background: transparent;
    border-bottom-color: var(--line);
    background-image: none;
}

[data-theme="light"] .sidebar .note-item:hover {
    background: #edeee2;
}

[data-theme="light"] .sidebar .note-item.active,
[data-theme="light"] .sidebar .note-item.active:hover {
    background: #fffbc2;
    border-color: var(--line);
}

[data-theme="light"] .sidebar .note-item.active :is(h4, .note-preview, .note-preview *, .note-item-meta, .sort-handle) {
    color: var(--text);
}

[data-theme="light"] .markdown-body,
[data-theme="light"] .markdown-body :is(h1, h2, h3, h4, h5, h6, p, li, strong, em, blockquote, th, td) {
    color: var(--text);
}

[data-theme="light"] .markdown-body :is(pre, code, blockquote, th, tr:nth-child(even)) {
    background: #f1f2e9;
    color: #303426;
    border-color: var(--line);
}

[data-theme="light"] .markdown-body a {
    color: #555900;
    text-decoration-color: #8b9000;
}

[data-theme="light"] .markdown-body a:hover {
    background: var(--accent);
    color: #25271e;
}

[data-theme="light"] .markdown-toc a {
    color: var(--muted);
}

[data-theme="light"] .markdown-toc a:hover {
    background: #f5f5dc;
    color: var(--text);
}

[data-theme="light"] .markdown-toc a.active,
[data-theme="light"] .markdown-toc a.active:hover,
[data-theme="light"] .markdown-toc a.active:focus-visible {
    background: var(--accent);
    color: #25271e;
}

[data-theme="light"] .top-nav-user-actions .icon-button,
[data-theme="light"] .reading-tools .back-to-top,
[data-theme="light"] .secondary-btn {
    background: #f1f2e8;
    color: var(--text);
    border-color: var(--line);
    box-shadow: none;
}

[data-theme="light"] .top-nav-user-actions .icon-button:hover,
[data-theme="light"] .reading-tools .back-to-top:hover,
[data-theme="light"] .rail-toggle:hover,
[data-theme="light"] .rail-toggle:focus-visible,
[data-theme="light"] .profile-btn[aria-expanded="true"] {
    background: var(--accent);
    color: #25271e;
    border-color: #b3af00;
    box-shadow: none;
}

[data-theme="light"] :is(.stack-form input, .stack-form textarea),
[data-theme="light"] #authScreen .stack-form :is(input, textarea) {
    background: #fff;
    color: var(--text);
    border-color: #afb39c;
    caret-color: #555900;
}

[data-theme="light"] :is(input, textarea)::placeholder {
    color: #717561;
}

[data-theme="light"] .stack-form button[type="submit"],
[data-theme="light"] #authScreen .auth-submit {
    background: var(--accent);
    color: #25271e;
    border-color: #b3af00;
}

[data-theme="light"] .auth-tabs button {
    color: var(--muted);
}

[data-theme="light"] .auth-tabs button.active {
    color: var(--text);
    background: var(--accent);
    border-color: #b3af00;
}

[data-theme="light"] :is(.footer-rule, .status-dot) {
    background: var(--accent);
}

[data-theme="light"] .reading-progress-bar {
    background: linear-gradient(90deg, #c9c500, var(--accent));
    box-shadow: none;
}

[data-theme="light"] :is(button, a, input, textarea, [tabindex]):focus-visible {
    outline-color: #777b00;
}

[data-theme="light"] ::selection {
    background: var(--accent);
    color: #25271e;
}

[data-theme="light"] * {
    scrollbar-color: #a8ad93 transparent;
}

[data-theme="light"] *::-webkit-scrollbar-thumb {
    background: #a8ad93;
}

/* Cyan point model sits directly on the light sidebar with no backing tile. */
[data-theme="dark"] .markdown-toc-title::before {
    color: var(--accent);
}

[data-theme="light"] .sidebar .brand-mark.seraphim-mark {
    background: transparent;
    color: #5fa9bb;
}

[data-theme="light"] .markdown-toc-title::before {
    color: #777b00;
}

/* Replace legacy cyan accents throughout light mode. The seraphim's cyan body
   and pale blue-violet highlight are the only intentional cool-color elements. */
[data-theme="light"] #appMessage[data-type="success"],
[data-theme="light"] .markdown-body :not(pre)>code,
[data-theme="light"] .markdown-body blockquote,
[data-theme="light"] .markdown-body blockquote.callout,
[data-theme="light"] .markdown-body blockquote.callout-bug,
[data-theme="light"] .markdown-body blockquote.callout-success,
[data-theme="light"] .markdown-body blockquote.callout-example,
[data-theme="light"] .article::after,
[data-theme="light"] .article-toc-panel,
[data-theme="light"] .sort-handle,
[data-theme="light"] .toc-toggle[aria-expanded="true"],
[data-theme="light"] .profile-btn[aria-expanded="true"] {
    border-color: #b3af00;
}

[data-theme="light"] .markdown-body :not(pre)>code,
[data-theme="light"] .markdown-body blockquote,
[data-theme="light"] .markdown-body blockquote.callout,
[data-theme="light"] .markdown-body blockquote.callout-bug,
[data-theme="light"] .markdown-body blockquote.callout-success,
[data-theme="light"] .markdown-body blockquote.callout-example,
[data-theme="light"] #authScreen .stack-form :is(input, textarea):focus,
[data-theme="light"] #authScreen .auth-tab:is(:hover, :focus-visible),
[data-theme="light"] .profile-btn[aria-expanded="true"] {
    background: rgba(255, 250, 0, .12);
}

[data-theme="light"] :is(.top-nav-brand:hover, .reading-tools .markdown-toc-title:hover,
    .toc-toggle[aria-expanded="true"], .sort-handle, .reading-footer p span) {
    color: #777b00;
}

[data-theme="light"] .article::after {
    border-bottom-color: var(--accent);
    border-left-color: var(--accent);
}

[data-theme="light"] .reading-footer {
    border-bottom-color: rgba(179, 175, 0, .36);
}

[data-theme="light"] .sidebar .note-item.active::before,
[data-theme="light"] .sidebar .note-list .note-item.drop-before::after,
[data-theme="light"] .sidebar .note-list .note-item.drop-after::after {
    background: var(--accent);
    box-shadow: 0 0 10px rgba(179, 175, 0, .38);
}

[data-theme="light"] #authScreen .auth-submit:hover:not(:disabled) {
    background: linear-gradient(110deg, #fffa00, #fff75c, #deda00, #fffa00);
    box-shadow: 0 6px 20px rgba(179, 175, 0, .18);
}

[data-theme="light"] :is(.auth-card, .publish-card):hover {
    background-image: radial-gradient(260px circle at 20% 0%, rgba(255, 250, 0, .1), transparent 72%);
}

[data-theme="light"] :is(.ambient-beam, .industrial-block-secondary) {
    background: linear-gradient(transparent, rgba(255, 250, 0, .3), transparent);
}

[data-theme="light"] .ambient-glow {
    background: radial-gradient(circle, rgba(255, 250, 0, .1), transparent 66%);
}

[data-theme="light"] :is(.top-navigation.is-scrolled, .markdown-body img:hover) {
    border-color: rgba(179, 175, 0, .38);
}

[data-theme="light"] :is(.reading-tools .back-to-top:focus-visible,
    .top-nav-user-actions .icon-button:focus-visible) {
    box-shadow: 0 0 0 4px rgba(255, 250, 0, .18);
}

[data-theme="light"] .stack-form :is(input, textarea):focus,
[data-theme="light"] .stack-form :is(input, textarea):focus-visible {
    border-color: #b3af00;
    box-shadow: 0 0 0 4px rgba(255, 250, 0, .12);
}

[data-theme="light"] .status-dot {
    animation: none;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(255, 250, 0, .18);
}

[data-theme="light"] .ambient-grid::after {
    filter: none;
    background:
        repeating-linear-gradient(to bottom, rgba(179, 175, 0, .5) 0 1px, transparent 1px 80px),
        repeating-linear-gradient(to bottom, rgba(179, 175, 0, .24) 0 1px, transparent 1px 16px);
    border-left-color: rgba(179, 175, 0, .25);
}

[data-theme="light"] .horizontal-ruler {
    filter: none;
    background:
        repeating-linear-gradient(to right, rgba(179, 175, 0, .5) 0 1px, transparent 1px 80px),
        repeating-linear-gradient(to right, rgba(179, 175, 0, .24) 0 1px, transparent 1px 16px);
    border-top-color: rgba(179, 175, 0, .25);
}

[data-theme="light"] .auth-submit::after {
    background: linear-gradient(105deg, transparent 25%, rgba(255, 250, 0, .22), transparent 75%);
}

/* Login copy must stay readable on the light card and its yellow controls. */
[data-theme="light"] #authScreen h1,
[data-theme="light"] #authScreen .auth-wordmark,
[data-theme="light"] #authScreen .auth-form-panel,
[data-theme="light"] #authScreen .auth-tab,
[data-theme="light"] #authScreen .stack-form label {
    color: var(--text);
}

[data-theme="light"] #authScreen .auth-wordmark span,
[data-theme="light"] #authScreen .auth-hint,
[data-theme="light"] #authScreen .field-hint {
    color: #59604e;
}

[data-theme="light"] #authScreen .auth-tabs {
    border-bottom-color: var(--line);
}

[data-theme="light"] #authScreen .auth-tab {
    background: transparent;
}

[data-theme="light"] #authScreen .auth-tab.active {
    background: var(--accent);
    color: #25271e;
    border-bottom-color: #b3af00;
}

[data-theme="light"] #authScreen .auth-tab:is(:hover, :focus-visible) {
    background: rgba(255, 250, 0, .16);
    color: var(--text);
}

[data-theme="light"] #authScreen .auth-tab.active:is(:hover, :focus-visible) {
    background: var(--accent);
    color: #25271e;
}

[data-theme="light"] #authScreen .auth-back {
    color: var(--text);
}

[data-theme="light"] #authScreen .auth-back:hover {
    color: #59604e;
}

/* Light-theme contrast pass: keep legacy terminal labels, symbols and
   generated content readable after the workspace changes from dark to light. */
:root[data-theme="light"] {
    --accent-ink: #686d00;
    --icon-ink: #3f4639;
    --muted-strong: #555c4b;
}

[data-theme="light"] .page-shell::before,
[data-theme="light"] .content::before,
[data-theme="light"] .sidebar nav::after,
[data-theme="light"] .article-toc-panel::after,
[data-theme="light"] .markdown-body::before {
    color: rgba(45, 48, 30, .56);
}

[data-theme="light"] .page-shell::after {
    background: linear-gradient(90deg, var(--accent) 0 74px,
            rgba(45, 48, 30, .22) 74px 30%, transparent 70%);
}

[data-theme="light"] .sidebar .brand-kicker,
[data-theme="light"] .sidebar .nav-header,
[data-theme="light"] .sidebar .nav-header-caption {
    color: var(--muted-strong);
}

[data-theme="light"] .sidebar .note-item,
[data-theme="light"] .sidebar .note-item h4 {
    color: var(--text);
}

[data-theme="light"] .sidebar .note-item h4,
[data-theme="light"] .sidebar .note-item.active h4 {
    color: #303426;
}

[data-theme="light"] .sidebar .note-preview,
[data-theme="light"] .sidebar .note-item:hover .note-preview,
[data-theme="light"] .sidebar .note-item-meta,
[data-theme="light"] .sidebar .sort-handle,
[data-theme="light"] .sidebar .note-item.active :is(.note-preview,
    .note-preview *, .note-item-meta, .sort-handle) {
    color: var(--muted-strong);
}

[data-theme="light"] .sidebar .note-item,
[data-theme="light"] .sidebar .note-item:hover,
[data-theme="light"] .sidebar .note-item.active,
[data-theme="light"] .sidebar .note-item.active:hover {
    border-bottom-color: #d0d4c2;
}

[data-theme="light"] .sidebar .note-item:hover {
    background: #f0f1e5;
}

[data-theme="light"] .sidebar .note-item.active,
[data-theme="light"] .sidebar .note-item.active:hover {
    background: #fffbc2;
}

[data-theme="light"] .sidebar .note-list .note-item {
    background-image: linear-gradient(rgba(104, 109, 0, .34), rgba(104, 109, 0, .34));
}

[data-theme="light"] .sidebar .note-item-meta>span:last-child,
[data-theme="light"] .sidebar .note-item.active :is(.note-item-meta,
    .note-item-meta>span:last-child, .sort-handle) {
    border-color: #aeb49d;
}

[data-theme="light"] .sidebar .sort-handle:hover {
    color: var(--accent-ink);
}

[data-theme="light"] .sidebar .note-list,
[data-theme="light"] .sidebar .note-list .note-preview {
    scrollbar-color: #929a7e transparent;
}

[data-theme="light"] .sidebar .note-list.is-sorting .note-item.is-sorting,
[data-theme="light"] .sort-floating-layer .sort-floating-card {
    background: #f4f5ed;
    color: var(--text);
    border-color: #8f9700;
}

[data-theme="light"] .nav-calendar {
    color: var(--muted-strong);
}

[data-theme="light"] .nav-clock {
    color: var(--icon-ink);
}

[data-theme="light"] .profile-popover,
[data-theme="light"] .profile-popover::before {
    background: var(--panel);
    border-color: var(--line);
}

[data-theme="light"] .profile-popover::before {
    border-top-color: var(--accent-ink);
    border-left-color: var(--accent-ink);
}

[data-theme="light"] .profile-popover .ui-icon,
[data-theme="light"] .rail-toggle .ui-icon,
[data-theme="light"] .top-nav-user-actions .ui-icon,
[data-theme="light"] .reading-tools .ui-icon,
[data-theme="light"] .delete-btn .ui-icon,
[data-theme="light"] .auth-back .ui-icon {
    color: currentColor;
}

[data-theme="light"] #appMessage {
    background: #fff;
    color: var(--text);
}

[data-theme="light"] #appMessage[data-type="success"] {
    border-color: #a9ad00;
    color: var(--accent-ink);
}

[data-theme="light"] #appMessage[data-type="error"] {
    border-color: #a95545;
    color: #873d32;
}

[data-theme="light"] .markdown-body::before,
[data-theme="light"] .markdown-body mjx-container {
    color: var(--text);
}

[data-theme="light"] .markdown-body blockquote,
[data-theme="light"] .markdown-body blockquote.callout,
[data-theme="light"] .markdown-body blockquote.callout-warning,
[data-theme="light"] .markdown-body blockquote.callout-danger,
[data-theme="light"] .markdown-body blockquote.callout-failure,
[data-theme="light"] .markdown-body blockquote.callout-bug,
[data-theme="light"] .markdown-body blockquote.callout-tip,
[data-theme="light"] .markdown-body blockquote.callout-success,
[data-theme="light"] .markdown-body blockquote.callout-info,
[data-theme="light"] .markdown-body blockquote.callout-abstract,
[data-theme="light"] .markdown-body blockquote.callout-example {
    color: #303426;
}

[data-theme="light"] .markdown-body .callout-title {
    color: var(--accent-ink);
}

[data-theme="light"] .markdown-body .callout-warning .callout-title,
[data-theme="light"] .markdown-body .callout-danger .callout-title,
[data-theme="light"] .markdown-body .callout-failure .callout-title,
[data-theme="light"] .markdown-body .callout-bug .callout-title,
[data-theme="light"] #authScreen .eyebrow {
    color: var(--accent-ink);
}

[data-theme="light"] .markdown-toc li::before {
    background: #737b62;
}

[data-theme="light"] .markdown-toc .toc-level-1::before {
    background: var(--accent-ink);
}

[data-theme="light"] .markdown-toc a.active,
[data-theme="light"] .markdown-toc a.active:hover,
[data-theme="light"] .markdown-toc a.active:focus-visible {
    color: #25271e;
}

[data-theme="light"] .reading-footer p span,
[data-theme="light"] .markdown-toc-title::before,
[data-theme="light"] .top-nav-brand:hover,
[data-theme="light"] .reading-tools .markdown-toc-title:hover {
    color: var(--accent-ink);
}

[data-theme="light"] .terrain-field {
    stroke: #707761;
}

[data-theme="light"] .terrain-field .terrain-major {
    stroke: #444b3d;
}

[data-theme="light"] .industrial-lines {
    opacity: .58;
    background:
        linear-gradient(90deg, var(--accent-ink), transparent) left 35% top 22% / 140px 1px no-repeat,
        linear-gradient(var(--accent-ink), transparent) right 7% top 15% / 1px 180px no-repeat,
        linear-gradient(90deg, transparent, #71785f) right 4% bottom 17% / 220px 1px no-repeat,
        linear-gradient(#71785f, transparent) left 9% bottom 9% / 1px 96px no-repeat;
}

[data-theme="light"] .industrial-lines::before,
[data-theme="light"] .industrial-lines::after {
    background:
        linear-gradient(#71785f, #71785f) center / 1px 100% no-repeat,
        linear-gradient(#71785f, #71785f) center / 100% 1px no-repeat;
}

/* Reading navigation uses the active theme as a consistent left-edge marker. */
.article-toc-panel {
    border-left: 0;
    box-shadow: inset 3px 0 0 var(--accent) !important;
}

.reading-tools .back-to-top,
.reading-tools .back-to-top[data-placement="above"] {
    border-left: 0;
    border-right: 1px solid var(--line);
    box-shadow: inset 3px 0 0 var(--accent) !important;
}

/* Inactive articles stay transparent; only the selected article carries a fill. */
[data-theme="light"] .sidebar .note-item:not(.active),
[data-theme="light"] .sidebar .note-item:not(.active):hover,
[data-theme="light"] .sidebar .note-item:not(.active):focus-visible {
    background: transparent;
}

[data-theme="light"] .sidebar .note-item.active,
[data-theme="light"] .sidebar .note-item.active:hover {
    background: #fff96b;
    color: #25271e;
}

/* The yellow accent is too close to the light navigation surface for the
   horse mark; use the readable accent ink for the SVG silhouette. */
[data-theme="light"] .top-navigation .top-nav-mark.flat-knight {
    color: var(--accent-ink);
}

[data-theme="light"] .sidebar .brand-mark.seraphim-mark {
    color: #c9a227;
}

/* Home: editorial credits around a living point-cloud sculpture. */
.top-nav-pages {
    display: flex;
    align-items: stretch;
    gap: clamp(10px, 2.2vw, 36px);
    margin-left: clamp(12px, 2.5vw, 38px);
    flex-shrink: 0;
}

.top-nav-pages a {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 3px;
    min-width: clamp(70px, 8vw, 132px);
    padding: 8px clamp(12px, 1.6vw, 24px) 9px;
    border: 0;
    color: var(--text);
    text-decoration: none;
    transition: color 180ms ease;
}

.top-nav-pages a::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 180ms ease;
}

.top-nav-page-title {
    font: 700 clamp(.76rem, 1.15vw, 1.08rem)/1.05 "Oswald", "Arial Narrow", sans-serif;
    letter-spacing: .025em;
    white-space: nowrap;
}

.top-nav-page-caption {
    color: var(--muted);
    font: 500 clamp(.64rem, .9vw, .82rem)/1.1 "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    letter-spacing: .06em;
    white-space: nowrap;
}

.top-nav-pages a:hover,
.top-nav-pages a[aria-current="page"] {
    color: var(--accent);
}

.top-nav-pages a:hover .top-nav-page-caption,
.top-nav-pages a[aria-current="page"] .top-nav-page-caption {
    color: inherit;
}

.top-nav-pages a:hover::after,
.top-nav-pages a[aria-current="page"]::after {
    transform: scaleX(1);
}

[data-theme="light"] .top-nav-pages a {
    color: var(--text);
}

[data-theme="light"] .top-nav-pages a:hover,
[data-theme="light"] .top-nav-pages a[aria-current="page"] {
    color: var(--accent-ink);
}

[data-theme="light"] .top-nav-pages a::after {
    background: var(--accent-ink);
}

[data-theme="light"] .top-nav-user-actions #bgmToggleBtn[aria-pressed="true"] {
    border-color: var(--accent-ink);
    background: var(--accent);
    color: #25271e;
}

[data-theme="light"] .top-nav-pages a[aria-current="page"] {
    background: var(--accent);
    color: #25271e;
    box-shadow: none;
}

[data-theme="light"] .top-nav-pages a[aria-current="page"]::after {
    display: none;
}

[data-theme="light"] .top-nav-pages a:hover:not([aria-current="page"]) {
    background: rgba(255, 250, 0, .2);
}

body:not([data-page="archive"]) .reading-progress-bar,
body:not([data-page="archive"]) .top-nav-metrics,
body:not([data-page="archive"]) .top-nav-user-actions .toc-toggle {
    display: none;
}

body:not([data-page="archive"]) .top-nav-date {
    margin-left: auto;
}

@media (min-width: 701px) {

    /* The desktop navigation has a single row, so the selected light-theme
       block can run cleanly from the bar's top edge to its bottom edge. */
    .top-nav-pages {
        align-self: stretch;
    }

    .top-nav-pages a {
        margin-block: -13px;
        padding-block: 13px;
    }
}

.home-screen {
    position: relative;
    z-index: 1;
    min-height: 850px;
    min-height: max(850px, 100svh);
    padding: 140px clamp(24px, 7vw, 130px) 84px;
    overflow: hidden;
    isolation: isolate;
    color: #f1f4ef;
    background: radial-gradient(ellipse at 57% 48%, rgba(36, 70, 67, .48), transparent 62%),
        linear-gradient(125deg, #111817, #182120 58%, #101616);
}

.home-screen::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0;
    opacity: .15;
    pointer-events: none;
    background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(180, 210, 205, .07) 3px 4px);
}

.home-heading {
    position: relative;
    z-index: 2;
    width: fit-content;
    pointer-events: none;
}

.home-index {
    margin: 0 0 20px;
    font: 600 .65rem/1.6 "Cascadia Code", monospace;
    letter-spacing: .18em;
    color: #b4c6c0;
}

.home-heading h1 {
    margin: 0 0 18px;
    font: 900 clamp(64px, 7.4vw, 142px)/.94 "Arial Black", "Segoe UI", sans-serif;
    letter-spacing: -.065em;
    opacity: .86;
}

.home-subtitle {
    margin: 0 0 18px;
    font: 800 clamp(20px, 2.1vw, 36px)/1.18 "Segoe UI", sans-serif;
    letter-spacing: -.04em;
}

.home-translation {
    font-size: .83rem;
    letter-spacing: .12em;
}

.home-sculpture {
    position: absolute;
    z-index: 1;
    top: 8%;
    left: 12%;
    width: 80%;
    height: 92%;
    color: #101216;
    cursor: grab;
    touch-action: pan-y;
}

.home-sculpture canvas {
    touch-action: pan-y;
}

.home-sculpture:active {
    cursor: grabbing;
}

.home-sculpture .poploong-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.home-sculpture .poploong-poster--wenpao {
    display: none;
}

[data-theme="light"] .home-sculpture .poploong-poster--wupao {
    display: none;
}

[data-theme="light"] .home-sculpture .poploong-poster--wenpao {
    display: block;
}

.home-sculpture.seraphim-ready .poploong-poster {
    visibility: hidden;
}

.home-sculpture:not(.seraphim-ready) canvas {
    visibility: hidden;
}

.home-editorial {
    position: relative;
    z-index: 2;
    width: fit-content;
    max-width: 330px;
    margin-top: clamp(90px, 15vh, 190px);
}

.home-editorial h2 {
    margin: 0 0 18px;
    font: 800 clamp(28px, 2.5vw, 42px)/1.04 "Segoe UI", sans-serif;
    letter-spacing: -.045em;
}

.home-editorial>p:not(.home-index) {
    color: #b4c6c0;
    font-size: .8rem;
    line-height: 1.8;
}

.home-enter {
    display: inline-flex;
    align-items: center;
    gap: 50px;
    margin-top: 22px;
    padding: 12px 0;
    border-bottom: 1px solid currentColor;
    color: inherit;
    text-decoration: none;
    font-weight: 700;
    font-size: .85rem;
}

.home-enter span {
    color: var(--accent);
    font-size: 1.6rem;
    transition: transform 180ms ease;
}

.home-enter:hover span {
    transform: translate(3px, -3px);
}

.home-signature {
    position: absolute;
    z-index: 2;
    right: clamp(24px, 7vw, 130px);
    bottom: 116px;
    text-align: right;
    pointer-events: none;
}

.home-signature-cn {
    font-size: clamp(24px, 2.6vw, 46px);
    font-weight: 800;
    line-height: 1.25;
    margin: 0 0 22px;
}

.home-signature-en {
    margin: 0;
    font: 900 clamp(56px, 6.7vw, 124px)/.87 "Arial Black", "Segoe UI", sans-serif;
    letter-spacing: -.065em;
    opacity: .86;
}

.home-signature-en em {
    font-style: normal;
    color: #9cd5cf;
}

.home-footer {
    position: absolute;
    z-index: 2;
    bottom: 28px;
    left: clamp(24px, 7vw, 130px);
    right: clamp(24px, 7vw, 130px);
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid rgba(200, 220, 215, .2);
    font: 500 .6rem/1.6 "Cascadia Code", "Microsoft YaHei", monospace;
    letter-spacing: .08em;
    color: #b4c6c0;
}

.home-footer a {
    color: inherit;
    text-decoration: none;
}

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

[data-theme="light"] .home-screen {
    color: #272b20;
    background: radial-gradient(ellipse at 57% 48%, rgba(225, 206, 133, .3), transparent 62%),
        linear-gradient(125deg, #f5f5e9, #e9eadb 58%, #f9f9ee);
}

[data-theme="light"] .home-sculpture {
    color: #fffaf0;
}

[data-theme="light"] .home-index,
[data-theme="light"] .home-editorial>p:not(.home-index),
[data-theme="light"] .home-footer {
    color: #555c4b;
}

[data-theme="light"] .home-signature-en em,
[data-theme="light"] .home-enter span,
[data-theme="light"] .home-footer a:hover {
    color: var(--accent-ink);
}

[data-theme="light"] .home-footer {
    border-color: var(--line);
}

@media (max-width: 1200px) {
    .top-nav-pages {
        margin-left: 6px;
        gap: 16px;
    }

    .top-navigation .top-nav-status {
        display: none;
    }
}

@media (min-width: 701px) and (max-width: 1000px) {
    .home-screen {
        min-height: 1240px;
    }

    .home-sculpture {
        top: 340px;
        left: 0;
        width: 100%;
        height: 560px;
    }

    .home-editorial {
        margin-top: 530px;
        max-width: 45%;
    }

    .home-signature {
        bottom: 150px;
        max-width: 45%;
    }

    .home-signature-en {
        font-size: clamp(46px, 6vw, 60px);
    }
}

@media (max-width: 700px) {
    .top-navigation .top-nav-date {
        display: none;
    }

    .home-screen {
        min-height: 1050px;
        padding-top: 164px;
    }

    .home-heading h1 {
        font-size: clamp(48px, 11vw, 76px);
    }

    .home-sculpture {
        top: 300px;
        left: 0;
        width: 100%;
        height: 450px;
    }

    .home-editorial {
        margin-top: 345px;
        max-width: 48%;
    }

    .home-editorial h2 {
        font-size: 23px;
    }

    .home-editorial .home-index {
        font-size: .55rem;
    }

    .home-signature {
        bottom: 160px;
        max-width: 45%;
    }

    .home-signature .home-index {
        display: none;
    }

    .home-signature-cn {
        font-size: 22px;
    }

    .home-signature-en {
        font-size: clamp(40px, 8vw, 56px);
    }

    .home-footer {
        flex-wrap: wrap;
        font-size: .55rem;
        gap: 12px;
    }

    .home-footer>span:nth-child(2) {
        order: 3;
        width: 100%;
    }

    .home-enter {
        gap: 20px;
    }

    .top-nav-pages {
        margin-left: auto;
        gap: 14px;
    }

    .top-nav-pages a {
        font-size: .6rem;
        padding: 8px 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-enter span {
        transition: none;
    }
}

/* Large continuous topography shared by HOME, archive and account screens. */
.terrain-contours {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.ambient-grid {
    background: radial-gradient(ellipse at 57% 48%, #203632, transparent 72%), #111817;
}

[data-theme="light"] .ambient-grid {
    background: radial-gradient(ellipse at 57% 48%, #eeeedc, transparent 72%), #f8f9f2;
}

.home-screen,
[data-theme="light"] .home-screen {
    background: transparent;
}

/* HOME article previews: native swipe/scroll with an optional automatic advance. */
.home-editorial.article-banner {
    position: absolute;
    left: clamp(24px, 7vw, 130px);
    bottom: 116px;
    width: 330px;
    max-width: 30%;
    margin-top: 0;
}

.article-banner-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
}

.article-banner-heading .home-index {
    margin: 0;
}

.article-banner-count,
.article-banner-date {
    color: #b4c6c0;
    font: 500 .65rem/1.5 "Cascadia Code", monospace;
}

.article-banner-progress {
    position: relative;
    width: 100%;
    height: 2px;
    margin: 0 0 10px;
    overflow: hidden;
    background: rgba(180, 210, 205, .22);
}

.article-banner-progress span {
    display: block;
    width: 100%;
    height: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    background: var(--accent);
    will-change: transform;
}

.article-banner-track {
    display: flex;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    border-top: 1px solid rgba(180, 210, 205, .32);
}

.article-banner-track::-webkit-scrollbar {
    display: none;
}

.article-banner-card {
    flex: 0 0 100%;
    min-width: 0;
    min-height: 160px;
    box-sizing: border-box;
    padding: 12px 2px 8px;
    display: flex;
    flex-direction: column;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    color: inherit;
    text-decoration: none;
}

.article-banner-card h2 {
    min-width: 0;
    max-width: 100%;
    font-size: clamp(20px, 2vw, 28px);
    line-height: 1.14;
    margin: 6px 0;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

.article-banner-excerpt {
    flex: 0 1 auto;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    color: #b4c6c0;
    font-size: .76rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-line;
}

.article-banner-excerpt mjx-container {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    vertical-align: middle;
}

.article-banner-read {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    width: fit-content;
    max-width: 100%;
    margin: 6px 0 0 auto;
    padding: 4px 0 3px;
    color: inherit;
    font-size: .73rem;
    text-decoration: none;
    transition: color 180ms ease, transform 180ms ease;
}

.article-banner-read>span:first-child {
    color: inherit;
    font-size: inherit;
}

.article-banner-read span[aria-hidden="true"] {
    color: var(--accent);
    font-size: 1.2rem;
    line-height: 1;
    transition: transform 180ms ease;
}

.article-banner-read:hover,
.article-banner-read:focus-visible {
    color: var(--accent);
    transform: translateX(3px);
}

.article-banner-read:hover span[aria-hidden="true"],
.article-banner-read:focus-visible span[aria-hidden="true"] {
    transform: translate(3px, -2px);
}

.article-banner-card:hover h2 {
    color: var(--accent);
}

.article-banner-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.article-banner-controls {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
    padding-top: 0;
}

.article-banner-controls button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    min-width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: .75rem;
    cursor: pointer;
    opacity: .72;
    transition: color 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.article-banner-controls button .ui-icon {
    width: 16px;
    height: 16px;
}

.article-banner-button-icon {
    display: inline-block;
    font: 600 1.35rem/1 "Segoe UI Symbol", "Arial Unicode MS", sans-serif;
}

.article-banner-controls button:hover:not(:disabled),
.article-banner-controls button:focus-visible {
    color: var(--accent);
    opacity: 1;
    transform: translateY(-1px);
}

.article-banner-controls button:disabled {
    opacity: .35;
    cursor: default;
}

.article-banner-empty {
    min-height: 130px;
    font-size: .8rem;
    line-height: 1.8;
}

[data-theme="light"] .article-banner :is(.article-banner-count, .article-banner-date, .article-banner-excerpt) {
    color: #555c4b;
}

[data-theme="light"] .article-banner-progress {
    background: rgba(85, 92, 75, .25);
}

[data-theme="light"] .article-banner :is(.article-banner-track, .article-banner-controls, button) {
    border-color: #9da48e;
}

[data-theme="light"] .article-banner-card:hover h2 {
    color: var(--accent-ink);
}

[data-theme="light"] .article-banner-read {
    color: inherit;
}

[data-theme="light"] .article-banner-read span[aria-hidden="true"] {
    color: var(--accent-ink);
}

[data-theme="light"] .article-banner-read:hover,
[data-theme="light"] .article-banner-read:focus-visible {
    color: var(--accent-ink);
}

@media (max-width: 1000px) {
    .home-editorial.article-banner {
        bottom: 150px;
        max-width: 45%;
    }
}

@media (max-width: 700px) {
    .home-editorial.article-banner {
        bottom: 160px;
        max-width: 48%;
    }

    .article-banner-card {
        min-height: 145px;
    }

    .article-banner-card h2 {
        font-size: 18px;
    }

    .article-banner-excerpt {
        font-size: .72rem;
    }

    .article-banner-count,
    .article-banner-date {
        font-size: .55rem;
    }

    .article-banner-controls {
        gap: 5px;
    }

    .article-banner-controls button {
        width: 22px;
        min-width: 22px;
        height: 22px;
    }

    .article-banner-controls button .ui-icon {
        width: 14px;
        height: 14px;
    }
}

/* Stack the compact navigation into two predictable rows on phones so the
   three page choices remain visible beside the account controls. */
@media (max-width: 700px) {
    .top-navigation {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: auto auto;
        align-items: center;
        gap: 0 12px;
        height: 116px;
        min-height: 116px;
        padding: 10px 12px 8px;
    }

    .top-nav-brand {
        grid-column: 1;
        grid-row: 1;
        min-width: 0;
    }

    .top-nav-user-actions {
        grid-column: 2;
        grid-row: 1;
        width: auto;
        margin-left: 0;
        justify-content: flex-end;
        border-left: 0;
        padding-left: 0;
    }

    .top-nav-pages {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        min-width: 0;
        margin: 0;
        gap: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .top-nav-pages::-webkit-scrollbar {
        display: none;
    }

    .top-nav-pages a {
        flex: 1 1 0;
        min-width: 0;
        padding: 6px 6px 8px;
    }

    .top-nav-page-title {
        font-size: clamp(.7rem, 3.2vw, .9rem);
    }

    .top-nav-page-caption {
        font-size: clamp(.6rem, 2.8vw, .75rem);
    }
}
