:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --ink: #1d1f21;
  --muted: #5d6166;
  --line: #dddcd5;
  --accent: #2f5d8a;
  --accent-ink: #ffffff;
  --accent-soft: #e7eef6;
  --good: #2e7d4f;
  --good-soft: #e3f3e9;
  --warn-soft: #fff4dc;
  --body: #e8804f;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { font-size: 17px; line-height: 1.5; }
h1 { font-size: 1.65rem; line-height: 1.25; margin: 0 0 0.75rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
p { margin: 0 0 0.8rem; }
a { color: var(--accent); }
code { background: #f0efea; padding: 0 0.3em; border-radius: 4px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1.5rem; justify-content: space-between;
  padding: 0.55rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; font-size: 0.95rem; color: var(--muted); }
.progress { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; color: var(--muted); }
.bar { width: 180px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #4f8fc7); transition: width 0.4s; }
.banner { background: var(--warn-soft); padding: 0.5rem 1rem; font-size: 0.9rem; text-align: center; }

.page { max-width: 780px; margin: 2rem auto; padding: 0 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
}
.page .card + .card { margin-top: 1rem; }
.card.center { text-align: center; }
.lead { font-size: 1.08rem; }
.step { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 0.4rem; }
ul.tight { margin: 0 0 0.8rem; padding-left: 1.2rem; }
ul.tight li { margin-bottom: 0.35rem; }
ul.rules-ack li { margin-bottom: 0.9rem; padding: 0.15rem 0.4rem; border-radius: 6px; transition: background 0.3s; }
ul.rules-ack li.need { background: var(--warn-soft); outline: 2px solid #d9a21b; }
ul.rules-ack button.ack { display: block; margin-top: 0.35rem; font-size: 0.9rem; font-weight: 600; padding: 0.3rem 0.9rem;
                          color: var(--accent); border: 2px solid var(--accent); }
ul.rules-ack li.acked button.ack { color: var(--good); border-color: var(--good); background: var(--good-soft); }
button.primary.blocked { background: #a9b4bf; cursor: not-allowed; }
.hint.warn { color: #9a6a00; font-weight: 700; }
.anchors { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0.5rem 0 1rem;
           background: var(--accent-soft); padding: 0.7rem 1rem; border-radius: 8px; }
.anchors b { font-variant-numeric: tabular-nums; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin: 0.4rem 0 0.6rem; }
.form label { display: grid; gap: 0.25rem; font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.form input, .form select { font: inherit; font-weight: 400; color: var(--ink); padding: 0.45rem 0.6rem; border: 1px solid var(--line);
                            border-radius: 7px; background: var(--surface); min-width: 0; }
.form input:focus, .form select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.consent { display: flex; gap: 0.6rem; align-items: flex-start; margin: 1rem 0; }
.consent input { margin-top: 0.35rem; width: 18px; height: 18px; }
.figure { margin: 0.5rem 0 1rem; }
.figure img { width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; }
.figure figcaption { font-size: 0.92rem; color: var(--muted); margin-top: 0.5rem; }
.big-emoji { font-size: 3rem; line-height: 1; margin-bottom: 0.5rem; }

/* tutorial examples (scored like a clip, then our scores + why) */
.example { border: 1px solid var(--line); border-radius: 10px; padding: 0.8rem 1rem; }
.example .tag { display: inline-block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
                color: var(--muted); min-width: 4.5rem; font-style: normal; }
.example .tag.better { color: var(--good); }
.ex-text { margin-top: 0.25rem; font-style: italic; }
.ex-q { margin-top: 0.2rem; }
/* after "Show our scores": scale locked, our score under each description */
.cap.revealed { cursor: default; }
.cap.revealed .scale input:disabled + span.n { cursor: default; }
.cap.revealed .scale input:disabled:not(:checked) + span.n:hover { border-color: var(--line); }
.our-score { display: block; margin-top: 0.45rem; font-size: 0.9rem; color: var(--muted); }
.verdict { margin-top: 0.8rem; font-size: 0.97rem; background: #f7f7f4; border-radius: 8px; padding: 0.6rem 0.8rem; }
.match { color: var(--good); font-weight: 700; }
.nomatch { color: #9a6a00; font-weight: 700; }

button.primary {
  font: inherit; font-weight: 600; padding: 0.7rem 1.5rem; border-radius: 9px; border: 0;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button.primary:disabled { background: #a9b4bf; cursor: not-allowed; }
button.ghost {
  font: inherit; font-size: 0.9rem; padding: 0.35rem 0.8rem; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
button.ghost[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
button.link { font: inherit; font-size: 0.9rem; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; margin-left: auto; padding: 0; }
.actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.1rem; }
.actions.centered { justify-content: center; }
.hint { font-size: 0.88rem; color: var(--muted); }

/* ---- item screen ---- */
.item {
  /* the video takes all the width the descriptions do not need */
  display: grid; grid-template-columns: minmax(0, 1fr) clamp(360px, 30vw, 520px); gap: 1.25rem;
  margin: 0.75rem auto; padding: 0 16px; align-items: start;
}
.media { position: sticky; top: 52px; }
.video-wrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden;
              aspect-ratio: 4 / 3; cursor: zoom-in; }
/* as large as fits next to the descriptions and above the controls + scale (4:3 clips) */
.media .video-wrap { width: min(100%, calc((100vh - 175px) * 4 / 3)); margin: 0 auto; }
.video-wrap video { display: block; width: 100%; height: 100%; object-fit: fill; transition: transform 0.25s; }
.video-wrap[data-zoom] { cursor: zoom-out; }
.video-wrap[data-zoom] video { transform: scale(2); }
.video-wrap[data-zoom="0"] video { transform-origin: 0 0; }
.video-wrap[data-zoom="1"] video { transform-origin: 100% 0; }
.video-wrap[data-zoom="2"] video { transform-origin: 0 100%; }
.video-wrap[data-zoom="3"] video { transform-origin: 100% 100%; }
.video-wrap[data-zoom] .lbl { display: none; }
.video-wrap[data-zoom="0"] .lbl.tl, .video-wrap[data-zoom="1"] .lbl.tr,
.video-wrap[data-zoom="2"] .lbl.bl, .video-wrap[data-zoom="3"] .lbl.br { display: block; left: 8px; top: 8px; }
.video-wrap:fullscreen { display: grid; place-items: center; border-radius: 0; aspect-ratio: auto; cursor: default; }
.video-wrap:fullscreen video { width: auto; height: 100vh; max-width: 100vw; object-fit: contain; }
.video-wrap:fullscreen .lbl { display: none; }
.video-wrap .lbl {
  position: absolute; font-size: 0.78rem; font-weight: 600; padding: 0.15rem 0.5rem;
  background: rgba(20, 22, 25, 0.62); color: #fff; border-radius: 4px; pointer-events: none;
}
.lbl.tl { left: 8px; top: 8px; } .lbl.tr { left: calc(50% + 8px); top: 8px; }
.lbl.bl { left: 8px; top: calc(50% + 8px); } .lbl.br { left: calc(50% + 8px); top: calc(50% + 8px); }
.controls { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-top: 0.6rem; }
.controls .hint { margin-left: auto; }
.legend { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.35rem; margin-top: 0.6rem; }
.legend div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0.3rem 0.5rem;
              font-size: 0.78rem; line-height: 1.25; color: var(--muted); border-top: 4px solid var(--c); }
.legend b { display: block; color: var(--ink); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.legend div:nth-child(1) { --c: #c8553d; } .legend div:nth-child(2) { --c: #e08e45; } .legend div:nth-child(3) { --c: #d9c34a; }
.legend div:nth-child(4) { --c: #8db35a; } .legend div:nth-child(5) { --c: #3f8f5a; }

.about { display: flex; align-items: center; gap: 0.6rem; background: var(--accent-soft); border-radius: 10px;
         padding: 0.6rem 0.9rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.about .icon { font-size: 1.4rem; line-height: 1; flex: none; }
.about .about-text { flex: 1 1 14rem; }
.captions { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.cap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cap.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cap.done:not(.active) { background: #fbfbf9; }
.cap.done .letter { background: var(--good); }
.cap.best { border-color: var(--good); box-shadow: 0 0 0 3px var(--good-soft); } /* tutorial: the one we score higher */
.cap-head { display: flex; gap: 0.7rem; align-items: flex-start; }
/* optional free-text reason per description (config.js captionReasons) */
.reason { margin-top: 0.35rem; text-align: right; }
.reason-toggle { font: inherit; font-size: 0.78rem; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; }
.reason-toggle:hover { color: var(--accent); text-decoration: underline; }
.reason-input { width: 100%; box-sizing: border-box; font: inherit; font-size: 0.86rem; padding: 0.3rem 0.5rem;
                border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.reason-input:focus { outline: none; border-color: var(--accent); }
.letter {
  flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 0.9rem; margin-top: 0.1rem; transition: background 0.2s;
}
.cap-text { margin: 0; line-height: 1.45; }
.scale { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 0.3rem; margin-top: 0.6rem; }
.scale label { position: relative; }
.scale input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scale span.n {
  display: grid; place-items: center; height: 2.1rem; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-variant-numeric: tabular-nums;
  font-size: 0.95rem; transition: transform 0.08s;
}
.scale span.n:hover { border-color: var(--accent); }
.scale input:focus-visible + span.n { outline: 2px solid var(--accent); outline-offset: 1px; }
.scale input:checked + span.n { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; transform: scale(1.06); }
.ranking { margin-top: 0.9rem; padding: 0.65rem 0.9rem; border: 1px dashed var(--line); border-radius: 10px; font-size: 0.95rem; }
.ranking .seq { font-weight: 700; letter-spacing: 0.02em; }
.extra { margin-top: 0.9rem; display: grid; gap: 0.5rem; font-size: 0.95rem; }
.extra summary { cursor: pointer; color: var(--muted); }
.extra textarea { font: inherit; font-size: 0.95rem; width: 100%; min-height: 3.2rem; padding: 0.5rem; border: 1px solid var(--line); border-radius: 7px; margin-top: 0.4rem; }
.extra textarea:disabled { background: #f0efea; color: var(--muted); cursor: not-allowed; }
.practice-note { background: var(--warn-soft); border-radius: 10px; padding: 0.6rem 0.9rem; margin-bottom: 0.9rem; font-size: 0.95rem; }
.keys { margin-top: 0.6rem; }

/* guide dialog */
dialog#guide { max-width: 760px; width: calc(100% - 32px); border: 0; border-radius: var(--radius); padding: 1.2rem 1.4rem;
               box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
dialog#guide::backdrop { background: rgba(20, 22, 25, 0.45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg-head h2 { margin: 0; }
dialog#guide .example { margin-bottom: 0.6rem; }

/* end screen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.6rem; margin: 1.2rem 0; }
.stats div { background: var(--accent-soft); border-radius: 10px; padding: 0.7rem 0.5rem; display: grid; }
.stats b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stats span { font-size: 0.85rem; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; z-index: 20;
  background: var(--ink); color: #fff; padding: 0.6rem 1.1rem; border-radius: 999px; font-weight: 600; font-size: 0.95rem;
  transition: opacity 0.3s, transform 0.3s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1000px) {
  .item { grid-template-columns: 1fr; }
  .media { position: static; }
  .media .video-wrap { width: 100%; }
  .keys { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .bar { width: 80px; }
  .card { padding: 1rem; }
  .scale span.n { height: 2rem; font-size: 0.9rem; }
  .example .tag { display: block; }
  .legend { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.2rem; }
  .legend div { font-size: 0.68rem; padding: 0.25rem 0.3rem; }
  .form { grid-template-columns: 1fr; }
}
