:root {
    --paper: #f7f4ee;
    --panel: #fffdf8;
    --ink: #24211f;
    --muted: #746f68;
    --line: #e7ded2;
    --line-strong: #cdbfad;
    --blue: #7a4cc2;
    --blue-soft: #f1ebff;
    --green: #2f7d57;
    --green-soft: #e9f4ed;
    --amber: #b36b1e;
    --amber-soft: #fff0d2;
    --red: #9e2f2f;
    --red-soft: #ffe7df;
    --violet: #7652aa;
    --record-rust: #a24a32;
    --record-gold: #d8a84e;
    --record-night: #282421;
    --shadow: 0 16px 42px rgba(45, 35, 24, 0.14);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at 18% 0%, rgba(216, 168, 78, .24) 0, transparent 31vw),
        radial-gradient(circle at 88% 12%, rgba(162, 74, 50, .16) 0, transparent 26vw),
        linear-gradient(180deg, #eee8dd 0%, var(--paper) 46%, #fbfaf6 100%);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    letter-spacing: 0;
}

body.word-editor-page {
    height: 100%;
    overflow: clip;
}

body.word-editor-page .app-shell {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

.public-editor-page .title-input {
    border-color: rgba(19, 92, 138, .24);
}

.public-editor-page .status-pill {
    background: #eef8ff;
    color: #135c8a;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px clamp(16px, 4vw, 36px);
    background: rgba(251, 250, 247, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    box-shadow: 0 5px 16px rgba(38, 99, 235, 0.22);
    flex: 0 0 auto;
    display: block;
}

.brand-title {
    font-weight: 750;
    font-size: 17px;
    white-space: nowrap;
}

.record-hero {
    margin-bottom: 18px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    padding: 28px;
    border: 1px solid rgba(162, 74, 50, .24);
    border-radius: 8px;
    color: #fff8ec;
    background:
        linear-gradient(135deg, rgba(40, 36, 33, .96), rgba(91, 52, 43, .92) 52%, rgba(162, 74, 50, .82)),
        radial-gradient(circle at 82% 12%, rgba(216, 168, 78, .42), transparent 32%);
    box-shadow: 0 18px 46px rgba(50, 36, 24, .22);
}

.record-kicker {
    display: block;
    margin-bottom: 8px;
    color: #f7d58a;
    font-size: 12px;
    font-weight: 760;
    text-transform: uppercase;
}

.record-hero h1 {
    max-width: 760px;
    margin: 0;
    font-size: clamp(28px, 4vw, 48px);
    line-height: 1.08;
    font-weight: 850;
}

.record-hero p {
    max-width: 680px;
    margin: 12px 0 0;
    color: rgba(255, 248, 236, .84);
    font-size: 16px;
    line-height: 1.7;
}

.topbar-spacer {
    flex: 1;
}

.button,
.icon-button {
    border: 1px solid var(--line-strong);
    background: var(--panel);
    color: var(--ink);
    min-height: 36px;
    border-radius: 7px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}

.button {
    padding: 0 13px;
}

.svg-icon {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    color: currentColor;
    display: inline-block;
}

.svg-icon.tiny {
    width: 14px;
    height: 14px;
}

.svg-icon.invert {
    filter: brightness(0) invert(1);
}

.icon-button {
    width: 36px;
    padding: 0;
}

.button:hover,
.icon-button:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.button:active,
.icon-button:active {
    transform: translateY(1px);
}

.button.primary {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.button.primary:hover {
    background: #000;
    border-color: #000;
    color: #fff;
}

.meta-toggle {
    display: none;
}

.sidebar-toggle {
    display: none;
}

.button.danger {
    border-color: #f1b8b3;
    color: var(--red);
    background: var(--red-soft);
}

.button.success {
    border-color: #9fd7bd;
    color: var(--green);
    background: var(--green-soft);
}

.main {
    width: min(1540px, 100%);
    margin: 0 auto;
    padding: 24px clamp(14px, 4vw, 36px) 48px;
}

.editor-main {
    width: 100%;
    max-width: none;
    height: calc(100dvh - 65px);
    padding: 14px clamp(16px, 2.2vw, 34px);
    overflow: hidden;
}

.worktop {
    display: grid;
    grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.side-panel,
.list-panel,
.editor-panel,
.meta-panel,
.reader-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.side-panel {
    padding: 16px;
    position: sticky;
    top: 78px;
}

.drawer-head {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

.app-sidebar {
    display: grid;
    gap: 8px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.sidebar-link {
    min-height: 38px;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 650;
}

.sidebar-link:hover,
.sidebar-link.active {
    border-color: var(--line);
    background: #fffaf0;
    color: var(--ink);
}

.sidebar-link.active {
    border-color: var(--blue);
    background: var(--blue-soft);
    color: var(--blue);
}

.search-filter-form {
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.section-title {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 700;
}

.title-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.filter-form {
    display: grid;
    gap: 12px;
}

.field {
    display: grid;
    gap: 7px;
}

.field label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 650;
}

.check-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
}

.check-line input {
    width: 16px;
    height: 16px;
    accent-color: var(--blue);
}

.public-submit-alert {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid #f1c27d;
    border-left: 4px solid var(--amber);
    border-radius: 8px;
    background: #fff8e8;
}

.public-submit-alert strong {
    color: #8a4c0b;
    font-size: 15px;
}

.public-submit-alert p {
    margin: 0;
    color: #6f4f22;
    line-height: 1.65;
    font-size: 13px;
}

.input,
.select,
.textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--ink);
    border-radius: 7px;
    outline: none;
}

.input,
.select {
    height: 38px;
    padding: 0 11px;
}

.textarea {
    min-height: 92px;
    padding: 10px 12px;
    resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-soft);
}

.type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.type-chip {
    min-height: 38px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    border-radius: 7px;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    justify-content: start;
    gap: 9px;
    padding: 5px 9px;
    font-size: 13px;
}

.type-chip span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.type-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: inline-grid;
    place-items: center;
    background: linear-gradient(135deg, #f6efff, #fff9ee);
    box-shadow: inset 0 0 0 1px rgba(122, 76, 194, .11), 0 4px 10px rgba(122, 76, 194, .10);
}

.type-icon img {
    width: 21px;
    height: 21px;
    display: block;
}

.type-chip.active {
    border-color: var(--blue);
    background: var(--blue-soft);
    color: var(--blue);
    font-weight: 700;
}

.collection-list {
    display: grid;
    gap: 8px;
}

.collection-link {
    min-height: 36px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
}

.collection-link:hover,
.collection-link.active {
    border-color: var(--blue);
    color: var(--ink);
    background: #fafcff;
}

.collection-link span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.collection-link strong {
    font-size: 12px;
    color: var(--muted);
}

.collection-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--collection-color, var(--blue));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--collection-color, var(--blue)) 18%, transparent);
}

