/* ---------- tokens ---------- */
/* "Dojo": warm paper and charcoal, one vermilion seal-red accent. */
:root {
  --bg: #f4f1ea;
  --surface: #fffdf9;
  --surface-2: #f0ebe2;
  --border: #e4ddd1;
  --text: #1e1b17;
  --text-2: #4b453d;
  --muted: #776f64;
  --accent: #c9432a;
  --accent-ink: #ffffff;
  --accent-soft: #fae5dc;
  --good: #2b7a4b;
  --good-soft: #e1f0e5;
  --bad: #b32424;
  --bad-soft: #f8e0de;
  --warn: #a36712;
  --ring: rgba(201, 67, 42, 0.32);
  --ink: #1e1b17;
  --ink-text: #fffdf9;
  /* sequential vermilion ramp (data viz) */
  --seq-0: #eee8de;
  --seq-1: #f4c4b2;
  --seq-2: #e78a6b;
  --seq-3: #c9432a;
  --seq-4: #852816;
  --bar: #d4532f;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.05), 0 2px 6px rgba(60, 40, 20, 0.04);
  --shadow-lg: 0 18px 50px rgba(50, 30, 10, 0.18);
  --radius: 16px;
  --nav-w: 244px;
  --font-ui: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #151311;
    --surface: #1d1a17;
    --surface-2: #27231f;
    --border: #36312b;
    --text: #f2ede5;
    --text-2: #d2c9bc;
    --muted: #9a9083;
    --accent: #ff6e4d;
    --accent-ink: #1c0c06;
    --accent-soft: #3b211a;
    --good: #5cc788;
    --good-soft: #152a1d;
    --bad: #f25c5c;
    --bad-soft: #3a1a1a;
    --warn: #e6a94a;
    --ring: rgba(255, 110, 77, 0.45);
    --ink: #f2ede5;
    --ink-text: #151311;
    --seq-0: #2a2622;
    --seq-1: #5e2c1e;
    --seq-2: #a4432b;
    --seq-3: #e2633f;
    --seq-4: #ffb39c;
    --bar: #f2704f;
    --shadow: none;
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #151311;
  --surface: #1d1a17;
  --surface-2: #27231f;
  --border: #36312b;
  --text: #f2ede5;
  --text-2: #d2c9bc;
  --muted: #9a9083;
  --accent: #ff6e4d;
  --accent-ink: #1c0c06;
  --accent-soft: #3b211a;
  --good: #5cc788;
  --good-soft: #152a1d;
  --bad: #f25c5c;
  --bad-soft: #3a1a1a;
  --warn: #e6a94a;
  --ring: rgba(255, 110, 77, 0.45);
  --ink: #f2ede5;
  --ink-text: #151311;
  --seq-0: #2a2622;
  --seq-1: #5e2c1e;
  --seq-2: #a4432b;
  --seq-3: #e2633f;
  --seq-4: #ffb39c;
  --bar: #f2704f;
  --shadow: none;
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* ---------- base ---------- */
* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 0.4em;
}
h1 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}
h2 {
  font-size: 1.25rem;
}
h3 {
  font-size: 1.05rem;
}
p {
  margin: 0 0 0.6em;
}
a {
  color: var(--accent);
  text-decoration: none;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: default;
  opacity: 0.5;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}
.block {
  display: block;
}
.center {
  text-align: center;
}
.grow {
  flex: 1;
  min-width: 0;
}
.good-text {
  color: var(--good);
  font-weight: 600;
}
.danger-text {
  color: var(--bad);
  cursor: pointer;
}
.loading {
  padding: 4rem 1rem;
  text-align: center;
  color: var(--muted);
}
pre.code {
  background: var(--surface-2);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  overflow-x: auto;
}

/* ---------- layout ---------- */
#app {
  min-height: 100vh;
}
.nav {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  z-index: 10;
}
.nav nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  color: var(--text-2);
  font-weight: 500;
}
.nav nav a:hover {
  background: var(--surface-2);
}
.nav nav a.on {
  background: var(--accent-soft);
  color: var(--accent);
}
.ni {
  width: 1.4em;
  text-align: center;
}
.badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 99px;
  padding: 0 0.45em;
  min-width: 1.5em;
  text-align: center;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  padding: 0 0.4rem;
}
.logo {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.nav-foot {
  margin-top: auto;
  padding: 0 0.5rem;
}
main#view {
  margin-left: var(--nav-w);
  padding: 1.5rem 1.5rem 3rem;
  min-height: 100vh;
}
.nav[hidden] + main#view {
  margin-left: 0;
}
.tabbar {
  display: none;
}
.page {
  max-width: 1040px;
  margin: 0 auto;
}
.page.narrow {
  max-width: 720px;
}
.page-head {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.2rem;
}
.page-head p {
  margin: 0;
}
.back {
  display: inline-block;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
section.card,
.page > .card {
  margin-bottom: 1rem;
}
.grid2,
.grid3,
.grid4 {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}
.grid2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid2.top {
  align-items: start;
}
.grid2 > .card,
.grid3 > .card,
.grid4 > .card {
  margin: 0;
}

/* focus mode (exercise player) */
body.focus .nav,
body.focus .topbar,
body.focus .tabbar {
  display: none !important;
}
body.focus main#view {
  margin-left: 0;
  padding: 0;
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover:not(:disabled) {
  background: var(--surface-2);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
  background: var(--accent);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.danger {
  color: var(--bad);
  border-color: var(--bad);
  background: transparent;
}
.btn.small {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}
.btn.wide {
  width: 100%;
}
.btn-row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.btn-row.left {
  justify-content: flex-start;
  margin: 0 0 1rem;
}
.link {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 0;
  font-weight: 500;
}
.link:hover {
  text-decoration: underline;
}
.icon-btn {
  border: 0;
  background: none;
  font-size: 1.25rem;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  color: var(--muted);
}
.icon-btn:hover {
  background: var(--surface-2);
}
input:not([type='checkbox']):not([type='range']),
select,
textarea {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  width: 100%;
  min-width: 0;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
input[type='checkbox'] {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--accent);
}
input[type='range'] {
  accent-color: var(--accent);
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 99px;
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
  color: var(--text-2);
}
.chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.seg {
  display: flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 1rem;
}
.seg button {
  flex: 1;
  border: 0;
  background: none;
  padding: 0.45rem;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 500;
}
.seg button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 600;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-2);
}
details summary {
  cursor: pointer;
  color: var(--text-2);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 1rem);
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: calc(100vw - 32px);
  font-size: 0.92rem;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.bad {
  background: var(--bad);
  color: #fff;
}

