/* Typing Tutor styles. No external fonts or CDNs: everything is served from this server. */
:root {
  --bg: #f6f2e9;
  --card: #ffffff;
  --ink: #1c2a28;
  --muted: #55645f;
  --line: #d9d2c1;
  --pine: #1d6b57;
  --pine-dark: #14503f;
  --amber: #ffd45e;
  --error: #b3261e;
  --ok: #1d6b57;
  --radius: 14px;
  --key: clamp(1.7rem, 6.4vw, 3.1rem);
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

  /* finger colours (light tints so the key letters stay readable) */
  --f-lp: #f6c9d0; --f-lr: #fbd9a8; --f-lm: #fff0a6; --f-li: #c9eab0;
  --f-ri: #b9e6e3; --f-rm: #bcd7f5; --f-rr: #d4c7f2; --f-rp: #efc3e6; --f-th: #e4e0d4;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.125rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

h1 { font-size: 2rem; margin: .4rem 0 .6rem; line-height: 1.2; }
h2 { font-size: 1.4rem; margin: 1.4rem 0 .6rem; }
a { color: var(--pine-dark); }
.subtle { color: var(--muted); margin: .2rem 0 1rem; }
.keys { font-family: var(--mono); letter-spacing: .15em; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1.2rem; background: var(--pine-dark); color: #fff;
}
.brand { color: #fff; font-weight: 700; font-size: 1.3rem; text-decoration: none; }
.who { display: flex; align-items: center; gap: .8rem; }
.who form { margin: 0; }
.topbar .btn-quiet { color: #fff; border-color: rgba(255,255,255,.6); }

.page { max-width: 62rem; margin: 0 auto; padding: 1rem 1.2rem 4rem; }
.crumbs { margin: .2rem 0; }

.card {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; margin: 1rem 0;
}
.narrow { max-width: 26rem; margin: 3rem auto; }
.stack { display: flex; flex-direction: column; gap: .5rem; }

.field {
  font: inherit; font-size: 1.25rem; padding: .65rem .8rem; width: 100%;
  border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.field:focus, .btn:focus-visible, a:focus-visible, input:focus-visible {
  outline: 4px solid #1b5fd1; outline-offset: 2px;
}

.btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  padding: .65rem 1.3rem; min-height: 3rem; border-radius: 10px;
  border: 2px solid var(--pine); background: #fff; color: var(--pine-dark);
}
.btn:hover { background: #eef6f3; }
.btn-primary { background: var(--pine); color: #fff; }
.btn-primary:hover { background: var(--pine-dark); }
.btn-quiet { background: transparent; border-color: var(--line); min-height: 2.4rem; padding: .3rem .9rem; }
.btn-big { font-size: 1.5rem; padding: .9rem 2.2rem; }

.notice { background: #fff6d6; border: 2px solid #e5cf7b; border-radius: 10px; padding: .6rem .9rem; }
.notice.error { background: #fde8e6; border-color: #e3a29d; color: #7a1812; }

.actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; }

/* ---- lesson list ---- */
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.lesson-card {
  display: flex; flex-direction: column; gap: .3rem; height: 100%; text-decoration: none; color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem;
}
.lesson-card:hover { border-color: var(--pine); }
.lesson-card.is-next { border-color: var(--pine); box-shadow: 0 0 0 3px #bfe0d4; }
.lesson-card.is-done { background: #f1f8f5; }
.lesson-title { font-weight: 700; }
.lesson-meta, .lesson-status { color: var(--muted); font-size: 1rem; }
.lesson-status { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: auto; }
.badge { display: inline-block; padding: .05rem .6rem; border-radius: 999px; border: 2px solid var(--line); font-size: .9rem; font-weight: 700; color: var(--ink); }
.badge-done { background: var(--ok); border-color: var(--ok); color: #fff; }
.badge-next { background: var(--amber); border-color: #d9b02b; }

/* ---- typing stage ---- */
.progress { height: .8rem; background: #e8e3d6; border-radius: 999px; overflow: hidden; margin-bottom: 1rem; }
.progress-bar { height: 100%; width: 0; background: var(--pine); transition: width .15s linear; }

.lines { font-family: var(--mono); font-size: clamp(1.6rem, 4.6vw, 2.6rem); line-height: 1.5; }
.line { padding: .25rem .4rem; border-radius: 8px; overflow-wrap: anywhere; }
.line.done { color: #8d9894; }
.line.upcoming { color: #3d4c48; opacity: .75; }
.line.current { background: #fbf8ef; }
.word { white-space: nowrap; }
.ch { display: inline-block; white-space: pre; min-width: .6em; text-align: center; border-bottom: 4px solid transparent; }
.ch.sp { min-width: .9em; border-bottom-color: #cfc8b4; }
.ch.ok { color: var(--ok); }
.ch.cur { background: var(--amber); border-bottom-color: var(--ink); border-radius: 6px 6px 0 0; }
.ch.err { outline: 4px dashed var(--error); outline-offset: -2px; animation: shake .25s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) { .ch.err { animation: none; } .progress-bar { transition: none; } }

.overlay-row { text-align: center; margin: 1rem 0 .2rem; }
.capture { position: absolute; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; font-size: 16px; }

/* ---- on-screen keyboard guide ---- */
.kbd-wrap { margin: 1rem 0; }
.toggle { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); cursor: pointer; }
.toggle input { width: 1.3rem; height: 1.3rem; }
.kbd-hidden .keyboard { display: none; }
.keyboard { display: flex; flex-direction: column; align-items: center; gap: .3rem; margin-top: .8rem; user-select: none; }
.krow { display: flex; justify-content: center; gap: .3rem; }
.key {
  width: var(--key); height: var(--key); display: flex; align-items: center; justify-content: center;
  border: 2px solid #b8b09b; border-radius: 8px; font: 700 clamp(.8rem, 2.4vw, 1.2rem)/1 var(--mono); color: var(--ink);
}
.key-wide { width: calc(var(--key) * 1.9); font-size: clamp(.65rem, 1.8vw, .95rem); }
.key-space { width: calc(var(--key) * 7); font-size: clamp(.65rem, 1.8vw, .95rem); }
.finger-lp { background: var(--f-lp); } .finger-lr { background: var(--f-lr); }
.finger-lm { background: var(--f-lm); } .finger-li { background: var(--f-li); }
.finger-ri { background: var(--f-ri); } .finger-rm { background: var(--f-rm); }
.finger-rr { background: var(--f-rr); } .finger-rp { background: var(--f-rp); }
.finger-th { background: var(--f-th); }
.key.target { outline: 5px solid var(--ink); outline-offset: 1px; transform: scale(1.12); position: relative; z-index: 1; }
.key.target::after { content: ""; position: absolute; inset: -2px; border-radius: 8px; border: 3px dashed #fff; pointer-events: none; }

/* ---- results ---- */
.results h2 { margin-top: 0; font-size: 1.8rem; }
.result-stats { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0; }
.result-stats div { flex: 1 1 8rem; background: #f6f2e9; border-radius: 10px; padding: .7rem 1rem; text-align: center; }
.result-stats dt { color: var(--muted); font-size: 1rem; }
.result-stats dd { margin: 0; font-size: 2rem; font-weight: 800; }
.results:focus { outline: none; }

/* ---- account management ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.who a { color: #fff; }
.who-name { opacity: .85; }
.messages { list-style: none; margin: .6rem 0; padding: 0; display: grid; gap: .5rem; }
.pagehead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem; }
.count { color: var(--muted); font-weight: 400; }
.actions.tight { margin-top: 0; }
.narrow-left { max-width: 34rem; }
.formgrid > div { display: flex; flex-direction: column; gap: .25rem; margin-bottom: 1rem; }
.formgrid input[type=text], .formgrid input[type=password], .formgrid input[type=file], .formgrid select {
  font: inherit; padding: .55rem .7rem; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.formgrid input[type=checkbox] { width: 1.3rem; height: 1.3rem; }
.formgrid .helptext, .formgrid [id$="_helptext"] { color: var(--muted); font-size: .95rem; }
.formgrid .errorlist { color: var(--error); margin: 0; padding-left: 1.1rem; font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: .8rem 1rem; align-items: end; padding: .8rem 1rem; }
.filters label { display: flex; flex-direction: column; gap: .2rem; font-size: 1rem; }
.filters .field { width: auto; min-width: 9rem; padding: .45rem .6rem; font-size: 1rem; }
.bulkbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin: .6rem 0; }
.bulkbar label { display: flex; align-items: center; gap: .5rem; }
.bulkbar .field { width: auto; font-size: 1rem; padding: .45rem .6rem; }
.tablewrap { overflow-x: auto; background: #fff; border: 2px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 1rem; }
.table th, .table td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: #f1ede1; font-size: .95rem; }
.table tr:last-child td { border-bottom: none; }
.table tr.is-disabled td { color: var(--muted); background: #faf8f2; }
.table input[type=checkbox] { width: 1.2rem; height: 1.2rem; }
.rowactions { display: flex; flex-wrap: wrap; gap: .4rem; }
.rowactions form { margin: 0; }
.btn-small { min-height: 2.2rem; padding: .25rem .7rem; font-size: .95rem; }
.btn-danger { border-color: var(--error); color: var(--error); }
.btn-danger:hover { background: #fde8e6; }
.creds .pw { font-size: 1.3rem; font-weight: 700; }
.creds td { font-size: 1.1rem; }

/* ---- assignments ---- */
.assignments h2 { margin-top: 0; }
.assign-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.assign { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem;
  border: 2px solid var(--line); border-radius: var(--radius); padding: .7rem 1rem; background: #fffdf6; }
.assign.is-done { background: #f1f8f5; }
.assign.is-overdue { border-color: var(--error); border-style: dashed; }
.assign-main { display: flex; flex-direction: column; gap: .15rem; }
.assign-goal, .assign-note { color: var(--muted); font-size: 1rem; }
.badge-late { background: #fde8e6; border-color: var(--error); color: #7a1812; }
.notice.goal { background: #e8f3ee; border-color: #8cc2ae; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .8rem 1.5rem; margin: 0; }
.facts dt { color: var(--muted); font-size: .95rem; }
.facts dd { margin: 0; font-weight: 600; }

/* ---- progress ---- */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: .8rem; margin: 1rem 0; }
.stat { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: .7rem 1rem; display: flex; flex-direction: column; }
.stat-num { font-size: 1.9rem; font-weight: 800; line-height: 1.15; }
.stat-num small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.stat-label { color: var(--muted); font-size: .95rem; }
.sortlink { color: inherit; text-decoration: none; white-space: nowrap; }
.sortlink:hover { text-decoration: underline; }
.flag { display: inline-block; background: #fff0c9; border: 1px solid #d9b02b; border-radius: 6px; padding: 0 .4rem; font-size: .9rem; margin: .1rem 0; }
.keychips { list-style: none; display: flex; flex-wrap: wrap; gap: .6rem; padding: 0; margin: .4rem 0; }
.keychips li { background: #f6f2e9; border-radius: 10px; padding: .3rem .7rem; }
kbd { font-family: var(--mono); font-weight: 700; background: #fff; border: 2px solid #b8b09b; border-bottom-width: 4px; border-radius: 6px; padding: 0 .45rem; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; }
.chart { margin: 0; }
.chart figcaption { font-weight: 700; margin-bottom: .2rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #e3dccb; stroke-width: 1; }
.chart .tick { font-size: 12px; fill: var(--muted); }
.chart .line { stroke: var(--pine); stroke-width: 3; stroke-linejoin: round; }
.chart .dot { fill: var(--pine); stroke: #fff; stroke-width: 1.5; }
.heat .key { width: calc(var(--key) * .85); height: calc(var(--key) * .85); }
.heat .key-space { width: calc(var(--key) * 6); }
.heat-none { background: #ece8dc; color: #8a8576; }
.heat-0 { background: #dcefe3; }
.heat-1 { background: #fff0b3; }
.heat-2 { background: #ffd27a; border-style: dashed; }
.heat-3 { background: #ff9f5a; border-width: 3px; }
.heat-4 { background: #c0392b; color: #fff; border-width: 4px; border-color: #000; }
.heat-spacer { visibility: hidden; }
.heat-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; }
.swatch { display: inline-block; width: 1.1rem; height: 1.1rem; border: 2px solid #b8b09b; border-radius: 4px; vertical-align: middle; margin-right: .3rem; }

@media print {
  .topbar, .noprint, .actions, .messages { display: none !important; }
  body { background: #fff; }
  .tablewrap { border: none; }
  .creds td, .creds th { border: 1px solid #999; padding: .5rem .7rem; }
}

@media (max-width: 40rem) {
  .page { padding: .6rem .7rem 3rem; }
  .card { padding: .9rem; }
  .krow { gap: .2rem; }
  .keyboard { gap: .2rem; }
}

/* ---- picture login ---- */
.picture-login { max-width: 46rem; margin: 0 auto; text-align: center; }
.pl-prompt { font-size: 1.6rem; font-weight: 700; margin: .6rem 0 1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .9rem; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: .3rem; cursor: pointer;
  background: #fff; border: 3px solid var(--line); border-radius: var(--radius);
  padding: .8rem .4rem; font: inherit; color: var(--ink); min-height: 8rem;
}
.tile:hover, .tile:focus-visible { border-color: var(--pine); background: #eef6f3; }
.tile-pic { font-size: 3.6rem; line-height: 1; }
.tile-name { font-size: 1.15rem; font-weight: 600; overflow-wrap: anywhere; }
.pl-who { display: flex; justify-content: center; align-items: center; gap: .8rem; font-size: 1.6rem; font-weight: 700; }
.pl-who .tile-pic { font-size: 3rem; }
.pl-slots { display: flex; justify-content: center; gap: .6rem; margin: .4rem 0 1rem; }
.pl-slot {
  width: 4.2rem; height: 4.2rem; display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; background: #fff; border: 3px dashed var(--line); border-radius: var(--radius);
}
.pl-slot.filled { border-style: solid; border-color: var(--pine); }
.pl-keys { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .7rem; max-width: 34rem; margin: 0 auto; }
.pl-key {
  font-size: 2.4rem; line-height: 1; min-height: 4.8rem; cursor: pointer;
  background: #fff; border: 3px solid var(--line); border-radius: var(--radius);
}
.pl-key:hover:not(:disabled), .pl-key:focus-visible { border-color: var(--pine); background: #eef6f3; }
.pl-key:disabled { opacity: .45; cursor: default; }
.picture-login .actions { justify-content: center; }

/* ---- teacher side: badges, class link, printable PIN cards ---- */
.badge { display: inline-block; background: #e8f3ee; border: 1px solid #8cc2ae; border-radius: 999px; padding: 0 .5rem; font-size: .9rem; }
.linkline { margin: .2rem 0 .4rem; overflow-wrap: anywhere; }
.pincards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; margin-top: 1rem; }
.pincard {
  background: #fff; border: 2px solid var(--ink); border-radius: var(--radius);
  padding: .8rem; text-align: center; break-inside: avoid;
}
.pincard-pic { font-size: 3.4rem; line-height: 1.1; }
.pincard-name { font-size: 1.3rem; font-weight: 700; }
.pincard-room { color: var(--muted); }
.pincard-pin { display: flex; justify-content: center; gap: .4rem; font-size: 2.2rem; margin: .5rem 0 .2rem; }
.pincard-digits { font-size: .8rem; color: var(--muted); }

/* ---- practice and tests ---- */
.timer { text-align: center; font: 800 clamp(2.2rem, 7vw, 3.4rem)/1.1 var(--mono); margin-bottom: .4rem; }
.choice-group { border: 0; padding: 0; margin: 0 0 1.1rem; }
.choice-group legend { font-weight: 700; font-size: 1.15rem; padding: 0; margin-bottom: .5rem; }
.choices { display: flex; flex-wrap: wrap; gap: .7rem; }
.choice { position: relative; flex: 1 1 11rem; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice span {
  display: flex; flex-direction: column; gap: .15rem; height: 100%;
  background: #fff; border: 3px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem;
}
.choice small { color: var(--muted); font-size: .95rem; }
.choice input:checked + span { border-color: var(--pine); background: #e8f3ee; box-shadow: 0 0 0 3px #bfe0d4; }
.choice input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.choice input:disabled + span { opacity: .55; }
.practice-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); align-items: start; }
.practice-link { display: block; margin-bottom: 1.2rem; }
