/* Palette ------------------------------------------------------------------ */

/* Registered so colour changes interpolate smoothly instead of jumping. */
@property --bg { syntax: '<color>'; inherits: true; initial-value: #f5f7fc; }
@property --ink { syntax: '<color>'; inherits: true; initial-value: #0e1628; }
@property --muted { syntax: '<color>'; inherits: true; initial-value: #687491; }
@property --surface { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --surface-solid { syntax: '<color>'; inherits: true; initial-value: #fbfcff; }
@property --accent { syntax: '<color>'; inherits: true; initial-value: #2f6bff; }
@property --accent-ink { syntax: '<color>'; inherits: true; initial-value: #1f56e0; }
@property --on-accent { syntax: '<color>'; inherits: true; initial-value: #fff; }
@property --blob-1 { syntax: '<color>'; inherits: true; initial-value: #4f8dff; }
@property --blob-2 { syntax: '<color>'; inherits: true; initial-value: #82b1ff; }
@property --blob-opacity { syntax: '<number>'; inherits: true; initial-value: 0.5; }
@property --error { syntax: '<color>'; inherits: true; initial-value: #e0404b; }
@property --tok-type { syntax: '<color>'; inherits: true; initial-value: #7a4fe0; }
@property --tok-string { syntax: '<color>'; inherits: true; initial-value: #0b8a72; }
@property --tok-number { syntax: '<color>'; inherits: true; initial-value: #c46100; }
@property --tok-comment { syntax: '<color>'; inherits: true; initial-value: #8f99b0; }

:root {
  --a-light: #2f6bff; --a-ink-light: #1f56e0; --a-dark: #6b93ff; --a-ink-dark: #a4bdff;
  --b1-light: #4f8dff; --b2-light: #8db5ff; --b1-dark: #2a5cff; --b2-dark: #1a3fae;
  --on-a-light: #fff; --on-a-dark: #fff;
  --blob-light: 0.5; --blob-dark: 0.42;
}

:root[data-accent="violet"] {
  --a-light: #7046f5; --a-ink-light: #5b33dc; --a-dark: #a58bff; --a-ink-dark: #c8b8ff;
  --b1-light: #8b5cff; --b2-light: #b9a1ff; --b1-dark: #6a35ff; --b2-dark: #4320b0;
}

:root[data-accent="red"] {
  --a-light: #e5394a; --a-ink-light: #cc2233; --a-dark: #ff6b78; --a-ink-dark: #ffa3ab;
  --b1-light: #ff5a66; --b2-light: #ff9aa2; --b1-dark: #d42537; --b2-dark: #8e1424;
}

:root[data-accent="green"] {
  --a-light: #0f9b74; --a-ink-light: #0a7d5d; --a-dark: #38d6a2; --a-ink-dark: #8fefcd;
  --b1-light: #2fd39a; --b2-light: #8be8c4; --b1-dark: #0b9468; --b2-dark: #065c41;
  --on-a-dark: #04261b;
}

:root[data-accent="orange"] {
  --a-light: #e5700b; --a-ink-light: #c25900; --a-dark: #ffa143; --a-ink-dark: #ffc58a;
  --b1-light: #ffa53d; --b2-light: #ffc98a; --b1-dark: #db6400; --b2-dark: #8f3f00;
  --on-a-dark: #2b1500;
}

:root[data-accent="mono"] {
  --a-light: #111318; --a-ink-light: #111318; --a-dark: #f2f3f6; --a-ink-dark: #f2f3f6;
  --b1-light: #a3a8b4; --b2-light: #cfd3db; --b1-dark: #4a505e; --b2-dark: #2c313b;
  --on-a-light: #fff; --on-a-dark: #111318;
  --blob-light: 0.55; --blob-dark: 0.5;
}

:root {
  color-scheme: light;
  --bg: #f5f7fc;
  --ink: #0e1628;
  --muted: #687491;
  --surface: rgba(255, 255, 255, 0.62);
  --surface-solid: #fbfcff;
  --line: color-mix(in srgb, var(--ink) 11%, transparent);
  --error: #e0404b;
  --scrim: rgba(14, 22, 40, 0.24);
  --accent: var(--a-light);
  --accent-ink: var(--a-ink-light);
  --on-accent: var(--on-a-light);
  --blob-1: var(--b1-light);
  --blob-2: var(--b2-light);
  --blob-opacity: var(--blob-light);
  --chip: color-mix(in srgb, var(--accent) 11%, transparent);
  --grain: 0.06;

  --tok-keyword: var(--accent-ink);
  --tok-type: #7a4fe0;
  --tok-string: #0b8a72;
  --tok-number: #c46100;
  --tok-comment: #8f99b0;
  --tok-constant: #c4366b;

  --sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070a14;
  --ink: #eaeefa;
  --muted: #8e99b6;
  --surface: rgba(18, 24, 44, 0.6);
  --surface-solid: #0e1324;
  --error: #ff7a84;
  --scrim: rgba(2, 4, 12, 0.6);
  --accent: var(--a-dark);
  --accent-ink: var(--a-ink-dark);
  --on-accent: var(--on-a-dark);
  --blob-1: var(--b1-dark);
  --blob-2: var(--b2-dark);
  --blob-opacity: var(--blob-dark);
  --grain: 0.09;

  --tok-type: #b49dff;
  --tok-string: #4fd6bd;
  --tok-number: #ffb15c;
  --tok-comment: #67728d;
  --tok-constant: #ff8fb8;
}

:root {
  transition:
    --bg 0.7s var(--ease), --ink 0.7s var(--ease), --muted 0.7s var(--ease), --surface 0.7s var(--ease),
    --surface-solid 0.7s var(--ease), --accent 0.7s var(--ease), --accent-ink 0.7s var(--ease),
    --on-accent 0.7s var(--ease), --error 0.7s var(--ease), --blob-1 1.4s var(--ease), --blob-2 1.4s var(--ease),
    --blob-opacity 1.4s var(--ease), --tok-type 0.7s, --tok-string 0.7s, --tok-number 0.7s, --tok-comment 0.7s;
}

/* Base --------------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--ink) 22%, transparent) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: color-mix(in srgb, var(--ink) 22%, transparent);
}

::-webkit-scrollbar-button {
  display: none;
}

::selection {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 0.1em 0.42em;
  border-radius: 8px;
  background: var(--chip);
  color: var(--accent-ink);
}

[hidden] {
  display: none !important;
}

/* Background --------------------------------------------------------------- */

.bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob,
.glow {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}

.blob {
  width: 62vmax;
  height: 62vmax;
  opacity: var(--blob-opacity);
  background: radial-gradient(closest-side, var(--blob-1), color-mix(in srgb, var(--blob-1) 40%, transparent) 55%, transparent);
  transition: opacity 0.8s var(--ease);
}

.blob:nth-child(even) {
  background: radial-gradient(closest-side, var(--blob-2), color-mix(in srgb, var(--blob-2) 40%, transparent) 55%, transparent);
}

.blob:nth-child(1) { left: -22vmax; top: -26vmax; animation: orbit-a 23s ease-in-out infinite; }
.blob:nth-child(2) { right: -24vmax; top: -8vmax; width: 50vmax; height: 50vmax; animation: orbit-b 29s ease-in-out infinite; }
.blob:nth-child(3) { left: 8vw; bottom: -34vmax; animation: orbit-c 26s ease-in-out infinite; }
.blob:nth-child(4) { right: 4vw; bottom: -10vmax; width: 38vmax; height: 38vmax; animation: orbit-a 34s ease-in-out infinite reverse; }
.blob:nth-child(5) { left: 30vw; top: 18vh; width: 30vmax; height: 30vmax; opacity: calc(var(--blob-opacity) * 0.55); animation: orbit-b 21s ease-in-out infinite reverse; }

@keyframes orbit-a {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  25% { transform: translate3d(16vw, 9vh, 0) scale(1.12); }
  50% { transform: translate3d(6vw, 26vh, 0) scale(0.92); }
  75% { transform: translate3d(-6vw, 10vh, 0) scale(1.06); }
}

@keyframes orbit-b {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  30% { transform: translate3d(-18vw, 14vh, 0) scale(0.9); }
  60% { transform: translate3d(-6vw, 32vh, 0) scale(1.15); }
  80% { transform: translate3d(4vw, 12vh, 0) scale(1); }
}

@keyframes orbit-c {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  35% { transform: translate3d(22vw, -18vh, 0) scale(1.1); }
  70% { transform: translate3d(-10vw, -8vh, 0) scale(0.94); }
}

.glow {
  left: 0;
  top: 0;
  width: 420px;
  height: 420px;
  margin: -210px 0 0 -210px;
  opacity: 0;
  background: radial-gradient(closest-side, var(--blob-1), transparent);
  transition: opacity 0.6s var(--ease);
}

.glow.on {
  opacity: calc(var(--blob-opacity) * 1.1);
}

.glow i {
  display: none;
}

/* Film grain hides colour banding in the soft gradients. */
.grain {
  position: absolute;
  inset: 0;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.bg.flash .blob {
  opacity: calc(var(--blob-opacity) * 1.45);
  transition-duration: 0.25s;
}

/* Progress bar ------------------------------------------------------------- */

.bar {
  position: fixed;
  z-index: 30;
  bottom: 0;
  left: 0;
  width: 0;
  height: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, var(--blob-2), var(--accent));
  opacity: 0.85;
  transition: width 0.7s var(--ease);
}

.bar::after {
  content: "";
  position: absolute;
  right: -2px;
  top: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  filter: blur(4px);
  opacity: 0.9;
}

/* Layout ------------------------------------------------------------------- */

#app {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.top {
  position: relative;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px clamp(16px, 4vw, 40px);
}

.top .group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border: 0;
  background: none;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
}

.wordmark i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent);
  animation: beat 3.2s var(--ease) infinite;
}

@keyframes beat {
  0%, 60%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent); }
  30% { box-shadow: 0 0 0 7px transparent; }
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  cursor: pointer;
  transition: transform 0.3s var(--spring), border-color 0.2s;
}

.icon-btn:hover {
  border-color: var(--accent);
  transform: scale(1.06);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.spin svg {
  transition: transform 0.6s var(--spring);
}

.icon-btn.spin:hover svg,
.icon-btn.spin[aria-expanded="true"] svg {
  transform: rotate(60deg);
}

.link {
  border: 0;
  background: none;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.link:hover {
  color: var(--accent-ink);
  background: var(--chip);
}

.link.danger:hover {
  color: var(--error);
  background: color-mix(in srgb, var(--error) 10%, transparent);
}

.btn {
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 15px 34px;
  min-height: 54px;
  background: color-mix(in srgb, var(--accent) 86%, transparent);
  color: var(--on-accent);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.35s var(--spring), box-shadow 0.3s var(--ease), background 0.3s;
}

.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.8s var(--ease);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px -14px var(--accent);
}

.btn:hover::after {
  transform: translateX(120%);
}

.btn:active {
  transform: scale(0.97);
}

.btn.ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
}

.btn.ghost::after {
  display: none;
}

.btn.ghost:hover {
  border-color: var(--accent);
  box-shadow: none;
}

.btn.swap {
  animation: swap 0.45s var(--spring);
}

@keyframes swap {
  from { transform: scale(0.9); }
}

/* Animations --------------------------------------------------------------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); filter: blur(6px); }
}

@keyframes word {
  from { opacity: 0; transform: translateY(0.45em); filter: blur(8px); }
}

@keyframes line-in {
  from { opacity: 0; transform: translateX(-10px); filter: blur(4px); }
}

@keyframes step-in {
  from { opacity: 0; transform: translateX(calc(var(--dir, 1) * 40px)); filter: blur(8px); }
}

@keyframes step-out {
  to { opacity: 0; transform: translateX(calc(var(--dir, 1) * -40px)); filter: blur(8px); }
}

@keyframes pop {
  0% { opacity: 0; transform: scale(0.4); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes ring {
  from { transform: scale(0.8); opacity: 0.6; }
  to { transform: scale(2.2); opacity: 0; }
}

@keyframes draw {
  from { stroke-dashoffset: 30; }
  to { stroke-dashoffset: 0; }
}

@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

@keyframes blink {
  50% { caret-color: transparent; }
}

@keyframes fade {
  from { opacity: 0; }
}

.w {
  display: inline-block;
  animation: word 0.7s var(--ease) both;
  animation-delay: calc(var(--base, 0ms) + var(--i) * 32ms);
}

.rise {
  animation: rise 0.7s var(--ease) both;
  animation-delay: var(--delay, 0ms);
}

/* Home --------------------------------------------------------------------- */

.home {
  flex: 1;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 22px;
  padding: 0 20px 10vh;
  text-align: center;
}

.home h1 {
  margin: 0;
  max-width: 13ch;
  font-size: clamp(42px, 8.4vw, 88px);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: -0.045em;
}

.home .sub {
  margin: 0;
  color: var(--muted);
  font-size: clamp(17px, 2.4vw, 21px);
}

.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.meta {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.meter {
  width: 180px;
  height: 4px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  width: var(--value);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blob-2), var(--accent));
  animation: grow 1.2s 0.5s var(--ease) both;
}

@keyframes grow {
  from { width: 0; }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 14px;
  font-weight: 500;
}

.badge i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* Topics ------------------------------------------------------------------- */

.topics {
  width: min(700px, 100%);
  margin: 0 auto;
  padding: 0 20px 80px;
}

.topics-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 28px;
}

.topics h2 {
  margin: 0;
  font-size: clamp(34px, 5.4vw, 48px);
  letter-spacing: -0.035em;
  font-weight: 600;
}

.topic {
  margin-bottom: 12px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  transition: border-color 0.3s, transform 0.4s var(--spring);
}

.topic:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.topic-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border: 0;
  background: none;
  text-align: left;
  font-weight: 600;
  font-size: 18px;
  cursor: pointer;
}

.topic-head .name {
  flex: 1;
}

.topic-head .chev {
  display: grid;
  color: var(--muted);
  transition: transform 0.45s var(--spring);
}

.topic.open .chev {
  transform: rotate(90deg);
}

.dots {
  display: flex;
  gap: 5px;
}

.dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}

.dots i.on {
  background: var(--accent);
}

.ratio {
  min-width: 34px;
  text-align: right;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.topic-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.5s var(--ease);
}

.topic.open .topic-body {
  grid-template-rows: 1fr;
}

.topic-body > div {
  min-height: 0;
  overflow: hidden;
  padding: 0 12px;
}

.topic.open .topic-body > div {
  padding-bottom: 12px;
}

.lrow {
  display: flex;
  align-items: center;
  border-radius: 20px;
  opacity: 0;
  transform: translateY(8px);
  transition: background 0.2s, opacity 0.4s var(--ease), transform 0.5s var(--ease);
  transition-delay: 0s, calc(var(--i) * 40ms + 60ms), calc(var(--i) * 40ms + 60ms);
}

.topic.open .lrow {
  opacity: 1;
  transform: none;
}

.lrow:hover {
  background: var(--chip);
}

.lstart {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.lstart .n {
  width: 26px;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.lstart .lt {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  transition: transform 0.35s var(--ease);
}

.lrow:hover .lt {
  transform: translateX(4px);
}

.state {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--line);
  color: var(--on-accent);
}

.state svg {
  display: none;
}

.lrow.done .state {
  border-color: var(--accent);
  background: var(--accent);
}

.lrow.done .state svg {
  display: block;
}

.lrow.current .state {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--chip);
}

/* Lesson player ------------------------------------------------------------ */

.stage {
  flex: 1;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 8px 20px 150px;
}

.step {
  width: min(640px, 100%);
  animation: step-in 0.55s var(--ease) both;
}

.step.out {
  animation: step-out 0.22s ease-in forwards;
}

.step.wide {
  width: min(780px, 100%);
}

.step.center {
  text-align: center;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.eyebrow code {
  font-size: 0.92em;
}

.big {
  margin: 0;
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.038em;
}

.big.sm {
  font-size: clamp(26px, 4.4vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.lead {
  margin: 0;
  font-size: clamp(23px, 3.8vw, 32px);
  line-height: 1.35;
  font-weight: 500;
  letter-spacing: -0.022em;
}

.big + .lead {
  margin-top: 22px;
  color: var(--muted);
  font-size: clamp(19px, 2.8vw, 24px);
}

.muted {
  color: var(--muted);
}

.step > .muted {
  margin: 14px 0 0;
}

.lines {
  margin: 0;
  padding: 0;
  list-style: none;
}

.lines li {
  position: relative;
  padding-left: 28px;
  margin: 0 0 22px;
  font-size: clamp(19px, 3vw, 24px);
  line-height: 1.4;
  animation: rise 0.7s var(--ease) both;
  animation-delay: calc(var(--i) * 0.45s + 0.1s);
}

.lines li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.6em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.table-wrap {
  margin-top: 24px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 15px;
}

th,
td {
  padding: 12px 18px 12px 0;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

tbody tr {
  animation: line-in 0.5s var(--ease) both;
  animation-delay: calc(var(--i) * 90ms + 200ms);
}

th {
  color: var(--muted);
  font-weight: 500;
}

.dock {
  position: fixed;
  z-index: 10;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  pointer-events: none;
}

.dock-inner {
  pointer-events: auto;
  width: min(640px, 100%);
  display: flex;
  align-items: center;
  gap: 10px;
}

.dock.flow {
  position: static;
  padding-top: 8px;
}

.stage:has(+ .dock.flow) {
  padding-bottom: 24px;
}

.dock.wide .dock-inner {
  width: min(780px, 100%);
}

.dock .spacer {
  flex: 1;
}

.kbd {
  color: var(--muted);
  font-size: 13px;
  opacity: 0.8;
}

/* Done screen */

.medal {
  position: relative;
  width: 84px;
  height: 84px;
  margin: 0 auto 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  animation: pop 0.7s var(--spring) both;
}

.medal::before,
.medal::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: ring 1.6s var(--ease) 0.3s both;
}

.medal::after {
  animation-delay: 0.6s;
}

.medal path {
  stroke-dasharray: 30;
  animation: draw 0.5s 0.35s var(--ease) both;
}

.stat {
  margin-top: 16px;
  color: var(--muted);
  font-size: 15px;
}

/* Confetti */

.fx {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.fx i {
  position: absolute;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: var(--c);
  animation: burst var(--t) var(--ease) forwards;
}

.fx i.sq {
  border-radius: 3px;
}

@keyframes burst {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r)) scale(1); opacity: 0; }
}

/* Code --------------------------------------------------------------------- */

.code,
.ed {
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.8;
  tab-size: 4;
}

.code {
  margin: 30px 0 0;
  overflow-x: auto;
  white-space: pre;
  scrollbar-width: thin;
}

.code .ln {
  display: block;
  min-height: 1.8em;
  animation: line-in 0.55s var(--ease) both;
  animation-delay: calc(var(--i) * 70ms + 180ms);
}

.code.static .ln {
  animation: none;
}

.tok-keyword { color: var(--tok-keyword); }
.tok-type { color: var(--tok-type); }
.tok-string { color: var(--tok-string); }
.tok-number { color: var(--tok-number); }
.tok-comment { color: var(--tok-comment); font-style: italic; }
.tok-constant { color: var(--tok-constant); }
.tok-method { font-weight: 500; }

.ed {
  position: relative;
  display: flex;
  margin-top: 30px;
}

.ed .gutter {
  margin: 0;
  padding-right: 22px;
  text-align: right;
  color: var(--muted);
  opacity: 0.45;
  user-select: none;
  font: inherit;
}

.pane {
  position: relative;
  flex: 1;
  min-width: 0;
}

/* Soft highlight behind the line that holds the caret. */
.pane::before {
  content: "";
  position: absolute;
  left: -12px;
  right: -12px;
  top: calc(var(--caret-line, 0) * 1.8em);
  height: 1.8em;
  border-radius: 10px;
  background: var(--chip);
  opacity: 0;
  transition: top 0.25s var(--ease), opacity 0.3s;
}

.ed:focus-within .pane::before {
  opacity: 1;
}

.hl,
.inp {
  margin: 0;
  padding: 0;
  border: 0;
  font: inherit;
  letter-spacing: 0;
  white-space: pre;
  tab-size: 4;
}

.hl {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.hl code {
  display: block;
  padding: 0;
  background: none;
  color: var(--ink);
  font-size: inherit;
  border-radius: 0;
}

.inp {
  position: relative;
  display: block;
  width: 100%;
  min-height: 1.8em;
  background: transparent;
  color: transparent;
  caret-color: var(--accent);
  resize: none;
  outline: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.inp::-webkit-scrollbar {
  display: none;
}

/* The answer line: only an underline and a blinking caret. */
.ed.line {
  padding: 12px 2px;
  font-size: clamp(16px, 2.6vw, 20px);
}

.ed.line::after,
.ed.line::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--line);
}

.ed.line::after {
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s var(--ease), background 0.3s;
}

.ed.line:focus-within::after,
.ed.line.ok::after {
  transform: scaleX(1);
}

.ed.line.err::after {
  background: var(--error);
  transform: scaleX(1);
}

.ed.line .pane::before {
  display: none;
}

.ed.line .inp {
  animation: blink 1.1s steps(1) infinite;
}

.ed.line.ok .inp {
  animation: none;
  caret-color: transparent;
}

.ed .tick {
  position: absolute;
  right: 0;
  top: 50%;
  margin-top: -16px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  animation: pop 0.5s var(--spring) both;
}

.ed .tick path {
  stroke-dasharray: 30;
  animation: draw 0.4s 0.15s var(--ease) both;
}

.ed.shake {
  animation: shake 0.42s;
}

.msg {
  min-height: 28px;
  margin-top: 16px;
  font-weight: 500;
  font-size: 16px;
}

.msg > * {
  animation: rise 0.45s var(--ease) both;
}

.msg p {
  margin: 0 0 4px;
}

.msg .ok {
  color: var(--accent-ink);
}

.msg .err {
  color: var(--error);
}

.msg .note-line {
  color: var(--muted);
  font-weight: 400;
  font-size: 15px;
}

.msg .code {
  margin-top: 6px;
  font-size: 15px;
}

.file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 30px 0 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
}

.file + .ed {
  margin-top: 18px;
}

.tools {
  display: flex;
  gap: 2px;
  font-family: var(--sans);
}

.tools .link {
  padding: 6px 12px;
  font-size: 14px;
}

.aids {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 26px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.35s var(--spring);
}

.chip:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.chip.on {
  border-color: var(--accent);
  background: var(--chip);
  color: var(--accent-ink);
}

.panel {
  margin-top: 18px;
  animation: rise 0.45s var(--ease) both;
}

.panel p {
  margin: 0 0 10px;
}

.panel .code {
  margin-top: 8px;
}

.plan {
  list-style: none;
  margin: 0;
  padding: 0;
}

.plan li {
  animation: line-in 0.45s var(--ease) both;
  animation-delay: calc(var(--i) * 60ms);
}

.plan label {
  display: flex;
  gap: 12px;
  padding: 7px 0;
  cursor: pointer;
}

.plan input {
  appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s, transform 0.35s var(--spring);
}

.plan input:checked {
  border-color: var(--accent);
  background: var(--accent);
  transform: scale(1.08);
  box-shadow: inset 0 0 0 4px var(--bg);
}

.plan input:checked + span {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent);
}

/* Settings popover --------------------------------------------------------- */

.pop {
  position: fixed;
  z-index: 45;
  top: 76px;
  right: clamp(16px, 4vw, 40px);
  width: min(320px, calc(100vw - 32px));
  padding: 22px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid) 58%, transparent);
  backdrop-filter: blur(30px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  box-shadow: 0 30px 60px -30px rgba(10, 20, 50, 0.35);
  transform-origin: top right;
  animation: pop-in 0.4s var(--spring) both;
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.85) translateY(-8px); }
}

.pop-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.pop-label:not(:first-child) {
  margin-top: 20px;
}

.seg {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 4px;
  border-radius: 999px;
  background: var(--chip);
}

.seg::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / var(--n));
  border-radius: 999px;
  background: var(--surface-solid);
  box-shadow: 0 2px 8px -2px rgba(10, 20, 50, 0.2);
  transform: translateX(calc(var(--at) * 100%));
  transition: transform 0.45s var(--spring);
}

