:root {
  color-scheme: light;
  --bg: #f4e9d2;
  --surface: #fffaf0;
  --text: #2e2418;
  --muted: #6e5d45;
  --line: #d8c7a3;
  --accent: #9a5b14;
  --accent-text: #fffaf0;
  --accent-soft: #ecd8a8;
  --hard: #d4572a;
  --hard-bg: #f8c7a8;
  --help: #2f78b8;
  --help-bg: #c6def2;
  --err: #a3261b;
}
* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.5;
}
#app { max-width: 46rem; margin: 0 auto; padding: 0 16px 4rem; }
#app.wide { max-width: 68rem; }
header.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; flex-wrap: wrap; }
header.top .title { font-weight: 600; }
.langs { display: flex; gap: 4px; }
.langs button { font: inherit; font-size: .85rem; padding: 4px 12px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; cursor: pointer; }
.langs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 1rem 0; }
h2 { font-size: 1.15rem; margin: 2rem 0 .5rem; }
p { margin: .8rem 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin: 12px 0; }
.field { margin: 1.4rem 0; }
.field > label, .field > .label, legend { display: block; font-weight: 600; margin-bottom: .3rem; }
fieldset { border: 0; padding: 0; margin: 1.4rem 0; }
.hint { color: var(--muted); font-size: .9rem; margin: 0 0 .4rem; }
input[type=number], input[type=text], textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text);
}
input[type=number] { max-width: 8rem; }
textarea { min-height: 5rem; resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible, .opt:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: .4rem 0; }
.check input { margin-top: .3rem; width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.know { margin: 1rem 0; }
.know .name { font-weight: 600; margin-bottom: 4px; }
.know .opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.opt { display: block; text-align: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px 6px; cursor: pointer; background: var(--surface); font-size: .9rem; user-select: none; position: relative; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt:has(input:checked) { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
@media (max-width: 40rem) { .know .opts { grid-template-columns: 1fr 1fr; } }
.btn { font: inherit; font-weight: 600; padding: 12px 28px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-text); cursor: pointer; }
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.err { color: var(--err); font-weight: 600; min-height: 1.4em; margin: .6rem 0; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 4px 0 18px; }
.progress > div { height: 100%; background: var(--accent); }
.steplabel { color: var(--muted); font-size: .9rem; }

/* Text under study */
.reading { font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; line-height: 1.75; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; user-select: none; -webkit-user-select: none; }
.reading p { margin: 0 0 1em; text-align: left; }
.reading p.center { text-align: center; }
.reading img { display: block; max-width: 100%; height: auto; margin: 1em auto; }
.w { cursor: default; border-radius: 3px; }
.pen-on .w { cursor: pointer; }
.pen-on .w:hover { outline: 1px dashed var(--muted); }
.w.m-hard { background: var(--hard-bg); box-shadow: inset 0 -3px 0 var(--hard); }
.w.m-help { background: var(--help-bg); box-shadow: inset 0 -3px 0 var(--help); text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 4px; }

/* Marking pens: a bar above the text on small screens, a panel to the left of the text on wide screens */
.textpage { display: block; }
.toolbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.toolbar .tbtitle { font-weight: 700; font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.toolbar .pens { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar .hint { display: none; }
.toolbar .count { display: block; margin-top: 6px; color: var(--muted); font-size: .85rem; }
.pen { display: flex; align-items: center; gap: 10px; font: inherit; font-weight: 600; font-size: 1rem; text-align: left; padding: 10px 14px; min-height: 52px; border-radius: 12px; border: 3px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.pen:hover { border-color: var(--muted); }
.pen .swatch { flex: none; font-family: Georgia, serif; font-weight: 700; padding: 2px 8px; border-radius: 4px; }
.pen[data-kind=hard] .swatch { background: var(--hard-bg); box-shadow: inset 0 -3px 0 var(--hard); }
.pen[data-kind=help] .swatch { background: var(--help-bg); box-shadow: inset 0 -3px 0 var(--help); }
.pen .plabel { flex: 1; }
.pen .tick { visibility: hidden; font-weight: 800; }
.pen[aria-pressed=true] .tick { visibility: visible; }
.pen[data-kind=hard][aria-pressed=true] { border-color: var(--hard); background: var(--hard-bg); }
.pen[data-kind=help][aria-pressed=true] { border-color: var(--help); background: var(--help-bg); }
@media (min-width: 62rem) {
  .textpage { display: grid; grid-template-columns: 15.5rem minmax(0, 46rem); gap: 28px; justify-content: center; align-items: start; }
  .toolbar { top: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 16px; margin: 0; }
  .toolbar .pens { flex-direction: column; }
  .toolbar .hint { display: block; margin-top: 12px; }
  .pen { width: 100%; font-size: 1.05rem; min-height: 60px; }
}
.rating { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; margin: .4rem 0; }
.rating .opt { padding: 10px 0; font-weight: 600; }
.rating-ends { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); }
@media (max-width: 34rem) { .rating { grid-template-columns: repeat(6, 1fr); } }
