/* Layout: app shell with a left sidebar (TaskTrack-style) and rounded content panels;
   printed sheets are real A4 paper with notebook squares, independent of the app theme. */
:root {
  --bg: #F3EFE6;
  --surface: #FFFDF8;
  --surface-2: #F8F4EA;
  --fg: #24221E;
  --muted: #6F695E;
  --line: #E3DCCD;
  --chip: #EDE7DA;
  --yellow: #F4C430;
  --coral: #F07258;
  --green: #6DBE94;
  --navy: #1F5A6E;
  --navy-text: #1F5A6E;
  --plum: #8E6CC9;
  --sky: #3E9BB5;
  --rose: #C2577E;
  --olive: #7C8A33;
  --focus: #1F5A6E;
  --shadow: 0 1px 2px rgb(60 45 20 / 6%), 0 8px 24px rgb(60 45 20 / 7%);

  --f-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --f-body: "Onest", "Segoe UI", system-ui, -apple-system, sans-serif;

  /* paper (fixed: a printed sheet is always white) */
  --p-ink: #22252B;
  --p-muted: #6B7079;
  --p-sq: #CFE0EC;
  --p-pen: #1D4FB8;
  --p-red: #D9482B;
  --cell: 5mm;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191815; --surface: #22211D; --surface-2: #2A2823; --fg: #F2EEE4; --muted: #A9A294;
    --line: #38352E; --chip: #302E28; --navy: #4C93AB; --navy-text: #8CC3D6; --plum: #B39BE6; --sky: #6FC0D8; --rose: #E58AAE; --olive: #B5C46A; --focus: #F4C430;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #191815; --surface: #22211D; --surface-2: #2A2823; --fg: #F2EEE4; --muted: #A9A294;
  --line: #38352E; --chip: #302E28; --navy: #4C93AB; --navy-text: #8CC3D6; --plum: #B39BE6; --sky: #6FC0D8; --rose: #E58AAE; --olive: #B5C46A; --focus: #F4C430;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px;
  padding: 24px 16px; border-right: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; flex-direction: column; gap: 10px; padding-inline: 8px; }
.brand-stk { display: flex; align-items: flex-end; height: 52px; padding-top: 6px; padding-left: 4px; }
.brand-stk .stk { margin-right: -8px; filter: drop-shadow(0 2px 0 rgb(0 0 0 / 8%)); }
.brand-stk .stk:nth-child(1) { transform: rotate(-12deg); }
.brand-stk .stk:nth-child(2) { transform: translateY(-8px) rotate(8deg); }
.brand-stk .stk:nth-child(3) { transform: rotate(-4deg); }
.brand-stk .stk:nth-child(4) { transform: translateY(-6px) rotate(14deg); }
.wordmark { font: 800 23px/1 var(--f-display); letter-spacing: -0.02em; position: relative; width: fit-content; }
.wordmark span { color: var(--fg); }
.wordmark::after { content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 4px; border-radius: 4px; background: var(--yellow); transform: rotate(-1.5deg); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 12px;
  background: transparent; text-align: left; cursor: pointer; font-weight: 500; color: var(--muted);
}
.nav button svg { width: 20px; height: 20px; flex: none; }
.nav button:hover { background: var(--surface-2); color: var(--fg); }
.nav button[aria-current="page"] { background: var(--fg); color: var(--bg); }
.nav .count { margin-left: auto; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--coral); color: #2a1610; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 16px; background: var(--surface-2); }
.side-foot label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.code-row { display: flex; gap: 8px; }
.code-row input {
  min-width: 0; flex: 1; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface);
  font: 700 15px/1 var(--f-display); letter-spacing: .08em; text-transform: uppercase;
}