.seg button {
  position: relative;
  padding: 8px 6px;
  border: 0;
  background: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.3s;
}

.seg button[aria-pressed="true"] {
  color: var(--ink);
}

.swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.swatch {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 0;
  background: var(--c);
  cursor: pointer;
  box-shadow: 0 0 0 0 var(--bg), 0 0 0 0 var(--c);
  transition: transform 0.35s var(--spring), box-shadow 0.3s var(--ease);
}

.swatch.mono {
  background: linear-gradient(135deg, #111318 50%, #f2f3f6 50%);
  outline: 1px solid var(--line);
}

.swatch:hover {
  transform: scale(1.12);
}

.swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent);
}

.pop .danger {
  margin: 20px 0 0 -14px;
}

/* Notes sheet -------------------------------------------------------------- */

.sheet {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--scrim) 70%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade 0.3s both;
}

.sheet-card {
  width: min(700px, 100%);
  max-height: 86dvh;
  overflow: auto;
  padding: clamp(24px, 5vw, 44px);
  border-radius: 32px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid) 60%, transparent);
  backdrop-filter: blur(32px) saturate(1.6);
  -webkit-backdrop-filter: blur(32px) saturate(1.6);
  box-shadow: 0 40px 90px -50px rgba(10, 20, 50, 0.5);
  animation: sheet-in 0.55s var(--spring) both;
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(40px) scale(0.97); }
}