/* ---------- auth / choose ---------- */
.auth {
  max-width: 400px;
  margin: 8vh auto 0;
}
.auth-brand {
  text-align: center;
  margin-bottom: 1.4rem;
}
.auth-brand .logo {
  width: 3.4rem;
  height: 3.4rem;
  font-size: 1.7rem;
  border-radius: 14px;
  margin-bottom: 0.6rem;
}
.auth-card label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 0.8rem;
}
.auth-card label input {
  margin-top: 0.3rem;
  font-weight: 400;
}
.err {
  color: var(--bad);
  font-size: 0.9rem;
  min-height: 1.2em;
  margin-bottom: 0.6rem;
}
/* ---------- home ---------- */
.time-card h2 {
  margin-bottom: 0.8rem;
}
.time-btns {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}
.time-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 0.8rem 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  transition: border-color 0.12s, background 0.12s;
}
.time-btn b {
  font-size: 1.1rem;
}
.time-btn span {
  font-size: 0.78rem;
  color: var(--muted);
}
.time-btn:hover {
  border-color: var(--accent);
}
.time-btn.rec {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.rest {
  margin-top: 0.4rem;
  font-size: 0.9rem;
}
.rest p {
  margin: 0.4rem 0 0;
  color: var(--text-2);
}
.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-align: center;
  min-height: 140px;
}
.ring {
  position: relative;
  width: 96px;
  height: 96px;
}
.ring circle {
  fill: none;
  stroke-width: 8;
}
.ring-bg {
  stroke: var(--surface-2);
}
.ring-fg {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dasharray 0.4s;
}
.ring-fg.done {
  stroke: var(--good);
}
.ring-txt {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}
.ring-txt b {
  font-size: 1.15rem;
}
.ring-txt span {
  font-size: 0.72rem;
  color: var(--muted);
}
.streak {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}
.streak b {
  font-size: 2rem;
}
.streak span:last-child {
  color: var(--muted);
}
.flame {
  font-size: 1.8rem;
  filter: grayscale(1);
  opacity: 0.4;
}
.flame.lit {
  filter: none;
  opacity: 1;
}
.week {
  display: flex;
  gap: 0.35rem;
}
.wd {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.wd i {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid transparent;
}
.wd.done i {
  background: var(--accent);
}
.wd.today i {
  border-color: var(--accent);
}
.wd.today span {
  color: var(--text);
  font-weight: 700;
}
.next-card {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.place-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  border-color: var(--accent, var(--border));
}
.place-card h3 {
  margin: 0 0 0.2rem;
}
.place-card p {
  margin: 0;
}
.page-head {
  flex-wrap: wrap;
}
.page-head > #place {
  margin-left: auto;
}
@media (max-width: 600px) {
  .place-card {
    flex-wrap: wrap;
  }
  .place-card .btn {
    width: 100%;
  }
}
.next-card h3 {
  margin: 0.1rem 0;
}
.next-card p {
  margin: 0;
}
.unit-icon {
  font-size: 1.6rem;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  flex: none;
}
.unit-icon.lg {
  width: 3.8rem;
  height: 3.8rem;
  font-size: 2rem;
}
.unit-icon.sm {
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1.15rem;
  border-radius: 9px;
}
.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.6rem;
}
.action {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.6rem;
  align-items: center;
  text-align: left;
  border: 0;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  color: var(--text);
}
.action span {
  grid-row: span 2;
  font-size: 1.4rem;
}
.action small {
  color: var(--muted);
}
.action:hover:not(:disabled) {
  background: var(--accent-soft);
}

/* ---------- path / units ---------- */
.units {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.unit {
  padding: 0;
  overflow: hidden;
}
.unit.complete {
  border-color: color-mix(in srgb, var(--good) 45%, var(--border));
}
.unit-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem 0.6rem;
  color: var(--text);
}
.unit-head h3 {
  margin: 0;
}
.unit-head p {
  margin: 0;
}
.mastery {
  text-align: center;
  line-height: 1.1;
}
.mastery b {
  font-size: 1.15rem;
  display: block;
}
.mastery span {
  font-size: 0.72rem;
  color: var(--muted);
}
.lesson-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.4rem 1.2rem 1rem 5.2rem;
}
.lesson-chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 99px;
  padding: 0.3rem 0.85rem;
  font-size: 0.85rem;
  color: var(--text-2);
}
.lesson-chip.done {
  background: var(--good-soft);
  border-color: transparent;
  color: var(--good);
  font-weight: 600;
}
.lesson-chip.next {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.lesson-chip.ghost {
  background: none;
}
.lesson-chip.locked {
  opacity: 0.55;
}
.unit.locked .unit-icon {
  filter: grayscale(1);
  opacity: 0.6;
}
.summary .missed {
  text-align: left;
  margin: 0.5rem auto 1rem;
  max-width: 26rem;
  display: grid;
  gap: 0.2rem;
}
.item-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.item-row:last-child {
  border-bottom: 0;
}
.sbars {
  display: inline-flex;
  gap: 2px;
  align-items: flex-end;
  flex: none;
}
.sbars i {
  width: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.sbars i:nth-child(1) {
  height: 6px;
}
.sbars i:nth-child(2) {
  height: 9px;
}
.sbars i:nth-child(3) {
  height: 12px;
}
.sbars i:nth-child(4) {
  height: 15px;
}
.sbars i.on {
  background: var(--accent);
  border-color: var(--accent);
}
.sbars.s4 i.on {
  background: var(--good);
  border-color: var(--good);
}

/* grammar notes (HTML from course data) */
.grammar h3 {
  margin-top: 1.1rem;
}
.grammar h3:first-child {
  margin-top: 0;
}
.grammar table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5rem 0 0.9rem;
  font-size: 0.93rem;
  display: block;
  overflow-x: auto;
}
.grammar th,
.grammar td {
  border-bottom: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  text-align: left;
}
.grammar th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
}
.grammar ul {
  padding-left: 1.2rem;
  margin: 0.4rem 0 0.8rem;
}
.grammar li {
  margin-bottom: 0.25rem;
}
.sayable {
  cursor: pointer;
  border-bottom: 1px dotted var(--muted);
}
.sayable:hover {
  color: var(--accent);
}
.list {
  padding: 0.3rem 0.4rem;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.65rem 0.7rem;
  border-radius: 10px;
  color: var(--text);
}
.list-row:hover {
  background: var(--surface-2);
}

