:root {
    --paper: #f6f3ed;
    --panel: #fffdfa;
    --ink: #232725;
    --muted: #7e847e;
    --line: #dddcd4;
    --line-strong: #c8c9c0;
    --teal: #0d766d;
    --teal-soft: #e6f1ed;
    --orange: #d67b42;
    --orange-soft: #faeee3;
    --coral: #c65d53;
    --shadow: 0 16px 40px rgba(37, 43, 39, .07);
    --radius: 8px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body {
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(13, 118, 109, .045) 1px, transparent 1px) 0 0 / 48px 48px,
        var(--paper);
    font-family: "Aptos", "Segoe UI", "Microsoft YaHei", sans-serif;
    letter-spacing: 0;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; }
.topbar {
    height: 78px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: rgba(246, 243, 237, .92);
}
.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--teal);
    border-radius: 6px;
    font-weight: 800;
    box-shadow: 4px 4px 0 #b7d2c9;
}
.eyebrow, .section-kicker {
    margin: 0;
    color: var(--teal);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.4px;
}
.brand-block h1 { margin: 2px 0 0; font-size: 17px; letter-spacing: .5px; }
.topbar-meta { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #3a9b73; box-shadow: 0 0 0 4px #dcefe4; }
.meta-divider { width: 1px; height: 14px; margin: 0 4px; background: var(--line-strong); }
.workspace {
    width: min(1480px, calc(100% - 48px));
    min-height: calc(100vh - 122px);
    margin: 24px auto 0;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 24px;
}
.panel-border {
    border: 1px solid var(--line);
    background: rgba(255, 253, 250, .84);
    box-shadow: var(--shadow);
}
.sidebar { min-height: 0; padding: 22px 18px 16px; display: flex; flex-direction: column; border-radius: var(--radius); }
.sidebar-heading, .list-heading, .content-toolbar, .toolbar-actions { display: flex; align-items: center; justify-content: space-between; }
.sidebar-heading h2 { margin: 5px 0 0; font-size: 20px; }
.record-count {
    min-width: 32px;
    padding: 5px 8px;
    text-align: center;
    color: var(--teal);
    background: var(--teal-soft);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 800;
}
.search-box {
    height: 42px;
    margin: 20px 0 16px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    background: #fff;
}
.search-box > span { color: var(--teal); font-size: 22px; line-height: 1; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.search-box input::placeholder { color: #a3a69f; }
kbd { padding: 2px 5px; color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; font-size: 10px; }
.filter-stack { display: grid; gap: 7px; }
.field-label { color: var(--muted); font-size: 11px; font-weight: 700; }
select {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 4px;
    outline: 0;
    background: #fff;
    font-size: 12px;
}
select:focus, .search-box:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13, 118, 109, .1); }
.library-rule { height: 1px; margin: 20px 0 14px; background: var(--line); }
.list-heading { margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 800; }
.text-button { padding: 0; color: var(--teal); border: 0; background: transparent; font-size: 11px; }
.text-button:hover { color: var(--coral); }
.record-list { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.record-item {
    width: 100%;
    padding: 11px 10px 11px 12px;
    display: grid;
    grid-template-columns: 27px 1fr;
    gap: 9px;
    text-align: left;
    border: 0;
    border-left: 2px solid transparent;
    background: transparent;
    color: var(--ink);
}
.record-item:hover { background: #f1f4ee; }
.record-item.is-active { border-left-color: var(--orange); background: var(--orange-soft); }
.record-number { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.record-item.is-active .record-number { color: var(--orange); font-weight: 800; }
.record-title { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; font-weight: 700; }
.record-source { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; font-size: 10px; }
.list-empty { padding: 24px 10px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.content-area { min-width: 0; padding: 5px 0 38px; }
.content-toolbar { min-height: 32px; border-bottom: 1px solid var(--line); }
.breadcrumb { overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
.toolbar-actions { gap: 6px; }
.icon-text-button {
    padding: 6px 9px;
    color: var(--muted);
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    font-size: 11px;
}
.icon-text-button span { margin-right: 3px; color: var(--teal); font-size: 15px; line-height: 0; vertical-align: -1px; }
.icon-text-button:hover { color: var(--ink); border-color: var(--line); background: #fff; }
.question-header { padding: 34px 4px 22px; display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 18px; align-items: end; }
.question-index { color: var(--orange); font-size: 42px; font-weight: 800; line-height: .9; letter-spacing: -1px; }
.question-copy h2 { max-width: 850px; margin: 5px 0 0; font-size: 38px; line-height: 1.2; letter-spacing: 0; overflow-wrap: anywhere; }
.question-copy p { margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.question-stats { padding: 9px 12px; border-left: 1px solid var(--line-strong); text-align: right; }
.stat-label { display: block; color: var(--muted); font-size: 10px; }
.question-stats strong { display: block; margin-top: 4px; color: var(--teal); font-size: 16px; font-variant-numeric: tabular-nums; }
.study-note { min-height: 38px; margin-bottom: 20px; padding: 9px 12px; display: flex; align-items: center; gap: 8px; color: #68756f; border: 1px solid #d5e5dc; background: var(--teal-soft); font-size: 11px; }
.note-mark { width: 16px; height: 16px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; border-radius: 50%; background: var(--teal); font-family: Georgia, serif; font-weight: 800; }
.tree-stage { padding: 0 4px; }
.tree-root { display: grid; gap: 9px; }
.tree-node { position: relative; border-left: 2px solid #cbded6; }
.tree-node.depth-1 { border-left-color: var(--teal); }
.tree-node.depth-2 { border-left-color: #b6d0c7; }
.tree-node.depth-3, .tree-node.depth-4 { border-left-color: #d8c6ad; }
.tree-node-head { min-height: 48px; padding: 11px 14px; display: flex; align-items: flex-start; gap: 9px; background: rgba(255, 253, 250, .83); }
.tree-toggle {
    width: 21px;
    height: 21px;
    padding: 0;
    flex: 0 0 auto;
    color: var(--teal);
    border: 1px solid #abd0c5;
    border-radius: 4px;
    background: #f4faf7;
    line-height: 17px;
    font-size: 16px;
    font-weight: 700;
}
.tree-toggle:hover { color: #fff; background: var(--teal); }
.tree-toggle.no-children { color: var(--orange); border-color: #edc7a6; background: #fff8f1; cursor: default; }
.tree-node-title { min-width: 0; padding-top: 2px; font-size: 14px; font-weight: 800; line-height: 1.5; overflow-wrap: anywhere; }
.tree-node-body { margin: 0 14px 12px 44px; padding: 12px 14px; color: #4f5752; border-left: 1px solid var(--line); background: #fff; font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.tree-node-text { white-space: pre-wrap; }
.content-table-wrap { max-width: 100%; margin: 2px 0; overflow-x: auto; overscroll-behavior-x: contain; }
.content-table { width: max-content; min-width: 100%; border-collapse: collapse; background: #fff; font-size: 12px; line-height: 1.65; }
.content-table th, .content-table td { min-width: 116px; padding: 8px 10px; color: #4f5752; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.content-table th { color: var(--teal); background: #f1f7f3; font-weight: 800; white-space: nowrap; }
.content-table td:first-child { color: var(--ink); font-weight: 700; background: #fbfaf6; }
.tree-node-children { margin: 0 0 10px 29px; display: grid; gap: 8px; }
.tree-node.is-collapsed .tree-node-body, .tree-node.is-collapsed .tree-node-children { display: none; }
.tree-node:not(.is-collapsed) > .tree-node-head { background: #f7fbf8; }
.tree-node:not(.is-collapsed) > .tree-node-head .tree-node-title { color: var(--teal); }
.empty-state { min-height: 300px; padding: 60px 20px; display: grid; place-items: center; align-content: center; text-align: center; border: 1px dashed var(--line-strong); background: rgba(255, 253, 250, .5); }
.empty-glyph { color: var(--orange); font-size: 30px; }
.empty-state h3 { margin: 15px 0 5px; font-size: 16px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 12px; }
.app-footer { width: min(1480px, calc(100% - 48px)); margin: 18px auto 0; padding: 0 4px 22px; display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.error-panel { width: min(700px, calc(100% - 48px)); margin: 14vh auto; padding: 36px; border: 1px solid #e3c8c2; background: #fff8f5; }
.error-code { color: var(--coral); font-size: 10px; font-weight: 800; letter-spacing: 1.5px; }
.error-panel h2 { margin: 12px 0 8px; }
.error-panel p { margin: 0; color: var(--muted); font-size: 13px; }
@media (max-width: 920px) {
    .topbar { height: 68px; padding: 0 18px; }
    .topbar-meta { display: none; }
    .workspace { width: min(100% - 28px, 720px); margin-top: 14px; display: block; }
    .sidebar { max-height: 380px; margin-bottom: 18px; }
    .record-list { max-height: 190px; }
    .content-area { padding-bottom: 20px; }
    .question-header { padding-top: 25px; grid-template-columns: 43px minmax(0, 1fr); gap: 12px; }
    .question-index { font-size: 31px; }
    .question-stats { grid-column: 2; justify-self: start; padding: 0; border-left: 0; text-align: left; }
    .app-footer { width: min(100% - 28px, 720px); }
}
@media (max-width: 560px) {
    .workspace, .app-footer { width: calc(100% - 20px); }
    .topbar { padding: 0 12px; }
    .brand-block h1 { font-size: 15px; }
    .content-toolbar { align-items: flex-start; flex-direction: column; gap: 8px; padding-bottom: 8px; }
    .toolbar-actions { width: 100%; justify-content: flex-end; }
    .question-header { padding-left: 0; padding-right: 0; }
    .question-copy h2 { font-size: 25px; }
    .tree-stage { padding: 0; }
    .tree-node-head { padding-left: 10px; padding-right: 9px; }
    .tree-node-body { margin-left: 38px; padding: 10px; font-size: 12px; }
    .content-table { min-width: 560px; font-size: 11px; }
    .content-table th, .content-table td { min-width: 108px; padding: 7px 8px; }
    .tree-node-children { margin-left: 18px; }
    .app-footer { gap: 8px; flex-direction: column; }
}