.sheet-card h3 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: -0.03em;
  font-weight: 600;
}

.sheet-card h4 {
  margin: 34px 0 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.sheet-card p {
  margin: 0 0 8px;
}

.sheet-card ul {
  margin: 0;
  padding-left: 20px;
}

.sheet-card li {
  margin-bottom: 8px;
}

.sheet-card .code {
  margin: 4px 0 18px;
  font-size: 14.5px;
}

.sheet-card .row {
  justify-content: flex-start;
  margin-top: 30px;
}

/* Keyboard hints ------------------------------------------------------------ */

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 7px;
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  font: 500 12px/1 var(--sans);
  opacity: 0.75;
}

.btn kbd,
.chip kbd,
.drawer-handle kbd {
  margin-left: 10px;
  vertical-align: 1px;
}

.chip kbd {
  min-width: 18px;
  height: 18px;
  font-size: 11px;
}

.hint-key {
  margin-top: 18px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.hint-key kbd {
  margin-right: 6px;
}

/* Count badge on icon buttons */

.icon-btn {
  position: relative;
}

.icon-btn .count {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  animation: pop 0.45s var(--spring) both;
}

.icon-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--chip);
  color: var(--accent-ink);
}

.icon-btn.sm {
  width: 34px;
  height: 34px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: transparent;
  color: var(--muted);
}

