:root {
  --bg: #0e1116;
  --bg-elev: #161b23;
  --bg-elev-2: #1d232d;
  --line: #262d38;
  --text: #e6e9ef;
  --text-dim: #98a2b3;
  --text-faint: #6b7480;
  --learned: #38bdf8;
  --mastered: #f5b83d;
  --danger: #f87171;
  --lvl-beginner: #4ade80;
  --lvl-intermediate: #a78bfa;
  --lvl-advanced: #fb7185;
  --radius: 12px;
  --wrap: 900px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --bg-elev: #ffffff;
    --bg-elev-2: #eef1f5;
    --line: #dde1e8;
    --text: #131720;
    --text-dim: #5b6472;
    --text-faint: #8b94a3;
    --learned: #0284c7;
    --mastered: #b4790a;
    --danger: #dc2626;
    --lvl-beginner: #16a34a;
    --lvl-intermediate: #7c3aed;
    --lvl-advanced: #e11d48;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
a:hover { text-decoration-color: currentColor; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */

.topbar {
  background: linear-gradient(180deg, var(--bg-elev), var(--bg));
  border-bottom: 1px solid var(--line);
}

.topbar-inner { padding: 20px 16px 16px; display: grid; gap: 16px; }

.brand { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.brand h1 {
  margin: 0;
  font-size: clamp(20px, 4vw, 26px);
  letter-spacing: -0.02em;
}

.brand-sub { margin: 2px 0 0; color: var(--text-dim); font-size: 13px; }

.stats { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }

@media (max-width: 520px) { .stats { grid-template-columns: 1fr; } }

.stat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.stat-label { font-size: 13px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 6px; }
.stat-value { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-learned { background: var(--learned); }
.dot-mastered { background: var(--mastered); }

.bar { height: 8px; border-radius: 999px; background: var(--bg-elev-2); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; transition: width .3s ease; }
.bar-learned { background: var(--learned); }
.bar-mastered { background: var(--mastered); }

.level-stats {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}

.level-stats li {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.level-stats .lvl-name { font-size: 12px; color: var(--text-dim); }
.level-stats .lvl-nums { font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.level-stats .lvl-nums b { font-weight: 600; }
.level-stats .lvl-nums .m { color: var(--mastered); }

.ghost-btn {
  flex: none;
  border: 1px solid var(--line); background: transparent; color: var(--text-dim);
  border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.ghost-btn:hover { color: var(--text); }
#reset-btn:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); }

/* ---------- list ---------- */

main { padding-top: 16px; padding-bottom: 40px; }

/* Block flow, not grid: the group headers are position:sticky, and a grid item can
   only stick inside its own row. */
.trick-list { list-style: none; margin: 0; padding: 0; }

.group-head {
  position: sticky; top: 0; z-index: 10;
  margin: 28px 0 8px;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
  border-left-width: 4px; border-left-style: solid; border-left-color: var(--lvl);
  border-bottom-width: 1px; border-bottom-style: solid;
  border-bottom-color: color-mix(in srgb, var(--lvl) 35%, transparent);
  border-radius: 4px;
  font-size: 15px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text);
}

.group-head::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--lvl) 45%, transparent), transparent);
}

.group-head[data-level="Beginner"] { --lvl: var(--lvl-beginner); }
.group-head[data-level="Intermediate"] { --lvl: var(--lvl-intermediate); }
.group-head[data-level="Advanced"] { --lvl: var(--lvl-advanced); }

.group-head:first-child { margin-top: 4px; }

.trick {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 6px;
}

.trick.is-learned { border-left: 3px solid var(--learned); }
.trick.is-mastered { border-left: 3px solid var(--mastered); }

.trick-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  width: 100%; background: none; border: 0; color: inherit; font: inherit; text-align: left;
  cursor: pointer;
}
.trick-row:hover { background: var(--bg-elev-2); }
.trick-row:focus-visible { outline: 2px solid var(--learned); outline-offset: -2px; }

.trick-num {
  flex: none; width: 28px;
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-faint);
}

.trick-main { flex: 1; min-width: 0; }
.trick-name { display: block; font-weight: 500; }
.trick-meta { display: block; font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.trick-meta .note { color: var(--text-dim); }

.play-hint { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-faint); }
.play-hint svg { width: 16px; height: 16px; fill: currentColor; }
.trick-row[aria-expanded="true"] .play-hint { color: var(--learned); }

.marks { display: flex; gap: 6px; padding: 10px 12px 10px 52px; flex-wrap: wrap; }

.mark {
  border: 1px solid var(--line); background: var(--bg-elev-2); color: var(--text-dim);
  border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 12.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s, border-color .15s;
}
.mark:hover { color: var(--text); }
.mark svg { width: 13px; height: 13px; fill: currentColor; opacity: .55; }
.mark[aria-pressed="true"] svg { opacity: 1; }
.mark-learned[aria-pressed="true"] {
  background: color-mix(in srgb, var(--learned) 18%, transparent);
  border-color: var(--learned); color: var(--learned);
}
.mark-mastered[aria-pressed="true"] {
  background: color-mix(in srgb, var(--mastered) 18%, transparent);
  border-color: var(--mastered); color: var(--mastered);
}

.player { border-top: 1px solid var(--line); background: #000; }
.player-frame { position: relative; aspect-ratio: 16 / 9; }
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--bg-elev-2); font-size: 12px; color: var(--text-dim);
}
.player-foot a { color: var(--text-dim); }
.player-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.site-footer { padding-bottom: 48px; font-size: 13px; color: var(--text-dim); }
.site-footer .muted { color: var(--text-faint); font-size: 12px; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 16px; font-size: 13px; z-index: 60;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