.list-panel {
    overflow: hidden;
}

.list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.list-head h1 {
    margin: 0;
    font-size: clamp(20px, 3vw, 28px);
    line-height: 1.2;
}

.article-list {
    display: grid;
}

.article-item {
    display: grid;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--line);
    transition: background .16s ease, box-shadow .16s ease;
}

.article-item:hover {
    background: #fafcff;
}

.public-article-card[data-href] {
    cursor: pointer;
}

.public-article-card[data-href]:focus-visible {
    outline: 3px solid var(--blue-soft);
    outline-offset: -3px;
}

.public-article-card[data-href]:hover {
    box-shadow: inset 3px 0 0 var(--blue);
}

.article-item:last-child {
    border-bottom: 0;
}

.article-card-link {
    display: grid;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.article-row,
.article-title-wrap,
.article-meta-line {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.article-card-head {
    min-width: 0;
}

.article-title-wrap {
    flex-wrap: wrap;
}

.article-meta-line {
    justify-content: flex-start;
    gap: 10px 14px;
    color: #9aa4ad;
    font-size: 12px;
}

.article-author {
    color: #8a949e;
    font-size: 12px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-stat {
    color: #a4adb6;
    white-space: nowrap;
}

.article-meta-line .review-toggle {
    margin-left: auto;
}

.article-tiny-meta {
    font-size: 12px;
    color: #7d8992;
}

.article-title {
    font-size: clamp(20px, 2.2vw, 25px);
    font-weight: 800;
    line-height: 1.28;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-title:hover,
.article-open-link:hover {
    color: var(--blue);
    text-decoration: underline;
}

.article-summary {
    color: #374151;
    line-height: 1.78;
    font-size: 15px;
    word-break: break-word;
}

.article-preview {
    position: relative;
    display: grid;
    gap: 10px;
}

.article-content-shell {
    position: relative;
}

.public-article-card.is-collapsed .article-content-shell {
    max-height: 430px;
    overflow: hidden;
}

.public-article-card.is-collapsed .article-content-shell::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 78px;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 253, 248, 0), var(--panel));
}

.article-expand {
    justify-self: start;
}

.article-markdown-preview > .render-content,
.article-markdown-preview > .plain-content {
    font-size: inherit;
}

.article-markdown-preview .render-content h1 {
    font-size: 1.55em;
}

.article-markdown-preview .render-content h2 {
    font-size: 1.32em;
}

.collection-nest {
    margin: 14px;
    border: 1px solid color-mix(in srgb, var(--collection-color, var(--blue)) 28%, var(--line));
    border-radius: 8px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--collection-color, var(--blue)) 7%, white), #fff);
    overflow: hidden;
}