.icon-btn.sm:hover,
.icon-btn.sm.on {
  color: var(--accent-ink);
}

/* Form controls */

.field,
.note-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 16px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  outline: 0;
  transition: border-color 0.25s, box-shadow 0.35s var(--ease);
}

.note-input {
  resize: vertical;
  min-height: 64px;
  line-height: 1.5;
}

.field:focus,
.note-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--chip);
}

.btn.small {
  min-height: 40px;
  padding: 8px 20px;
  font-size: 14px;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.small {
  font-size: 13px;
}

.switch {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  transition: background 0.3s var(--ease);
}

.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px -1px rgba(0, 0, 0, 0.25);
  transition: transform 0.4s var(--spring);
}

.switch[aria-checked="true"] {
  background: var(--accent);
}

.switch[aria-checked="true"] i {
  transform: translateX(18px);
  background: var(--on-accent);
}

.setting-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  font-size: 14px;
  font-weight: 500;
}

.setting-line > span {
  flex: 1;
}

.setting-line .link {
  padding: 6px 10px;
  font-size: 13px;
}

.check-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
}

.check-line input {
  accent-color: var(--accent);
}

.check-line b {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 14px;
}

.check-line .muted {
  font-size: 13px;
}

.row.left {
  justify-content: flex-start;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 30px 0;
  animation: rise 0.5s var(--ease) both;
}