/* ---------- words ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
}
.toolbar input {
  max-width: 320px;
}

/* ---------- stats ---------- */
.kpi {
  display: flex;
  flex-direction: column;
}
.kpi span {
  color: var(--muted);
  font-size: 0.85rem;
}
.kpi b {
  font-size: 1.7rem;
  line-height: 1.2;
}
.kpi small {
  color: var(--muted);
}
.chart-wrap {
  position: relative;
}
.chart {
  width: 100%;
  height: auto;
  display: block;
  margin: 0.4rem 0 0.6rem;
}
.chart .axis {
  stroke: var(--border);
  stroke-width: 1;
}
.chart .goal {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.7;
}
.axis-t {
  fill: var(--muted);
  font-size: 10px;
}
.bar-fill {
  fill: var(--bar);
}
.hov:hover .bar-fill {
  fill: var(--seq-3);
}
.hov {
  cursor: default;
}
.tip {
  display: none;
  position: absolute;
  background: var(--text);
  color: var(--bg);
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}
.heat {
  width: 100%;
  max-width: 420px;
  height: auto;
  display: block;
}
.hm {
  stroke: var(--surface);
  stroke-width: 1;
}
.hm.hov:hover {
  stroke: var(--text);
}
.hm.l0,
.sw.hm.l0 {
  fill: var(--seq-0);
  background: var(--seq-0);
}
.hm.l1,
.sw.hm.l1 {
  fill: var(--seq-1);
  background: var(--seq-1);
}
.hm.l2,
.sw.hm.l2 {
  fill: var(--seq-2);
  background: var(--seq-2);
}
.hm.l3,
.sw.hm.l3 {
  fill: var(--seq-3);
  background: var(--seq-3);
}
.hm.l4,
.sw.hm.l4 {
  fill: var(--seq-4);
  background: var(--seq-4);
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  align-items: center;
  font-size: 0.85rem;
  margin: 0.6rem 0;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.sw {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.sw.s1,
.seg-s.s1 {
  background: var(--seq-1);
}
.sw.s2,
.seg-s.s2 {
  background: var(--seq-2);
}
.sw.s3,
.seg-s.s3 {
  background: var(--seq-3);
}
.sw.s4,
.seg-s.s4 {
  background: var(--seq-4);
}
.strength-bar {
  position: relative;
  height: 16px;
  border-radius: 4px;
  background: var(--seq-0);
  overflow: hidden;
  margin: 0.6rem 0;
}
.seg-s {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 4px;
}
.unit-stat {
  display: grid;
  grid-template-columns: minmax(140px, 1.3fr) 2fr 90px;
  gap: 0.8rem;
  align-items: center;
  padding: 0.3rem 0;
  font-size: 0.92rem;
}
.unit-stat .bar,
.goal-line .bar,
.player-top .bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.unit-stat .bar div,
.goal-line .bar div,
.player-top .bar div {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s;
}
table.data {
  border-collapse: collapse;
  width: 100%;
  margin-top: 0.5rem;
}
table.data th,
table.data td {
  text-align: left;
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
table.data th {
  color: var(--muted);
  font-weight: 600;
}

/* ---------- settings ---------- */
.form h3 {
  margin-bottom: 0.7rem;
}
.form label.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}
.form label.row:last-of-type {
  border-bottom: 0;
}
.form label.row select,
.form label.row input[type='range'] {
  width: auto;
  max-width: 55%;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  max-width: 360px;
}
.stack .btn {
  align-self: flex-start;
}

/* ---------- player ---------- */
.player {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
}
.player-top {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
}
.player-top .bar {
  flex: 1;
  height: 12px;
}
.player-top .bar div {
  background: var(--good);
}
.timer {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.9rem;
  min-width: 3em;
  text-align: right;
}
.player-body {
  flex: 1;
  padding: 1rem 1.2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.player-foot {
  position: sticky;
  bottom: 0;
  padding: 1rem 1.2rem calc(1rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}
.player-foot > .btn,
.player-foot .btn-row .btn {
  min-width: 140px;
}
.player-foot.good {
  background: var(--good-soft);
  border-color: transparent;
}
.player-foot.bad {
  background: var(--bad-soft);
  border-color: transparent;
}
.player-foot .feedback {
  flex-basis: 100%;
}
.player-foot > .btn:last-child {
  margin-left: auto;
}
.ex-label {
  font-size: 1.2rem;
  font-weight: 700;
}
.in-lang {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.6rem;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  vertical-align: middle;
}
.new-badge {
  display: inline-block;
  align-self: flex-start;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.1rem 0.55rem;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.intro-card {
  text-align: center;
  padding: 1.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.target {
  font-size: 1.5rem;
  font-weight: 700;
}
.target.big {
  font-size: 2rem;
  line-height: 1.2;
}
/* "sounds like" respelling */
.sounds {
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 2px 0 4px;
  cursor: help;
}
/* courses with no voice: hide play buttons and mics */
body.silent .speak-btn,
body.silent .chip[data-say],
body.silent #testv {
  display: none;
}
.sounds.sm {
  font-size: 0.85rem;
  margin: 1px 0;
}
.english {
  color: var(--text-2);
  font-size: 1.05rem;
}
.note {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  font-size: 0.92rem;
  color: var(--text-2);
}
.prompt-en {
  font-size: 1.3rem;
  font-weight: 600;
}
.speakers {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.speak-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.1rem;
  display: inline-grid;
  place-items: center;
  flex: none;
}
.speak-btn:hover {
  border-color: var(--accent);
}
.speak-btn.big {
  width: 4rem;
  height: 4rem;
  font-size: 1.7rem;
  background: var(--accent);
  border-color: var(--accent);
}
.speak-btn.slow {
  width: 2.8rem;
  height: 2.8rem;
}
.speak-btn.sm {
  width: 2rem;
  height: 2rem;
  font-size: 0.85rem;
}
.options {
  display: grid;
  gap: 0.6rem;
}
.opt {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  text-align: left;
  border: 2px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font-size: 1.05rem;
  transition: border-color 0.1s, background 0.1s;
}
.opt:hover:not(:disabled) {
  border-color: var(--accent);
}
.opt .k {
  display: inline-grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
  flex: none;
}
.opt.right {
  border-color: var(--good);
  background: var(--good-soft);
}
.opt.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}
.opt:disabled {
  opacity: 1;
}
textarea.answer {
  font-size: 1.15rem;
  resize: none;
  padding: 0.8rem 1rem;
  border-width: 2px;
  border-radius: 12px;
}
.chars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.char {
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  background: var(--surface);
  border-radius: 9px;
  min-width: 2.6rem;
  height: 2.6rem;
  padding: 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color 0.1s, background 0.1s, transform 0.05s;
}
.char:hover {
  border-color: var(--accent);
}
.char:active {
  transform: translateY(1px);
  background: var(--accent-soft);
}
.char.shift {
  color: var(--muted);
}
.char.shift[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.build-answer {
  min-height: 3.6rem;
  border-bottom: 2px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.4rem 0;
  align-content: flex-start;
}
.build-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  padding-top: 0.4rem;
}
.tile {
  border: 2px solid var(--border);
  border-bottom-width: 3px;
  background: var(--surface);
  border-radius: 10px;
  padding: 0.4rem 0.8rem;
  font-size: 1.02rem;
}
.tile:hover:not(:disabled) {
  border-color: var(--accent);
}
.tile-ph {
  visibility: hidden;
}
.tile.used {
  opacity: 0.25;
}
.mic {
  align-self: center;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 2rem;
  box-shadow: 0 0 0 0 var(--ring);
  transition: box-shadow 0.2s;
}
.mic.on {
  background: var(--bad);
  animation: pulse 1.2s infinite;
}
.mic.sm {
  width: 2.7rem;
  height: 2.7rem;
  font-size: 1.15rem;
  flex: none;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(196, 61, 61, 0.45);
  }
  100% {
    box-shadow: 0 0 0 18px rgba(196, 61, 61, 0);
  }
}
.match {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.match .col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tile.m {
  padding: 0.7rem;
  text-align: center;
}
.tile.m.sel {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.tile.m.done {
  border-color: var(--good);
  color: var(--good);
  opacity: 0.45;
}
.tile.m.bad {
  border-color: var(--bad);
  background: var(--bad-soft);
  animation: shake 0.3s;
}
@keyframes shake {
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}
.feedback {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.fb-title {
  font-size: 1.2rem;
  font-weight: 800;
}
.player-foot.good .fb-title {
  color: var(--good);
}
.player-foot.bad .fb-title {
  color: var(--bad);
}
.fb-ans {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.fb-ans .muted.small {
  flex-basis: 100%;
}
.fb-note {
  font-size: 0.92rem;
  color: var(--text-2);
}
.fb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
}
.ai-out:not(:empty) {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.92rem;
  white-space: pre-wrap;
}
.center-card {
  max-width: 520px;
  margin: 3rem auto;
  text-align: center;
}
.summary .big-emoji {
  font-size: 3.5rem;
}
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}
.stat {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.6rem 0.2rem;
  display: flex;
  flex-direction: column;
}
.stat b {
  font-size: 1.3rem;
}
.stat span {
  font-size: 0.78rem;
  color: var(--muted);
}
.goal-line {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: center;
  font-size: 0.9rem;
  margin: 0.8rem 0;
}

/* ---------- conversation ---------- */
.scen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.8rem;
}
.scen {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: left;
  transition: border-color 0.12s, transform 0.08s;
}
.scen:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.scen-icon {
  font-size: 1.8rem;
}
.chat-page {
  max-width: 780px;
  margin: -1.5rem auto -3rem;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 0.4rem;
  border-bottom: 1px solid var(--border);
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.msg.me {
  align-self: flex-end;
  align-items: flex-end;
}
.msg.them {
  align-self: flex-start;
}
.bub {
  padding: 0.6rem 0.9rem;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 1.02rem;
}
.msg.me .bub {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  border-bottom-right-radius: 4px;
}
.msg.them .bub {
  border-bottom-left-radius: 4px;
}
.bub-tools {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.35rem;
}
.tr {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.3rem;
}
.corr {
  margin-top: 0.3rem;
  background: var(--good-soft);
  border-radius: 10px;
  padding: 0.4rem 0.7rem;
  font-size: 0.92rem;
  max-width: 100%;
}
.corr > div:first-child {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.typing {
  display: flex;
  gap: 4px;
  padding: 0.9rem 1rem;
}
.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1s infinite;
}
.typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.typing i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes blink {
  50% {
    opacity: 0.25;
  }
}
.chat-foot {
  border-top: 1px solid var(--border);
  padding: 0.6rem 0.4rem calc(0.8rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.hints {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.hints:empty {
  display: none;
}
.chat-foot .chars .char {
  min-width: 2rem;
  height: 2rem;
  font-size: 0.95rem;
}
.chat-input {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* pronunciation lab */
.lab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  text-align: center;
}
.lab-res {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}
.lab-res:empty {
  display: none;
}
.score {
  display: flex;
  align-items: baseline;
  gap: 0.15rem;
}
.score b {
  font-size: 2.4rem;
}
.score span {
  color: var(--muted);
}
.score.good b {
  color: var(--good);
}
.score.ok b {
  color: var(--warn);
}
.score.bad b {
  color: var(--bad);
}

/* ---------- responsive ---------- */
/* ---------- admin ---------- */
.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  vertical-align: middle;
}
.pill.warn {
  background: color-mix(in srgb, var(--warn) 16%, var(--surface));
  color: var(--warn);
}
.pill.bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.pending-card {
  border-color: color-mix(in srgb, var(--warn) 50%, var(--border));
}
.pend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 0.6rem 0;
  border-top: 1px solid var(--border);
}
.pend-row .btn-row {
  margin: 0;
}
.users-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.users-head h3 {
  margin: 0;
}
.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 0.5rem 1.2rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--border);
}
.user-row.denied .ur-main {
  opacity: 0.6;
}
.ur-name {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.15rem;
}
.ur-ai-top {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}
.ur-ai .bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.ur-ai .bar div {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
}
.ur-ai .bar.full div {
  background: var(--warn);
}
.limit-form {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.limit-form input[name='limit'] {
  width: 9.5rem;
  flex: 0 0 auto;
  padding: 0.35rem 0.6rem;
}
.limit-form .model-select {
  width: auto;
  flex: 0 1 13rem;
  min-width: 0;
  padding: 0.35rem 0.6rem;
}
.ur-actions {
  grid-column: 1 / -1;
  margin: 0;
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch span {
  width: 34px;
  height: 20px;
  border-radius: 99px;
  background: var(--border);
  position: relative;
  transition: background 0.15s;
}
.switch span::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.switch input:checked + span {
  background: var(--good);
}
.switch input:checked + span::after {
  transform: translateX(14px);
}
.switch input:focus-visible + span {
  box-shadow: 0 0 0 3px var(--ring);
}
.auth-card.center {
  text-align: center;
}
.auth-card .big-emoji {
  font-size: 3rem;
}
.auth-card .btn-row {
  justify-content: center;
}
@media (max-width: 760px) {
  .user-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .grid4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid2 {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 760px) {
  .nav {
    display: none;
  }
  main#view {
    margin-left: 0;
    padding: 1rem 16px calc(5rem + env(safe-area-inset-bottom));
  }
  .tabbar:not([hidden]) {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.3rem 0.2rem calc(0.3rem + env(safe-area-inset-bottom));
    z-index: 10;
  }
  .tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.05rem;
    font-size: 0.7rem;
    color: var(--muted);
    padding: 0.25rem 0;
    position: relative;
  }
  .tabbar a .ni {
    font-size: 1.25rem;
  }
  .tabbar a.on {
    color: var(--accent);
    font-weight: 600;
  }
  .tabbar .badge {
    position: absolute;
    top: 0;
    left: 55%;
    font-size: 0.62rem;
  }
  h1 {
    font-size: 1.35rem;
  }
  .grid3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid3 > :last-child {
    grid-column: 1 / -1;
  }
  .grid3 .stat-card {
    min-height: 0;
  }
  .time-btns {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .lesson-row {
    padding-left: 1.2rem;
  }
  .unit-stat {
    grid-template-columns: 1fr 70px;
  }
  .unit-stat .bar {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .next-card {
    flex-wrap: wrap;
  }
  .next-card .btn {
    width: 100%;
  }
  .chat-page {
    margin: -1rem -16px calc(-5rem - env(safe-area-inset-bottom));
    height: calc(100dvh - 4rem - env(safe-area-inset-bottom));
  }
  .chat-head,
  .chat-log,
  .chat-foot {
    padding-left: 16px;
    padding-right: 16px;
  }
  .target.big {
    font-size: 1.6rem;
  }
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .toolbar input {
    max-width: none;
  }
  .form label.row select {
    max-width: 60%;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
.streak span:last-child {
  white-space: nowrap;
}

/* ---------- chess ---------- */
.cboard {
  width: 100%;
  aspect-ratio: 1;
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.clayout {
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(260px, 1fr);
  gap: 1.2rem;
  align-items: start;
  margin-bottom: 1rem;
}
.cboard-col,
.cside {
  min-width: 0;
}
.cside > .card {
  margin-bottom: 0.8rem;
}
@media (max-width: 900px) {
  .clayout {
    grid-template-columns: minmax(0, 1fr);
  }
  .cboard-col {
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
  }
}
.cstatus {
  min-height: 1.6em;
}
/* review: the board stays on screen while the moves and the coach's answers scroll */
.pinbtn {
  display: none;
}
@media (min-width: 901px) {
  .clayout.rv .cboard-col {
    position: sticky;
    top: 1rem;
  }
}
@media (max-width: 900px) {
  .pinbtn {
    display: inline-flex;
  }
  .pinbtn[aria-pressed='true'] {
    background: var(--accent-soft);
    border-color: var(--accent);
  }
  .clayout.rv .cboard-col.pinned {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg);
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
  }
  .clayout.rv .cboard-col.pinned .evalwrap {
    width: min(60vw, 300px);
    margin: 0 auto;
  }
  .clayout.rv .cboard-col.pinned .navbtns {
    margin-top: 0.4rem;
  }
}
@media (max-width: 760px) {
  .clayout.rv .cboard-col.pinned {
    top: calc(56px + env(safe-area-inset-top));
  }
}
.cstatus p {
  margin: 0.4rem 0 0;
}
.mlist {
  margin-top: 0.6rem;
  max-height: 220px;
  overflow-y: auto;
  position: relative;
  line-height: 1.9;
  font-size: 0.92rem;
}
.mlist .mn {
  color: var(--muted);
  font-size: 0.85em;
  margin-left: 0.2rem;
}
.mv {
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  padding: 0.05rem 0.3rem;
  border-radius: 5px;
  cursor: pointer;
}
.mv:disabled {
  cursor: default;
}
.mv.on {
  background: var(--accent);
  color: var(--accent-ink);
}
.mv sup {
  font-weight: 700;
  margin-left: 1px;
}
.mono {
  font-family: ui-monospace, Consolas, monospace;
}
.navbtns {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}
.navbtns.sm {
  justify-content: flex-start;
  margin: 0 0 0.3rem;
}
.ctiles .stat-card {
  min-height: 96px;
}
.ctiles .big {
  font-size: 1.6rem;
  font-weight: 700;
}
.ccard {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.ccard h3 {
  margin: 0 0 0.25rem;
}
.ccard p {
  margin: 0 0 0.7rem;
}
.grow {
  flex: 1;
  min-width: 0;
}
h2.sec {
  font-size: 1.1rem;
  margin: 1.4rem 0 0.7rem;
}
.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  vertical-align: middle;
}
.tag.good {
  background: var(--good-soft);
  color: var(--good);
}
.tag.warn {
  color: var(--warn);
}
.tag.bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.ogrid,
.lgrid,
.botgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
  gap: 0.8rem;
}
.ocard,
.lcard {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s;
}
.ocard:hover,
.lcard:hover,
.bot:hover,
.grow-row:hover {
  border-color: var(--accent);
}
.ocard p {
  margin: 0;
}
.ocard-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}
.lcard {
  flex-direction: row;
  align-items: center;
  gap: 0.8rem;
}
.lines .line-row {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.line-row h3 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
}
.line-row p {
  margin: 0.15rem 0;
}
.line-btns {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .lines .line-row {
    flex-direction: column;
    align-items: stretch;
  }
  .line-btns .btn {
    flex: 1;
  }
}
.tips {
  padding-left: 1.2rem;
  margin: 0.4rem 0 0;
}
.tips li {
  margin-bottom: 0.35rem;
}
.lesson-body {
  line-height: 1.6;
}
.lesson-body h3 {
  margin: 1.2rem 0 0.4rem;
}
.lboard {
  margin: 1rem auto;
  max-width: 380px;
}
.lboard figcaption {
  margin-top: 0.5rem;
  font-size: 0.92rem;
  color: var(--text-2);
}
.lboard figcaption p {
  margin: 0.2rem 0 0;
}
.cvals {
  border-collapse: collapse;
  margin: 0.6rem 0;
}
.cvals td,
.cvals th {
  border: 1px solid var(--border);
  padding: 0.3rem 0.8rem;
  text-align: left;
}
.tchips {
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.pstatus {
  font-size: 1.02rem;
}
.botgrid {
  margin-bottom: 1rem;
}
.bot {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  text-align: left;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  margin: 0;
}
.bot.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--ring);
}
.bot-ic {
  font-size: 1.8rem;
}
.play-opts {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.gameover {
  font-size: 1.15rem;
  font-weight: 700;
}
.gameover.good {
  color: var(--good);
}
.gameover.bad {
  color: var(--bad);
}
.glist {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.grow-row {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  color: var(--text);
  text-decoration: none;
  margin: 0 !important;
  padding: 0.7rem 1rem;
}
.gres {
  font-weight: 700;
  min-width: 3rem;
}
.gres.good {
  color: var(--good);
}
.gres.bad {
  color: var(--bad);
}
textarea#pgn {
  width: 100%;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
}
.prog .bar {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 0.4rem;
}
.prog .bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s;
}
.evalwrap {
  display: flex;
  gap: 6px;
}
.evalwrap > .cboard {
  flex: 1;
  min-width: 0;
}
.evalbar {
  position: relative;
  width: 16px;
  flex-shrink: 0;
  border-radius: 4px;
  background: #403d39;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
}
.evalbar.flipped {
  flex-direction: column;
}
.evalbar span {
  display: block;
  width: 100%;
  height: 50%;
  background: #f2f2f2;
  transition: height 0.3s;
}
.evalbar b {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  font-size: 0.6rem;
  color: #888;
  white-space: nowrap;
}
.egraph svg {
  width: 100%;
  height: 80px;
  display: block;
  border-radius: 6px;
  cursor: pointer;
}
.g-bg {
  fill: #403d39;
}
.g-area {
  fill: #f2f2f2;
}
.g-mid {
  stroke: #888;
  stroke-width: 1;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
}
.g-cur {
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.gm {
  stroke: var(--surface);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.gm.mistake {
  fill: #e58a1f;
}
.gm.blunder {
  fill: #d23c3c;
}
.rmoves {
  max-height: 260px;
}
.mv.book {
  color: #a0805a;
}
.mv.best,
.mv.excellent {
  color: var(--good);
}
.mv.inacc {
  color: #b8921b;
}
.mv.mistake {
  color: #e07a10;
  font-weight: 600;
}
.mv.blunder {
  color: var(--bad);
  font-weight: 700;
}
.mv.on.book,
.mv.on.best,
.mv.on.excellent,
.mv.on.inacc,
.mv.on.mistake,
.mv.on.blunder,
.mv.on.goodm {
  color: var(--accent-ink);
}
.mclass {
  font-size: 1.05rem;
}
.mclass.blunder {
  color: var(--bad);
}
.mclass.mistake {
  color: #e07a10;
}
.mclass.inacc {
  color: #b8921b;
}
.mclass.best,
.mclass.excellent {
  color: var(--good);
}
.acc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.acc-table th,
.acc-table td {
  padding: 0.3rem 0.4rem;
  text-align: center;
}
.acc-table th:first-child {
  text-align: left;
}
.acc-table tr.me {
  background: var(--accent-soft);
}
.acc-table td.acc {
  font-weight: 700;
  font-size: 1.05rem;
}
.acc-table td.inacc {
  color: #b8921b;
}
.acc-table td.mistake {
  color: #e07a10;
}
.acc-table td.blunder {
  color: var(--bad);
}
.keym {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.coachout {
  margin-top: 0.6rem;
  line-height: 1.55;
}
.coach-ask {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.coach-ask {
  flex-wrap: wrap;
}
.coach-ask input {
  flex: 1 1 12rem;
  min-width: 0;
}
.coach-at {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: 0.3rem;
}
.coach-qa + .coach-qa {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}
.coach-q {
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.promo {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.promo-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 0.8rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 90%;
}
.promo-box p {
  width: 100%;
  text-align: center;
  margin: 0 0 0.3rem;
}
.promo-box button {
  font-size: 2.2rem;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

/* board coordinates: inside the squares, scaled with the board, solid contrasting colours */
.cboard {
  container-type: inline-size;
}
.cboard.cg-wrap coords {
  opacity: 1;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  font-size: 12px;
  font-size: max(11px, 2.6cqw);
  line-height: 1;
}
.cboard.cg-wrap coords.ranks {
  left: 0;
  top: 0;
  width: auto;
  height: 100%;
}
.cboard.cg-wrap coords.ranks coord {
  transform: none;
  padding: 3px 0 0 3px;
}
.cboard.cg-wrap coords.files {
  left: 0;
  bottom: 0;
  width: 100%;
  height: auto;
  text-align: right;
  text-transform: none;
}
.cboard.cg-wrap coords.files coord {
  flex: 1 1 0;
  padding: 0 3px 2px 0;
}
/* light text on dark squares (a1 is dark), dark text on light squares */
.cboard.orientation-white .ranks :nth-child(odd),
.cboard.orientation-white .files :nth-child(odd),
.cboard.orientation-black .ranks :nth-child(even),
.cboard.orientation-black .files :nth-child(even) {
  color: #f0d9b5;
}
.cboard.orientation-white .ranks :nth-child(even),
.cboard.orientation-white .files :nth-child(even),
.cboard.orientation-black .ranks :nth-child(odd),
.cboard.orientation-black .files :nth-child(odd) {
  color: #8b5e3c;
}

/* ================= dojo look: nav, course switcher, course picker ================= */
::selection {
  background: var(--accent-soft);
}
.ic {
  width: 1.25em;
  height: 1.25em;
  flex: none;
}
.flag-ic {
  width: 27px;
  height: 18px;
  flex: none;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.flag-ic.sm {
  width: 21px;
  height: 14px;
  border-radius: 3px;
  vertical-align: -2px;
  margin-right: 2px;
}
.flag-ic.big {
  width: 52px;
  height: 35px;
  border-radius: 7px;
}
.subj {
  white-space: nowrap;
}

/* sidebar */
.nav {
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 1.1rem 0.8rem 0.9rem;
  gap: 0.9rem;
}
.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.logo {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-family: 'Yu Mincho', 'Hiragino Mincho ProN', 'Noto Serif CJK JP', serif;
  font-size: 1.15rem;
  font-weight: 700;
  transform: rotate(-4deg);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.28);
}
.nav nav {
  gap: 1px;
}
.nav nav a {
  position: relative;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  color: var(--text-2);
}
.nav nav a .ni {
  display: inline-flex;
  width: auto;
  color: var(--muted);
}
.nav nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav nav a.on {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow), 0 0 0 1px var(--border);
}
.nav nav a.on .ni {
  color: var(--accent);
}
.nav-foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.3rem 0;
  border-top: 1px solid var(--border);
}
.me {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1;
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.92rem;
}
.me .grow {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--ink-text);
  font-weight: 700;
  font-size: 0.85rem;
}
.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem 0.2rem 0.45rem;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.streak-pill .ic {
  width: 1.05em;
  height: 1.05em;
}
.streak-pill.hot {
  background: var(--accent-soft);
  color: var(--accent);
}
.streak-pill.hot .ic {
  fill: currentColor;
  fill-opacity: 0.25;
}

/* course switcher button */
.course-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 0.12s, background 0.12s;
}
.course-btn:hover,
.course-btn[aria-expanded='true'] {
  border-color: var(--accent);
}
.cb-txt {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.2;
}
.cb-txt small {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.cb-txt b {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cb-chev {
  color: var(--muted);
  transition: transform 0.15s;
}
.course-btn[aria-expanded='true'] .cb-chev {
  transform: rotate(180deg);
}

/* course menu (popover on desktop, bottom sheet on phones) */
.course-menu {
  position: fixed;
  inset: 0;
  z-index: 60;
}
.cm-sheet {
  position: absolute;
  top: var(--cm-top, 7rem);
  left: var(--cm-left, 0.8rem);
  width: 320px;
  max-height: calc(100vh - var(--cm-top, 7rem) - 1rem);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  animation: cm-in 0.14s ease-out;
}
@keyframes cm-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}
.cm-head {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--muted);
  padding: 0.5rem 0.6rem 0.35rem;
}
.cm-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
}
.cm-item:hover {
  background: var(--surface-2);
}
.cm-item.on {
  background: var(--accent-soft);
}
.cm-item .grow {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.cm-item small {
  color: var(--muted);
  font-size: 0.8rem;
}
.cm-item > .ic {
  color: var(--accent);
}

/* mobile top bar */
.topbar {
  display: none;
}

/* course picker */
.page.choose {
  max-width: 900px;
  padding-top: 1.5rem;
}
.choose-head {
  margin-bottom: 0.5rem;
}
.choose-head h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  margin-bottom: 0.25rem;
}
.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.group-t {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 1.8rem 0 0.7rem;
}
.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
}
.lang-pick {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.9rem 1rem;
  text-align: left;
  padding: 1.15rem 1.15rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}
.lang-pick:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(60, 30, 10, 0.08);
}
.lang-pick.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.lp-txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.lp-txt b {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.lp-native {
  color: var(--muted);
  font-size: 0.85rem;
}
.lp-txt small {
  color: var(--text-2);
  font-size: 0.9rem;
  margin-top: 0.45rem;
}
.lp-go {
  grid-column: 1 / -1;
  justify-self: end;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent);
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
  width: 100%;
  text-align: right;
}

/* surfaces and controls */
.card {
  border-color: var(--border);
}
.btn {
  border-radius: 11px;
  font-weight: 650;
}
.btn.primary {
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.btn.primary:hover:not(:disabled) {
  filter: brightness(1.06);
}
.page-head h1 {
  margin-bottom: 0.15rem;
}

/* ================= admin analytics ================= */
.seg.big button {
  padding: 0.45rem 1rem;
}
.kpi b em {
  font-style: normal;
  font-size: 0.6em;
  color: var(--muted);
  font-weight: 600;
  margin-left: 0.2em;
}
.grid2.tight {
  gap: 0.6rem;
}
h3.mt {
  margin-top: 1.1rem;
}
ul.plain {
  list-style: none;
  padding: 0;
  margin: 0;
}
ul.plain li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}
ul.plain li:last-child {
  border-bottom: 0;
}
.table-scroll {
  overflow-x: auto;
  margin: 0 -0.2rem;
}
.table-scroll table {
  min-width: 520px;
}
.num-bar {
  white-space: nowrap;
}
.meter {
  display: inline-block;
  width: 72px;
  height: 6px;
  border-radius: 99px;
  background: var(--seq-0);
  overflow: hidden;
  vertical-align: middle;
  margin-right: 0.35rem;
}
.meter > span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--bar);
}
.leaders {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: lead;
}
.leaders li {
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.2rem 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  counter-increment: lead;
}
.leaders li::before {
  content: counter(lead);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.leaders li:last-child {
  border-bottom: 0;
}
.leaders li > .link {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leaders li > .link:hover {
  color: var(--accent);
  text-decoration: underline;
}
.leaders li > span.muted:first-of-type {
  grid-column: 2;
  grid-row: 2;
}
.lead-n {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.feed {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 520px;
  overflow-y: auto;
}
.feed li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.feed li:last-child {
  border-bottom: 0;
}
.feed-i {
  flex: none;
  width: 1.4rem;
  text-align: center;
}
.feed-t {
  flex: 1;
  min-width: 0;
}
.feed time {
  flex: none;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}
.heat.hours {
  width: 100%;
  height: auto;
}
.mini-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}
.mini-kpis > div {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
}
.mini-kpis b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}
.mini-kpis span {
  color: var(--muted);
  font-size: 0.8rem;
}
.ustats {
  margin-top: 0.8rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--border);
}

/* ================= phones ================= */
@media (max-width: 760px) {
  .topbar:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    position: sticky;
    top: 0;
    z-index: 20;
    height: 56px;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    box-sizing: content-box;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .topbar .brand {
    padding: 0;
  }
  .topbar .logo {
    width: 1.9rem;
    height: 1.9rem;
    font-size: 1rem;
  }
  .course-btn.top {
    flex: 1;
    min-width: 0;
    width: auto;
    padding: 0.4rem 0.65rem;
    gap: 0.55rem;
    box-shadow: none;
    border-radius: 99px;
  }
  .course-btn.top .cb-txt small {
    display: none;
  }
  .course-btn.top .flag-ic {
    width: 24px;
    height: 16px;
  }
  .course-menu {
    background: rgba(20, 14, 8, 0.42);
    animation: fade-in 0.15s ease-out;
  }
  .cm-sheet {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 82vh;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    padding: 0.4rem 0.6rem calc(0.8rem + env(safe-area-inset-bottom));
    animation: sheet-up 0.2s ease-out;
  }
  .cm-sheet::before {
    content: '';
    display: block;
    width: 38px;
    height: 4px;
    border-radius: 99px;
    background: var(--border);
    margin: 0.3rem auto 0.4rem;
  }
  .cm-item {
    padding: 0.75rem 0.6rem;
  }
  .tabbar:not([hidden]) {
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
  /* Same box on every tab, so selecting one only changes its colour: no shift, and the pill
     stays centred (the global .ni width used to squeeze the padded pill off to one side). */
  .tabbar a .ni {
    display: inline-flex;
    justify-content: center;
    width: auto;
    font-size: 1.3rem;
    border-radius: 99px;
    padding: 0.1rem 0.9rem;
  }
  .tabbar a.on .ni {
    background: var(--accent-soft);
  }
  main#view {
    padding-top: 1.1rem;
  }
  .chat-page {
    height: calc(100dvh - 4rem - 57px - env(safe-area-inset-bottom) - env(safe-area-inset-top));
  }
  h1 {
    font-size: 1.5rem;
  }
  .page.choose {
    padding-top: 0.5rem;
  }
  .lang-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.6rem;
  }
  .lang-pick {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    padding: 0.85rem 0.9rem;
    gap: 0.85rem;
  }
  .lang-pick .flag-ic.big {
    width: 42px;
    height: 28px;
    border-radius: 6px;
  }
  .lang-pick .lp-txt small {
    margin-top: 0.15rem;
    font-size: 0.84rem;
  }
  .lp-go {
    grid-column: auto;
    border: 0;
    padding: 0;
    width: auto;
    font-size: 0.82rem;
  }
  .group-t {
    margin-top: 1.3rem;
  }
  .mini-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
.auth-flags {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 0.2rem;
}
.prompt-en.quote {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 0.6rem 1rem 0.7rem;
}
.quote-lang {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* chess.com-style move badges in the corner of a square */
.sqmark {
  position: absolute;
  z-index: 5;
  width: 5.2cqw;
  height: 5.2cqw;
  min-width: 18px;
  min-height: 18px;
  margin: 0.3cqw 0 0 -0.3cqw;
  transform: translateX(-100%);
  display: grid;
  place-items: center;
  border-radius: 50%;
  font: 800 max(11px, 3.1cqw) / 1 system-ui, sans-serif;
  color: #fff;
  background: #81b64c;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  animation: sqpop 0.18s ease-out;
}
@keyframes sqpop {
  from {
    transform: translateX(-100%) scale(0.4);
  }
}
.sqmark.k-best { background: #5d9948; }
.sqmark.k-excellent { background: #2f9e8f; }
.sqmark.k-book { background: #a88865; font-size: max(9px, 2.5cqw); }
.sqmark.k-inacc { background: #f0c22c; color: #2b2112; }
.sqmark.k-mistake { background: #e58f2a; }
.sqmark.k-blunder,
.sqmark.k-wrong { background: #ca3431; }
.sqmark.k-mate { background: #262421; }
.pline {
  margin-top: 0.6rem;
}
.pline .mv.k-best,
.pline .mv.k-good {
  color: var(--good);
}
.pline .mv.on {
  color: var(--accent-ink);
}

/* tactics leaderboard */
.lbcard {
  margin-top: 0.8rem;
}
.ltable td.num,
.ltable th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ltable td.rank {
  width: 2.5rem;
  font-weight: 700;
  font-size: 1.05rem;
}
.ltable td.who {
  font-weight: 600;
}
.ltable td.key {
  font-weight: 800;
}
.ltable tr.you td {
  background: var(--accent-soft);
}
.ltable tr.gap td {
  text-align: center;
  color: var(--muted);
}
@media (max-width: 560px) {
  .ltable .hide-sm {
    display: none;
  }
}
.pcoach {
  margin-top: 0.8rem;
}
.ccl {
  margin-top: 0.7rem;
}

/* ---- chess.com-style move labels in the game review ---- */
.sqmark.k-brilliant { background: #1baca6; }
.sqmark.k-great { background: #5c8bb0; }
.sqmark.k-excellent { background: #81b64c; font-size: max(9px, 2.5cqw); }
.sqmark.k-miss { background: #ee6b55; }
.cbadge {
  display: inline-grid;
  place-items: center;
  width: 1.45em;
  height: 1.45em;
  border-radius: 50%;
  font: 800 0.72rem / 1 system-ui, sans-serif;
  color: #fff;
  vertical-align: -0.2em;
  background: #81b64c;
}
.cbadge.k-brilliant { background: #1baca6; }
.cbadge.k-great { background: #5c8bb0; }
.cbadge.k-best { background: #5d9948; }
.cbadge.k-excellent { background: #81b64c; font-size: 0.6rem; }
.cbadge.k-good { background: #8ea37f; }
.cbadge.k-book { background: #a88865; font-size: 0.6rem; }
.cbadge.k-inacc { background: #f0c22c; color: #2b2112; }
.cbadge.k-mistake { background: #e58f2a; }
.cbadge.k-miss { background: #ee6b55; }
.cbadge.k-blunder { background: #ca3431; }
.mv.brilliant,
.mclass.brilliant,
.acc-table td.brilliant {
  color: #14958f;
  font-weight: 700;
}
.mv.great,
.mclass.great,
.acc-table td.great {
  color: #4a7ba3;
  font-weight: 600;
}
.mv.miss,
.mclass.miss,
.acc-table td.miss {
  color: #e0533d;
  font-weight: 600;
}
.mv.on.brilliant,
.mv.on.great,
.mv.on.miss {
  color: var(--accent-ink);
}
.gm.brilliant { fill: #1baca6; }
.gm.great { fill: #5c8bb0; }
.gm.miss { fill: #ee6b55; }
.acc-table .krow th {
  font-weight: 500;
  font-size: 0.88rem;
  white-space: nowrap;
}
.acc-table .krow td {
  padding: 0.12rem 0.4rem;
}
.acc-table th.me,
.acc-table td.me {
  background: var(--accent-soft);
}
.acc-table .accrow td {
  font-weight: 700;
  font-size: 1.1rem;
}
.acc-table .accrow th,
.acc-table .accrow td {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}
/* trying your own line: a light white filter over the board, like chess.com's analysis */
#rvboard.variation cg-board::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.45);
  z-index: 1;
  pointer-events: none;
}
.varbar {
  border: 1px dashed var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.7rem;
}
.varbar .varmoves {
  max-height: none;
  margin: 0.3rem 0 0.5rem;
}
.tryhint {
  margin: 0.5rem 0 0;
}

/* What's new / changelog */
.whatsnew {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.4rem 0.5rem 0;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
}
.whatsnew:hover,
.whatsnew.on {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn .badge {
  margin-left: 0.3rem;
}
.changelog .cl-day {
  margin-bottom: 1rem;
}
.changelog .cl-day h3 {
  margin: 0 0 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.cl-new {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 99px;
  padding: 0.1em 0.6em;
}
.changelog ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}
.changelog li {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  line-height: 1.45;
}
.cl-kind {
  flex: none;
  width: 5.6em;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 6px;
  padding: 0.12em 0;
}
.cl-kind.new {
  background: var(--accent-soft);
  color: var(--accent);
}
.cl-kind.improved {
  background: var(--good-soft);
  color: var(--good);
}
.cl-kind.fixed {
  background: var(--bad-soft);
  color: var(--bad);
}
.cl-text b {
  margin-right: 0.25rem;
}

/* Shared Grayhub account: per-app access toggles on each admin user row */
.ur-apps { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.ur-apps .switch { font-size: 13px; }

/* "Back to Grayhub" links (shared account hub) */
.hub-back {
  display: block;
  width: fit-content;
  margin: 0 auto 1rem;
  padding: 0.35rem 0.7rem;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
}
.hub-back:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.hub-top {
  display: grid;
  place-items: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  color: var(--muted);
  font-size: 1.1rem;
  text-decoration: none;
}
.hub-top:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