.collection-nest-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 22px 18px;
    border-bottom: 1px solid color-mix(in srgb, var(--collection-color, var(--blue)) 20%, var(--line));
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--collection-color, var(--blue)) 16%, white), color-mix(in srgb, var(--collection-color, var(--blue)) 6%, white));
}

.collection-nest-head h2 {
    margin: 0;
    color: color-mix(in srgb, var(--collection-color, var(--blue)) 68%, #111827);
    font-size: clamp(24px, 3vw, 34px);
    font-weight: 850;
    line-height: 1.08;
}

.collection-nest-head p {
    margin: 6px 0 0;
    color: color-mix(in srgb, var(--collection-color, var(--blue)) 45%, #6b7280);
    font-size: 13px;
    font-weight: 650;
}

.collection-nest-list .article-item {
    margin: 0;
    border-bottom: 1px solid var(--line);
}

.collection-nest-list .article-item:last-child {
    border-bottom: 0;
}

.review-actions {
    display: flex;
    justify-content: flex-end;
}

.button.tiny {
    min-height: 26px;
    padding: 4px 9px;
    font-size: 12px;
}

.submit-panel {
    margin-top: 18px;
    padding: clamp(18px, 4vw, 26px);
    border-top: 1px solid var(--line);
    background: #fffdf8;
    display: grid;
    gap: 16px;
}

.submit-panel h2 {
    margin: 0 0 6px;
}

.submit-panel p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.public-submit-form {
    display: grid;
    gap: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: #f2f4f6;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}

.badge.blue {
    background: var(--blue-soft);
    color: var(--blue);
}

.badge.green {
    background: var(--green-soft);
    color: var(--green);
}

.badge.amber {
    background: var(--amber-soft);
    color: var(--amber);
}

.badge.red {
    background: var(--red-soft);
    color: var(--red);
}

.collection-badge {
    color: var(--collection-color, var(--blue));
    background: color-mix(in srgb, var(--collection-color, var(--blue)) 12%, white);
}

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

.empty {
    min-height: 280px;
    display: grid;
    place-items: center;
    padding: 32px;
    color: var(--muted);
    text-align: center;
    line-height: 1.8;
}

.search-page-main {
    width: min(1540px, 100%);
    display: block;
}

.search-content {
    min-width: 0;
}

.search-panel {
    height: auto;
    min-height: 0;
    margin-bottom: 18px;
    padding: clamp(18px, 3vw, 28px);
    border: 1px solid rgba(162, 74, 50, .22);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 14px 34px rgba(45, 35, 24, .10);
}

.record-search-panel {
    background:
        linear-gradient(180deg, rgba(255, 252, 246, .97), rgba(255, 253, 248, .98)),
        radial-gradient(circle at 84% 0%, rgba(216, 168, 78, .20), transparent 28%);
}

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

.search-panel-head h1 {
    margin: 0;
    font-size: clamp(28px, 5vw, 44px);
    line-height: 1.12;
}

.search-panel-head p {
    max-width: 680px;
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

.search-count {
    flex: 0 0 auto;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff8eb;
    color: var(--record-rust);
    font-size: 13px;
    font-weight: 750;
}

.search-form {
    display: grid;
    gap: 14px;
}

.search-box {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 8px 8px 8px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
}

.search-input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
    font-size: 18px;
}

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

.search-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.search-actions .muted {
    margin-right: auto;
    font-size: 13px;
}

.search-results {
    display: block;
    height: auto;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
}

.search-result-item {
    display: block;
    height: auto;
    min-height: 0;
    padding: 18px clamp(16px, 3vw, 24px);
    border-bottom: 1px solid var(--line);
}

.search-result-item:last-child {
    border-bottom: 0;
}

.search-result-item:hover {
    background: #fffaf0;
}

.search-result-title {
    width: fit-content;
    max-width: 100%;
    color: var(--blue);
    font-size: 20px;
    font-weight: 760;
    line-height: 1.35;
    word-break: break-word;
}

.search-result-title:hover {
    text-decoration: underline;
}

.search-snippet {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.72;
    word-break: break-word;
}

.search-snippet.compact {
    font-size: 13px;
}

.search-snippet.content-snippet {
    color: #374151;
}

.search-snippet.content-snippet strong {
    color: var(--ink);
}

.search-hit {
    padding: 0 2px;
    border-radius: 4px;
    background: #ffe28a;
    color: #20170f;
}

.search-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
}

.collection-admin-main {
    display: grid;
    gap: 18px;
}

.collection-admin-hero {
    min-height: 168px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    padding: clamp(22px, 5vw, 40px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(30, 48, 68, .92), rgba(61, 80, 82, .82)),
        radial-gradient(circle at 78% 12%, rgba(216, 168, 78, .34), transparent 28%);
    color: #fff8ec;
}

.collection-admin-hero h1 {
    margin: 0;
    font-size: clamp(28px, 5vw, 46px);
    line-height: 1.08;
}

.collection-admin-hero p {
    max-width: 700px;
    margin: 10px 0 0;
    color: rgba(255, 248, 236, .82);
    line-height: 1.7;
}

.collection-admin-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 16px;
    align-items: start;
}

.collection-admin-list {
    display: grid;
    gap: 10px;
}

.collection-admin-card,
.collection-admin-form {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow-soft);
}