/* Settings extras */

.pop {
  max-height: calc(100dvh - 100px);
  overflow: auto;
}

.sync-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sync-box .link {
  padding: 6px 10px;
  font-size: 13px;
}

.big-box {
  margin: 18px 0 4px;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--chip);
}

.sync-status.error .muted {
  color: var(--error);
}

.pop-foot {
  display: flex;
  justify-content: space-between;
  margin: 18px -14px 0;
}

.pop .danger {
  margin: 0;
}

.steps-list {
  padding-left: 20px;
}

.steps-list li {
  margin-bottom: 8px;
}

.link.inline {
  padding: 2px 6px;
  color: var(--accent-ink);
  text-decoration: none;
}

.msg-line {
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 500;
}

.msg-line.err {
  color: var(--error);
}

.sheet-card .field {
  margin-top: 6px;
}

.sheet-card .note-input {
  margin-top: 18px;
}

/* Shortcut list */

.sheet.wide .sheet-card {
  width: min(820px, 100%);
}

.key-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px 36px;
  margin-top: 22px;
}

.key-group {
  animation: rise 0.5s var(--ease) both;
  animation-delay: calc(var(--i) * 70ms + 80ms);
}

.key-group h4 {
  margin: 10px 0 6px;
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
}

.key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  font-size: 15px;
}

