/* Shared application layout and component tokens. */
:root {
  --ink: #232a31;
  --muted: #606a76;
  --quiet: #727d89;
  --paper: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f0f3f5;
  --line: #e0e5e9;
  --teal: #13796d;
  --coral: #2463b4;
  --gold: #956517;
  --selected: #e8f3ef;
  --hover: #f1f5f7;
  --header-height: 64px;
  --sidebar-width: 208px;
  --mobile-nav-height: calc(64px + env(safe-area-inset-bottom, 0px));
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
*, *::before, *::after { letter-spacing: 0; }
[hidden] { display: none !important; }
html { scroll-padding-top: calc(var(--header-height) + 20px); }
body { min-height: 100dvh; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: .45; }
:is(button, a, input, textarea, select, summary):focus-visible { outline: 2px solid var(--coral); outline-offset: 3px; }
main:focus { outline: none; }
img { max-width: 100%; }
.ui-icon, .nav-icon { display: inline-block; width: 20px; height: 20px; flex: 0 0 20px; background: currentColor; }
.ui-icon { mask: var(--icon) center / contain no-repeat; -webkit-mask: var(--icon) center / contain no-repeat; }
.nav-icon { mask: var(--nav-icon) center / contain no-repeat; -webkit-mask: var(--nav-icon) center / contain no-repeat; }
.nav-icon-books { --nav-icon: url('/vendor/icons/book-open.svg'); }
.nav-icon-practice { --nav-icon: url('/vendor/icons/square-pen.svg'); }
.nav-icon-formulas { --nav-icon: url('/vendor/icons/sigma.svg'); }
.nav-icon-people { --nav-icon: url('/vendor/icons/users-round.svg'); }
.skip-link { position: fixed; top: 8px; left: 16px; z-index: 100; padding: 12px 20px; background: var(--surface); border: 1px solid var(--line); clip-path: inset(50%); }
.skip-link:focus { clip-path: none; }
.app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 35; width: var(--sidebar-width); display: flex; flex-direction: column; padding: 30px 16px 20px; border-right: 1px solid var(--line); background: var(--surface); }
.workspace-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; font-weight: 700; font-size: 18px; }
.workspace-brand small { display: block; margin-top: 3px; color: var(--quiet); font-size: 11px; font-weight: 400; }
.brand-mark { width: 36px; height: 36px; position: relative; flex: 0 0 36px; display: inline-block; overflow: hidden; border: 1px solid #173b55; border-radius: 5px; background: #173b55; box-shadow: 0 2px 6px #173b5526; }
.brand-mark::before { content: ""; position: absolute; width: 23px; height: 23px; top: 5px; left: 5px; background: #fff; -webkit-mask: url('/vendor/icons/sigma.svg') center / contain no-repeat; mask: url('/vendor/icons/sigma.svg') center / contain no-repeat; }
.brand-mark::after { content: "A"; position: absolute; right: 4px; bottom: 1px; color: #d7b36a; background: transparent; font-family: Georgia, "Times New Roman", serif; font-size: 9px; font-weight: 700; line-height: 1; }
.desktop-nav { display: grid; gap: 6px; margin-top: 42px; }
.desktop-nav a { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 10px 14px; border-radius: 6px; color: var(--muted); }
.desktop-nav a:hover { background: var(--hover); color: var(--ink); }
.desktop-nav a[aria-current] { background: var(--selected); color: var(--teal); font-weight: 650; }
.sidebar-footer { display: grid; gap: 4px; margin-top: auto; padding: 20px 10px 0; border-top: 1px solid var(--line); color: var(--quiet); font-size: 11px; }
.sidebar-footer strong { color: var(--muted); font-size: 12px; font-weight: 500; }
#app { margin-left: var(--sidebar-width); }
.site-header { position: sticky; top: 0; z-index: 30; height: var(--header-height); padding: 0 36px; background: var(--surface); backdrop-filter: none; }
.page-breadcrumb, .header-actions { display: flex; align-items: center; gap: 14px; min-width: 0; }
.page-breadcrumb { font-size: 13px; }
.page-breadcrumb > span { color: var(--quiet); }
.page-breadcrumb .ui-icon { width: 14px; height: 14px; flex-basis: 14px; color: var(--quiet); }
.page-breadcrumb strong { font-weight: 550; }
.brand { font-size: 14px; font-weight: 550; }
.home-main, .formula-main, .mathematician-main, .practice-main { width: min(1160px, calc(100% - 72px)); margin: 0 auto; padding: 34px 0 64px; }
.practice-main { max-width: 880px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-heading h1 { margin: 0; font-size: 26px; line-height: 1.4; font-weight: 700; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.page-heading > div { min-width: 0; }
.icon-button { width: 40px; height: 40px; flex: 0 0 40px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); }
.icon-button:hover, .text-button:hover, .outline-button:hover, .back-button:hover { border-color: var(--line); color: var(--ink); background: var(--hover); }
.knowledge-carousel { margin: 0 0 26px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.knowledge-carousel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px 0; }
.knowledge-carousel-head > div { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.knowledge-carousel-eyebrow { color: var(--teal); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.knowledge-carousel-head strong { color: var(--ink); font-size: 13px; font-weight: 600; }
.knowledge-carousel-count { flex: 0 0 auto; color: var(--quiet); font-size: 11px; font-variant-numeric: tabular-nums; }
.knowledge-carousel-stage { min-height: 132px; padding: 8px 18px 10px; }
.knowledge-carousel-card { min-height: 114px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; gap: 20px; padding: 10px 0 4px; color: inherit; }
.knowledge-carousel-card:hover .knowledge-carousel-title { color: var(--teal); }
.knowledge-carousel-copy { min-width: 0; }
.knowledge-carousel-meta { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--quiet); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.knowledge-carousel-label { flex: 0 0 auto; padding: 3px 7px; border-radius: 3px; background: var(--selected); color: var(--teal); font-size: 11px; font-weight: 600; }
.knowledge-carousel-title { margin-top: 9px; color: var(--ink); font-size: 19px; line-height: 1.4; font-weight: 650; transition: color .18s; }
.knowledge-carousel-copy > p { display: -webkit-box; margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.7; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.knowledge-carousel-formula { min-height: 30px; margin-top: 5px; color: var(--teal); font-size: 18px; overflow-x: auto; overflow-y: hidden; }
.knowledge-carousel-formula mjx-container { margin: 0 !important; }
.knowledge-carousel-link { align-self: end; display: inline-flex; align-items: center; gap: 5px; padding-bottom: 3px; color: var(--teal); font-size: 12px; white-space: nowrap; }
.knowledge-carousel-link .ui-icon { width: 15px; height: 15px; }
.knowledge-carousel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px 13px; }
.knowledge-carousel-dots { display: flex; align-items: center; gap: 5px; }
.knowledge-carousel-dots button { width: 6px; height: 6px; padding: 0; border: 0; border-radius: 50%; background: var(--line); }
.knowledge-carousel-dots button.is-active { width: 18px; border-radius: 4px; background: var(--teal); }
.knowledge-carousel-controls { display: flex; gap: 4px; }
.knowledge-carousel-controls button { width: 28px; height: 28px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--muted); }
.knowledge-carousel-controls button:hover { border-color: var(--teal); color: var(--teal); background: var(--selected); }
.knowledge-carousel-controls .ui-icon { width: 15px; height: 15px; }
.knowledge-carousel-loading { min-height: 132px; display: grid; place-items: center; color: var(--quiet); font-size: 13px; }
:is(.practice-launch-button, .practice-start-button, .practice-submit-button, .practice-next-button, .practice-secondary-button, .read-button) { gap: 8px; min-height: 42px; padding: 10px 16px; border-radius: 6px; font-size: 13px; font-weight: 550; line-height: 1.4; }
:is(.practice-launch-button, .practice-start-button, .practice-submit-button) { background: var(--teal); border-color: var(--teal); color: #fff; }
:is(.practice-launch-button, .practice-start-button, .practice-submit-button):not(:disabled):hover { background: #0d665c; border-color: #0d665c; }
:is(.practice-launch-button, .practice-start-button, .practice-next-button) .ui-icon { margin: 0; font-size: inherit; line-height: inherit; }
:is(.practice-secondary-button, .practice-next-button, .read-button) { background: var(--surface); border-color: var(--line); color: var(--ink); }
:is(.practice-secondary-button, .practice-next-button, .read-button):not(:disabled):hover { background: var(--hover); border-color: var(--teal); color: var(--teal); }
.read-button { width: 100%; }
.recent-reading { display: flex; align-items: center; gap: 14px; padding: 0 0 24px; margin-bottom: 24px; border-bottom: 1px solid var(--line); color: var(--teal); }
.recent-reading > span:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
.recent-reading small { color: var(--quiet); font-size: 11px; }
.recent-reading strong { color: var(--ink); font-size: 14px; font-weight: 550; }
.recent-page { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.book-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 20px; overflow: visible; border: 0; background: transparent; }
.book-card { display: flex; flex-direction: column; align-items: stretch; gap: 20px; min-height: 0; padding: 0; background: transparent; }
.book-card:hover, body.theme-night .book-card, body.theme-night .book-card:hover { background: transparent; transform: none; }
.book-cover { width: 100%; aspect-ratio: 0.707; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-soft); box-shadow: 0 3px 8px #17232a12; transition: box-shadow .18s; }
.book-cover:hover { box-shadow: 0 5px 15px #17232a26; }
.book-cover img { object-fit: contain; }
.book-info { min-height: 174px; flex: 1; }
.book-info h3 { font-family: inherit; font-size: 15px; line-height: 1.6; }
.book-publisher { margin-top: 6px; font-size: 11px; }
.book-bottom { display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; align-items: stretch; gap: 12px; padding-top: 18px; }
.book-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; }
.book-progress-bar { display: block; width: 100%; height: 3px; border: 0; border-radius: 3px; overflow: hidden; background: var(--line); color: var(--teal); }
.book-progress-bar::-webkit-progress-bar { background: var(--line); }
.book-progress-bar::-webkit-progress-value { background: var(--teal); }
.book-progress-bar::-moz-progress-bar { background: var(--teal); }
.loading-state, .error-state { grid-column: 1 / -1; padding: 64px 20px; color: var(--muted); font-size: 14px; }
.error-state p { margin: 0 0 20px; }
.formula-workbench, .mathematician-workbench { min-width: 0; padding-top: 0; }
.formula-toolbar, .mathematician-toolbar { position: sticky; top: var(--header-height); z-index: 10; display: grid; grid-template-columns: 1fr; gap: 16px; padding: 0 0 18px; background: var(--paper); }
.formula-search { position: relative; display: block; max-width: 480px; }
.formula-search > .ui-icon { position: absolute; top: 13px; left: 14px; width: 18px; height: 18px; color: var(--quiet); pointer-events: none; }
.formula-search input { height: 44px; border-radius: 6px; padding: 0 14px 0 42px; font-size: 14px; }
.formula-search input::placeholder { color: var(--quiet); }
.formula-categories, .mathematician-eras { flex-wrap: wrap; gap: 6px; overflow: visible; padding: 0; }
.formula-category { min-height: 36px; padding: 7px 12px; border: 1px solid transparent; border-radius: 5px; font-size: 13px; }
.formula-category:hover { background: var(--hover); border-color: var(--line); color: var(--ink); }
.formula-category.is-active { background: var(--selected); border-color: transparent; color: var(--teal); font-weight: 600; }
.formula-list, .mathematician-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 22px; border: 0; background: transparent; }
.formula-card, .mathematician-card { min-height: 0; padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow-wrap: anywhere; }
.formula-card:hover, .mathematician-card:hover, body.theme-night .formula-card:hover, body.theme-night .mathematician-card:hover { background: var(--surface); }
.formula-card-head, .mathematician-card-head { padding-bottom: 12px; }
.formula-index, .mathematician-index { font-family: inherit; font-size: 12px; color: var(--quiet); }
.formula-category-label, .mathematician-era-label { font-size: 12px; color: var(--teal); }
.formula-card h3, .mathematician-card h3 { font-family: inherit; font-size: 18px; }
.formula-purpose, .formula-conditions, .mathematician-copy { font-size: 13px; line-height: 1.8; }
.formula-display { min-width: 0; max-width: 100%; min-height: 70px; margin: 18px 0 10px; padding: 14px 0; border: 0; background: transparent; font-size: 18px; scrollbar-width: thin; }
.formula-display mjx-container { flex: 0 0 auto; }
.formula-conditions { max-width: 100%; overflow-x: auto; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); }
.mathematician-english-name { color: var(--quiet); margin-bottom: 8px; }
.mathematician-card h4 { font-size: 12px; color: var(--ink); }
.mathematician-formulas { margin-top: 12px; padding-top: 0; }
.mathematician-formula h5 { font-family: inherit; }
.mathematician-formula .formula-display { padding: 10px 0; font-size: 17px; }
.mathematician-formula .formula-conditions { font-size: 12px; }
.formula-empty, .mathematician-empty { display: grid; justify-items: center; gap: 20px; padding: 72px 16px; border: 1px dashed var(--line); border-radius: 6px; background: transparent; }
.formula-empty strong, .mathematician-empty strong { font-size: 15px; font-weight: 550; }
.practice-page { min-height: 100dvh; }
.practice-setup, .practice-session, .practice-finished { margin: 0; padding: 0; border: 0; background: transparent; }
.practice-setup-head { align-items: center; padding: 4px 0 24px; }
.practice-setup-head h2 { font-family: inherit; font-size: 18px; }
.practice-pool-count { display: flex; align-items: baseline; gap: 6px; border: 0; min-width: 0; padding: 0; white-space: nowrap; }
.practice-pool-count strong { font-family: inherit; font-size: 24px; color: var(--teal); }
.practice-pool-count span { font-size: 12px; }
.practice-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin: 0; padding-top: 24px; }
.practice-fieldset { grid-column: 1 / -1; grid-row: 1; }
.practice-fieldset legend { margin-bottom: 8px; }
.practice-field > span, .practice-fieldset legend { font-size: 13px; font-weight: 500; color: var(--ink); }
.practice-field select { height: 46px; padding: 0 12px; border-radius: 6px; font-size: 14px; text-overflow: ellipsis; }
.practice-scope { padding: 4px; gap: 4px; border-radius: 7px; background: var(--surface-soft); }
.practice-scope-button { min-height: 40px; border: 1px solid transparent; border-radius: 4px; font-size: 13px; }
.practice-scope-button.is-active { border-color: var(--line); background: var(--surface); color: var(--teal); box-shadow: 0 1px 3px #17232a09; }
.practice-scope-button:hover { background: var(--surface); border-color: var(--line); color: var(--teal); }
.practice-form > .practice-start-button { grid-column: 1 / -1; justify-self: end; min-width: 180px; margin-top: 4px; }
.practice-message, .practice-timeout { border-radius: 4px; background: var(--surface-soft); color: var(--coral); }
.practice-header-summary { display: flex; align-items: baseline; gap: 8px; margin: 0; flex: initial; color: var(--muted); font-size: 12px; white-space: nowrap; }
.practice-header-summary strong { color: var(--teal); font-family: inherit; font-size: 18px; font-variant-numeric: tabular-nums; }
.practice-back-icon { display: flex; align-items: center; }
.practice-brand { min-height: 40px; }
.practice-draft-toggle { min-height: 40px; padding: 0 12px; border-radius: 6px; font-size: 13px; color: var(--ink); }
.practice-draft-toggle:hover, .practice-draft-toggle[aria-expanded="true"] { background: var(--selected); border-color: var(--teal); color: var(--teal); }
.practice-session-active .page-heading { display: none; }
.practice-session-active .app-sidebar, body[data-route="read"] .app-sidebar { display: none; }
.practice-session-active #app, body[data-route="read"] #app { margin-left: 0; }
.practice-session-active .practice-main { max-width: 900px; }
.practice-progress-line { display: flex; flex-direction: row; justify-content: space-between; margin: 0; padding: 0 0 18px; border-top: 0; font-size: 13px; }
.practice-question-card { margin-top: 24px; padding: 0; background: transparent; }
.practice-prompt { font-family: inherit; font-size: 16px; line-height: 1.9; overflow-wrap: anywhere; }
.practice-question-content { min-width: 0; }
.practice-question-image { width: auto; max-width: 100%; max-height: none; height: auto; margin: 20px auto 0; border: 0; }
.practice-figure { margin: 18px 0 0; border: 0; border-radius: 4px; background: transparent; }
.practice-figure summary { width: fit-content; min-height: 44px; padding: 10px 0; font-family: inherit; font-size: 13px; }
.image-preview-button { display: block; width: 100%; padding: 0; background: transparent; cursor: zoom-in; }
.image-preview-button img { margin-top: 8px; max-height: 440px; }
.image-dialog { width: min(1100px, calc(100vw - 24px)); height: min(900px, calc(100dvh - 32px)); max-height: none; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.image-dialog[open] { display: flex; flex-direction: column; }
.image-dialog::backdrop { background: #17232aaa; }
.image-dialog-head { display: flex; justify-content: space-between; align-items: center; flex: 0 0 auto; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.image-dialog-head strong { min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.image-dialog-head > div { display: flex; flex-shrink: 0; }
.image-dialog-content { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 12px; background: var(--surface-soft); }
.image-dialog-content img { display: block; width: auto; max-width: 100%; height: auto; max-height: 100%; margin: 0 auto; object-fit: contain; }
.image-dialog.is-enlarged .image-dialog-content img { max-width: none; max-height: none; }
body:has(.image-dialog[open], .confirm-dialog[open]) { overflow: hidden; }
.practice-answer-field { margin-top: 24px; }
.practice-answer-field > span { color: var(--ink); font-size: 13px; font-weight: 500; }
.practice-answer-field textarea { border-radius: 6px; font-family: inherit; font-size: 16px; line-height: 1.7; min-height: 150px; }
.practice-actions { flex-direction: row; align-items: center; gap: 10px; margin-top: 16px; }
.previous-question { margin-right: auto; }
.practice-feedback { padding: 20px 0; border-left: 0; border-top: 1px solid var(--line); background: transparent; }
.practice-feedback > strong { font-size: 15px; }
.practice-answer-content { font-size: 15px; line-height: 1.85; overflow-wrap: anywhere; }
.practice-question-context { gap: 6px; margin-top: 28px; padding-top: 16px; font-size: 12px; line-height: 1.7; }
.practice-question-context strong { font-size: 12px; font-weight: 500; }
.practice-finished { padding: 54px 0; }
.practice-finished h2 { font-family: inherit; font-size: 24px; margin-top: 20px; }
.completion-icon { width: 52px; height: 52px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--selected); color: var(--teal); }
.completion-icon .ui-icon { width: 28px; height: 28px; }
.practice-finished-actions { flex-direction: row; flex-wrap: wrap; }
.practice-finished-stats strong { font-family: inherit; font-size: 32px; color: var(--teal); }
.practice-draft-overlay { inset: var(--header-height) 0 0; height: calc(100dvh - var(--header-height)); background: #ffffff26; }
.practice-draft-toolbar { top: auto; bottom: max(16px, env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 32px); padding: 8px; gap: 8px; border-radius: 8px; background: var(--surface); box-shadow: 0 4px 22px #17232a24; }
.draft-tool, .draft-action-button, .draft-clear-button { display: inline-flex; justify-content: center; align-items: center; min-width: 40px; height: 40px; border-radius: 4px; }
.draft-tool:hover, .draft-tool.is-active, .draft-action-button:not(:disabled):hover, .draft-clear-button:hover { background: var(--selected); border-color: transparent; color: var(--teal); }
.draft-color-control input { width: 34px; height: 34px; }
.practice-draft-context-menu { max-width: calc(100vw - 16px); border-radius: 6px; background: var(--surface); flex-wrap: wrap; }
.practice-draft-context-menu button, .draft-selected-color { min-height: 40px; }
.reader-toolbar { grid-template-columns: minmax(0, 1fr) auto auto; gap: 24px; height: var(--header-height); min-height: var(--header-height); padding: 10px 24px; background: var(--surface); backdrop-filter: none; }
.reader-progress { grid-column: auto; grid-row: auto; margin: 0; font-size: 13px; }
.reader-progress input { height: 38px; font-size: 14px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); }
.reader-book-title { color: var(--ink); font-family: inherit; font-size: 14px; }
.toolbar-actions { grid-column: auto; grid-row: auto; gap: 8px; }
.outline-button, .text-button { height: 40px; padding: 0 12px; gap: 6px; border-radius: 5px; font-size: 13px; }
.outline-button[aria-expanded="true"] { color: var(--teal); background: var(--selected); border-color: var(--teal); }
.zoom-controls { display: flex; align-items: center; gap: 0; }
.zoom-controls .text-button { width: 56px; padding: 0; border: 0; font-variant-numeric: tabular-nums; }
.reader-layout, .reader-content { min-height: calc(100dvh - var(--header-height)); }
.reader-content { padding: 28px 24px 60px; background: #e8ebee; }
.reader-content-head { margin-bottom: 18px; font-size: 12px; }
.page-frame { min-height: 0; scroll-margin-top: calc(var(--header-height) + 12px); box-shadow: 0 2px 12px #17232a12; }
.page-canvas-wrap canvas { max-width: 100%; height: auto !important; }
.toc-panel, .exercise-panel { top: var(--header-height); bottom: 0; z-index: 45; padding: 22px; visibility: hidden; background: var(--surface); overscroll-behavior: contain; }
.toc-panel.is-open, .exercise-panel.is-open { visibility: visible; }
.toc-panel { width: min(360px, calc(100vw - 32px)); }
.exercise-panel { width: min(480px, calc(100vw - 24px)); }
.toc-head, .exercise-head { align-items: center; padding-bottom: 18px; }
.toc-head h2, .exercise-head h2 { font: 600 19px/1.4 "Segoe UI", "Microsoft YaHei", sans-serif; }
.toc-item { min-height: 42px; border-radius: 4px; }
.toc-item:hover, .exercise-question:hover { background: var(--selected); color: var(--ink); }
.exercise-chapter h3 { font-family: inherit; }
.exercise-question { padding: 10px 4px; font-size: 13px; overflow-wrap: anywhere; }
.exercise-section-button { min-height: 44px; }
.exercise-answer-content { overflow-x: auto; overflow-wrap: anywhere; }
.reader-backdrop { position: fixed; inset: var(--header-height) 0 0; z-index: 40; background: #17232a45; cursor: default; }
body:has(.reader-backdrop:not([hidden])) { overflow: hidden; }
.theme-menu { top: calc(var(--header-height) + 8px); right: 24px; z-index: 50; gap: 12px; padding: 12px; border-radius: 8px; background: var(--surface); }
.theme-choice { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--line); }
.theme-choice[aria-pressed="true"] { outline: 2px solid var(--teal); outline-offset: 3px; }
.theme-choice[data-theme="paper"] { background: #fff; }
.theme-choice[data-theme="ink"] { background: #e8efea; }
.theme-choice[data-theme="night"] { background: #25282c; }
body.theme-ink { --paper: #edf3ef; --surface: #f8fbf9; --surface-soft: #e3ece6; --line: #d1dfd6; --hover: #e5eee8; }
body.theme-ink .reader-content { background: #d9e3dc; }
body.theme-night { --ink: #e9edef; --muted: #b3bcc5; --quiet: #9ba5af; --paper: #191c20; --surface: #22262b; --surface-soft: #2b3036; --line: #3a424b; --teal: #74cbb7; --coral: #8bb9f4; --gold: #d8b67a; --selected: #243e37; --hover: #2b3138; }
body.theme-night :is(.site-header, .reader-toolbar, .toc-panel, .exercise-panel, .theme-menu, .formula-card, .mathematician-card, .practice-draft-toolbar, .practice-draft-context-menu) { background: var(--surface); }
body.theme-night :is(.practice-setup, .practice-session, .practice-finished) { background: transparent; }
body.theme-night :is(.practice-start-button, .practice-submit-button, .practice-launch-button) { color: #16251f; }
body.theme-night :is(.practice-start-button, .practice-submit-button, .practice-launch-button):hover { background: #9edbcb; border-color: #9edbcb; }
body.theme-night .reader-content { background: #141619; }
.confirm-dialog { width: min(400px, calc(100vw - 40px)); padding: 26px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.confirm-dialog::backdrop { background: #17232a66; }
.confirm-dialog h2 { margin: 0; font-size: 19px; }
.confirm-dialog p { color: var(--muted); line-height: 1.8; }
.confirm-dialog .dialog-actions { display: flex; justify-content: end; gap: 10px; margin-top: 24px; }
@media (min-width: 1500px) { .home-main { padding-top: 48px; } .book-grid { gap: 28px; } }
@media (max-width: 1199px) and (min-width: 761px) {
  :root { --sidebar-width: 180px; }
  .app-sidebar { padding-inline: 12px; }
  .workspace-brand { font-size: 16px; gap: 9px; }
  .workspace-brand small { font-size: 10px; }
  .site-header { padding-inline: 24px; }
  .home-main, .formula-main, .mathematician-main, .practice-main { width: calc(100% - 48px); }
  .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 18px; }
  .formula-card, .mathematician-card { padding: 18px; }
  .practice-draft-toolbar { flex-wrap: wrap; max-width: 720px; width: calc(100% - 32px); }
  .practice-draft-tool-list { width: 100%; }
  .practice-draft-settings { width: 100%; justify-content: end; border-left: 0; border-top: 1px solid var(--line); padding-top: 6px; }
}
@media (max-width: 950px) { .formula-list, .mathematician-list { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  :root { --header-height: calc(56px + env(safe-area-inset-top, 0px)); }
  body { padding-bottom: var(--mobile-nav-height); }
  .app-sidebar { display: none; }
  #app { margin-left: 0; }
  .site-header { height: var(--header-height); padding: env(safe-area-inset-top, 0px) 16px 0; }
  .page-breadcrumb > span, .page-breadcrumb > .ui-icon { display: none; }
  .page-breadcrumb strong, .brand { font-size: 16px; font-weight: 650; }
  .header-actions { gap: 10px; }
  .mobile-nav { height: var(--mobile-nav-height); background: var(--surface); z-index: 35; box-shadow: none; }
  .mobile-nav a { font-size: 11px; gap: 5px; }
  .mobile-nav a[aria-current="page"]::before { display: none; }
  .mobile-nav a .nav-icon { width: 22px; height: 22px; }
  .home-main, .formula-main, .mathematician-main, .practice-main { width: calc(100% - 32px); padding: 24px 0 28px; }
  .page-heading { margin-bottom: 24px; gap: 12px; }
  .page-heading h1 { font-size: 22px; }
  .page-heading p { font-size: 12px; margin-top: 6px; }
  .knowledge-carousel { margin-bottom: 20px; border-radius: 6px; }
  .knowledge-carousel-head { padding: 12px 14px 0; }
  .knowledge-carousel-head > div { gap: 7px; }
  .knowledge-carousel-head strong { font-size: 12px; }
  .knowledge-carousel-stage { min-height: 144px; padding: 7px 14px 10px; }
  .knowledge-carousel-card { min-height: 126px; gap: 10px; padding-top: 10px; }
  .knowledge-carousel-title { margin-top: 8px; font-size: 17px; }
  .knowledge-carousel-copy > p { font-size: 12px; line-height: 1.65; }
  .knowledge-carousel-formula { font-size: 16px; }
  .knowledge-carousel-link { font-size: 11px; }
  .knowledge-carousel-foot { padding: 0 14px 11px; }
  .formula-page .page-heading h1, .mathematician-page .page-heading h1, .practice-page .page-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .formula-page .page-heading, .mathematician-page .page-heading { margin-bottom: 10px; }
  .formula-page .page-heading p, .mathematician-page .page-heading p { margin: 0; }
  .page-heading .practice-launch-button { padding-inline: 12px; font-size: 12px; }
  .page-heading .practice-launch-button .ui-icon { display: none; }
  .book-grid { grid-template-columns: 1fr; gap: 0; }
  .book-card { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 18px; padding: 20px 0; border-bottom: 1px solid var(--line); align-items: center; }
  .book-card:first-child { padding-top: 0; }
  .book-cover { width: 86px; }
  .book-info { min-height: 125px; }
  .book-info h3 { font-size: 15px; line-height: 1.5; }
  .book-publisher { font-size: 11px; margin-top: 4px; }
  .book-bottom { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; padding-top: 10px; }
  .book-meta { display: grid; gap: 2px; font-size: 11px; }
  .book-progress-bar { grid-column: 1 / -1; grid-row: 2; }
  .read-button { grid-column: 2; grid-row: 1; width: auto; min-height: 40px; padding: 8px 10px; font-size: 12px; }
  .recent-reading { gap: 10px; margin-bottom: 20px; padding-bottom: 20px; }
  .recent-reading strong { font-size: 13px; }
  .recent-reading > .ui-icon:first-child { display: none; }
  .formula-search { max-width: none; }
  .formula-search input { font-size: 16px; }
  .formula-toolbar, .mathematician-toolbar { top: var(--header-height); gap: 12px; padding: 10px 0 12px; box-shadow: none; }
  .formula-categories, .mathematician-eras { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; padding-bottom: 4px; }
  .formula-category { min-height: 40px; }
  .formula-list, .mathematician-list { gap: 12px; margin-top: 16px; }
  .formula-card, .mathematician-card { padding: 18px 16px; }
  .formula-display { font-size: 17px; }
  .practice-setup-head { padding-bottom: 20px; gap: 10px; }
  .practice-setup-head h2 { font-size: 17px; }
  .practice-pool-count strong { font-size: 22px; }
  .practice-form { gap: 20px 12px; padding-top: 20px; }
  .practice-field select { font-size: 16px; padding-inline: 8px; }
  .practice-scope-button { font-size: 12px; padding: 0 4px; }
  .practice-form > .practice-start-button { width: 100%; }
  .practice-header-summary { display: flex; gap: 5px; margin-left: 0; }
  .practice-header-summary span { display: none; }
  .practice-header-summary strong { font-size: 16px; }
  .practice-draft-toggle { padding: 0 8px; }
  .practice-page.is-session .practice-brand .practice-back-icon { width: 20px; height: 20px; display: flex; border: 0; background: transparent; }
  .practice-page.is-session .practice-brand .practice-back-icon::before { content: none; }
  .practice-session-active, body[data-route="read"] { padding-bottom: 0; }
  .practice-session-active .mobile-nav, body[data-route="read"] .mobile-nav { display: none; }
  .practice-session-active .practice-main { padding-top: 20px; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .practice-progress-line { flex-direction: row; align-items: center; font-size: 12px; }
  .practice-prompt { font-size: 16px; }
  .practice-answer-field textarea { font-size: 16px; }
  .practice-actions { flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .practice-actions > button { width: auto; padding: 10px 12px; font-size: 12px; }
  .practice-actions .ui-icon { width: 16px; height: 16px; flex-basis: 16px; }
  .practice-question-context { margin-top: 24px; }
  .practice-finished-actions > button { width: auto; }
  .practice-draft-toolbar { top: auto; bottom: max(8px, env(safe-area-inset-bottom)); left: 8px; right: 8px; width: auto; max-width: none; flex-wrap: wrap; padding: 6px; gap: 6px; transform: none; }
  .practice-draft-tool-list { width: 100%; }
  .practice-draft-settings { width: 100%; gap: 3px; padding: 6px 0 0; border-left: 0; border-top: 1px solid var(--line); justify-content: space-between; }
  .draft-size-control input { width: 54px; }
  .draft-tool, .draft-action-button, .draft-clear-button { min-width: 38px; height: 40px; padding: 0 4px; }
  body[data-route="read"] { --header-height: calc(108px + env(safe-area-inset-top, 0px)); }
  .reader-toolbar { height: var(--header-height); min-height: var(--header-height); grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 40px 40px; gap: 8px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px; }
  .reader-actions { gap: 6px; }
  .reader-book-title { font-size: 12px; }
  .reader-progress { grid-column: 2; grid-row: 1; min-width: 108px; font-size: 12px; }
  .reader-progress > span:first-child { display: none; }
  .reader-progress input { width: 42px; font-size: 16px; }
  .toolbar-actions { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; gap: 4px; }
  .outline-button { padding: 0 9px; gap: 5px; font-size: 12px; }
  .outline-button .ui-icon { width: 17px; height: 17px; flex-basis: 17px; }
  .zoom-controls .icon-button { width: 36px; flex-basis: 36px; }
  .zoom-controls .text-button { width: 48px; font-size: 12px; }
  .reader-content { padding: 18px 8px 32px; overflow-x: auto; }
  .reader-content .page-stack { width: calc((100vw - 16px) * var(--reader-zoom, 1)); max-width: none; }
  .reader-content-head { padding: 0 4px; }
  .toc-panel, .exercise-panel { top: var(--header-height); bottom: 0; padding: 20px 16px; }
  .theme-menu { top: calc(var(--header-height) + 8px); right: 12px; }
}
@media (max-width: 359px) {
  .home-main, .formula-main, .mathematician-main, .practice-main { width: calc(100% - 24px); }
  .book-card { grid-template-columns: 76px minmax(0, 1fr); gap: 14px; }
  .book-cover { width: 76px; }
  .header-actions { gap: 5px; }
  .practice-actions > button { padding-inline: 9px; gap: 4px; }
  .toolbar-actions > .outline-button .ui-icon { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