.collection-admin-card {
    display: grid;
    gap: 10px;
    padding: 14px;
}

.collection-admin-pick {
    width: 100%;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 11px;
    align-items: start;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.collection-admin-pick strong {
    display: block;
    color: var(--ink);
    font-size: 18px;
    line-height: 1.32;
}

.collection-admin-pick em {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-style: normal;
    font-size: 13px;
    line-height: 1.55;
}

.collection-admin-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.collection-admin-form {
    position: sticky;
    top: 78px;
    display: grid;
    gap: 12px;
    padding: 16px;
}

.form-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.form-head h2 {
    margin: 0;
    font-size: 21px;
}

.form-head span {
    color: var(--muted);
    font-size: 12px;
}

.collection-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 104px;
    gap: 10px;
}

.collection-active-line {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfcfd;
}

.collection-admin-actions {
    justify-content: flex-end;
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 16px;
    align-items: stretch;
    height: 100%;
    min-height: 0;
}

.editor-panel {
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.editor-head {
    padding: 15px 16px;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 12px;
}

.title-input {
    width: 100%;
    border: 0;
    outline: 0;
    font-size: clamp(22px, 4vw, 34px);
    line-height: 1.25;
    font-weight: 800;
    color: var(--ink);
    background: transparent;
}

.title-input::placeholder {
    color: #a8b1b8;
}

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

.status-pill {
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    background: #f2f4f6;
    color: var(--muted);
}

.status-pill.saving {
    background: var(--amber-soft);
    color: var(--amber);
}

.status-pill.saved {
    background: var(--green-soft);
    color: var(--green);
}

.status-pill.error {
    background: var(--red-soft);
    color: var(--red);
}

.editor-body {
    min-height: 0;
    display: grid;
    overflow: hidden;
}

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

.article-textarea {
    width: 100%;
    min-height: 0;
    height: 100%;
    border: 0;
    outline: 0;
    resize: vertical;
    padding: 22px;
    color: var(--ink);
    background: #fff;
    line-height: 1.85;
    font-size: 16px;
    font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: auto;
}

.article-textarea.mono {
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 15px;
}

.preview-pane {
    display: none;
    min-height: 0;
    height: 100%;
    padding: 24px;
    background: #fff;
    overflow: auto;
    border-left: 1px solid var(--line);
    contain: layout paint;
}

.preview-pane.active,
.article-textarea.active {
    display: block;
}

.article-textarea:not(.active) {
    display: none;
}

.editor-body.split .article-textarea,
.editor-body.split .preview-pane {
    display: block;
    min-height: 0;
    height: 100%;
    resize: none;
}

.editor-body.split .article-textarea:not(.active) {
    display: block;
}

.meta-panel {
    padding: 13px;
    display: grid;
    gap: 12px;
    grid-template-rows: minmax(0, 1fr);
    position: sticky;
    top: 78px;
    max-height: calc(100dvh - 92px);
    overflow: hidden;
    align-content: start;
}

.meta-panel-head {
    display: none;
}

.meta-panel-scroll {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-right: 2px;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #a8b4c7 transparent;
}

.meta-panel-scroll::-webkit-scrollbar {
    width: 8px;
}

.meta-panel-scroll::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: #a8b4c7;
    background-clip: padding-box;
}