.key-set {
  display: flex;
  gap: 4px;
}

.key-row kbd,
.sheet .btn kbd {
  min-width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: var(--chip);
  color: var(--accent-ink);
  font-size: 12px;
  opacity: 1;
}

.sheet .btn kbd {
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
}

/* Soft, see-through prompt after a lesson */

.sheet.soft {
  background: color-mix(in srgb, var(--bg) 25%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sheet.soft .sheet-card {
  width: min(520px, 100%);
  background: color-mix(in srgb, var(--surface-solid) 66%, transparent);
  backdrop-filter: blur(28px) saturate(1.6);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
  box-shadow: 0 40px 80px -40px rgba(10, 20, 50, 0.45);
}

/* Template packs */

.pack {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}

.pack summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  list-style: none;
  cursor: pointer;
}

.pack summary::-webkit-details-marker {
  display: none;
}

.pack-name {
  flex: 1;
  font-weight: 600;
}

.pack-list {
  max-height: 280px;
  overflow: auto;
  padding: 4px 18px 14px;
  border-top: 1px solid var(--line);
}

/* Template cheat sheet (side panel) */

.side {
  position: fixed;
  z-index: 35;
  top: 80px;
  right: 16px;
  bottom: 16px;
  width: min(380px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid) 56%, transparent);
  backdrop-filter: blur(30px) saturate(1.6);
  -webkit-backdrop-filter: blur(26px) saturate(1.5);
  box-shadow: 0 30px 70px -40px rgba(10, 20, 50, 0.5);
  animation: side-in 0.5s var(--spring) both;
}

@keyframes side-in {
  from { opacity: 0; transform: translateX(40px) scale(0.98); }
}

.side-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.side-head h3 {
  flex: 1;
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.side-hint {
  margin: 0;
}

.side-list {
  flex: 1;
  overflow: auto;
  margin: 0 -8px;
  padding: 0 8px;
}

.side-list h4 {
  margin: 16px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.tpl {
  display: block;
  width: 100%;
  margin-bottom: 4px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: none;
  text-align: left;
  cursor: pointer;
  animation: line-in 0.4s var(--ease) both;
  animation-delay: calc(min(var(--i), 12) * 25ms);
  transition: background 0.2s, border-color 0.2s;
}

.tpl:hover,
.tpl:focus-visible {
  background: var(--chip);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  outline: 0;
}

.tpl-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.tpl-head b {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-ink);
}

.tpl-head span {
  color: var(--muted);
  font-size: 13px;
}

.tpl .code {
  margin: 6px 0 0;
  max-height: 140px;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12.5px;
  line-height: 1.6;
  mask-image: linear-gradient(to bottom, #000 75%, transparent);
}

@media (min-width: 1180px) {
  body.side-open .stage,
  body.side-open .topics,
  body.side-open .notes-page {
    padding-right: 400px;
  }

  body.side-open .dock {
    padding-right: 420px;
  }
}

.stage,
.topics,
.notes-page,
.home,
.dock {
  transition: padding 0.5s var(--ease);
}

/* Template placeholders and suggestions inside the editor */

.ph {
  border-radius: 4px;
  background: var(--chip);
  box-shadow: inset 0 -1px color-mix(in srgb, var(--accent) 40%, transparent);
}

.ph.on {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: inset 0 -2px var(--accent);
}

.fresh {
  display: inline-block;
  animation: type-in 0.24s var(--ease) both;
}

@keyframes type-in {
  from { opacity: 0; transform: translateY(0.35em); filter: blur(3px); }
}

.step .ed {
  z-index: 4;
}

.suggest {
  position: fixed;
  z-index: 70;
  min-width: 260px;
  max-width: min(420px, 80vw);
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid) 86%, transparent);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  box-shadow: 0 24px 50px -24px rgba(10, 20, 50, 0.45);
  font-family: var(--sans);
  white-space: normal;
  animation: pop-in 0.3s var(--spring) both;
  transform-origin: top left;
}

