@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Newsreader:wght@500&family=Space+Grotesk:wght@600&display=swap");

:root {
  --ground: #f3f5f7;
  --card: #ffffff;
  --ink: #10151b;
  --sub: #55606e;
  --line: #dce1e7;
  --new-bg: #d9f2e6;
  --new-ink: #0a5c43;
  --tag-bg: #e9e6fb;
  --tag-ink: #3b2fa0;
  --old: #8a94a1;
  --warn: #b3321b;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.45 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.h { font-family: "Space Grotesk", Inter, sans-serif; font-weight: 600; letter-spacing: -0.01em; }
.sub { color: var(--sub); }
.fr { font-family: Newsreader, Georgia, serif; font-weight: 500; line-height: 1.12; }

button, .btn {
  font: 500 15px Inter, system-ui, sans-serif;
  min-height: 46px; padding: 0 20px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--ink); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
button.quiet, .btn.quiet { background: var(--card); color: var(--ink); border: 1px solid #c3cad3; }
button.danger { background: var(--card); color: var(--warn); border: 1px solid #e3c2ba; }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #7fb5ff; outline-offset: 2px; }

label { font-size: 14px; font-weight: 500; display: flex; flex-direction: column; gap: 6px; }
textarea { border-radius: 10px; border: 1px solid #c3cad3; padding: 12px 14px; font: 400 15px/1.45 Inter, system-ui, sans-serif; background: #fff; color: var(--ink); resize: vertical; }
input, select {
  height: 48px; border-radius: 10px; border: 1px solid #c3cad3; padding: 0 14px;
  font: 400 16px Inter, system-ui, sans-serif; background: #fff; color: var(--ink); min-width: 0;
}
.card { background: var(--card); border-radius: 14px; border: 1px solid var(--line); }

/* ---------- the board ---------- */
.board { container-type: inline-size; display: flex; flex-direction: column; height: 100%; background: var(--card); min-height: 0; }
.board-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px clamp(16px, 4cqw, 40px); border-bottom: 1px solid var(--line);
}
.board-head .h { font-size: clamp(15px, 2.2cqw, 20px); }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--sub); white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #b9c1cb; }
.live.on .dot { background: #12a06f; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.board-body {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: clamp(18px, 4cqw, 44px) clamp(16px, 4cqw, 40px) clamp(28px, 6cqw, 64px);
  display: flex; flex-direction: column; gap: clamp(22px, 4cqw, 40px);
}
.empty { margin: auto; text-align: center; max-width: 30ch; color: var(--sub); font-size: clamp(16px, 2.6cqw, 22px); }

.topic { display: flex; flex-direction: column; gap: clamp(14px, 2.6cqw, 26px); }
.topic-title { align-self: flex-start; font-size: clamp(12px, 1.6cqw, 15px); font-weight: 600; color: var(--sub); text-transform: uppercase; letter-spacing: 0.06em; background: var(--ground); padding: 5px 12px; border-radius: 999px; }
.item { display: flex; flex-direction: column; gap: clamp(4px, 0.9cqw, 10px); position: relative; }
.item .fr { font-size: clamp(26px, 6.2cqw, 68px); overflow-wrap: anywhere; }
.item .meaning { font-size: clamp(15px, 2.5cqw, 24px); color: var(--sub); }
.item .note { font-size: clamp(14px, 2.2cqw, 20px); max-width: 44ch; }
.row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px clamp(10px, 1.8cqw, 18px); }
.tagline { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; font-size: clamp(13px, 1.9cqw, 17px); color: var(--sub); }
.tag { background: var(--tag-bg); color: var(--tag-ink); font-weight: 500; padding: 2px 9px; border-radius: 6px; }
.new { background: var(--new-bg); color: var(--new-ink); border-radius: 0.14em; padding: 0 0.12em; margin: 0 -0.04em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
/* A sentence broken into chunks, each over its own meaning. */
.gloss { display: flex; flex-wrap: wrap; align-items: flex-start; gap: clamp(10px, 1.6cqw, 18px) clamp(8px, 1.4cqw, 16px); }
.chunk { display: flex; flex-direction: column; gap: 6px; }
.chunk .fr { padding-bottom: 6px; border-bottom: 3px solid var(--line); }
.chunk .fr.new { border-bottom-color: #7fd6b4; }
.chunk-meaning { font-size: clamp(12px, 1.7cqw, 16px); color: var(--sub); padding: 0 2px; }

/* A base form on the left, branching out to each form it turns into. */
.family { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; }
.family-root {
  align-self: center; background: var(--tag-bg); color: var(--tag-ink); border-radius: 14px;
  padding: clamp(10px, 1.8cqw, 18px) clamp(14px, 2.4cqw, 24px);
}
.family-root .fr { font-size: clamp(22px, 4.2cqw, 44px); }
.family-root .meaning { color: var(--tag-ink); opacity: 0.8; font-size: clamp(13px, 1.8cqw, 17px); }
.branches {
  flex: 1; min-width: min(100%, 240px); display: flex; flex-direction: column; justify-content: center;
  gap: clamp(14px, 2.4cqw, 24px); margin-left: clamp(18px, 3cqw, 34px); padding: 6px 0;
  border-left: 3px solid #c9c2f2;
}
.branch { padding-left: clamp(26px, 4cqw, 44px); }
.branch::before {
  content: ""; position: absolute; left: 0; top: clamp(30px, 5.2cqw, 54px);
  width: clamp(18px, 3cqw, 32px); border-top: 3px solid #c9c2f2;
}
.branch::after {
  content: ""; position: absolute; left: clamp(12px, 2.2cqw, 24px); top: calc(clamp(30px, 5.2cqw, 54px) - 4.5px);
  border: 6px solid transparent; border-left-color: #c9c2f2;
}
.branch-label { font-size: clamp(12px, 1.7cqw, 15px); font-weight: 500; color: var(--tag-ink); }
.branch .fr { font-size: clamp(24px, 5.2cqw, 56px); }
@container (max-width: 520px) {
  .family { flex-direction: column; align-items: flex-start; }
  .family-root { align-self: flex-start; }
  .branches { margin-left: 22px; padding-top: 14px; }
}

.rule-note { border-left: 4px solid #f0c36b; background: #fdf6e3; border-radius: 0 10px 10px 0; padding: 10px 14px; max-width: 60ch; }
.asked { background: var(--ground); border-radius: 14px; padding: clamp(12px, 2.2cqw, 20px); max-width: 60ch; display: flex; flex-direction: column; gap: 4px; }
.asked .q { font-size: clamp(11px, 1.5cqw, 13px); font-weight: 600; color: var(--sub); text-transform: uppercase; letter-spacing: 0.06em; }
.asked .question { font-size: clamp(15px, 2.3cqw, 20px); font-weight: 500; }
.asked .a { font-size: clamp(15px, 2.4cqw, 21px); padding-left: 12px; border-left: 3px solid #7fd6b4; margin-top: 4px; }
.asked .a.wait { color: var(--old); font-style: italic; border-left-color: var(--line); }

/* Earlier topics and earlier lines step back so the newest thing stands out. */
.topic.past .item .fr { font-size: clamp(18px, 3.2cqw, 30px); color: var(--old); }
.topic.past .meaning, .topic.past .note, .topic.past .tagline, .topic.past .chunk-meaning, .topic.past .branch-label { display: none; }
.topic.past .family-root .fr, .topic.past .branch .fr { font-size: clamp(18px, 3.2cqw, 30px); }
.topic.past .chunk .fr { border-bottom: 0; padding-bottom: 0; }
/* Rules stay readable in earlier topics, just smaller and quieter. */
.topic.past .rule-note { padding: 6px 12px; background: transparent; border-left-color: var(--line); }
.topic.past .rule-note .note { display: block; font-size: clamp(13px, 1.8cqw, 16px); color: var(--old); }
.topic.past { gap: 8px; }
.board.recap .topic.past .item .fr { color: var(--ink); }
.board.recap .topic.past .meaning { display: block; }
.item.fresh { animation: arrive 0.45s var(--age, 0ms) ease-out both; }
@keyframes arrive { from { opacity: 0; transform: translateY(10px); } }
/* New words are written on from left to right; chunks land one after another. */
.item.fresh .write-on { animation: write-on 0.7s var(--age, 0ms) cubic-bezier(0.3, 0, 0.2, 1) both; }
@keyframes write-on { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 -2% 0 0); } }
.item.fresh .chunk { animation: land 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
@keyframes land { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
.item.fresh.branch::before { animation: grow 0.35s var(--age, 0ms) ease-out both; transform-origin: left; }
@keyframes grow { from { transform: scaleX(0); } }
.item.fresh .meaning, .item.fresh .note, .item.fresh .tagline, .item.fresh .branch-label { animation: arrive 0.5s calc(0.35s + var(--age, 0ms)) ease-out both; }

/* Provisional: written from a sentence that is still being spoken, and may be rewritten. */
.item.draft .fr, .item.draft .meaning, .item.draft .note, .item.draft .chunk-meaning, .item.draft .question { opacity: 0.55; }
.item.draft .fr { background: linear-gradient(90deg, currentColor 30%, #9aa5b1 50%, currentColor 70%); background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: forming 1.6s linear infinite; }
.item.draft .fr .new, .item.draft .fr.new { -webkit-text-fill-color: currentColor; }
@keyframes forming { from { background-position: 110% 0; } to { background-position: -110% 0; } }
.item .fr, .item .meaning, .item .note { transition: opacity 0.4s; }

/* The live strip: bars that move while someone is speaking, and the words as they are heard. */
.pulse { display: flex; align-items: center; gap: 12px; padding: 10px clamp(16px, 4cqw, 40px); border-top: 1px solid var(--line); min-height: 44px; }
.pulse[hidden] { display: none; }
.bars { display: inline-flex; align-items: center; gap: 3px; height: 18px; flex: none; }
.bars i { width: 3px; height: 4px; border-radius: 2px; background: #b9c1cb; }
.pulse.speaking .bars i { background: #12a06f; animation: bounce 0.9s ease-in-out infinite; }
.pulse.speaking .bars i:nth-child(2) { animation-delay: 0.15s; }
.pulse.speaking .bars i:nth-child(3) { animation-delay: 0.3s; }
.pulse.speaking .bars i:nth-child(4) { animation-delay: 0.45s; }
.pulse.speaking .bars i:nth-child(5) { animation-delay: 0.6s; }
@keyframes bounce { 0%, 100% { height: 4px; } 50% { height: 18px; } }
.pulse.writing .bars i { background: var(--tag-ink); animation: bounce 0.6s ease-in-out infinite; }
.hearing {
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; font-size: clamp(13px, 1.9cqw, 16px); color: var(--sub);
}
/* Only when the words run past the left edge do they fade out there. */
.hearing.over { -webkit-mask-image: linear-gradient(to right, transparent, #000 48px); mask-image: linear-gradient(to right, transparent, #000 48px); }

/* A shimmering outline where the next item is being written. */
.sketch { display: flex; flex-direction: column; gap: 12px; padding: 4px 0 8px; }
.sketch i { display: block; height: clamp(14px, 2.4cqw, 22px); border-radius: 8px; background: linear-gradient(90deg, #eceff3 20%, #dfe9e4 45%, #eceff3 70%); background-size: 240% 100%; animation: shimmer 1.2s linear infinite; }
.sketch i.w60 { width: 60%; height: clamp(26px, 5cqw, 52px); }
.sketch i.w35 { width: 35%; }
.sketch i.w45 { width: 45%; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

@media (prefers-reduced-motion: reduce) {
  .item.fresh, .item.fresh *, .item.fresh.branch::before, .live.on .dot, .pulse .bars i, .sketch i, .item.draft .fr { animation: none !important; }
}

.remove {
  position: absolute; top: 0; right: 0; min-height: 30px; padding: 0 10px; font-size: 13px;
  background: var(--card); color: var(--sub); border: 1px solid var(--line); opacity: 0;
}
.item:hover .remove, .remove:focus-visible { opacity: 1; }
@media (hover: none) { .remove { opacity: 1; } }

.board-foot { padding: 10px clamp(16px, 4cqw, 40px); border-top: 1px solid var(--line); font-size: 13px; color: var(--sub); }

/* ---------- pages ---------- */
.full { height: 100dvh; }
.start { max-width: 560px; margin: 0 auto; padding: clamp(32px, 8vh, 96px) 20px; display: flex; flex-direction: column; gap: 22px; }
.start h1 { font-size: clamp(32px, 6vw, 46px); line-height: 1.05; }
.pair { display: flex; gap: 12px; }
.pair > * { flex: 1; min-width: 0; }

.teacher { display: grid; grid-template-columns: minmax(0, 1fr) 360px; height: 100dvh; }
.side { border-left: 1px solid var(--line); padding: 18px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.side .card { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.side h2 { font-size: 14px; font-weight: 500; }
.qr { width: 150px; height: 150px; align-self: center; }
.link { font-size: 14px; overflow-wrap: anywhere; text-align: center; }
.heard { font-size: 13px; color: var(--sub); display: flex; flex-direction: column; gap: 6px; height: 220px; overflow-y: auto; background: var(--ground); border-radius: 8px; padding: 10px; }
.heard .interim { color: var(--old); font-style: italic; }
.problem { color: var(--warn); font-size: 13px; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.buttons > * { flex: 1; white-space: nowrap; }
@media (max-width: 820px) {
  .teacher { grid-template-columns: 1fr; grid-template-rows: 55dvh auto; height: auto; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
}

/* An earlier topic can be opened back up to read it as it was. */
.topic-toggle { align-self: flex-start; display: flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; border-radius: 999px; min-height: 36px; }
.topic-toggle .topic-title { margin: 0; }
.topic-hint { font-size: clamp(12px, 1.5cqw, 14px); font-weight: 500; color: var(--new-ink); }
.topic-toggle:focus-visible { outline: 2px solid var(--new-ink); outline-offset: 3px; }
.topic.reopened { padding-left: 14px; border-left: 3px solid var(--line); }

/* ---------- recap: what to remember, and the questions ---------- */
.recap-box { display: flex; flex-direction: column; gap: 14px; max-width: 62ch; padding-top: clamp(18px, 3cqw, 32px); margin-top: clamp(10px, 2cqw, 20px); border-top: 1px solid var(--line); }
.recap-box:empty { display: none; }
.recap-title { font-family: "Space Grotesk", Inter, sans-serif; font-size: clamp(20px, 3cqw, 28px); font-weight: 600; margin-top: 10px; text-wrap: balance; }
.recap-sub { color: var(--sub); font-size: 14px; font-weight: 400; }
.recap-wait { color: var(--sub); animation: pulse 1.6s ease-in-out infinite; }
.takeaways { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.takeaways li { padding: 12px 16px; background: var(--ground); border-radius: 12px; font-size: clamp(15px, 2.2cqw, 19px); line-height: 1.45; }
.quiz-name { max-width: 34ch; }
.quiz-q { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.quiz-q.busy { opacity: 0.6; pointer-events: none; }
.quiz-q > * { grid-column: 2; }
.quiz-n { grid-column: 1; grid-row: 1; width: 26px; height: 26px; border-radius: 50%; background: var(--ground); color: var(--sub); font-size: 13px; font-weight: 600; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.quiz-prompt { font-size: clamp(16px, 2.3cqw, 20px); font-weight: 500; line-height: 1.4; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option { justify-content: flex-start; width: 100%; background: var(--card); color: var(--ink); border: 1px solid #c3cad3; text-align: left; font-family: Newsreader, Georgia, serif; font-size: clamp(17px, 2.4cqw, 21px); font-weight: 400; padding: 10px 14px; min-height: 44px; }
.quiz-option:disabled { opacity: 1; color: var(--sub); }
.quiz-option.is-right { background: #e3f6ec; border-color: #7fd6b4; color: var(--new-ink); }
.quiz-option.is-wrong { background: #fbeeea; border-color: #e3c2ba; color: var(--warn); text-decoration: line-through; }
.quiz-type { display: flex; gap: 8px; }
.quiz-type input { flex: 1; min-width: 0; font-family: Newsreader, Georgia, serif; font-size: 19px; }
.quiz-verdict { font-weight: 600; font-size: 15px; }
.quiz-verdict.ok { color: var(--new-ink); }
.quiz-verdict.no { color: var(--warn); }
.quiz-verdict strong { font-family: Newsreader, Georgia, serif; font-size: 19px; font-weight: 500; color: var(--ink); }
.quiz-why { color: var(--sub); font-size: 15px; line-height: 1.45; }
.quiz-score { font-family: "Space Grotesk", Inter, sans-serif; font-size: clamp(20px, 3cqw, 26px); font-weight: 600; padding: 8px 0 30px; }

/* ---------- the teacher's review of the answers ---------- */
.review { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.review-q { display: flex; flex-direction: column; gap: 4px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.review-q .fr-answer { font-family: Newsreader, Georgia, serif; font-size: 16px; }
.meter { height: 6px; border-radius: 3px; background: var(--ground); overflow: hidden; }
.meter i { display: block; height: 100%; background: #7fd6b4; }
.review .wrongs { color: var(--warn); }
.review details summary { cursor: pointer; padding: 6px 0; font-weight: 500; display: flex; justify-content: space-between; gap: 8px; }
.review details p { padding: 2px 0 2px 10px; color: var(--sub); }
.review details p.no { color: var(--warn); }

/* ---------- joining, and asking a question ---------- */
.join { margin: auto; width: min(100% - 32px, 380px); display: flex; flex-direction: column; gap: 14px; padding: 12vh 0; }
.join input { font-size: 18px; }
.ask { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px clamp(14px, 3cqw, 28px); border-top: 1px solid var(--line); }
.ask input { min-width: 0; font-size: 16px; }
.ask-note { grid-column: 1 / -1; font-size: 13px; color: var(--sub); min-height: 0; }
.ask-note:empty { display: none; }
.asked-show { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 14px; margin-top: 10px; padding: 12px 14px; background: var(--card); border-radius: 10px; }
.asked-show .fr { font-size: clamp(20px, 3.4cqw, 32px); }
.asked-from { color: var(--old); }
.asked-arrow { color: var(--sub); font-size: clamp(18px, 3cqw, 28px); }
.asked-example { display: flex; flex-direction: column; gap: 4px; }
.joined { font-size: 13px; color: var(--sub); }

/* ---------- landing page ---------- */
.wordmark { font-family: "Space Grotesk", Inter, sans-serif; font-weight: 600; font-size: 20px; color: var(--new-ink); text-decoration: none; letter-spacing: -0.01em; }
.land { height: auto; }
.land main { display: flex; flex-direction: column; gap: clamp(56px, 9vw, 112px); padding: 0 clamp(18px, 5vw, 56px) clamp(56px, 9vw, 112px); max-width: 1180px; margin: 0 auto; }
.land-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px clamp(18px, 5vw, 56px); max-width: 1180px; margin: 0 auto; }
.land-join { display: flex; gap: 8px; }
.land-join input { width: 150px; height: 42px; }
.land-join button { min-height: 42px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: clamp(28px, 5vw, 64px); align-items: center; padding-top: clamp(20px, 5vw, 56px); }
.hero-words { display: flex; flex-direction: column; gap: 22px; }
.hero h1 { font-size: clamp(38px, 5.6vw, 68px); line-height: 1.02; text-wrap: balance; }
.lede { font-size: clamp(17px, 1.6vw, 20px); line-height: 1.5; color: var(--sub); max-width: 54ch; text-wrap: pretty; }
.hero-go { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; }
.hero-go .sub { font-size: 14px; }
.demo { overflow: hidden; box-shadow: 0 24px 60px -30px rgba(16, 21, 27, 0.35); }
.demo .board { height: auto; }
.demo .board-body { overflow: visible; }
.how, .for { display: flex; flex-direction: column; gap: 26px; align-items: flex-start; }
.how h2, .for h2 { font-size: clamp(26px, 3.4vw, 40px); line-height: 1.1; text-wrap: balance; }
.steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; width: 100%; }
.steps li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.steps h3 { font-size: 17px; font-weight: 600; line-height: 1.3; }
.steps p { color: var(--sub); font-size: 15px; line-height: 1.5; }
.step-n { width: 30px; height: 30px; border-radius: 50%; background: var(--new-bg); color: var(--new-ink); font-weight: 600; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.for { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: clamp(24px, 5vw, 56px); }
.land-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; padding: 22px clamp(18px, 5vw, 56px); border-top: 1px solid var(--line); color: var(--sub); font-size: 13px; max-width: 1180px; margin: 0 auto; }
.mine { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mine li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.mine a { color: var(--ink); font-weight: 500; }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .steps { grid-template-columns: 1fr; }
  .land-join input { width: 118px; }
}
