:root {
  color-scheme: light;
  --canvas: #f3f4ef;
  --paper: #ffffff;
  --ink: #203830;
  --secondary: #6e7b73;
  --line: #e3e8df;
  --accent: #347761;
  --accent-soft: #eaf3e9;
  --sidebar: #163c32;
  --sidebar-text: #edf4eb;
  --code: #192c25;
  --code-ink: #dce9dd;
  --mono: Consolas, "Cascadia Code", "SFMono-Regular", monospace;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; color: inherit; background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 7px 11px; transition: background .15s, border-color .15s, color .15s; }
button:hover { background: #f0f5ed; border-color: #b5cbb7; }
button:disabled { opacity: .4; cursor: default; }
button:disabled:hover { background: inherit; border-color: var(--line); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #8fb69a; outline-offset: 3px; }
a { color: var(--accent); text-underline-offset: 3px; }
input, textarea, select { min-width: 0; border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; background: #fff; color: var(--ink); }
textarea { resize: vertical; line-height: 1.7; }
p { margin: 0 0 12px; line-height: 1.8; }
h1, h2, h3, h4 { margin: 0; line-height: 1.45; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
code, pre { font-family: var(--mono); }
code { font-size: .94em; }
ul, ol { padding-left: 22px; line-height: 1.9; }
[hidden], .hidden { display: none !important; }
.muted { color: var(--secondary); font-size: 12px; line-height: 1.65; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap; border: 1px solid var(--line); border-radius: 7px; padding: 7px 11px; font-size: 12px; background: white; color: var(--ink); }
.button-primary { background: var(--accent); border-color: var(--accent); color: white; }
.button-primary:hover { background: #285f4c; border-color: #285f4c; }
.button-quiet { background: transparent; border-color: transparent; color: var(--secondary); }
.button-quiet:hover { background: #eff3ec; color: var(--ink); }
.icon-button { width: 31px; height: 31px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); width: 100%; height: 100vh; height: 100dvh; }

.sidebar { display: flex; flex-direction: column; min-height: 0; padding: 29px 17px 20px; background: var(--sidebar); color: var(--sidebar-text); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 9px; margin-bottom: 35px; text-decoration: none; color: inherit; }
.brand-icon { display: grid; place-items: center; flex: 0 0 39px; width: 39px; height: 39px; border: 1px solid #ffffff33; border-radius: 11px; color: #d0e6b8; font-family: "Microsoft YaHei", sans-serif; font-size: 21px; font-weight: 550; letter-spacing: 0; padding: 0; }
.brand-name { display: block; font-size: 22px; font-weight: 650; letter-spacing: 3px; }
.brand-subtitle { display: block; margin-top: 4px; font-size: 9px; letter-spacing: 1px; color: #9ab5a7; white-space: nowrap; }
.side-section-label { padding: 0 10px; margin: 0 0 12px; color: #96b2a3; font-size: 10px; letter-spacing: 1.3px; }
.session-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 4px; margin-bottom: 18px; border-radius: 8px; background: #09281f66; gap: 2px; }
.session-filters button { border: none; background: transparent; color: #b3c8ba; border-radius: 5px; padding: 8px 1px; font-size: 11px; white-space: nowrap; }
.session-filters button:hover { background: #ffffff0b; color: white; }
.session-filters button.active { background: #416756; color: #fff; box-shadow: 0 1px 3px #0001; }
.search-box { display: block; position: relative; margin-bottom: 9px; }
.search-box > span { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: #97b5a1; font-size: 18px; line-height: 1; pointer-events: none; }
.search-box input { display: block; width: 100%; padding: 10px 11px 10px 31px; font-size: 12px; background: #ffffff08; border-color: #ffffff16; color: white; }
.search-box input::placeholder { color: #91ab9c; }
.category-select { width: 100%; margin-bottom: 22px; padding: 8px 10px; font-size: 11px; background: #214639; color: #b4cbbd; border-color: #ffffff16; }
.category-select option { background: #214639; color: white; }
.library-filters { display: grid; gap: 6px; margin-bottom: 6px; min-width: 0; flex-shrink: 0; }
.library-filters .category-select { grid-column: auto; margin: 0; }
.filter-result-count { margin: 0 5px 8px; color: #96b2a3; font-size: 10px; line-height: 1.6; }
#problem-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -5px; padding: 0 5px 12px; scrollbar-width: thin; scrollbar-color: #547664 transparent; }
.problem-item { display: flex; align-items: flex-start; text-align: left; gap: 10px; width: 100%; padding: 14px 11px; margin: 0 0 6px; color: #c7d7ca; border: 1px solid transparent; background: transparent; border-radius: 8px; }
.problem-item:hover { color: white; background: #ffffff08; border-color: transparent; }
.problem-item.active { color: #fff; background: #315b48; border-color: #71947735; }
.problem-order { flex: 0 0 19px; padding-top: 2px; color: #88aa94; font: 11px/1.5 var(--mono); }
.problem-item.active .problem-order { color: #b4d295; }
.problem-item-body { flex: 1; min-width: 0; }
.problem-item-title { display: block; font-size: 13px; font-weight: 550; line-height: 1.65; overflow-wrap: anywhere; }
.problem-item-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: #92b09e; font-size: 10px; line-height: 1.4; }
.problem-item.active .problem-item-meta { color: #b6cbb6; }
.status-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; flex: 0 0 5px; background: #7d9487; }
.status-dot.new { background: #7d9487; }
.status-dot.forgot { background: #dca48b; }
.status-dot.hint { background: #e4c77b; }
.status-dot.remembered { background: #a3cd85; }
.sidebar-footer { border-top: 1px solid #ffffff15; padding: 20px 9px 0; }
.sidebar-progress { display: flex; justify-content: space-between; gap: 5px; color: #c4d5c4; font-size: 11px; line-height: 1.7; }
.progress-track { background: #ffffff12; height: 4px; margin: 10px 0 12px; border-radius: 5px; overflow: hidden; }
.progress-track > span { display: block; height: 100%; border-radius: 5px; width: 0; background: #b8ce95; transition: width .25s; }
.save-status { color: #8faa99; font-size: 10px; line-height: 1.6; }
.sidebar-actions { display: flex; gap: 7px; margin-top: 12px; }
.sidebar-actions button { flex: 1; padding: 6px 3px; font-size: 10px; border-color: #ffffff20; color: #bacfbc; background: transparent; }
.sidebar-actions button:hover { background: #ffffff0c; border-color: #ffffff40; }
.sidebar .empty { padding: 15px 10px; color: #a5bead; font-size: 12px; line-height: 1.8; }
.list-empty { padding: 15px 10px; color: #b0c8b6; font-size: 12px; line-height: 1.85; }
.save-status.save-error { color: #ffd0a8; font-size: 11px; font-weight: 600; }

.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 15px; padding: 0 30px; border-bottom: 1px solid var(--line); background: #fafbf7; }
.breadcrumb { display: flex; align-items: center; gap: 9px; color: #7c877d; font-size: 11px; letter-spacing: .2px; }
.breadcrumb strong { color: #425d4b; font-weight: 550; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions button { font-size: 11px; padding: 6px 9px; }
.problem-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px 30px 19px; flex: 0 0 auto; }
.heading-copy { min-width: 0; }
.eyebrow { color: #8b968a; letter-spacing: 1.6px; font-size: 10px; font-weight: 600; margin-bottom: 7px; text-transform: uppercase; }
h1 { font-size: clamp(23px, 2.1vw, 31px); font-weight: 650; letter-spacing: -.7px; }
.problem-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.tag { display: inline-flex; align-items: center; border: 1px solid #dfe5da; border-radius: 4px; padding: 2px 7px; color: #7b8877; background: #f8f9f5; font-size: 10px; line-height: 1.55; }
.tag.easy { color: #518468; background: #eaf3e7; border-color: #d9e8d3; }
.tag.medium { color: #a58640; background: #fbf4e2; border-color: #ede0bb; }
.tag.hard { color: #ae5863; background: #f9e9ec; border-color: #efcfd5; }
.source-link { display: inline-flex; gap: 5px; align-items: center; color: #7b8a78; font-size: 11px; text-decoration: none; padding: 5px 8px; }
.source-link:hover { color: var(--accent); }
.problem-nav { display: flex; align-items: center; gap: 6px; }
.problem-nav button { background: #fcfdf9; font-size: 12px; white-space: nowrap; }
.modebar { display: flex; align-items: center; gap: 18px; padding: 0 30px 17px; flex: 0 0 auto; }
.mode-tabs { display: inline-flex; flex: 0 0 auto; gap: 3px; padding: 4px; border: 1px solid #e0e6db; border-radius: 9px; background: #e9ede4; }
.mode-tabs button { min-width: 72px; padding: 7px 12px; border-color: transparent; border-radius: 6px; background: transparent; font-size: 12px; color: #768370; }
.mode-tabs button:hover { color: #34573c; background: #f5f8f0; }
.mode-tabs button.active { color: #2d5d40; background: white; box-shadow: 0 1px 5px #183d2510; }
.mode-description { color: #8b9588; font-size: 11px; line-height: 1.7; }
.study-grid { display: grid; grid-template-columns: minmax(0, 1.06fr) minmax(0, 1fr); gap: 18px; flex: 1; min-height: 0; margin: 0 30px 19px; }
.panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; border: 1px solid #e1e6db; border-radius: 12px; overflow: hidden; background: var(--paper); box-shadow: 0 3px 12px #28402003; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: 0 0 auto; min-height: 49px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.panel-title { font-size: 12px; font-weight: 650; color: #3a5440; }
.panel-actions { display: flex; align-items: center; gap: 5px; }
.panel-actions button { padding: 4px 7px; font-size: 10px; background: transparent; border-color: transparent; color: #84907c; }
.panel-actions button:hover { border-color: #dde5d7; background: #f5f8f0; color: #36583d; }
.question-region { flex: 0 1 auto; max-height: 30vh; overflow-y: auto; padding: 17px 20px 14px; scrollbar-width: thin; }
.question-summary { font-size: 14px; line-height: 1.95; margin-bottom: 14px; color: #4f5e51; }
.examples { display: grid; gap: 8px; }
.example-card { padding: 10px 12px; border-left: 2px solid #b7cbb0; background: #f6f8f2; border-radius: 0 6px 6px 0; font-size: 12px; line-height: 1.85; overflow-wrap: anywhere; }
.example-card p { margin: 0; font-size: 13px; line-height: 1.85; }
.example-card code { color: #475d44; }
.example-label { color: #84917d; margin-right: 5px; font-size: 10px; }
.constraints { margin-top: 11px; font-size: 11px; color: #8b9585; line-height: 1.8; }
.constraints summary { cursor: pointer; }
.constraints ul { margin: 7px 0 0; padding-left: 19px; }
.mnemonic-bar { display: flex; align-items: flex-start; flex: 0 0 auto; gap: 10px; padding: 12px 18px; border-top: 1px solid #e6ebdf; border-bottom: 1px solid #e6ebdf; background: #f1f6e9; color: #4b6d3f; font-size: 13px; line-height: 1.85; }
.mnemonic-label { flex: 0 0 auto; color: #859b6c; font-size: 10px; padding-top: 2px; letter-spacing: 1px; }
.recall-toolbar { flex: 0 0 auto; padding: 12px 14px 9px; background: #f9faf6; border-bottom: 1px solid var(--line); }
.mask-levels { display: flex; gap: 4px; flex-wrap: wrap; }
.mask-levels button { flex: 1 1 auto; font-size: 10px; padding: 6px 7px; color: #7b8972; background: transparent; }
.mask-levels button.active { background: #3c7150; color: white; border-color: #3c7150; }
.recall-actions { display: flex; align-items: center; gap: 7px; margin-top: 9px; }
.recall-actions button { padding: 5px 8px; font-size: 10px; }
.recall-hint { margin: 7px 0 0; font-size: 10px; color: #929c89; line-height: 1.65; }
.code-toolbar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; color: #91ac95; background: var(--code); font: 10px/1.5 var(--mono); border-bottom: 1px solid #ffffff0a; }
.code-toolbar .lang-tag { color: #cad7b1; letter-spacing: .7px; }
.code-toolbar .code-hint { color: #829a87; font: 10px/1.5 "Microsoft YaHei", sans-serif; }
#code-hint { color: #a0b39c; font-size: 10px; }
.code-container { flex: 1 1 auto; min-height: 115px; overflow: auto; padding: 11px 0 20px; background: var(--code); color: var(--code-ink); scrollbar-width: thin; scrollbar-color: #49664c transparent; }
.code-block { padding: 4px 0; border-left: 3px solid transparent; }
.code-block.active { background: #d7eb9b09; border-left-color: #a9c287; }
.block-heading { display: flex; align-items: center; gap: 8px; margin: 0 9px 5px 42px; padding: 2px 5px; width: calc(100% - 51px); text-align: left; border-color: transparent; background: transparent; border-radius: 3px; color: #9fc19d; font-size: 10px; line-height: 1.6; }
.block-heading:hover { border-color: #a4c89322; background: #ffffff05; }
.block-title { white-space: nowrap; color: #a2bf84; }
.block-cue { color: #6f937b; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-lines { min-width: max-content; }
.code-preamble { min-width: max-content; }
.code-line { display: flex; align-items: flex-start; position: relative; min-height: 26px; font: 13px/26px var(--mono); padding: 0 8px 0 0; border-left: 2px solid transparent; }
.code-line.active { background: #ffffff06; }
.code-line.trace-active { background: #d5e9a823; border-left-color: #c3d58f; }
.code-line.bookmarked { background: #efc36909; }
.code-line.bookmarked .line-number { color: #c8ac76; }
.line-number { flex: 0 0 39px; width: 39px; text-align: right; padding-right: 12px; font-size: 10px; color: #53705e; user-select: none; }
.line-content { white-space: pre; min-height: 26px; flex: 1 0 auto; padding-right: 10px; tab-size: 4; }
.bookmark-button { flex: 0 0 23px; align-self: center; width: 23px; height: 22px; padding: 0; margin-left: 7px; color: #77957b; border: 0; background: transparent; border-radius: 4px; line-height: 22px; font-size: 12px; opacity: .35; }
.code-line:hover .bookmark-button, .bookmark-button:focus-visible, .code-line.bookmarked .bookmark-button { opacity: 1; }
.bookmark-button:hover { background: #ffffff0b; color: #d8c087; }
.masked-placeholder { color: #71937a; font-style: italic; cursor: pointer; letter-spacing: .5px; font-size: 11px; }
.code-line.masked .line-content { color: #71937a; }
.syntax-token { display: inline; padding: 0; margin: 0; border: 0; border-radius: 0; background: transparent; color: inherit; font: inherit; vertical-align: baseline; text-decoration: underline dotted #86a18a55; text-underline-offset: 4px; }
.syntax-token:hover { background: #b4d1971c; color: #e2ebc1; }
.token-keyword { color: #c8c0e6; }
.token-string { color: #c6d69a; }
.token-number { color: #e2c695; }
.token-comment { color: #71917b; font-style: italic; }
.token-name { color: #91c4bf; }
.empty-code { color: #90ab92; text-align: center; padding: 38px 20px; font-size: 12px; line-height: 1.9; }

.write-area { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--code); padding: 14px 16px; gap: 9px; overflow-y: auto; }
.editor-label { color: #9db69d; font-size: 11px; display: flex; justify-content: space-between; gap: 8px; }
#editor { display: block; width: 100%; flex: 1 0 210px; min-height: 210px; max-height: 70vh; font: 13px/1.9 var(--mono); border: 1px solid #4d695344; border-radius: 6px; padding: 13px; color: #e2ecd9; background: #10251e; tab-size: 4; white-space: pre; overflow: auto; resize: vertical; }
#editor::placeholder { color: #627e67; }
.editor-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px; }
.editor-actions button { padding: 6px 9px; font-size: 11px; }
.draft-status { font-size: 10px; color: #8da18c; }
.diff-panel { border: 1px solid #456047; border-radius: 5px; overflow: auto; font: 11px/1.9 var(--mono); background: #10251e; color: #bfd0b9; flex-shrink: 0; }
.diff-panel > p { padding: 12px; font: 11px/1.8 "Microsoft YaHei", sans-serif; margin: 0; }
.diff-summary { padding: 12px; font: 12px/1.8 "Microsoft YaHei", sans-serif; color: #b8cbaa; border-bottom: 1px solid #ffffff12; white-space: normal; }
.diff-summary strong { color: #d8e7c7; font-weight: 600; }
.diff-summary p { color: #96ac8f; font-size: 11px; margin: 5px 0 0; }
.diff-row { display: flex; min-width: max-content; padding: 0 10px; }
.diff-row.add { color: #b7daa8; background: #75b76b14; }
.diff-row.remove { color: #dfa79a; background: #e2978210; }
.diff-number { flex: 0 0 45px; width: 45px; color: #6b846c; user-select: none; }
.diff-text { white-space: pre; padding-right: 12px; }

.right-tabs { display: flex; flex: 0 0 auto; align-items: stretch; gap: 13px; padding: 0 17px; min-height: 49px; border-bottom: 1px solid var(--line); }
.right-tabs button { position: relative; padding: 13px 2px; background: transparent; border: none; border-radius: 0; color: #8a9583; font-size: 11px; white-space: nowrap; }
.right-tabs button:hover { color: #467044; background: transparent; }
.right-tabs button.active { color: #3a6541; font-weight: 650; }
.right-tabs button.active::after { content: ""; position: absolute; bottom: -1px; height: 2px; left: 0; right: 0; background: #527e4d; }
.right-content { flex: 1; min-height: 0; padding: 20px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #d4dfcd transparent; }
.explanation-section { margin-bottom: 24px; }
.explanation-section:last-child { margin-bottom: 0; }
.explanation-title { color: #405b40; font-size: 15px; font-weight: 650; margin-bottom: 10px; }
.explanation-body { color: #6f7c69; font-size: 14px; line-height: 1.95; }
.explanation-body p:last-child { margin-bottom: 0; }
.step-card { display: flex; gap: 11px; width: 100%; text-align: left; background: #fbfcf9; border: 1px solid #e7ecdf; padding: 13px 12px; border-radius: 8px; margin-bottom: 8px; }
.step-card:hover { border-color: #bbcfaf; background: #f6faef; }
.step-card.active { background: #eff5e6; border-color: #bbd1a3; }
.step-index { flex: 0 0 21px; width: 21px; height: 21px; display: grid; place-items: center; color: #79965e; border: 1px solid #dce6d1; border-radius: 50%; font: 10px/1 var(--mono); background: white; }
.step-card.active .step-index { color: white; background: #769b5c; border-color: #769b5c; }
.step-copy { min-width: 0; color: #66765d; font-size: 13px; line-height: 1.9; }
.step-copy strong { display: block; color: #486340; font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.step-copy p { margin: 0; font-size: 13px; line-height: 1.9; }
.insight-card { padding: 14px 16px; border: 1px solid #dfe8d3; background: #f3f7ec; border-radius: 8px; color: #678050; font-size: 13px; line-height: 1.9; margin-bottom: 17px; }
.insight-card strong { color: #4f6b3d; }
.complexity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 10px 0; }
.complexity-card { padding: 13px; background: #f6f8f2; border: 1px solid #e7ebdf; border-radius: 8px; color: #8b977e; font-size: 10px; line-height: 1.8; }
.complexity-card strong { display: block; font: 600 17px/1.6 var(--mono); color: #53713f; }
.pitfall-card { padding: 11px 13px; border-left: 2px solid #d8c79c; background: #fbf9f2; margin: 8px 0; border-radius: 0 6px 6px 0; color: #8d846d; font-size: 13px; line-height: 1.85; }
.pitfall-card strong, .pitfall-card h4 { display: block; font-size: 13px; font-weight: 600; color: #8a7854; margin-bottom: 4px; }
.pitfall-card p { margin: 0; font-size: 13px; }
.syntax-card { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; border: 1px solid #e4eade; border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; background: #fbfcf9; color: #77866e; font-size: 13px; line-height: 1.85; }
.syntax-card > span:last-child { margin-left: auto; color: #98aa87; }
.syntax-card h3, .syntax-card strong { font-size: 12px; color: #4c6843; }
.syntax-card p { margin: 7px 0; font-size: 13px; }
.syntax-card code { background: #e9f0e2; padding: 2px 5px; border-radius: 3px; }
.syntax-example { margin-top: 8px; padding: 10px; border-radius: 5px; background: #edf2e7; color: #657f50; font: 11px/1.85 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.memory-card { margin-bottom: 9px; background: #fbfcf9; border: 1px solid #e4eade; border-radius: 8px; font-size: 13px; }
.memory-card summary { cursor: pointer; padding: 14px; color: #506c46; line-height: 1.85; }
.memory-card summary > span { color: #9bad8c; font: 10px/1.8 var(--mono); margin-right: 9px; }
.memory-card[open] summary { border-bottom: 1px solid #e9eee3; }
.memory-answer { color: #7b8972; padding: 13px 14px; line-height: 1.9; background: #f5f8f0; border-radius: 0 0 8px 8px; }
.personal-note { margin: 20px 0; }
.personal-note label { display: block; color: #607654; font-size: 12px; margin-bottom: 8px; }
.personal-note textarea, #personal-note { width: 100%; min-height: 120px; padding: 12px; border-color: #dfe7d7; background: #fcfdf9; color: #4f6547; font-size: 13px; }
.personal-note textarea::placeholder, #personal-note::placeholder { color: #9aa590; }
.note-list { display: grid; gap: 9px; margin-top: 12px; }
.note-item { padding: 12px; background: #faf9f1; border: 1px solid #e8e2c9; border-radius: 7px; color: #877e60; font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.note-item code { display: block; color: #566c46; margin: 7px 0; white-space: pre-wrap; }
.note-item button { font-size: 10px; padding: 3px 6px; float: right; }

.trace-header { display: flex; flex-direction: column; gap: 6px; align-items: stretch; margin-bottom: 9px; }
.trace-header .eyebrow { margin-bottom: 1px; }
.trace-title { color: #45633e; font-size: 17px; font-weight: 600; line-height: 1.65; }
.trace-caption { color: #748367; font-size: 13px; line-height: 1.85; margin: 3px 0 8px; }
.trace-controls { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin: 15px 0 20px; }
.trace-controls button { padding: 6px 10px; font-size: 11px; }
.trace-counter { color: #9aa78d; font: 11px/1.6 var(--mono); white-space: nowrap; }
.trace-stage { border: 1px solid #e0e8d6; border-radius: 9px; background: #f6f9f0; padding: 20px 12px 16px; margin-bottom: 15px; overflow: hidden; }
.trace-cells { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; align-items: flex-start; padding: 0 0 6px; }
.trace-cell { flex: 0 0 auto; min-width: 39px; text-align: center; border: 1px solid #dce5d1; border-radius: 6px; color: #7b8b6c; background: #fff; padding: 8px 7px 6px; font: 14px/1.3 var(--mono); transition: background .15s, border-color .15s; }
.trace-cell.active { border-color: #8baa71; color: #4c7036; background: #e8f0dc; box-shadow: 0 0 0 2px #e2edd5; }
.trace-cell.found { border-color: #6f9b73; color: #2d6a40; background: #e3f0df; }
.trace-cell.muted { opacity: .46; }
.cell-value { display: block; }
.trace-cell { max-width: 100%; overflow-wrap: anywhere; }
.cell-label { display: block; margin-top: 6px; color: #9da98f; font: 9px/1.4 var(--mono); }
.trace-pointers { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 9px 0 2px; min-height: 17px; }
.pointer-label { display: inline-block; color: #76945e; font: 10px/1.5 var(--mono); background: #edf3e1; border-radius: 4px; padding: 2px 6px; margin-top: 5px; }
.variable-grid { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0; }
.variable-chip { display: flex; flex-direction: column; gap: 3px; min-width: 62px; padding: 8px 12px; border: 1px solid #e1e8d8; border-radius: 5px; background: white; font: 11px/1.8 var(--mono); color: #849377; overflow-wrap: anywhere; }
.variable-chip strong { color: #4d703d; font-size: 14px; font-weight: 600; }
.trace-groups { display: grid; gap: 7px; margin-top: 14px; }
.group-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid #e0e7d5; background: #fff; border-radius: 5px; font: 11px/1.8 var(--mono); }
.group-key { color: #79985a; min-width: 35px; }
.group-values { color: #66785a; overflow-wrap: anywhere; }
.trace-answer { padding: 11px 12px; margin: 12px 0 0; border: 1px solid #cbdcbd; border-radius: 6px; background: #eaf3df; color: #5a7a40; font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.trace-answer span { display: block; color: #8aa078; font-size: 10px; margin-bottom: 3px; }
.trace-answer strong { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.trace-line-hint { color: #91a080; font-size: 10px; line-height: 1.8; }
.bar-chart { display: flex; align-items: flex-end; justify-content: center; gap: 6px; height: 180px; margin: 5px 0 12px; padding: 0 4px; }
.chart-column { flex: 1; max-width: 34px; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart-bar { width: 100%; min-height: 5px; background: #d4dfc7; border-radius: 3px 3px 0 0; position: relative; display: flex; align-items: flex-start; justify-content: center; padding-top: 5px; font: 10px/1.4 var(--mono); color: #6f8660; }
.chart-bar.in-container { background: #bacfa6; }
.chart-bar.active { background: #97b777; color: #fff; }
.chart-bar.found { background: #65996b; color: #fff; }
.chart-label { margin-top: 7px; color: #9ba78d; font: 9px/1 var(--mono); }

.review-bar { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; min-height: 76px; gap: 12px; padding: 14px 30px; border-top: 1px solid var(--line); background: #fcfdf9; }
.review-caption { color: #7e8a75; font-size: 11px; line-height: 1.8; }
.review-caption strong { display: block; font-weight: 600; color: #48623f; font-size: 12px; }
.review-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.review-actions button { font-size: 11px; padding: 9px 14px; white-space: nowrap; }
.review-actions button[data-rating="forgot"] { color: #a58476; background: #fbf6f2; border-color: #e9dcd3; }
.review-actions button[data-rating="hint"] { color: #9d8954; background: #fcf9ed; border-color: #e8dfbf; }
.review-actions button[data-rating="remembered"] { color: white; background: #467954; border-color: #467954; }
.review-actions button[data-rating="remembered"]:hover { background: #356240; }
.review-actions button.selected { box-shadow: 0 0 0 2px #c5d8b8; }
.next-review { color: #94a086; font-size: 10px; line-height: 1.7; }
.session-link { color: #6b8b55; font-size: 11px; background: transparent; border-color: transparent; }
.toast { position: fixed; left: calc(50% + 90px); bottom: 97px; max-width: min(500px, 85vw); transform: translateX(-50%); padding: 12px 20px; border: 1px solid #4c6954; border-radius: 9px; background: #214834; color: #eef7e7; box-shadow: 0 8px 30px #153a2525; font-size: 12px; line-height: 1.8; z-index: 100; text-align: center; pointer-events: none; }
dialog.modal { width: min(610px, 90vw); max-height: 85vh; padding: 0; border: 1px solid #dae4d1; border-radius: 13px; background: #fcfdf9; color: var(--ink); box-shadow: 0 22px 100px #0c2e2733; }
dialog.modal::backdrop { background: #15372b66; backdrop-filter: blur(2px); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 19px 23px; border-bottom: 1px solid var(--line); }
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-close { width: 29px; height: 29px; padding: 0; background: transparent; color: #8b9a80; border-color: transparent; font-size: 19px; }
.modal-body { padding: 22px 23px; overflow-y: auto; max-height: 65vh; color: #708165; font-size: 13px; line-height: 1.9; }
.modal-body h3 { font-size: 13px; color: #4b6940; margin: 16px 0 8px; }
.modal-body h3:first-child { margin-top: 0; }
.modal-body p { font-size: 13px; }
.shortcut-grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; align-items: center; margin: 15px 0; }
kbd { display: inline-block; padding: 1px 6px; border: 1px solid #dce4d4; border-radius: 4px; box-shadow: 0 2px 0 #e2e8db; background: #fff; color: #6a8059; font: 10px/1.8 var(--mono); white-space: nowrap; }
.syntax-popover { padding: 16px; border: 1px solid #ccd9be; border-radius: 8px; background: #fbfdf5; color: #657953; box-shadow: 0 8px 32px #1e40251a; max-width: min(360px, 85vw); font-size: 12px; line-height: 1.9; z-index: 30; }

@media (min-width: 1650px) {
  .app-shell { grid-template-columns: 255px minmax(0, 1fr); }
  .workspace { max-width: 1900px; width: 100%; }
  .topbar, .problem-heading, .review-bar { padding-left: 40px; padding-right: 40px; }
  .modebar { padding-left: 40px; padding-right: 40px; }
  .study-grid { margin-left: 40px; margin-right: 40px; gap: 23px; }
  .right-content { padding: 26px; }
  .code-line { font-size: 14px; line-height: 28px; min-height: 28px; }
  .line-content { min-height: 28px; }
  .question-summary { font-size: 14px; }
  .step-copy, .step-copy p { font-size: 14px; }
  .explanation-body { font-size: 15px; }
}

@media (max-width: 1150px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .topbar, .problem-heading, .review-bar { padding-left: 20px; padding-right: 20px; }
  .modebar { padding-left: 20px; padding-right: 20px; gap: 11px; }
  .study-grid { margin-left: 20px; margin-right: 20px; gap: 12px; }
  .panel-header { padding-left: 13px; padding-right: 13px; }
  .question-region, .right-content { padding: 15px; }
  .right-tabs { gap: 10px; padding: 0 13px; }
  .right-tabs button { font-size: 10px; }
  .mode-description { font-size: 10px; }
  .review-actions button { padding: 8px 10px; font-size: 10px; }
  .review-caption { font-size: 10px; }
  .review-caption strong { font-size: 11px; }
  .recall-actions { flex-wrap: wrap; }
  .code-line { font-size: 12px; }
}

@media (max-width: 800px) {
  body { overflow: auto; }
  .app-shell { display: block; height: auto; min-height: 100dvh; }
  .sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 0 8px; padding: 16px 16px 10px; min-height: auto; }
  .brand { grid-column: 1 / -1; margin: 0 0 15px; padding: 0; }
  .brand-icon { flex-basis: 34px; width: 34px; height: 34px; font-size: 19px; }
  .brand-name { font-size: 19px; }
  .brand-subtitle { font-size: 8px; }
  .side-section-label { display: none; }
  .sidebar-footer { display: flex; grid-column: 1 / -1; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 0 0; }
  .sidebar-progress, .sidebar-footer .progress-track { display: none; }
  .sidebar-footer .save-status { flex: 1; font-size: 9px; margin: 0; }
  .sidebar-footer .save-status.save-error { color: #ffd0a8; font-size: 10px; }
  .sidebar-actions { flex: 0 0 160px; margin: 0; gap: 6px; }
  .sidebar-actions button { padding: 6px; font-size: 10px; }
  .session-filters { position: absolute; top: 17px; right: 16px; width: 190px; margin: 0; }
  .session-filters button { padding: 7px 2px; }
  .search-box { display: block; grid-column: 1; width: 100%; margin: 0; }
  .search-box input { padding: 8px 10px 8px 29px; }
  .category-select { display: block; grid-column: 2; width: 100%; padding: 8px 7px; margin: 0; }
  #problem-list { grid-column: 1 / -1; display: flex; flex-wrap: nowrap; gap: 7px; overflow-x: auto; min-width: 0; padding: 0 0 2px; margin: 10px 0 0; }
  .problem-item { width: 170px; min-width: 170px; gap: 6px; padding: 9px; margin: 0; }
  .problem-item-title { font-size: 11px; }
  .problem-order { flex-basis: 15px; font-size: 10px; }
  .problem-item-meta { font-size: 9px; margin-top: 4px; }
  .workspace { min-height: calc(100dvh - 180px); }
  .topbar { min-height: 45px; padding: 0 16px; }
  .breadcrumb { font-size: 10px; }
  .top-actions { gap: 4px; }
  .top-actions button { font-size: 10px; padding: 5px 7px; }
  .problem-heading { padding: 19px 16px 14px; gap: 10px; align-items: flex-start; }
  h1 { font-size: 25px; }
  .eyebrow { font-size: 9px; margin-bottom: 5px; }
  .problem-tags { gap: 5px; margin-top: 8px; }
  .tag { font-size: 9px; }
  .problem-nav { gap: 4px; }
  .problem-nav button { padding: 6px 8px; font-size: 10px; }
  .source-link { font-size: 10px; padding: 5px 0; }
  .modebar { padding: 0 16px 14px; align-items: flex-start; gap: 10px; }
  .mode-tabs { padding: 3px; }
  .mode-tabs button { min-width: 56px; padding: 7px 10px; font-size: 11px; }
  .mode-description { font-size: 10px; padding-top: 3px; }
  .study-grid { grid-template-columns: minmax(0, 1fr); margin: 0 16px 16px; gap: 14px; flex: none; }
  .panel { min-height: 200px; }
  .question-region { max-height: none; padding: 16px; overflow: visible; }
  .question-summary { font-size: 14px; }
  .panel-header { padding-left: 16px; padding-right: 16px; }
  .code-container { max-height: 570px; min-height: 200px; }
  .code-line { font-size: 13px; line-height: 26px; }
  .line-content { min-height: 26px; }
  .right-content { max-height: none; overflow: visible; padding: 18px; }
  .right-tabs { gap: 18px; padding: 0 16px; }
  .right-tabs button { font-size: 11px; padding: 14px 0; }
  .recall-toolbar { padding-left: 15px; padding-right: 15px; }
  .mask-levels button { font-size: 11px; padding: 7px; }
  .recall-actions button { font-size: 11px; }
  .write-area { min-height: 360px; }
  #editor { flex-basis: 280px; }
  .review-bar { position: sticky; bottom: 0; z-index: 10; min-height: 72px; padding: 11px 16px; flex-wrap: wrap; box-shadow: 0 -5px 18px #1b392408; }
  .review-caption { flex: 1; min-width: 110px; }
  .review-actions { gap: 5px; }
  .review-actions button { padding: 8px 10px; font-size: 11px; }
  .next-review { font-size: 9px; }
  .toast { left: 50%; bottom: 94px; width: max-content; }
  .bookmark-button { opacity: .75; }
}

@media (max-width: 430px) {
  .brand { gap: 8px; }
  .brand-name { font-size: 18px; letter-spacing: 2px; }
  .brand-subtitle { letter-spacing: 1px; font-size: 7px; }
  .session-filters { width: 170px; right: 12px; }
  .session-filters button { font-size: 10px; }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .topbar, .problem-heading, .review-bar { padding-left: 12px; padding-right: 12px; }
  .problem-heading { flex-wrap: wrap; }
  .heading-copy { flex: 1; min-width: 190px; }
  .problem-heading > .problem-nav { align-self: center; }
  .problem-tags { margin-top: 7px; }
  .modebar { padding-left: 12px; padding-right: 12px; }
  .mode-description { display: none; }
  .study-grid { margin-left: 10px; margin-right: 10px; }
  .right-tabs { gap: 14px; }
  .line-number { flex-basis: 31px; width: 31px; padding-right: 9px; }
  .block-heading { margin-left: 32px; width: calc(100% - 41px); }
  .code-line { font-size: 12px; }
  .review-bar { gap: 8px; }
  .review-caption { width: 100%; flex-basis: 100%; display: flex; justify-content: space-between; align-items: center; }
  .review-caption strong { font-size: 11px; }
  .review-actions { width: 100%; }
  .review-actions button { flex: 1; font-size: 10px; padding: 8px; }
  .trace-cell { min-width: 33px; padding-left: 5px; padding-right: 5px; font-size: 12px; }
  .trace-cells { gap: 5px; }
}

@media (max-width: 360px) {
  .session-filters { position: static; grid-column: 1 / -1; width: 100%; margin: 0 0 10px; }
  .sidebar { grid-template-columns: minmax(0, 1fr) 105px; }
  .sidebar-actions { flex-basis: 145px; }
  .top-actions > .muted { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Reading layout: the two panes own the space, with one vertical scroll per pane. */
:root { --reading-size: 11px; }
.app-shell { grid-template-columns: 180px minmax(0, 1fr); }
.sidebar { padding: 14px 12px 10px; }
.sidebar > :not(#problem-list) { flex-shrink: 0; }
.brand { margin-bottom: 12px; padding: 0 5px; gap: 8px; }
.brand-icon { flex-basis: 31px; width: 31px; height: 31px; font-size: 17px; }
.brand-name { font-size: 19px; }
.brand-subtitle { font-size: 8px; letter-spacing: .3px; }
.side-section-label { margin-bottom: 8px; padding: 0 5px; font-size: 9px; }
.session-filters { margin-bottom: 9px; }
.session-filters button { font-size: 9px; padding: 6px 0; }
.search-box input { font-size: 11px; padding-top: 7px; padding-bottom: 7px; }
.library-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.library-filters .category-select { padding-left: 3px; padding-right: 3px; }
.filter-result-count { margin-bottom: 6px; }
#problem-list { padding-bottom: 4px; overflow-anchor: none; }
.problem-item { padding: 8px 7px; gap: 6px; margin-bottom: 3px; }
.problem-item-title { font-size: 12px; }
.problem-item-meta { font-size: 9px; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.problem-order { font-size: 10px; flex-basis: 17px; }
.category-select { margin-bottom: 12px; font-size: 10px; padding: 6px 8px; }
.sidebar-footer { padding: 8px 5px 0; max-height: 43%; overflow-y: auto; scrollbar-width: thin; }
.sidebar-footer .progress-track { margin: 5px 0 6px; height: 3px; }
.sidebar-footer .save-status { margin: 0 0 3px; }
.storage-settings { margin-top: 4px; font-size: 10px; color: #bed3c0; }
.storage-settings > summary { cursor: pointer; padding: 3px 0; width: fit-content; }
.storage-settings[open] > summary { color: #edf4eb; }
.storage-settings .local-file-panel { margin: 6px 0 0; padding: 6px 0; border-bottom: 0; }
.storage-settings .sidebar-actions { margin-top: 6px; }
.workspace { max-width: none; width: auto; }
.topbar { min-height: 30px; padding: 0 10px; }
.breadcrumb { font-size: 10px; }
.top-actions { gap: 8px; }
.reading-size-label { font-size: 10px; color: var(--secondary); }
#reading-size { padding: 2px 5px; font-size: 10px; }
.workspace-controls { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; gap: 10px; padding: 7px 10px; min-height: 50px; }
.problem-heading { flex: 1; min-width: 0; padding: 0; gap: 12px; }
.heading-copy { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
#problem-meta { display: none; }
h1 { font-size: 20px; line-height: 1.4; letter-spacing: 0; }
.problem-tags { margin: 0; gap: 5px; }
.tag { font-size: 10px; }
.problem-nav { flex-shrink: 0; }
.source-link { font-size: 11px; padding: 3px; }
.modebar { padding: 0; flex-shrink: 0; }
.mode-tabs { padding: 3px; }
.mode-tabs button { font-size: 12px; min-width: 56px; padding: 4px 8px; }
.mode-description { display: none; }
.study-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin: 0 10px 8px; }
.panel { border-radius: 8px; }
.panel-header { min-height: 34px; padding: 7px 12px; }
.panel-title { font-size: 13px; }
.panel-actions button { font-size: 11px; padding: 3px 5px; }
.left-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #b6c7b0 transparent; }
.question-region { flex: none; max-height: none; padding: 12px 14px 10px; overflow: visible; }
.question-summary { color: #354b3e; font-size: var(--reading-size); line-height: 1.75; margin-bottom: 10px; }
.question-details { color: #687b61; font-size: 11px; }
.question-details > summary { cursor: pointer; width: fit-content; line-height: 1.8; }
.question-details > summary span { margin-left: 8px; color: #8a9684; font-size: 10px; }
.question-details .examples { margin-top: 12px; }
.example-trees { display: grid; gap: 8px; margin-top: 10px; }
.detached-trees { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 8px; margin-top: 8px; }
.example-card, .example-card p { font-size: var(--reading-size); line-height: 1.75; }
.example-label { font-size: 10px; }
.question-details .constraints { font-size: var(--reading-size); color: #586c51; }
.mnemonic-bar { padding: 7px 14px; font-size: var(--reading-size); line-height: 1.6; }
.mnemonic-label { font-size: 10px; }
.code-toolbar { padding: 6px 12px; font-size: 10px; gap: 8px; }
.code-tools { display: flex; align-items: center; gap: 10px; }
.line-recall-controls { display: none; align-items: center; gap: 7px; }
.line-recall-controls button { padding: 3px 7px; border-color: #69857466; background: #29473a; color: #cadac8; font: 10px/1.5 "Microsoft YaHei", sans-serif; white-space: nowrap; }
.line-recall-controls button:hover { background: #3d604b; color: #fff; }
#line-recall-count { min-width: 38px; color: #cadac8; font: 10px/1.5 var(--mono); text-align: center; white-space: nowrap; }
#code-hint { font-size: 10px; }
#toggle-code-hints { padding: 3px 7px; border-color: #69857466; background: #29473a; color: #cadac8; font: 10px/1.5 "Microsoft YaHei", sans-serif; }
#toggle-code-hints:hover, #toggle-code-hints[aria-pressed="true"] { background: #3d604b; color: #fff; }
.code-container { flex: none; height: auto; min-height: 0; max-height: none; padding: 10px 0 14px; overflow-x: auto; overflow-y: hidden; }
.code-line { font-size: var(--reading-size); line-height: 1.65; min-height: 18px; }
.line-content { min-height: 18px; }
.line-number { font-size: 10px; }
.code-preamble { border-left: 3px solid transparent; }
.block-heading { padding-top: 2px; padding-bottom: 2px; margin-bottom: 2px; font-size: 10px; }
.block-cue { font-size: 10px; }
.code-container:not(.show-code-hints) .block-heading { display: none; }
.code-container:not(.show-code-hints) .code-block { padding: 0; background: transparent; }
.bookmark-button { width: 20px; flex-basis: 20px; height: 18px; line-height: 18px; font-size: 11px; }
.masked-placeholder { font-size: var(--reading-size); }
.recall-toolbar { position: sticky; top: 0; z-index: 3; padding: 10px 16px; box-shadow: 0 3px 7px #2038300a; }
.mask-levels button, .recall-actions button { font-size: 11px; }
.recall-hint { font-size: 10px; }
.write-area { flex: none; min-height: 400px; overflow: visible; }
.editor-label { font-size: 11px; flex-wrap: wrap; }
#editor { font-size: var(--reading-size); min-height: 270px; line-height: 1.65; }
.editor-actions button { font-size: 11px; }
.draft-status { font-size: 10px; }
.diff-panel { font-size: var(--reading-size); }
.right-tabs { min-height: 34px; flex-wrap: wrap; gap: 0 12px; padding: 0 10px; }
.right-tabs button { font-size: 12px; padding: 8px 0; }
.right-content { padding: 13px 14px; font-size: var(--reading-size); }
.analysis-steps { display: grid; gap: 15px; padding: 0; margin: 17px 0; list-style: none; }
.analysis-step { display: flex; gap: 10px; align-items: flex-start; }
.analysis-index { display: grid; place-items: center; flex: 0 0 24px; height: 24px; border: 1px solid #dce6d1; border-radius: 50%; background: #f3f7ec; color: #567849; font: 10px/1 var(--mono); }
.analysis-copy { min-width: 0; overflow-wrap: anywhere; }
.explanation-section .analysis-copy h3 { margin: 0 0 4px; font-size: calc(var(--reading-size) + 1px); line-height: 1.7; color: #36573e; }
.analysis-copy p { margin: 0; color: #465b3f; font-size: var(--reading-size); line-height: 1.85; }
.analysis-takeaway p { margin: 5px 0 0; }
.explanation-title { font-size: calc(var(--reading-size) + 2px); line-height: 1.6; color: #2f503b; }
.explanation-body, .step-copy, .step-copy p { font-size: var(--reading-size); line-height: 1.8; color: #465b3f; }
.step-copy strong { font-size: var(--reading-size); }
.step-card { padding: 9px 10px; margin-bottom: 7px; gap: 8px; }
.step-index { width: 19px; flex-basis: 19px; height: 19px; font-size: 10px; }
.explanation-section h3 { font-size: calc(var(--reading-size) + 1px); margin: 14px 0 8px; }
.insight-card, .pitfall-card, .pitfall-card p, .memory-card, .personal-note textarea, #personal-note { font-size: var(--reading-size); }
.pitfall-card strong { font-size: var(--reading-size); }
.syntax-card { display: flex; width: 100%; align-items: center; gap: 9px; padding: 10px; text-align: left; font-size: var(--reading-size); }
.syntax-card > span:last-child { margin-left: auto; }
.syntax-example, .note-item, .memory-answer { font-size: var(--reading-size); }
.personal-note label { font-size: var(--reading-size); }
.complexity-card { font-size: 11px; padding: 10px; }
.complexity-card strong { font-size: 15px; }
.complexity-note { font-size: 11px; }
.trace-title { font-size: calc(var(--reading-size) + 2px); }
.trace-caption { font-size: var(--reading-size); color: #536c47; }
.trace-controls button { font-size: 11px; }
.trace-counter { font-size: 11px; }
.trace-cell { font-size: 14px; }
.cell-label, .pointer-label { font-size: 10px; }
.variable-chip { font-size: 11px; }
.group-row, .trace-answer { font-size: 12px; }
.trace-line-hint { font-size: 10px; }
.review-bar { min-height: 52px; padding: 7px 10px; }
.review-caption, .review-caption strong { font-size: 11px; }
.review-actions button { font-size: 11px; padding: 6px 9px; }
.session-link { font-size: 11px; }
.local-file-panel { margin: 10px 0; padding: 9px 0; border-top: 1px solid #ffffff15; border-bottom: 1px solid #ffffff15; min-width: 0; }
.local-file-heading { font-size: 10px; color: #bed3c0; margin-bottom: 4px; }
#local-file-status { margin: 0; font-size: 9px; line-height: 1.65; color: #92b29c; overflow-wrap: anywhere; }
#local-file-status.file-error { color: #ffd0a8; }
.local-file-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.local-file-actions button { font-size: 9px; padding: 4px 6px; background: #ffffff08; color: #d0e3cf; border-color: #ffffff25; }
.local-file-actions button:hover { background: #ffffff14; }
.file-choice-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 1100px) and (min-width: 801px) {
  .app-shell { grid-template-columns: 165px minmax(0, 1fr); }
  .session-filters { padding: 3px; gap: 1px; }
  .workspace-controls { gap: 8px; }
  .mode-tabs button { min-width: 58px; padding: 6px 8px; }
  .problem-nav { gap: 3px; }
  .source-link { display: none; }
  .right-tabs { gap: 12px; padding: 0 14px; }
  .right-tabs button { font-size: 14px; }
  .panel-actions { gap: 0; }
  .panel-actions button { font-size: 12px; }
  .review-bar { flex-wrap: wrap; gap: 6px; }
}

@media (max-width: 800px) {
  .app-shell { display: block; }
  .sidebar { padding: 15px 12px 10px; }
  .search-box { grid-column: 1 / -1; }
  .library-filters { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 8px 0 0; }
  .filter-result-count { grid-column: 1 / -1; margin: 5px 0 0; }
  .brand { margin-bottom: 15px; }
  .topbar { min-height: 40px; padding: 0 12px; }
  .breadcrumb { display: none; }
  .top-actions { width: 100%; justify-content: flex-end; }
  .workspace-controls { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; }
  .problem-heading { padding: 0; flex-wrap: nowrap; }
  .heading-copy { flex: 1; min-width: 0; gap: 7px; }
  h1 { font-size: 23px; }
  .problem-nav { gap: 3px; }
  .source-link { font-size: 12px; }
  .modebar { padding: 0; }
  .study-grid { grid-template-columns: minmax(0, 1fr); margin: 0 10px 12px; }
  .left-scroll { overflow: visible; flex: none; }
  .question-region { padding: 16px; }
  .code-container { min-height: 0; max-height: none; }
  .code-line { font-size: var(--reading-size); }
  .recall-toolbar { position: static; }
  .right-content { padding: 18px; overflow: visible; }
  .right-tabs { gap: 0 6px; padding: 0 10px; }
  .right-tabs button { font-size: 12px; }
  .review-bar { padding: 10px 12px; }
  .review-actions button { font-size: 12px; }
  .trace-cell { font-size: 15px; }
  .variable-chip { font-size: 13px; }
  .sidebar-footer { flex-wrap: wrap; max-height: none; overflow: visible; }
  .sidebar-footer #local-file-status { flex: 1 1 100%; grid-column: auto; }
  .storage-settings { flex: 1 1 100%; margin: 0; }
  .storage-settings .sidebar-actions { max-width: 220px; }
  .local-file-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 3px 8px; margin: 0; padding: 7px 0; }
  .local-file-heading { grid-column: 1; margin: 0; }
  #local-file-status { grid-column: 1; margin: 0; }
  .local-file-actions { grid-column: 2; grid-row: 1 / 3; justify-content: flex-end; }
}

/* Reuse the original pane in the browser's modal layer, keeping code and drafts intact. */
body.code-expanded { overflow: hidden; }
.random-mask-settings { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin: 8px 0; font-size: 10px; }
.random-mask-settings select { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink); font: inherit; }
.random-mask-settings span { color: var(--secondary); }
.expanded-practice-controls { display: none; gap: 5px; align-items: center; }
.code-dialog .expanded-practice-controls { display: inline-flex; }
.code-dialog .code-tools { flex-wrap: wrap; }
.partial-write-banner { display: flex; flex: 0 0 auto; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; background: #d5e9c811; border: 1px solid #8ca47e55; border-radius: 5px; color: #c4d8bc; font-size: 10px; }
.partial-write-banner button { border: 1px solid #8ca47e66; background: #d5e9c811; color: #d6e8cf; white-space: nowrap; }
.recall-actions { flex-wrap: wrap; }
.code-dialog { inset: 0; margin: 0; padding: 0; width: 100vw; max-width: none; height: 100vh; height: 100dvh; max-height: none; border: 0; border-radius: 0; overflow: hidden; background: var(--paper); color: var(--ink); }
.code-dialog[open] { display: flex; }
.code-dialog::backdrop { background: #163c3299; }
.code-dialog .left-panel { flex: 1; width: 100%; height: 100%; min-height: 0; border: 0; border-radius: 0; box-shadow: none; }
.code-dialog .left-scroll { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: auto; background: var(--code); }
.code-dialog .question-region { background: var(--paper); }
.code-dialog .code-container { flex: 1 0 auto; min-height: 0; max-height: none; }
.code-dialog .write-area { flex: 1 0 auto; min-height: 360px; }
.code-dialog #editor { max-height: none; }
.code-dialog .panel-header { flex-wrap: wrap; justify-content: flex-end; }
.code-dialog .panel-title, .code-dialog .recall-toolbar { display: none; }
.code-dialog .code-toolbar.line-recall { position: sticky; top: 0; z-index: 4; }
.code-dialog .line-recall-controls { display: flex; }
.code-dialog .line-recall #code-hint { display: none; }
.code-dialog .panel-actions { flex-shrink: 0; }
.code-dialog #toggle-code-expand { color: var(--accent); border-color: #bfd1bd; background: var(--accent-soft); }

/* A roomy draft editor and an independently scrollable reference in the right pane. */
.writing-mode .left-scroll { display: flex; flex-direction: column; }
.writing-mode .write-area, .code-dialog .write-area { flex: 1 0 330px; min-height: 330px; padding: 11px 12px; gap: 8px; }
.editor-label { flex: 0 0 auto; align-items: baseline; }
.editor-label > span { color: #93ac97; font-size: 10px; }
.editor-frame { display: flex; flex: 1 0 220px; min-height: 220px; min-width: 0; overflow: hidden; background: #10251e; border: 1px solid #4d695388; border-radius: 6px; }
.editor-frame:focus-within { border-color: #8fb69a; box-shadow: 0 0 0 1px #8fb69a44; }
.editor-gutter { flex: 0 0 39px; overflow: hidden; color: #7b9680; background: #ffffff03; border-right: 1px solid #ffffff09; user-select: none; }
#editor-lines { padding: 12px 8px 12px 2px; text-align: right; white-space: pre; font: var(--reading-size)/1.65 var(--mono); }
#editor { flex: 1 1 auto; width: 0; min-width: 0; min-height: 220px; max-height: none; margin: 0; border: 0; border-radius: 0; padding: 12px 10px; resize: none; background: transparent; font: var(--reading-size)/1.65 var(--mono); scrollbar-width: thin; scrollbar-color: #49664c transparent; }
#editor:focus-visible { outline: none; }
.editor-status { display: flex; flex: 0 0 auto; justify-content: space-between; gap: 8px; flex-wrap: wrap; color: #9eb69e; font-size: 10px; line-height: 1.6; }
.editor-actions { flex: 0 0 auto; justify-content: flex-end; }
#editor-key-hint { margin-right: auto; color: #93ac97; font-size: 10px; }
.editor-actions button { white-space: nowrap; }
.reference-panel { display: flex; flex: 1; flex-direction: column; min-height: 0; min-width: 0; }
.reference-panel .panel-header { flex: 0 0 auto; flex-wrap: wrap; gap: 4px 8px; }
.reference-panel .panel-title { font-size: 13px; }
.reference-language { margin-left: 7px; color: var(--secondary); font-size: 10px; font-weight: 400; }
#close-comparison { font-size: 11px; padding: 3px 5px; }
.comparison-summary { flex: 0 0 auto; padding: 9px 12px; background: #f5f8ef; border-bottom: 1px solid var(--line); font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
#comparison-status { font-weight: 550; }
.comparison-summary p { margin: 3px 0 0; font-size: 10px; line-height: 1.6; color: #718369; }
.reference-panel .diff-panel { flex: 1 1 0; min-width: 0; min-height: 0; margin: 0; padding: 12px 0; border: 0; border-radius: 0; background: var(--code); color: var(--code-ink); overflow: auto; scrollbar-width: thin; scrollbar-color: #49664c transparent; }
.reference-line { min-width: max-content; padding: 0 12px 0 0; font: var(--reading-size)/1.65 var(--mono); }
.reference-line.remove { background: #e2ad7321; color: var(--code-ink); box-shadow: inset 2px 0 #d6ae76; }
.reference-number { flex: 0 0 39px; width: 39px; padding-right: 10px; text-align: right; color: #8ba18e; font: inherit; }
.reference-text { padding-right: 12px; font: inherit; }
.code-dialog.writing-comparison { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1px; background: var(--line); }
.code-dialog.writing-comparison .right-panel { height: 100%; min-height: 0; border: 0; border-radius: 0; }
.code-dialog.writing-comparison .write-area { min-height: 330px; }
@media (max-width: 1100px) {
  .panel-header { flex-wrap: wrap; gap: 4px; }
  .panel-actions { flex-wrap: wrap; }
}
@media (max-width: 800px) {
  .writing-mode .left-scroll { flex: 1; min-height: 0; overflow: auto; }
  .writing-mode .editor-frame { min-height: 300px; }
  .writing-mode #editor { min-height: 300px; }
  .writing-comparison.study-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; gap: 6px; }
  .writing-comparison .panel { min-height: 0; }
  .writing-comparison .panel-header { padding: 8px; }
  .writing-comparison .panel-title { font-size: 11px; }
  .writing-comparison .panel-actions { flex-wrap: wrap; }
  .writing-comparison .panel-actions button { font-size: 10px; }
  .writing-comparison .question-region { max-height: 160px; overflow: auto; padding: 10px; }
  .writing-comparison .write-area { padding: 8px; min-height: 420px; }
  .writing-comparison .editor-label > span, .writing-comparison #editor-key-hint, .writing-comparison .reference-language { display: none; }
  .writing-comparison .editor-gutter { flex-basis: 28px; }
  .writing-comparison #editor { padding-left: 7px; }
  .writing-comparison .editor-actions { justify-content: flex-start; }
  .writing-comparison .editor-actions button { padding: 6px; font-size: 10px; }
  .writing-comparison .comparison-summary { padding: 8px; }
  .writing-comparison .reference-panel .diff-panel { flex: 1 1 300px; }
}
