:root {
  --bg: #f5f0e4;
  --surface: #fffdf7;
  --paper: #fffaf0;
  --ink: #173a3a;
  --muted: #6e7977;
  --line: #ded5c4;
  --accent: #f2ad21;
  --accent-strong: #e46a47;
  --teal: #237a78;
  --soft: #dcefed;
  --shadow: 0 10px 30px rgba(54, 49, 36, .10);
  --editor-size: 16px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
html { scrollbar-color: var(--muted) var(--surface); scrollbar-width: thin; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-track { background: var(--surface); }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 70%, var(--surface)); border: 3px solid var(--surface); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }
body { color: var(--ink); background: var(--bg); font-family: Inter, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif; overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 72%, white); outline-offset: 2px; }

.theme-academic {
  --bg: #e9edf2; --surface: #fff; --paper: #fff; --ink: #17293d; --muted: #647386;
  --line: #d7dee8; --accent: #356fbb; --accent-strong: #284f87; --teal: #276a8b; --soft: #eaf1fa;
}
.theme-ink {
  --bg: #dfe8e1; --surface: #f8fbf6; --paper: #fbfdf8; --ink: #143d31; --muted: #65766d;
  --line: #cbd8cd; --accent: #d69f35; --accent-strong: #9b5542; --teal: #1f6d56; --soft: #e0efe6;
}