.suggest .opt {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
}

.suggest .opt b {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--accent-ink);
}

.suggest .opt span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest .opt.on {
  background: var(--chip);
}

/* Typewriter for code */

.code.typing .ln {
  animation: none;
}

.type-caret {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  margin-left: 1px;
  vertical-align: -0.2em;
  background: var(--accent);
  animation: blink-bar 0.9s steps(1) infinite;
}

@keyframes blink-bar {
  50% { opacity: 0; }
}

/* Notes ----------------------------------------------------------------------- */

.notes-page {
  width: min(700px, 100%);
  margin: 0 auto;
  padding: 0 20px 80px;
}

.notes-page h2 {
  margin: 8px 0 24px;
  font-size: clamp(34px, 5.4vw, 48px);
  letter-spacing: -0.035em;
  font-weight: 600;
}

.composer {
  padding: 16px;
  border-radius: 26px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.composer .note-input,
.drawer .note-input {
  border: 0;
  padding: 6px 4px;
  background: none;
  box-shadow: none;
  resize: none;
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}

.notes-tools {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 22px 0 10px;
}

.notes-tools .field {
  flex: 1;
}

.notes-tools .seg {
  flex: none;
  min-width: 280px;
}

.note {
  padding: 16px 4px 12px;
  border-bottom: 1px solid var(--line);
  animation: rise 0.5s var(--ease) both;
  animation-delay: calc(min(var(--i, 0), 10) * 40ms);
  transition: opacity 0.25s, transform 0.25s var(--ease);
}

.note.removing {
  opacity: 0;
  transform: translateX(24px);
}

.note-text {
  margin: 0;
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: 10px;
  white-space: pre-wrap;
  outline: 0;
  transition: background 0.2s;
}

.note-text:focus {
  background: var(--chip);
}

.note.resolved .note-text {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent);
}

.note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.note-actions {
  display: flex;
  gap: 2px;
}

.note-actions a.icon-btn {
  color: var(--muted);
}

/* Notes drawer: a small pill at the bottom that grows into a panel */

body.with-drawer .dock {
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

.drawer {
  position: fixed;
  z-index: 25;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: 190px;
  height: 44px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid) 52%, transparent);
  backdrop-filter: blur(26px) saturate(1.6);
  -webkit-backdrop-filter: blur(26px) saturate(1.6);
  box-shadow: 0 16px 40px -28px rgba(10, 20, 50, 0.5);
  transform: translateX(-50%);
  transition:
    width 0.55s var(--spring),
    height 0.55s var(--spring),
    bottom 0.45s var(--ease),
    border-radius 0.45s var(--ease),
    background 0.3s;
}

.drawer:not(.open):hover {
  width: 204px;
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.drawer.open {
  width: min(680px, calc(100vw - 24px));
  height: min(52dvh, 440px);
  bottom: 0;
  border-radius: 26px 26px 0 0;
  background: color-mix(in srgb, var(--surface-solid) 78%, transparent);
}

.drawer-handle {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 42px;
  padding: 0 16px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.drawer-handle:hover {
  color: var(--ink);
}

.drawer-handle .grip {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-135deg) translate(-2px, -2px);
  transition: transform 0.45s var(--spring);
}

.drawer.open .drawer-handle .grip {
  transform: rotate(45deg) translate(-2px, -2px);
}

.drawer-handle kbd {
  margin: 0;
}

.drawer-body {
  flex: 1;
  overflow: auto;
  padding: 0 22px 22px;
  opacity: 0;
  transition: opacity 0.25s;
}

.drawer.open .drawer-body {
  opacity: 1;
  transition-delay: 0.15s;
}

.drawer .note-input {
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--chip);
}

.drawer-list .note:last-child {
  border-bottom: 0;
}

/* Toast */

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 110px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid) 62%, transparent);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px) scale(0.96);
  transition: opacity 0.3s var(--ease), transform 0.45s var(--spring);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

/* Page transitions */

:root.instant {
  transition: none;
}

:root.theme-vt::view-transition-old(root) {
  animation: none;
}

:root.theme-vt::view-transition-new(root) {
  animation: reveal 0.75s var(--ease) both;
}

@keyframes reveal {
  from { clip-path: circle(0 at var(--vt-x) var(--vt-y)); }
  to { clip-path: circle(var(--vt-r) at var(--vt-x) var(--vt-y)); }
}


::view-transition-old(root) {
  animation: vt-out 0.22s ease-in both;
}

::view-transition-new(root) {
  animation: vt-in 0.42s var(--ease) both;
}