.main { min-width: 0; padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.view-head h1 { font: 700 28px/1.15 var(--f-display); letter-spacing: -0.02em; }
.view-head p { margin: 6px 0 0; color: var(--muted); max-width: 60ch; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px; border: 0; cursor: pointer;
  font-weight: 600; white-space: nowrap; transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 18px; height: 18px; }
.btn.yellow { background: var(--yellow); color: #2B2410; box-shadow: 0 2px 0 #C99B12; }
.btn.ink { background: var(--fg); color: var(--bg); }
.btn.ghost { background: var(--chip); color: var(--fg); }
.btn.small { padding: 7px 14px; font-size: 14px; }

/* ---------- generator ---------- */
.gen { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.config > * { flex-shrink: 0; }
.config { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; padding-right: 4px; scrollbar-width: thin; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.panel h2 { font: 600 13px/1 var(--f-body); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: 12px; }

.rows { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row > span { font-size: 14px; color: var(--muted); }
.txt { width: 100%; padding: 9px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface-2); }
.seg { display: inline-flex; background: var(--chip); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgb(0 0 0 / 12%); }
.chk { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--fg); margin: 0; }

.tcard { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px 14px 20px; box-shadow: var(--shadow); overflow: hidden; }
.tcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--c); }
.tcard.off { box-shadow: none; background: transparent; }
.tcard.off::before { opacity: .35; }
.tcard.off .tb { display: none; }
.tcard.off h3 { color: var(--muted); }
.th { display: flex; align-items: center; gap: 10px; }
.th h3 { font: 600 15px/1.2 var(--f-display); flex: 1; min-width: 0; }
.tb { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.fld { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.fld .lbl { color: var(--muted); }
.rng { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.num {
  width: 76px; padding: 6px 8px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface-2);
  font-variant-numeric: tabular-nums; text-align: right; color: var(--fg);
}
.num.sm { width: 54px; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 99px; overflow: hidden; }
.stepper button { width: 28px; height: 28px; border: 0; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; }
.stepper button:hover { background: var(--chip); }
.stepper input { width: 34px; border: 0; background: transparent; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; -moz-appearance: textfield; padding: 0; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.sw { appearance: none; -webkit-appearance: none; width: 40px; height: 24px; border-radius: 99px; background: var(--chip); position: relative; cursor: pointer; flex: none; margin: 0; transition: background .15s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / 25%); transition: transform .15s; }
.sw:checked { background: var(--fg); }
.sw:checked::after { transform: translateX(16px); }
.ops { display: flex; gap: 6px; }
.ops label { cursor: pointer; }
.ops input { position: absolute; opacity: 0; pointer-events: none; }
.ops span { display: inline-grid; place-items: center; width: 34px; height: 30px; border-radius: 9px; border: 1.5px solid var(--line); font-weight: 700; color: var(--muted); }
.ops input:checked + span { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.ops input:focus-visible + span { outline: 2.5px solid var(--focus); outline-offset: 2px; }
.focus-note { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--yellow) 22%, var(--surface)); border: 1px solid color-mix(in srgb, var(--yellow) 60%, var(--line)); }
.focus-note button { margin-left: auto; border: 0; background: transparent; text-decoration: underline; cursor: pointer; color: var(--muted); font-size: 13px; }

.preview { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.pv-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.pv-sum { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.sheets { display: flex; flex-direction: column; gap: 28px; }
.sheet-group { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.sg-label { align-self: flex-start; font: 600 13px/1 var(--f-body); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.pages { display: flex; flex-direction: column; gap: 22px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 64px 16px; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: 22px; }
.empty strong { color: var(--fg); font: 600 18px/1.3 var(--f-display); }

/* ---------- A4 page: plain black-and-white worksheet ---------- */
.page {
  width: 210mm; height: 297mm; background: #fff; color: var(--p-ink); padding: 10mm 14mm 6mm;
  display: flex; flex-direction: column; box-shadow: 0 2px 4px rgb(0 0 0 / 8%), 0 18px 40px rgb(40 30 10 / 14%);
  border-radius: 2mm; font: 400 3.5mm/1.45 var(--f-body); position: relative; overflow: hidden;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.pg-logo { position: absolute; top: 3.5mm; right: 14mm; display: flex; align-items: center; gap: .6mm; color: var(--p-muted); font: 700 2.6mm/1 var(--f-display); letter-spacing: -0.01em; }
.pg-logo .stk { width: 3.4mm; height: 3.4mm; }
.pg-logo span { margin-left: 1mm; }
.pg-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 8mm; padding-bottom: 2.4mm; margin-bottom: 3mm; border-bottom: .8mm solid #111; }
.ph-title { font: 700 6.2mm/1.15 var(--f-body); letter-spacing: -0.01em; flex: 1 1 auto; min-width: 0; }
.ph-cont { font-weight: 500; font-size: 4mm; color: var(--p-muted); }
.ph-r { display: flex; align-items: flex-end; gap: 5mm; flex: none; padding-bottom: .6mm; }
.field { display: inline-flex; align-items: flex-end; gap: 1.6mm; font-size: 3.9mm; color: #222; }
.field .fl { display: inline-block; width: 30mm; border-bottom: .3mm solid #111; height: 4.6mm; }
.field .fl.short { width: 20mm; }
.code { font: 500 3.9mm/1 var(--f-body); color: #111; white-space: nowrap; }
.pg-body { flex: 1; min-height: 0; overflow: hidden; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 5mm 4mm; align-content: start; }
.pg-foot { display: flex; justify-content: space-between; padding-top: 1.8mm; font-size: 2.7mm; color: var(--p-muted); border-top: .25mm solid #E3E6EA; margin-top: 2mm; }

/* task sheet: ruled like a notebook, 30 equal lines; a problem takes as many lines as its text needs,
   its text sits on the lines (line-height = line pitch), working lines follow */
.pg-body.ruled { position: relative; display: block; }
.rl-bg, .rl-fg { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(var(--lines), minmax(0, 1fr)); }
.rl-bg > div { border-bottom: .3mm dashed #BFC5CE; }
.rl-measure { position: absolute; left: 0; right: 0; top: 0; visibility: hidden; }
.q-item { position: relative; min-width: 0; }
.q-text { font: 600 13pt/var(--pitch) var(--f-body); padding: 0 28mm 0 7mm; text-indent: -7mm; font-variant-numeric: tabular-nums; position: relative; top: .9mm; }
.q-text b { font-weight: 700; }
.q-item:not(.prose) .q-text { font-weight: 700; white-space: nowrap; }
.q-item.prose .q-text { font-weight: 500; font-size: 12pt; }
.q-box { position: absolute; right: 0; bottom: .7mm; width: 24mm; height: calc(var(--pitch) * .68); border: .4mm solid #1d1d1f; border-radius: 1.4mm; }

/* answer sheet, short: blue problem, bold answer on the right, monospace chain below */
.pg-body.short { gap: 0; }
.s-item { padding: 1.5mm 0 1.4mm; border-bottom: .3mm dashed #C9CED6; break-inside: avoid; }
.s-row { display: flex; justify-content: space-between; align-items: baseline; gap: 6mm; }
.s-q { font: 700 13pt/1.25 var(--f-body); color: #24357A; font-variant-numeric: tabular-nums; }
.s-a { font: 700 13pt/1.25 var(--f-body); color: #111; white-space: nowrap; font-variant-numeric: tabular-nums; }
.s-chain { margin-top: .4mm; font: 400 10.5pt/1.4 "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; color: #555; letter-spacing: .03em; word-spacing: .05em; }

/* grid layouts (column / squares) and the detailed answer sheet */
.item { min-width: 0; display: flex; flex-direction: column; gap: 1.6mm; break-inside: avoid; }
.item-top { display: flex; align-items: center; gap: 2mm; min-height: 6mm; }
.q-num { font: 700 3.9mm/1 var(--f-body); }
.answer { margin-left: auto; font: 700 3.9mm/1 var(--f-body); color: #111; white-space: nowrap; font-variant-numeric: tabular-nums; }
.aexpr { font: 700 3.7mm/1.2 var(--f-body); color: #24357A; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.paper {
  padding: var(--cell) 0 var(--cell) var(--cell); border: 1px solid var(--p-sq); border-radius: 1.6mm; overflow: hidden;
  background-color: #fff;
  background-image: linear-gradient(var(--p-sq) 1px, transparent 1px), linear-gradient(90deg, var(--p-sq) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}
.paper > * + * { margin-top: var(--cell); }
.blank { height: calc(var(--cell) * var(--n)); }
.cg { width: max-content; }
.cr { display: grid; grid-template-columns: repeat(var(--w), var(--cell)); height: var(--cell); }
.cc { display: flex; align-items: center; justify-content: center; font: 500 3.8mm/1 var(--f-body); font-variant-numeric: tabular-nums; position: relative; }
.cc.op { font-weight: 700; }
.cc.sm { font-size: 2.9mm; justify-content: flex-start; padding-left: .6mm; }
.cc.ans { color: var(--p-pen); }
.cc.ul { box-shadow: inset 0 -.5mm 0 currentColor; }
.cc.ul:not(.ans) { box-shadow: inset 0 -.5mm 0 var(--p-ink); }
.cr.carry .cc { font-size: 2.6mm; font-weight: 600; color: var(--p-red); align-items: flex-end; padding-bottom: .5mm; }
.cc.x { color: var(--p-ink); }
.cc.x::after { content: ""; position: absolute; left: 22%; right: 22%; top: 50%; height: .35mm; background: var(--p-red); transform: rotate(-35deg); }
.steps { margin: 0; padding: 0 0 0 4.2mm; font-size: 3mm; line-height: 1.45; display: flex; flex-direction: column; gap: .6mm; }
.steps li::marker { color: var(--p-muted); font-weight: 600; }
.steps b { font-weight: 650; }
.steps .math { font-variant-numeric: tabular-nums; }
.check { font-size: 2.9mm; color: #2E7D57; display: flex; gap: 1.4mm; align-items: baseline; }
.check::before { content: "✓"; font-weight: 700; }

/* ---------- journal ---------- */
.list { display: flex; flex-direction: column; gap: 12px; }
.jcard { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px 16px 24px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; gap: 12px; }
.jcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--c); }
.jhead { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.jhead h3 { font: 600 16px/1.25 var(--f-display); }
.jmeta { color: var(--muted); font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.jhead .actions { margin-left: auto; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.pill.wait { background: color-mix(in srgb, var(--yellow) 30%, var(--surface)); color: var(--fg); }
.pill.good { background: color-mix(in srgb, var(--green) 30%, var(--surface)); color: var(--fg); }
.pill.mid { background: color-mix(in srgb, var(--coral) 28%, var(--surface)); color: var(--fg); }
.mix-dots { display: inline-flex; gap: 4px; }
.mix-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.grade { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.grade p { margin: 0; color: var(--muted); font-size: 14px; }
.gprobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.gp {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface-2); cursor: pointer; text-align: left; font-variant-numeric: tabular-nums; font-size: 14px; min-width: 0;
}
.gp .mk { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--green); color: #15301f; }
.gp .ex { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp[aria-pressed="true"] { border-color: var(--coral); background: color-mix(in srgb, var(--coral) 14%, var(--surface)); }
.gp[aria-pressed="true"] .mk { background: var(--coral); color: #2a1610; }
.grade-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.grade-foot .actions { margin-left: auto; }

/* ---------- progress ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.tile .v { font: 700 30px/1.1 var(--f-display); font-variant-numeric: tabular-nums; }
.tile .k { color: var(--muted); font-size: 13px; margin-top: 4px; }
.prog { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.donut-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; flex: none; }
.legend { display: flex; flex-direction: column; gap: 10px; flex: 1; min-width: 180px; }
.lg { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 14px; }
.lg i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.lg .p { font-variant-numeric: tabular-nums; color: var(--muted); }
.skills { display: flex; flex-direction: column; gap: 10px; }
.sk { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 14px; }
.sk .bar { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--chip); overflow: hidden; }
.sk .bar i { display: block; height: 100%; border-radius: 99px; background: var(--c); }
.sk .p { font-variant-numeric: tabular-nums; color: var(--muted); }
.sk.weak .n { font-weight: 600; }
.suggest { display: flex; flex-direction: column; gap: 12px; background: var(--fg); color: var(--bg); border-color: var(--fg); }
.suggest h2 { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.suggest p { margin: 0; }
.suggest ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.muted { color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .gen { grid-template-columns: minmax(0, 1fr); }
  .config { position: static; max-height: none; overflow: visible; }
  .prog { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; }
  .brand-stk { display: none; }
  .nav { flex-direction: row; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav button { padding: 8px 12px; }
  .nav button { width: auto; flex: none; }
  .side-foot { display: none; }
  .main { padding: 18px 16px 40px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- print ---------- */
@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff !important; }
  .side, .config, .pv-bar, .view-head, .sg-label, [data-view]:not([data-view="gen"]) { display: none !important; }
  .shell, .gen, .main, .preview, .sheets, .sheet-group:not([hidden]), .pages { display: block !important; padding: 0 !important; margin: 0 !important; gap: 0 !important; }
  .sheets { zoom: 1 !important; }
  .page { box-shadow: none; border-radius: 0; break-after: page; margin: 0; height: 296.5mm; }
}

/* ---------- difficulty slider ---------- */
.lvl { display: flex; flex-direction: column; gap: 10px; }
.lvl-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lvl-num { font: 700 20px/1 var(--f-display); letter-spacing: -0.01em; }
.lvl-top .muted { font-size: 13px; }
#f-level {
  --pct: 44%;
  appearance: none; -webkit-appearance: none; width: 100%; height: 28px; margin: 0; background: transparent; cursor: pointer;
}
#f-level::-webkit-slider-runnable-track {
  height: 10px; border-radius: 99px;
  background: linear-gradient(90deg, var(--green), var(--yellow) 50%, var(--coral));
}
#f-level::-moz-range-track { height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--green), var(--yellow) 50%, var(--coral)); }
#f-level::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; margin-top: -8px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--fg); box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
}
#f-level::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 3px solid var(--fg); }
.lvl-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: -4px; }
.lvl-desc { margin: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.5em; }

/* ---------- misc additions ---------- */
.pv-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.focus-note .actions { margin-left: auto; align-items: center; gap: 8px; flex-wrap: nowrap; }
.focus-note.adapt { flex-wrap: wrap; align-items: center; }
.focus-note.adapt > span:first-child { flex: 1 1 200px; }
.focus-note .actions button:not(.btn) { margin: 0; }
.jtitle { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.code-chip { font: 700 11px/1 var(--f-display); letter-spacing: .08em; padding: 4px 8px; border-radius: 99px; border: 1.5px solid var(--line); color: var(--fg); }
.jmeta { align-items: center; }
.jnext { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.gcount { font-size: 14px; font-variant-numeric: tabular-nums; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 12px);
  background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-weight: 600; box-shadow: var(--shadow);
  z-index: 10; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media print { .toast { display: none !important; } }


.ops.wide { flex-wrap: wrap; }
.ops.wide span { width: auto; padding: 0 10px; font-weight: 600; font-size: 13px; }
.fld.kinds { align-items: flex-start; flex-direction: column; }

.pv-sum.warn { color: var(--coral); font-weight: 600; }

.fld-note { margin: 0; font-size: 13px; color: var(--muted); }
.s-item.prose .s-q { font-weight: 500; font-size: 11pt; }
.s-note { margin-top: .4mm; font-size: 10pt; color: #8a3b16; }