.meta-panel-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.meta-fold {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    padding: 0;
    overflow: hidden;
}

.meta-fold > summary {
    min-height: 38px;
    display: flex;
    align-items: center;
    padding: 0 11px;
    cursor: pointer;
    color: var(--ink);
    font-size: 13px;
    font-weight: 750;
    list-style: none;
}

.meta-fold > summary::-webkit-details-marker {
    display: none;
}

.meta-fold > summary::after {
    content: "+";
    margin-left: auto;
    color: var(--muted);
}

.meta-fold[open] > summary {
    border-bottom: 1px solid var(--line);
    background: #f6f9ff;
}

.meta-fold[open] > summary::after {
    content: "-";
}

.meta-fold > :not(summary) {
    margin: 11px;
}

.toggle-line {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-top: 1px solid var(--line);
}

.toggle-line:first-child {
    border-top: 0;
}

.switch {
    position: relative;
    width: 46px;
    height: 26px;
    flex: 0 0 auto;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    border-radius: 999px;
    background: #c8d0d6;
    transition: background .18s ease;
}

.slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, .22);
    transition: transform .18s ease;
}

.switch input:checked + .slider {
    background: var(--blue);
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
}

.share-box {
    display: grid;
    gap: 8px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

.collection-box {
    border-color: #cbd8f7;
    background: linear-gradient(180deg, #fbfcff, #f7fbf8);
}

.color-line {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
}

.color-swatch {
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
}

.share-url {
    width: 100%;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 7px 9px;
    background: #fff;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.reader-wrap {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 28px clamp(16px, 4vw, 36px) 56px;
}

.reader-panel {
    padding: clamp(22px, 5vw, 44px);
}

.comments-panel {
    margin-top: 18px;
    padding: clamp(18px, 4vw, 28px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.comments-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.comments-head h2 {
    margin: 0;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.comment-form {
    display: grid;
    gap: 10px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.comment-form-inline {
    margin: 8px 0 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--blue);
    border-radius: 0 8px 8px 0;
    background: #fbfcff;
}

.comment-login-hint {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #fbfcfd;
}

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

.comment-identity-row {
    display: grid;
    grid-template-columns: minmax(0, 180px) minmax(0, 1fr);
    gap: 10px;
}

.comment-identity-row label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.comment-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.comment-item {
    border-left: 3px solid var(--line);
    padding: 11px 12px 11px 13px;
    margin-left: calc(var(--depth, 0) * 20px);
    background: #fbfcfd;
    border-radius: 0 8px 8px 0;
}

.comment-item.depth-limited {
    margin-left: 80px;
}

.comment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
}

.comment-author {
    color: var(--ink);
    font-weight: 750;
}

.comment-content {
    white-space: pre-wrap;
    line-height: 1.75;
}

.comment-reply-to {
    display: inline-flex;
    width: fit-content;
    max-width: 100%;
    margin-bottom: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 12px;
    font-weight: 650;
}

.comment-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.comment-action {
    border: 0;
    background: transparent;
    color: var(--blue);
    padding: 0;
    cursor: pointer;
    font-size: 13px;
}

.reader-title {
    margin: 0;
    font-size: clamp(28px, 6vw, 46px);
    line-height: 1.18;
    letter-spacing: 0;
}

.reader-author {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 15px;
}

.reader-author strong {
    color: var(--ink);
    font-size: 18px;
}

.reader-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 16px;
}

.reader-extra {
    display: grid;
    gap: 8px;
    margin: 0 0 26px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

.reader-extra-row {
    display: grid;
    grid-template-columns: auto 42px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    line-height: 1.65;
    color: var(--muted);
    font-size: 14px;
}

.reader-extra-row strong {
    color: var(--ink);
    min-width: 42px;
}

.plain-content,
.render-content {
    font-size: 16px;
    line-height: 1.9;
    word-break: break-word;
}

.plain-content {
    white-space: pre-wrap;
}

.render-content h1,
.render-content h2,
.render-content h3,
.render-content h4 {
    margin: 1.4em 0 .6em;
    line-height: 1.32;
}

.render-content p {
    margin: .75em 0;
    white-space: pre-wrap;
}

.render-content h1 {
    font-size: 1.8em;
}

.render-content h2 {
    font-size: 1.48em;
    border-bottom: 2px solid var(--line);
    padding-bottom: 8px;
}

.render-content h3 {
    font-size: 1.25em;
}

.render-content h4 {
    font-size: 1.12em;
}

.render-content ul,
.render-content ol {
    padding-left: 1.6em;
}

.render-content blockquote {
    margin: 1em 0;
    padding: 10px 16px;
    border-left: 4px solid var(--green);
    background: var(--green-soft);
}

.render-content code {
    background: #eef1f4;
    border-radius: 5px;
    padding: 2px 6px;
    font-family: Consolas, Monaco, "Courier New", monospace;
}

.render-content pre {
    overflow: auto;
    border-radius: 8px;
    background: #111827;
    color: #e5e7eb;
    padding: 0;
}

.render-content pre code {
    display: block;
    background: transparent;
    padding: 16px;
    color: inherit;
    white-space: pre;
}

.render-content .code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: #1f2937;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    font-size: 12px;
    font-family: Consolas, Monaco, "Courier New", monospace;
}

.render-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.render-content th,
.render-content td {
    border: 1px solid var(--line);
    padding: 9px 11px;
    text-align: left;
}

.render-content th {
    background: #f3f6f8;
}

.render-content img {
    max-width: 100%;
    border-radius: 8px;
}

.render-content .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 0;
}

.math-fallback {
    color: var(--amber);
    font-family: Consolas, Monaco, "Courier New", monospace;
}

.mermaid-container {
    margin: 18px 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    overflow: auto;
}

.mermaid-container svg {
    max-width: 100%;
    height: auto;
}

.toast-zone {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 80;
    display: grid;
    gap: 8px;
}

.toast {
    max-width: min(360px, calc(100vw - 36px));
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
    color: var(--ink);
    font-size: 14px;
}

.toast.success {
    border-color: #9fd7bd;
    color: var(--green);
}

.toast.error {
    border-color: #f1b8b3;
    color: var(--red);
}

.dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(17, 24, 39, .42);
    backdrop-filter: blur(6px);
}

.dialog {
    width: min(420px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
    padding: 18px;
}

.dialog h2 {
    margin: 0 0 8px;
    font-size: 18px;
    line-height: 1.35;
}

.dialog p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.revision-list {
    display: grid;
    gap: 12px;
}

.revision-item {
    display: grid;
    gap: 9px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.revision-content {
    max-height: 240px;
    overflow: auto;
    white-space: pre-wrap;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfcfd;
    color: #374151;
    line-height: 1.75;
}

@media (max-width: 1023px) {
    .editor-body.split {
        grid-template-columns: 1fr;
    }

    .editor-body.split .preview-pane {
        display: none;
    }

    .editor-body.split .preview-pane.active {
        display: block;
    }

    .editor-body.split .article-textarea:not(.active) {
        display: none;
    }
}

@media (max-width: 880px) {
    .record-hero {
        align-items: flex-start;
        flex-direction: column;
        padding: 20px;
    }

    .record-hero h1 {
        font-size: 28px;
    }

    .collection-admin-hero {
        align-items: flex-start;
        flex-direction: column;
        padding: 20px;
    }

    .collection-admin-layout,
    .collection-form-grid {
        grid-template-columns: 1fr;
    }

    .collection-admin-form {
        position: static;
    }

    .collection-admin-actions {
        justify-content: stretch;
    }

    .collection-admin-actions .button {
        flex: 1 1 140px;
    }

    .article-item {
        padding: 15px 14px;
    }

    .article-meta-line {
        align-items: flex-start;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 6px 12px;
    }

    .article-meta-line .review-toggle {
        margin-left: 0;
    }

    body.word-editor-page {
        height: auto;
        overflow: auto;
    }

    body.word-editor-page .app-shell {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .worktop,
    .editor-layout {
        grid-template-columns: 1fr;
    }

    .side-panel,
    .worktop .meta-panel {
        display: none;
    }

    .word-editor-page .meta-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 69;
        display: none;
        max-height: calc(100dvh - 42px);
        grid-template-rows: auto minmax(0, 1fr);
        gap: 0;
        overflow: hidden;
        padding: 0;
        border: 1px solid var(--line);
        border-bottom: 0;
        border-radius: 18px 18px 0 0;
        background: #fff;
        box-shadow: 0 -18px 48px rgba(17, 24, 39, .18);
    }

    .word-editor-page.mobile-tools-open .meta-panel {
        display: grid;
    }

    .word-editor-page .meta-panel-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 18px 16px 12px;
        border-bottom: 1px solid var(--line);
        background:
            linear-gradient(90deg, rgba(38, 99, 235, .10), rgba(16, 185, 129, .07)),
            #fff;
    }

    .word-editor-page .meta-panel-head::before {
        content: "";
        position: absolute;
        top: 8px;
        left: 50%;
        width: 44px;
        height: 4px;
        border-radius: 999px;
        background: #cbd5e1;
        transform: translateX(-50%);
    }

    .word-editor-page .meta-panel-head strong {
        display: block;
        color: var(--ink);
        font-size: 15px;
        line-height: 1.2;
    }

    .word-editor-page .meta-panel-head span {
        display: block;
        margin-top: 3px;
        color: var(--muted);
        font-size: 12px;
        line-height: 1.3;
    }

    .word-editor-page .meta-close {
        width: 34px;
        height: 34px;
        font-size: 20px;
        line-height: 1;
    }

    .word-editor-page .meta-panel-scroll {
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 12px 12px 28px;
        gap: 10px;
        scrollbar-gutter: stable both-edges;
        scrollbar-width: thin;
        scrollbar-color: #94a3b8 #eef2f7;
    }

    .word-editor-page .meta-panel-scroll::-webkit-scrollbar {
        width: 10px;
    }

    .word-editor-page .meta-panel-scroll::-webkit-scrollbar-thumb {
        border: 3px solid #eef2f7;
        border-radius: 999px;
        background: #94a3b8;
    }

    .word-editor-page .meta-panel-scroll::-webkit-scrollbar-track {
        background: #eef2f7;
    }

    .word-editor-page .meta-fold {
        border-color: #d9e1ec;
        background: #fff;
        box-shadow: 0 8px 22px rgba(15, 23, 42, .05);
    }

    .word-editor-page .meta-fold[open] {
        border-color: #b9c9e8;
        box-shadow: 0 12px 28px rgba(38, 99, 235, .10);
    }

    .word-editor-page .meta-fold > summary {
        min-height: 42px;
        padding: 0 12px;
        font-size: 13px;
    }

    .word-editor-page .meta-fold > :not(summary) {
        margin: 10px 12px;
    }

    .word-editor-page .meta-panel .input,
    .word-editor-page .meta-panel .select {
        min-height: 38px;
    }

    .word-editor-page .meta-panel .textarea {
        min-height: 84px;
    }

    .editor-panel {
        height: auto;
        min-height: auto;
    }

    .editor-layout {
        height: auto;
    }

    .editor-body {
        overflow: visible;
    }

    .article-textarea,
    .preview-pane {
        min-height: 58vh;
        height: auto;
    }

    .topbar {
        flex-wrap: wrap;
    }

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

    .comment-item {
        margin-left: calc(var(--depth, 0) * 10px);
    }

    .comment-item.depth-limited {
        margin-left: 40px;
    }

    .revision-item .article-row {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .revision-item .topbar-spacer {
        display: none;
    }

    .revision-item .restore-btn {
        width: 100%;
    }

    .editor-main {
        height: auto;
        overflow: visible;
        padding-bottom: 18px;
    }

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

    .side-panel {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 95;
        width: min(360px, calc(100vw - 48px));
        max-height: none;
        overflow-y: auto;
        display: block;
        padding: 14px;
        border-radius: 0;
        border: 0;
        border-right: 1px solid var(--line);
        background: var(--panel);
        box-shadow: 18px 0 48px rgba(45, 35, 24, .22);
        transform: translateX(-105%);
        transition: transform .18s ease;
    }

    body.sidebar-open .side-panel {
        transform: translateX(0);
    }

    .drawer-head {
        min-height: 42px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 0 0 12px;
        margin-bottom: 12px;
        border-bottom: 1px solid var(--line);
    }

    .drawer-head strong {
        font-size: 16px;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 94;
        display: none;
        background: rgba(45, 35, 24, .36);
        backdrop-filter: blur(4px);
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .search-page-main {
        padding-top: 16px;
    }

    .search-panel {
        padding: 16px;
    }

    .search-panel-head {
        display: grid;
        gap: 10px;
        margin-bottom: 14px;
    }

    .search-count {
        width: fit-content;
    }

    .search-box {
        grid-template-columns: 18px minmax(0, 1fr);
        min-height: 50px;
    }

    .search-box .button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .search-input {
        font-size: 16px;
    }

    .search-filters {
        grid-template-columns: 1fr;
    }

    .search-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .search-actions .muted {
        grid-column: 1 / -1;
    }

    .search-actions .button {
        width: 100%;
    }

    .search-result-title {
        font-size: 18px;
    }
}

@media print {
    .topbar,
    .button,
    .icon-button {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .reader-wrap {
        padding: 0;
    }

    .reader-panel {
        border: 0;
        padding: 0;
    }
}