@keyframes vt-out {
  to { opacity: 0; filter: blur(6px); }
}

@keyframes vt-in {
  from { opacity: 0; filter: blur(6px); transform: translateY(8px); }
}

/* Small screens and reduced motion ----------------------------------------- */

@media (max-width: 560px) {
  body {
    font-size: 16px;
  }

  .btn {
    padding-inline: 26px;
  }

  .code,
  .ed {
    font-size: 14.5px;
  }

  .topic-head {
    padding: 18px 20px;
  }

  .dots,
  kbd,
  .hint-key {
    display: none;
  }

  .notes-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .notes-tools .seg {
    min-width: 0;
  }

  .stage {
    align-content: start;
    padding-top: 6vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }

  .blob,
  .ed.line .inp {
    animation: none !important;
  }
}

/* Fit to screen ---------------------------------------------------------------
   The page itself never scrolls. Lesson steps scale down to fit, the practice
   editor and long lists scroll inside their own area. */

html,
body {
  height: 100%;
  overflow: hidden;
}

#app {
  height: 100dvh;
  min-height: 0;
}

.top {
  flex: none;
}

.stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: clamp(4px, 2vh, 18px) 20px;
}

.stage.practice {
  align-content: stretch;
  grid-template-rows: minmax(0, 1fr);
}

.dock,
.dock.flow {
  position: relative;
  flex: none;
  padding: clamp(10px, 2.4vh, 22px) 20px clamp(14px, 3vh, 26px);
  pointer-events: auto;
}

body.with-drawer .dock {
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}

.home,
.topics,
.notes-page {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.home {
  gap: clamp(10px, 2.6vh, 22px);
  padding-bottom: 6vh;
}

.home h1 {
  font-size: clamp(36px, min(8.4vw, 11vh), 88px);
}

.big {
  font-size: clamp(26px, min(6vw, 7vh), 54px);
}

.big.sm {
  font-size: clamp(21px, min(4.4vw, 5.4vh), 40px);
}

.lead {
  font-size: clamp(18px, min(3.8vw, 4.3vh), 32px);
}

.big + .lead {
  margin-top: clamp(10px, 2.4vh, 22px);
  font-size: clamp(16px, min(2.8vw, 3.3vh), 24px);
}

.eyebrow {
  margin-bottom: clamp(6px, 1.6vh, 14px);
}

.lines li {
  margin-bottom: clamp(10px, 2.4vh, 22px);
  font-size: clamp(16px, min(3vw, 3.5vh), 24px);
}

.code,
.ed {
  font-size: clamp(13px, min(1.5vw, 2.15vh), 16px);
}

.code {
  margin-top: clamp(12px, 3vh, 30px);
}

.ed {
  margin-top: clamp(14px, 3.2vh, 30px);
}

.medal {
  width: clamp(56px, 10vh, 84px);
  height: clamp(56px, 10vh, 84px);
  margin-bottom: clamp(14px, 3.4vh, 28px);
}

/* Practice: title, editor and aids share the height; the editor scrolls inside. */

.step.practice {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.step.practice > * {
  flex: none;
}

.step.practice .big.sm {
  font-size: clamp(19px, min(3.4vw, 4.2vh), 34px);
}

.step.practice .file {
  margin-top: clamp(10px, 2.2vh, 30px);
}

.step.practice .ed-box {
  flex: 1 1 auto;
  min-height: 96px;
  overflow: auto;
  margin-top: clamp(8px, 1.6vh, 18px);
}

.step.practice .ed {
  margin-top: 0;
}

.step.practice .aids {
  margin-top: clamp(8px, 1.8vh, 26px);
}

.step.practice .panel {
  max-height: 34%;
  overflow: auto;
  margin-top: clamp(8px, 1.6vh, 18px);
}

/* The answer line wraps long answers instead of letting them run past the edge. */

.ed.line .hl,
.ed.line .inp {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.ed.line .inp {
  overflow: hidden;
}

.ed.line .pane {
  margin-right: 44px;
}

@media (max-height: 680px) {
  .top {
    padding-block: 10px;
  }

  .hint-key,
  .home .meta .meter {
    display: none;
  }
}

@media (max-width: 560px) {
  .stage {
    align-content: center;
    padding-top: 8px;
  }
}

/* Topics stay within short screens too */

.topics-head {
  margin: 0 0 clamp(12px, 3vh, 28px);
}

.topics h2,
.notes-page h2 {
  font-size: clamp(28px, min(5.4vw, 7vh), 48px);
}

.topic {
  margin-bottom: clamp(6px, 1.3vh, 12px);
}

.topic-head {
  padding: clamp(10px, 2.1vh, 20px) 24px;
  font-size: clamp(16px, 2.4vh, 18px);
}

.lstart {
  padding: clamp(7px, 1.4vh, 13px) 14px;
  border-radius: 16px;
}

@media (min-width: 900px) {
  .topics {
    width: min(1080px, 100%);
  }

  .topic-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 14px;
    align-items: start;
  }
}

@media (max-width: 560px) {
  .topics {
    padding-bottom: 16px;
  }

  .topic {
    border-radius: 22px;
  }

  .topic-head {
    padding: 9px 18px;
    font-size: 15px;
  }

  .lstart {
    padding: 6px 10px;
    gap: 10px;
  }

  .lrow .link {
    padding: 6px 10px;
    font-size: 13px;
  }
}

.lstart:focus-visible,
.topic-head:focus-visible {
  outline-offset: -3px;
  border-radius: 16px;
}

.head-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