.app-header { height: 64px; display: flex; align-items: center; gap: 22px; padding: 0 18px; background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 235px; }
.brand-lockup strong { display: block; font-size: 17px; letter-spacing: .5px; }
.brand-lockup small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.brand-dot { width: 17px; height: 17px; border-radius: 6px 50% 50% 50%; transform: rotate(45deg); background: linear-gradient(135deg, var(--accent), var(--accent-strong)); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 16%, transparent); }
.notebook-title { flex: 1; min-width: 120px; max-width: 440px; border: 1px solid transparent; border-radius: 8px; padding: 8px 10px; background: transparent; font-weight: 650; text-align: center; color: var(--ink); }
.notebook-title:hover, .notebook-title:focus { border-color: var(--line); background: var(--paper); outline: none; }
.book-switcher { display: flex; align-items: center; gap: 6px; min-width: 220px; }
.book-switcher select { width: 165px; padding: 8px 28px 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font-weight: 650; }
.button.compact { padding: 8px 10px; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.save-status { color: var(--muted); font-size: 12px; min-width: 64px; text-align: right; }

.button { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 9px 13px; cursor: pointer; transition: .18s ease; white-space: nowrap; }
.button:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.button:disabled { opacity: .58; cursor: not-allowed; transform: none; box-shadow: none; }
.button.primary { background: var(--ink); border-color: var(--ink); color: white; }
.button.danger { background: var(--accent-strong); border-color: var(--accent-strong); color: white; }
.button.ghost { background: transparent; }
.button.full { width: 100%; }

.workspace { height: calc(100vh - 64px); height: calc(100dvh - 64px); display: flex; }
.sidebar { width: 250px; flex: 0 0 250px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: relative; z-index: 15; }
.sidebar-head { padding: 15px 13px 11px; border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 9px; margin-top: 10px; padding: 8px 10px; background: var(--paper); color: var(--muted); }
.search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
.search input::-webkit-search-cancel-button { display: none; }
.search button { width: 28px; height: 28px; flex: 0 0 28px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.search button:hover { color: var(--ink); background: var(--soft); }
.note-list { padding: 8px; overflow: auto; flex: 1; }
.note-item { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 29px; align-items: stretch; border: 1px solid transparent; border-radius: 10px; background: transparent; margin: 2px 0; overflow: hidden; }
.note-item:hover { background: color-mix(in srgb, var(--soft) 55%, transparent); }
.note-item.active { background: var(--soft); border-color: color-mix(in srgb, var(--teal) 22%, transparent); }
.note-open { width: 100%; min-width: 0; border: 0; background: transparent; padding: 10px 7px 10px 11px; text-align: left; color: inherit; cursor: pointer; }
.note-item-title, .note-item-preview, .note-item-time { display: block; }
.note-item-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13.5px; font-weight: 700; }
.note-item-preview { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); margin-top: 4px; font-size: 10.5px; }
.note-item-time { color: var(--muted); margin-top: 4px; font-size: 10px; }
.note-item mark { padding: 0 1px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 48%, transparent); color: var(--ink); }
.chapter-drag-handle { width: 27px; height: 100%; min-height: 58px; border: 0; border-radius: 7px; padding: 0; background: transparent; color: var(--muted); cursor: grab !important; touch-action: none; letter-spacing: -2px; opacity: .42; font-size: 14px; line-height: 1; }
.note-item:hover .chapter-drag-handle, .note-item:focus-within .chapter-drag-handle { opacity: 1; background: var(--surface); color: var(--teal); }
.chapter-drag-handle:active { cursor: grabbing !important; }
.note-list.searching .chapter-drag-handle { visibility: hidden; pointer-events: none; }
.note-item.sortable-ghost { opacity: .35; background: var(--soft); }
.search-empty { padding: 24px 12px; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; }
.sidebar-foot { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; }
.text-button { border: 0; background: transparent; color: var(--teal); font-size: 12px; cursor: pointer; padding: 5px 2px; }
.text-button.danger { color: #b85f4a; }

.main-panel { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.note-head { min-height: 60px; padding: 9px 18px 8px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 15px; }
.note-title { border: 0; outline: none; background: transparent; color: var(--ink); font-size: 20px; font-weight: 750; flex: 1; min-width: 0; }
.note-meta { color: var(--muted); font-size: 11px; display: flex; gap: 12px; white-space: nowrap; }

.toolbar { min-height: 44px; background: var(--surface); border-bottom: 1px solid var(--line); padding: 5px 16px; display: flex; align-items: center; gap: 4px; overflow-x: auto; }
.toolbar button { min-width: 34px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 7px; background: transparent; cursor: pointer; color: var(--muted); white-space: nowrap; }
.toolbar button:hover { color: var(--ink); border-color: var(--line); background: var(--paper); }
.toolbar-spacer { flex: 1; }

.content-grid { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(300px, 1fr) minmax(330px, 1fr) 205px; background: var(--bg); }
.editor-pane, .preview-pane, .toc-pane { min-width: 0; min-height: 0; overflow: auto; }
.editor-pane { border-right: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 75%, var(--bg)); }
#editor { width: 100%; height: 100%; resize: none; border: 0; outline: 0; background: transparent; padding: 26px 28px 50vh; color: var(--ink); font-family: "Cascadia Code", "SFMono-Regular", Consolas, "Microsoft YaHei UI", monospace; font-size: var(--editor-size); line-height: 1.78; tab-size: 4; }
.preview-pane { background: var(--bg); padding: 24px; }
#preview { max-width: 820px; min-height: 100%; margin: 0 auto; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 45px 54px 100px; }
.toc-pane { border-left: 1px solid var(--line); background: var(--surface); padding: 19px 13px 40px; }
.toc-title { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; margin: 0 8px 10px; }
#tocList a { display: flex; align-items: baseline; gap: 5px; padding: 6px 8px; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; font-size: 12px; line-height: 1.4; }
#tocList a:hover, #tocList a.active { color: var(--teal); border-color: var(--accent); background: var(--soft); }
#tocList a.level-2 { padding-left: 18px; } #tocList a.level-3 { padding-left: 29px; font-size: 11px; }
.toc-entry-title { min-width: 0; overflow-wrap: anywhere; }
.toc-leader { min-width: 12px; flex: 1; border-bottom: 1px dotted currentColor; opacity: .55; transform: translateY(-.22em); }
.toc-page { flex: none; font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.toc-empty { color: var(--muted); font-size: 12px; padding: 8px; }

.markdown-body { font-family: "Noto Serif SC", "Source Han Serif SC", "Microsoft YaHei UI", "Microsoft YaHei", serif; color: var(--ink); font-size: 16px; line-height: 1.9; word-break: break-word; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { line-height: 1.4; margin-top: 1.7em; margin-bottom: .7em; scroll-margin-top: 24px; font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif; }
.markdown-body h1 { font-size: 2em; border-bottom: 2px solid var(--accent); padding-bottom: .28em; }
.markdown-body h2 { font-size: 1.5em; color: var(--teal); border-bottom: 1px solid var(--line); padding-bottom: .28em; }
.markdown-body h3 { font-size: 1.22em; }
.markdown-body h1:first-child { margin-top: 0; }
.markdown-body p { margin: .7em 0; }
.markdown-body a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.markdown-body blockquote { margin: 1.2em 0; padding: .8em 1.1em; border-left: 4px solid var(--accent); background: color-mix(in srgb, var(--soft) 60%, transparent); border-radius: 0 8px 8px 0; color: color-mix(in srgb, var(--ink) 88%, white); }
.markdown-body blockquote p:first-child { margin-top: 0; } .markdown-body blockquote p:last-child { margin-bottom: 0; }
.markdown-body .table-wrap { width: 100%; overflow-x: auto; margin: 1.3em 0; border-radius: 7px; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 0; font-size: .92em; display: table; }
.markdown-body .wide-table table { min-width: 680px; font-size: .86em; }
.markdown-body .nested-table { margin: .45em 0; overflow: visible; border-radius: 5px; }
.markdown-body .nested-table table { min-width: 0; font-size: .92em; background: var(--surface); }
.markdown-body td > .nested-table:first-child { margin-top: 0; }
.markdown-body td > .nested-table:last-child { margin-bottom: 0; }
.markdown-body th, .markdown-body td { border: 1px solid var(--line); padding: .55em .75em; text-align: left; }
.markdown-body th { background: var(--soft); font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif; }
.markdown-body td[rowspan], .markdown-body td[colspan], .markdown-body th[rowspan], .markdown-body th[colspan] { vertical-align: middle; }
.markdown-body tr:nth-child(even) td { background: color-mix(in srgb, var(--soft) 22%, transparent); }
.markdown-body pre { margin: 1.2em 0; border: 1px solid var(--line); border-radius: 9px; padding: 1em 1.1em; overflow: auto; background: #f6f8fa; line-height: 1.6; position: relative; }
.markdown-body pre.has-language { padding-top: 2.25em; }
.markdown-body pre.has-language::before { content: attr(data-language); position: absolute; top: 0; right: 0; padding: .28em .75em; border: 0 solid var(--line); border-width: 0 0 1px 1px; border-radius: 0 8px 0 7px; color: var(--muted); background: var(--soft); font: 700 10px "Segoe UI", sans-serif; letter-spacing: .5px; text-transform: uppercase; }
.markdown-body code { font-family: "Cascadia Code", Consolas, monospace; font-size: .88em; }
.markdown-body :not(pre) > code { color: #a64f38; background: #f5ece5; border-radius: 4px; padding: .15em .35em; }
.markdown-body img { max-width: 100%; height: auto; border-radius: 6px; }
.markdown-body hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.markdown-body .katex-display { overflow-x: auto; overflow-y: hidden; padding: .8em .2em; }
.markdown-body .formula-wide { font-size: .92em; }
.markdown-body .formula-ultrawide { font-size: .82em; }
.markdown-body .task-list-item { list-style: none; margin-left: -1.2em; }
.markdown-body input.task-list-item-checkbox { margin-right: .55em; accent-color: var(--teal); }
.markdown-body .footnotes { font-size: .86em; color: var(--muted); border-top: 1px solid var(--line); margin-top: 3em; }
.markdown-body blockquote.callout { border-left-width: 5px; padding-top: 1em; padding-bottom: 1em; }
.markdown-body .callout-definition { border-color: #397db4; background: #eaf3fa; }
.markdown-body .callout-theorem { border-color: #7a55a3; background: #f1eaf8; }
.markdown-body .callout-proof { border-color: var(--teal); background: var(--soft); }
.markdown-body .callout-note { border-color: var(--accent-strong); background: #fff0d8; }
.page-break-marker { border-top: 2px dashed var(--accent-strong); color: var(--accent-strong); margin: 2em 0; position: relative; }
.page-break-marker::after { content: "PDF 分页"; position: absolute; left: 50%; transform: translate(-50%, -50%); background: var(--paper); padding: 0 8px; font: 11px "Segoe UI", sans-serif; }
.render-error { background: #ffe5de; border: 1px solid #d67762; border-radius: 8px; padding: 12px; color: #7d2e20; }

.floating-settings { position: fixed; right: 18px; bottom: 16px; z-index: 30; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--ink); color: white; box-shadow: var(--shadow); cursor: pointer; }
dialog { border: 0; background: transparent; padding: 0; }
dialog::backdrop { background: rgba(15, 31, 31, .45); backdrop-filter: blur(3px); }
.dialog-card { width: min(420px, calc(100vw - 32px)); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 18px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.dialog-head h2 { margin: 0; } .dialog-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.dialog-head button { border: 0; background: transparent; font-size: 25px; cursor: pointer; }
.dialog-card label { display: grid; gap: 7px; margin: 15px 0; color: var(--muted); font-size: 13px; }
.dialog-card select, .dialog-card input[type="range"], .dialog-card input[type="text"], .dialog-card input:not([type]) { width: 100%; }
.dialog-card select, .dialog-card input[type="text"], .dialog-card input:not([type]) { padding: 10px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; }
.dialog-error { margin: 8px 0 0; color: #8f3525; font-size: 13px; }
.dialog-wide { width: min(650px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 40px)); max-height: min(760px, calc(100dvh - 40px)); overflow: auto; }
.inline-create { display: flex; gap: 8px; margin-bottom: 14px; }
.inline-create input { flex: 1; }
.book-manager-list, .export-book-list { display: grid; gap: 8px; max-height: 380px; overflow: auto; }
.book-manager-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.book-manager-item.active { border-color: var(--teal); background: var(--soft); }
.book-manager-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-manager-item small { display: block; color: var(--muted); margin-top: 3px; }
.book-item-actions { display: flex; gap: 5px; }
.book-item-actions button { border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 6px 8px; cursor: pointer; font-size: 11px; }
.book-item-actions .danger { color: #b85f4a; }
.dialog-two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detected-tags { display: flex; flex-wrap: wrap; gap: 6px; min-height: 29px; margin: 4px 0 16px; }
.detected-tags span { border-radius: 999px; padding: 5px 9px; background: var(--soft); color: var(--teal); font-size: 11px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.export-book-list label { display: flex; grid-template-columns: none; align-items: center; gap: 10px; margin: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--ink); cursor: pointer; }
.export-book-list input, .export-modes input { accent-color: var(--teal); }
.export-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 2px; }
.export-modes label { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); }
.dialog-export { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; }
.export-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.export-selection-summary { margin: 8px 0; color: var(--muted); font-size: 13px; }
.export-selection-list { display: grid; gap: 10px; max-height: 360px; overflow: auto; padding-right: 4px; }
.export-book-section { border: 1px solid var(--line); border-radius: 11px; background: var(--paper); overflow: hidden; }
.export-book-heading { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 10px !important; margin: 0 !important; padding: 11px 13px; color: var(--ink) !important; background: var(--soft); cursor: pointer; }
.export-book-heading span { display: flex; align-items: baseline; gap: 8px; }
.export-book-heading small { color: var(--muted); }
.export-chapter-list { display: grid; }
.export-chapter-row { display: grid; grid-template-columns: 22px minmax(150px, .8fr) minmax(210px, 1.2fr); align-items: center; gap: 10px; padding: 9px 13px; border-top: 1px solid var(--line); }
.export-chapter-copy { min-width: 0; }
.export-chapter-copy strong, .export-chapter-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.export-chapter-copy small { margin-top: 2px; color: var(--muted); }
.export-title-input { min-width: 0; padding: 8px 9px !important; }
.publication-fields { margin-top: 16px; border: 1px solid var(--line); border-radius: 11px; padding: 5px 13px 12px; }
.publication-fields legend { padding: 0 7px; color: var(--teal); font-weight: 700; }
.publication-fields label { margin: 8px 0; }
.publication-checks { display: flex; flex-wrap: wrap; gap: 9px 18px; margin-top: 5px; }
.publication-checks label { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--ink); }
.publication-profile-actions { display: flex; align-items: center; gap: 10px; margin-top: 11px; }
.publication-profile-actions span { color: var(--muted); font-size: 11px; }
.export-progress { margin-top: 15px; padding: 13px 14px; border: 1px solid color-mix(in srgb, var(--teal) 35%, var(--line)); border-radius: 11px; background: color-mix(in srgb, var(--soft) 62%, var(--surface)); }
.export-progress[hidden], #exportHistoryButton[hidden] { display: none; }
.export-progress-head { display: flex; justify-content: space-between; gap: 16px; color: var(--ink); font-size: 13px; }
.export-progress-head span { color: var(--teal); font-weight: 750; font-variant-numeric: tabular-nums; }
.export-progress progress { width: 100%; height: 10px; margin: 9px 0 5px; border: 0; border-radius: 999px; overflow: hidden; accent-color: var(--teal); background: var(--paper); }
.export-progress progress::-webkit-progress-bar { background: var(--paper); border-radius: 999px; }
.export-progress progress::-webkit-progress-value { background: linear-gradient(90deg, var(--teal), var(--accent)); border-radius: 999px; transition: width .28s ease; }
.export-progress p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.export-payment { margin-top: 12px; padding: 13px 14px; border: 1px solid color-mix(in srgb, var(--accent) 48%, var(--line)); border-radius: 11px; background: color-mix(in srgb, var(--soft) 68%, var(--surface)); }
.export-payment[hidden] { display: none; }
.export-payment p { margin: 6px 0 10px; color: var(--ink); }
.export-payment small { display: block; margin-top: 8px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); z-index: 80; background: var(--ink); color: white; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.auth-gate { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; background: rgba(20, 55, 54, .32); backdrop-filter: blur(5px); }
.auth-gate[hidden] { display: none; }
.auth-gate-card { width: min(440px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: 0 24px 72px rgba(20, 55, 54, .22); text-align: center; }
.auth-gate-kicker { margin: 0 0 10px; color: var(--accent-strong); font-size: 12px; letter-spacing: .08em; }
.auth-gate-card h1 { margin: 0; color: var(--ink); font-size: clamp(24px, 4vw, 32px); }
.auth-gate-card p:not(.auth-gate-kicker) { margin: 14px 0 24px; color: var(--muted); line-height: 1.7; }
.auth-gate-card .button { min-width: 180px; }
.auth-gate-card .button:disabled { cursor: not-allowed; opacity: .58; }
.icon-button { border: 0; background: transparent; font-size: 22px; padding: 6px; }
.mobile-only { display: none; }
.mobile-tabs { background: var(--surface); border-bottom: 1px solid var(--line); }
.mobile-tabs button { flex: 1; border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 10px; }
.mobile-tabs button.active { border-color: var(--accent); color: var(--teal); }
body.focus-mode .sidebar, body.focus-mode .preview-pane, body.focus-mode .toc-pane { display: none; }
body.focus-mode .content-grid { grid-template-columns: minmax(0, 900px); justify-content: center; }
body.focus-mode .editor-pane { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }

@media (max-width: 1100px) {
  .content-grid { grid-template-columns: minmax(280px, 1fr) minmax(340px, 1fr); }
  .toc-pane { display: none; }
  .brand-lockup { min-width: auto; } .brand-lockup small { display: none; }
  .book-switcher { min-width: 175px; } .book-switcher select { width: 120px; }
}
@media (max-width: 760px) {
  .mobile-only { display: flex; }
  .app-header { gap: 8px; height: 58px; padding: 0 10px; }
  .brand-lockup { min-width: 0; } .brand-lockup strong { font-size: 14px; white-space: nowrap; }
  .brand-dot { width: 12px; height: 12px; }
  .notebook-title, .save-status, .header-actions .button.ghost { display: none; }
  .book-switcher { min-width: 0; flex: 1; } .book-switcher select { width: 100%; }
  .book-switcher .button { display: none; }
  .header-actions { margin-left: auto; } .header-actions .button { padding: 8px 10px; font-size: 12px; }
  .workspace { height: calc(100vh - 58px); height: calc(100dvh - 58px); }
  .sidebar { position: fixed; top: 58px; left: 0; bottom: 0; transform: translateX(-102%); transition: .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .note-head { min-height: 54px; padding: 8px 12px; } .note-title { font-size: 17px; }
  .note-meta { display: none; } .toolbar { padding-left: 8px; }
  .mobile-tabs { display: flex; }
  .content-grid { display: block; min-height: 0; overflow: hidden; }
  .editor-pane, .preview-pane, .toc-pane { height: 100%; border: 0; }
  .content-grid[data-mobile-view="editor"] .preview-pane, .content-grid[data-mobile-view="editor"] .toc-pane { display: none; }
  .content-grid[data-mobile-view="preview"] .editor-pane, .content-grid[data-mobile-view="preview"] .toc-pane { display: none; }
  .content-grid[data-mobile-view="preview"] .preview-pane { display: block; padding: 10px; }
  .content-grid[data-mobile-view="toc"] .editor-pane, .content-grid[data-mobile-view="toc"] .preview-pane { display: none; }
  .content-grid[data-mobile-view="toc"] .toc-pane { display: block; padding: 20px; background: var(--surface); }
  #preview { border: 0; border-radius: 0; box-shadow: none; padding: 30px 24px 80px; }
  #editor { padding: 20px 16px 50vh; }
  .floating-settings { width: 42px; height: 42px; right: 12px; bottom: 12px; }
  .dialog-two-columns, .export-modes { grid-template-columns: 1fr; }
  .dialog-export { width: calc(100vw - 18px); max-height: calc(100vh - 18px); max-height: calc(100dvh - 18px); padding: 14px; }
  .export-chapter-row { grid-template-columns: 22px minmax(0, 1fr); }
  .export-title-input { grid-column: 2; }
  .publication-checks { display: grid; }
  .publication-profile-actions { align-items: flex-start; flex-direction: column; }
  .inline-create { flex-direction: column; }
}
