:root {
  --bg: #0a0b17;
  --panel: #13142a;
  --panel-2: #1c1d38;
  --line: #2d2e52;
  --text: #eceaf6;
  --muted: #a19fc0;
  --accent: #f4f1ff;
  --left: #a78bfa;
  --right: #ff8f4f;
  --loop: #2fd9c0;
  --radius: 7px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

#toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.group.right { margin-left: auto; }

button, .btn, select {
  appearance: none;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
button:hover, .btn:hover, select:hover { border-color: #4a4b7a; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }
button.on { background: #0f302c; border-color: var(--loop); color: var(--loop); }
select { max-width: 260px; text-overflow: ellipsis; }

#play { min-width: 40px; justify-content: center; }

.readout {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 118px;
}
.readout.dim { color: var(--muted); min-width: 0; }

.slider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.slider input { width: 110px; accent-color: var(--accent); }
.slider output { color: var(--text); font-variant-numeric: tabular-nums; min-width: 38px; }

.lbl { color: var(--muted); }
.lbl.part-me::before, .lbl.part-band::before {
  content: "";
  display: inline-block;
  width: 9px; height: 9px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: -1px;
}
.lbl.part-band::before { background: var(--left); }
.lbl.part-me::before { background: var(--right); }

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.seg button {
  border: 0;
  border-radius: 0;
  height: 26px;
  padding: 0 9px;
  background: var(--panel-2);
  color: var(--muted);
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-checked="true"] { background: #36376a; color: var(--text); }

#connectBtn.connected { color: var(--loop); border-color: #1d6b60; }
.connect { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 320px;
  display: flex; flex-direction: column; gap: 6px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.menu[hidden] { display: none; }
.menu .menu-title { margin: 0 0 2px; color: var(--muted); font-size: 12px; }
.menu > button {
  display: grid; justify-items: start; gap: 2px; height: auto; padding: 8px 10px; white-space: normal; text-align: left;
}
.menu > button span { color: var(--muted); font-size: 12px; }
.menu > button.on { border-color: #2c9c8c; background: #0f302c; }
.menu > button:disabled { opacity: .55; cursor: default; }
.menu-live { display: grid; gap: 8px; padding: 8px 2px 2px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.menu-live[hidden] { display: none; }
.menu-live select { max-width: 220px; }
.menu-live .meter { height: 8px; border-radius: 4px; background: #07080f; border: 1px solid var(--line); overflow: hidden; }
.menu-live .meter div { height: 100%; width: 0; background: linear-gradient(90deg, #7d5fe8, #2fd9c0 60%, #ff8f4f); }
.menu-live .small { margin: 0; }
.menu-live .small b { color: #9be3ad; font-size: 15px; }
.menu-live .slider input { width: 140px; }

#stage {
  display: flex;
  min-height: 0;
}
#board {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

#waitBadge, #toast {
  z-index: 2;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(14, 15, 32, .88);
  border: 1px solid var(--line);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
#waitBadge { top: 14px; color: var(--loop); border-color: #1d6b60; }
#waitBadge.score { color: #9be3ad; border-color: #3f7a4c; }
#toast { top: 54px; color: var(--text); }

#overview {
  height: 72px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

#overview { position: relative; }

dialog::backdrop { background: rgba(4, 4, 14, .6); }
dialog h2 { margin: 0 0 12px; font-size: 16px; }
dialog label { display: block; margin: 9px 0; }
dialog small { color: var(--muted); margin-left: 24px; }
dialog menu { display: flex; justify-content: flex-end; margin: 16px 0 0; padding: 0; }
dialog table { border-collapse: collapse; }
dialog td { padding: 4px 14px 4px 0; vertical-align: top; }
/* credits & licences */
.credits-link { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
button.link { height: auto; padding: 0; border: 0; background: none; color: #b8a3ff; text-decoration: underline; font-size: inherit; }
#credits { width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
#creditsBody { font-size: 13px; }
#creditsBody h3 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--loop); }
#creditsBody .note { color: var(--muted); margin: 0 0 8px; }
#creditsBody td { padding: 3px 14px 3px 0; }
#creditsBody .what { color: var(--muted); white-space: nowrap; }
#creditsBody td:last-child { white-space: nowrap; padding-right: 0; }
#creditsBody a { color: #b8a3ff; }
/* song library */
#library { width: min(1180px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; }
#library form { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
.lib-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.lib-head h2 { margin: 0; }
.lib-head input {
  flex: 1; max-width: 320px; height: 28px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-2); color: var(--text); font: inherit;
}
.lib-head button { margin-left: auto; }
#libraryList {
  overflow: auto;
  padding: 14px 18px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  align-items: start;
}
#libraryList section { display: flex; flex-direction: column; gap: 6px; }
#libraryList section[hidden], .story-card[hidden] { display: none; }
#libraryList h3 {
  margin: 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted);
}
#libraryList section[data-level="First steps"] h3 { color: #b8a3ff; }
#libraryList section[data-level="Game music"] h3 { color: #2fd9c0; }
#libraryList section[data-level="Film & TV music"] h3 { color: #ffb86b; }
#libraryList section[data-level^="My "] h3 { color: #ff8fb8; }
#libraryList section[data-level^="⌨"] h3 { color: #7ee2ff; }
.story-card { position: relative; }
.story-card .forget {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; padding: 0; line-height: 20px;
  border-radius: 50%; font-size: 12px; opacity: 0; color: var(--muted);
}
.story-card:hover .forget, .story-card:focus-within .forget { opacity: 1; }

#libraryList section[data-level="Easy"] h3 { color: #8fd05a; }
#libraryList section[data-level="Medium"] h3 { color: #e8c547; }
#libraryList section[data-level="Hard"] h3 { color: #f08a4b; }
#libraryList section[data-level="Very hard"] h3 { color: #f0605d; }
.story-card {
  display: grid; gap: 1px; justify-items: start;
  height: auto; padding: 7px 10px; text-align: left; white-space: normal;
}
.story-card .t { font-weight: 600; }
.story-card .c { color: var(--text); opacity: .85; font-size: 12px; }
.story-card .w { color: var(--muted); font-size: 11.5px; }
.story-card.current { border-color: var(--accent); background: #26274a; }
/* the library's filters: a group, and how hard */
.lib-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 18px 0; }
.lib-filters .chip {
  height: 26px; padding: 0 10px; border-radius: 13px; font-size: 12.5px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}
.lib-filters .chip small { color: var(--muted); font-size: 11px; }
.lib-filters .chip.on { background: #2e2c58; border-color: var(--accent); }
.lib-filters .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.lib-none { padding: 18px; color: var(--muted); margin: 0; }
#libraryList.one section:not([hidden]) {
  grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 18px;
}
#libraryList.one section h3 { grid-column: 1 / -1; }
.story-card .lvl {
  position: absolute; top: 7px; right: 8px; font-size: 10px; font-weight: 700; letter-spacing: .03em;
  padding: 1px 6px; border-radius: 8px; background: rgba(255,255,255,0.06);
}
.story-card .lvl.l1 { color: #8fd05a; } .story-card .lvl.l2 { color: #e8c547; }
.story-card .lvl.l3 { color: #f08a4b; } .story-card .lvl.l4 { color: #f0605d; }
.story-card .t { padding-right: 58px; }

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--panel-2);
  font: 12px ui-monospace, monospace;
  text-align: center;
}

#errors {
  position: fixed;
  left: 12px; right: 12px; bottom: 72px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #3b1113;
  border: 1px solid #7a2a2e;
  color: #ffd7d9;
  font: 12px ui-monospace, monospace;
  white-space: pre-wrap;
  z-index: 10;
}

@media (max-width: 720px) {
  #toolbar { gap: 6px 10px; padding: 6px 8px; }
  .slider input { width: 80px; }
  .group.right { margin-left: 0; }
}

/* ---------- the beginner course */
button.learn { border-color: #5a47b0; color: #d6cbff; }
button.learn:hover { border-color: #7d68d8; }

#coach[hidden] { display: none; }
#coach {
  flex: 0 0 360px;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 16px 12px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  font-size: 14px; line-height: 1.45;
}
#coach header { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
#coach header span { flex: 1; }
#coach button.icon { height: 26px; padding: 0 8px; }
#coach h2 { margin: 0; font-size: 18px; line-height: 1.25; }
#coach h3 { margin: 0 0 6px; font-size: 15px; color: #ddd4ff; }
#coach p { margin: 0 0 8px; }
#coach .dots { display: flex; flex-wrap: wrap; gap: 5px; }
#coach .dot {
  width: 28px; height: 28px; padding: 0; justify-content: center; border-radius: 50%;
  font-size: 12px; color: var(--muted);
}
#coach .dot.done { background: #1f3b26; border-color: #3f7a4c; color: #9be3ad; }
#coach .dot.current { border-color: var(--loop); color: var(--text); box-shadow: 0 0 0 2px rgba(47,217,192,.25); }
#coach .step { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
#coach .task { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
#coach .meta { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
#coach .status { margin: 0; }
#coach .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
#coach .chip {
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); font-weight: 600; font-size: 13px;
  color: var(--muted);
}
#coach .chip.now { border-color: var(--loop); color: var(--loop); }
#coach .chip.ok { border-color: #3f7a4c; color: #9be3ad; background: #1a2e20; }
#coach .complete { margin: 10px 0 0; color: #9be3ad; }
#coach .actions { display: flex; gap: 8px; }
#coach .actions button { flex: 1; justify-content: center; height: 36px; font-size: 14px; }
#coach .actions button.ready { background: #2b6d3d; border-color: #4aa564; color: #fff; font-weight: 600; }
#coach .actions button:disabled { opacity: .4; cursor: default; }
#coach footer.hear {
  margin-top: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  color: var(--muted); font-size: 12.5px; padding-top: 8px; border-top: 1px solid var(--line);
}
#coach footer .heard { color: #9be3ad; font-weight: 600; }
#coach button.link {
  height: auto; padding: 0; border: 0; background: none; color: #b8a3ff; text-decoration: underline; margin-left: auto;
}
#coach .setup { display: flex; flex-direction: column; gap: 8px; }
#coach .choice {
  display: grid; justify-items: start; gap: 2px; height: auto; padding: 9px 12px; text-align: left; white-space: normal;
}
#coach .choice span { color: var(--muted); font-size: 12.5px; }
#coach .choice.on { border-color: #4aa564; background: #1a2e20; }
#coach .micbox { padding: 4px 2px 6px; display: grid; gap: 8px; }
#coach .micbox select { max-width: 100%; }
#coach .meter { height: 8px; border-radius: 4px; background: #07080f; border: 1px solid var(--line); overflow: hidden; }
#coach .meter div { height: 100%; width: 0; background: linear-gradient(90deg, #7d5fe8, #2fd9c0 60%, #ff8f4f); }
#coach .small { font-size: 12.5px; color: var(--muted); margin: 0; }
#coach .small b { color: #9be3ad; font-size: 15px; }

/* ---------- the course home */
#course, #progress { width: min(1040px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; }
#course[open], #progress[open] { display: flex; flex-direction: column; }
#courseList, #progressBody { overflow: auto; padding: 12px 18px 20px; }
.home-top { display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; margin-bottom: 10px; }
.home-top .lvl { display: flex; gap: 10px; align-items: center; }
.home-top small { color: var(--muted); }
.home-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.home-actions button { height: auto; min-height: 38px; font-size: 14px; }
.home-actions button.big { flex-direction: column; align-items: flex-start; padding: 6px 14px; font-size: 15px; }
.home-actions button.big small { font-weight: 400; opacity: .75; font-size: 12px; }
#courseList p.how { color: var(--muted); font-size: 13px; margin: 10px 0 4px; max-width: 760px; }
.week { margin-top: 14px; }
.week h3 { margin: 0; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: #b8a3ff; }
.week p { margin: 2px 0 8px; color: var(--muted); font-size: 12.5px; }
.daytiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.daytile {
  display: grid; grid-template-columns: 30px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: start;
  height: auto; padding: 8px 9px; text-align: left; white-space: normal; border-radius: 10px;
}
.daytile .n {
  grid-row: 1 / 3; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); font-weight: 700; font-size: 12.5px;
}
.daytile .t { font-weight: 600; font-size: 13px; line-height: 1.25; }
.daytile .p { grid-column: 2; color: var(--muted); font-size: 11.5px; }
.daytile.current { border-color: var(--loop); box-shadow: 0 0 0 2px rgba(47,217,192,.2); }
.daytile.current .n { border-color: var(--loop); color: var(--loop); }
.daytile.started .n { border-color: #7d68d8; color: #b8a3ff; }
.daytile.done .n { background: #1f3b26; border-color: #3f7a4c; color: #9be3ad; }
.daytile.gold .n { background: #3b3212; border-color: #ffd24a; color: #ffd24a; }
#dayDetail {
  position: sticky; bottom: -20px; margin: 16px -18px -20px; padding: 14px 18px 18px;
  background: var(--panel-2); border-top: 1px solid var(--line); box-shadow: 0 -12px 30px rgba(0,0,0,.35);
  max-height: 55vh; overflow: auto;
}
#dayDetail[hidden] { display: none; }
#dayDetail .dd-head { display: flex; gap: 10px; align-items: flex-start; }
#dayDetail .dd-head > div { flex: 1; }
#dayDetail h3 { margin: 0; font-size: 17px; }
#dayDetail h4 { margin: 12px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #b8a3ff; }
#dayDetail p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
#dayDetail .dd-actions { display: flex; gap: 8px; margin-top: 10px; }
#dayDetail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
#dayDetail li { display: flex; gap: 10px; align-items: center; font-size: 13.5px; padding: 2px 0; }
#dayDetail li > span:nth-child(2) { flex: 1; }
#dayDetail li small { color: var(--muted); }
#dayDetail li .st { width: 42px; text-align: center; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#dayDetail li.ok .st { color: #9be3ad; font-weight: 700; }
#dayDetail li.rv { color: var(--muted); font-style: italic; }
#dayDetail li button { height: 24px; font-size: 12px; }

svg.ring .track { fill: none; stroke: var(--line); stroke-width: 6; }
svg.ring .fill { fill: none; stroke: var(--loop); stroke-width: 6; stroke-linecap: round; }
svg.ring .t1 { fill: var(--text); font-size: 15px; font-weight: 800; text-anchor: middle; }
svg.ring .t2 { fill: var(--muted); font-size: 8.5px; text-anchor: middle; }

@media (max-width: 900px) and (orientation: portrait) {          /* upright: the coach under the reader */
  #stage { flex-direction: column; }
  #coach { flex: 0 0 auto; max-height: 48%; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-height: 520px) and (orientation: landscape) {        /* a phone on its side: beside it, narrower */
  #coach { flex: 0 0 min(300px, 40vw); }
}

#coach .step.speaking { border-color: #7d68d8; box-shadow: 0 0 0 3px rgba(125,104,216,.2); }
#coach .bubble {
  position: relative; padding: 10px 12px; border-radius: 12px; background: #1f1c3d; border: 1px solid #4b3fa0;
  color: #efeaff; font-size: 14.5px;
}
#coach .bubble.speaking { border-color: #b8a3ff; box-shadow: 0 0 0 3px rgba(184,163,255,.16); }
#coach .complete { padding: 10px 12px; border-radius: 12px; background: #1a2e20; border: 1px solid #3f7a4c; color: #c9f2d3; }
#coach button.link.slower { align-self: center; margin: 0; font-size: 13px; }
#coach .voicepick { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
#coach .slider { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
#coach .slider input { flex: 1; }

/* ---------- results card */
.results {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); z-index: 5;
  width: min(380px, calc(100% - 32px)); padding: 18px 20px; text-align: center;
  background: rgba(19,20,42,.97); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.55);
}
.results[hidden] { display: none; }
.results .stars { font-size: 40px; letter-spacing: 4px; color: #ffd24a; line-height: 1.1; }
.results .stars.s0 { color: #5f5f82; }
.results .points { font-size: 34px; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.results .best { color: #9be3ad; font-weight: 700; }
.results .prev { color: var(--muted); }
.results .grid { display: grid; gap: 5px; margin: 14px 0; text-align: left; font-size: 13.5px; }
.results .grid div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.results .grid span { color: var(--muted); }
.results .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.story-card .stars, .lesson-card .stars { color: #ffd24a; font-size: 12px; letter-spacing: 1px; }
#coach .dot.star3 { background: #3b3212; border-color: #ffd24a; color: #ffd24a; }
.course-intro .streak { color: #ff9d5c; font-weight: 600; }

/* ---------- the coach: days, mastery, help */
#coach header .goal svg { width: 30px; height: 30px; display: block; }
#coach header .goal .t2 { display: none; }
#coach header .goal .t1 { font-size: 20px; }
#coach .dots { gap: 4px 8px; }
#coach .dots .sec { display: inline-flex; flex-wrap: wrap; gap: 3px; align-items: center; }
#coach .dots .sec i { font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); width: 100%; }
#coach .dot { width: 18px; height: 18px; font-size: 10px; }
#coach .step.won { border-color: #4aa564; box-shadow: 0 0 0 3px rgba(74,165,100,.25); }
#coach .meter-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
#coach .meter-row .need { color: #ffd24a; font-weight: 600; }
#coach .mastery { height: 8px; border-radius: 4px; background: #07080f; border: 1px solid var(--line); overflow: hidden; margin: 4px 0 2px; }
#coach .mastery i { display: block; height: 100%; background: linear-gradient(90deg, #7d5fe8, #2fd9c0); transition: width .4s; }
#coach .helping { margin: 6px 0 0; font-size: 12.5px; color: #ffd8a8; }
#coach .prompt { font-size: 40px; font-weight: 800; text-align: center; margin: 6px 0 10px; color: #fff; }
#coach .prompt small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
#coach .chip.bad { border-color: #7a2a2e; color: #ffb4b8; background: #3b1113; }

#coach .selfcheck { display: flex; gap: 6px; }
#coach .selfcheck button { flex: 1; justify-content: center; height: 36px; }
#coach .links { display: flex; gap: 14px; justify-content: center; }
#coach .links button.link { margin: 0; font-size: 12.5px; }
#coach .links button.link.offer { color: #ffd24a; font-weight: 700; }
#coach .actions.col { flex-direction: column; }
#coach .summary { text-align: center; display: grid; gap: 10px; }
#coach .summary .trophy { font-size: 46px; line-height: 1; }
#coach .summary h2 { font-size: 22px; }
#coach .summary .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#coach .summary .grid div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 2px; display: grid; }
#coach .summary .grid b { font-size: 17px; }
#coach .summary .grid span { font-size: 11px; color: var(--muted); }
.lvlbar { display: grid; gap: 3px; font-size: 13px; }
.lvlbar .bar, .skill .bar { height: 10px; border-radius: 5px; background: #07080f; border: 1px solid var(--line); overflow: hidden; }
.lvlbar .bar i, .skill .bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff8f4f, #ffd24a); }
.lvlbar small { color: var(--muted); }
.newbadges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* ---------- your progress */
#progressBody h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: #b8a3ff; }
#progressBody h3 small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; }
#progressBody .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
#progressBody .card { display: flex; gap: 12px; align-items: center; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; font-size: 13px; }
#progressBody .card span { color: var(--text); }
#progressBody .card small { color: var(--muted); }
#progressBody .card .big, .toast-card .big { font-size: 34px; line-height: 1; }
#progressBody .skills { display: grid; gap: 6px; }
.skill { display: grid; grid-template-columns: 170px 1fr 170px; gap: 10px; align-items: center; font-size: 13px; }
.skill .val { color: var(--muted); font-size: 12px; }
.skill .bar i { background: linear-gradient(90deg, #7d5fe8, #2fd9c0); }
#progressBody .two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
svg.chart { width: 100%; height: 110px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
svg.chart rect { fill: #7d5fe8; }
svg.chart.line polyline { fill: none; stroke: #2fd9c0; stroke-width: 1; vector-effect: non-scaling-stroke; }
svg.chart.line circle { fill: #2fd9c0; }
svg.chart.line .target { stroke: #ffd24a; stroke-dasharray: 2 2; stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .5; }
.coursemap { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; max-width: 560px; }
.coursemap .cell, .legend .cell { display: grid; place-items: center; height: 26px; border-radius: 6px; border: 1px solid var(--line);
  font-size: 11px; color: var(--muted); }
.cell.started { border-color: #7d68d8; color: #b8a3ff; }
.cell.done { background: #1f3b26; border-color: #3f7a4c; color: #9be3ad; }
.cell.gold { background: #3b3212; border-color: #ffd24a; color: #ffd24a; }
.legend { color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; }
.legend .cell { display: inline-block; width: 16px; height: 14px; }
#progressBody .trouble { display: grid; gap: 6px; max-width: 720px; }
#progressBody .trouble .row { display: flex; gap: 10px; align-items: center; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; }
#progressBody .trouble .row > span { flex: 1; }
#progressBody .trouble small { color: var(--muted); }
#progressBody .muted { color: var(--muted); font-size: 13px; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.badge { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted); opacity: .55; filter: grayscale(1); }
.badge.got { opacity: 1; filter: none; color: var(--text); background: var(--panel-2); border-color: #5a47b0; }
.badge .icon { font-size: 20px; }
.goalpick { display: flex; gap: 6px; flex-wrap: wrap; }
.goalpick button.on { border-color: var(--loop); color: var(--loop); background: #0f302c; }
@media (max-width: 760px) {
  #progressBody .two { grid-template-columns: 1fr; }
  .skill { grid-template-columns: 120px 1fr; }
  .skill .val { grid-column: 2; }
}

/* ---------- celebrations */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
#toasts { position: fixed; left: 16px; top: 96px; z-index: 60; display: grid; gap: 8px; pointer-events: none; }
.toast-card {
  display: flex; gap: 12px; align-items: center; min-width: 240px; max-width: 340px; padding: 10px 14px; border-radius: 12px;
  background: rgba(28,29,56,.97); border: 1px solid #5a47b0; box-shadow: 0 12px 30px rgba(0,0,0,.45); font-size: 13px;
  animation: toastIn .35s ease-out; transition: opacity .5s, transform .5s;
}
.toast-card.out { opacity: 0; transform: translateX(-30px); }
.toast-card.level { border-color: #ffd24a; }
.toast-card.goal { border-color: var(--loop); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }

/* ---------- the welcome tour (welcome.js) ---------- */
#welcome {
  position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; min-width: 0; overflow: hidden;
}
#welcome::backdrop { background: transparent; }
@supports (height: 100dvh) { #welcome { height: 100dvh; } }
.wl-screen {
  position: absolute; inset: 0; display: grid; place-items: center; overflow: auto; padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 0%, rgba(125, 95, 232, .22), transparent 60%), rgba(8, 9, 20, .94);
}
.wl-screen[hidden] { display: none; }
.wl-card {
  position: relative; width: min(720px, 100%); min-width: 0; padding: 28px 30px 22px; font-size: 14.5px; line-height: 1.5;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 24px 80px rgba(0, 0, 0, .5);
}
.wl-card h1 { margin: 6px 0 4px; font-size: 30px; line-height: 1.15; letter-spacing: -.01em; }
.wl-card h2 { margin: 6px 0 4px; font-size: 22px; }
.wl-lead { margin: 0 0 16px; color: var(--muted); font-size: 15.5px; }
.wl-lead strong { color: var(--text); }
.wl-small { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.wl-card menu { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px 16px; margin: 22px 0 0; padding: 0; }
.wl-card menu button { height: 36px; padding: 0 16px; font-size: 14px; }
.wl-card menu button.link { height: auto; padding: 0; margin-right: auto; white-space: normal; text-align: left; }

.wl-dots { display: flex; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; font-size: 12px; color: var(--muted); }
.wl-dots li { flex: 1; padding-top: 7px; border-top: 3px solid var(--line); }
.wl-dots li.done { border-color: #5a47b0; }
.wl-dots li.on { border-color: var(--loop); color: var(--text); font-weight: 600; }

.wl-plan { margin: 0 0 18px; padding: 0; list-style: none; counter-reset: plan; display: grid; gap: 10px; }
.wl-plan li { counter-increment: plan; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: center; }
.wl-plan li::before {
  content: counter(plan); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--loop); font-weight: 700; font-size: 13px;
}
.wl-voice { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.wl-voice span { margin-right: 4px; }

.wl-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.wl-choice, .wl-path {
  display: grid; grid-template-columns: 34px 1fr; column-gap: 8px; row-gap: 2px; align-content: start;
  height: auto; padding: 12px 14px; text-align: left; white-space: normal; border-radius: 10px; background: var(--panel-2);
}
.wl-choice .ic, .wl-path .ic { grid-row: span 3; font-size: 22px; line-height: 1.2; }
.wl-choice b, .wl-path b { font-size: 15px; }
.wl-choice span:not(.ic), .wl-path span:not(.ic) { color: var(--muted); font-size: 13px; line-height: 1.45; }
.wl-choice:hover:not([disabled]), .wl-path:hover { border-color: var(--loop); }
.wl-choice.on { border-color: var(--loop); background: #0f302c; }
.wl-choice[disabled] { opacity: .5; cursor: not-allowed; }



.wl-choices .wl-choice:last-child:nth-child(odd) { grid-column: 1 / -1; }
.wl-lead kbd, .wl-tips kbd { font-size: 12px; }
.wl-live { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #0e0f22; }
.wl-live p { margin: 0; }
.wl-live-head { display: flex; gap: 10px; align-items: baseline; }
.wl-live label { display: flex; gap: 8px; align-items: center; }
.wl-live select { flex: 1; min-width: 0; }
.wl-live .meter { height: 8px; border-radius: 4px; background: #07080f; border: 1px solid var(--line); overflow: hidden; }
.wl-live .meter div { height: 100%; width: 0; background: linear-gradient(90deg, #7d5fe8, #2fd9c0 60%, #ff8f4f); }
.wl-live > button { justify-self: start; }
.wl-live #wlHeard { color: var(--right); font-size: 16px; }
.wl-ok { color: var(--loop); font-weight: 700; }
.wl-tips { margin-top: 10px; padding: 10px 14px; border-radius: 10px; background: #2a2210; border: 1px solid #6b5520; }
.wl-tips ul { margin: 6px 0 0; padding-left: 18px; }
.wl-tips li { margin: 3px 0; }

.wl-paths { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 8px; }
.wl-path { padding: 16px; }
.wl-path b { font-size: 17px; }
.wl-path em { font-style: normal; color: var(--loop); font-size: 13px; font-weight: 600; margin-top: 6px; }
.wl-path:first-child { border-color: #5a47b0; }
.wl-goal { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 16px; color: var(--muted); }
.wl-goal span { margin-right: 6px; }

/* the look around: a spotlight on each part of the real screen, and what it's for */
.wl-spot {
  position: fixed; border: 2px solid var(--loop); border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 200vmax rgba(6, 7, 20, .72), 0 0 24px rgba(47, 217, 192, .35);
  transition: left .25s ease, top .25s ease, width .25s ease, height .25s ease;
}
.wl-tip {
  position: fixed; padding: 14px 16px 12px; font-size: 14.5px; line-height: 1.5; background: var(--panel);
  border: 1px solid var(--loop); border-radius: 12px; box-shadow: 0 16px 50px rgba(0, 0, 0, .55);
}
.wl-tip p { margin: 0; }
.wl-tip menu { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin: 12px 0 0; padding: 0; }
.wl-tip .wl-count { margin-right: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
@media (max-width: 400px) {                                    /* a small phone: "3 of 8" on a row of its own, above */
  .wl-tip menu { gap: 10px; flex-wrap: wrap; row-gap: 6px; }
  .wl-tip menu button:not(.link) { padding: 0 12px; }
  .wl-tip .wl-count { flex: 1 1 100%; order: -1; }
  .wl-tip menu .link { margin-right: auto; }
  .wl-tip .wl-long { display: none; }                          /* "Skip", so Back and Next share its row */
}
.wl-tip .wl-under { margin-top: 6px; color: var(--muted); font-size: 13px; }

/* the first time: the welcome shows before the scripts have loaded (index.html), until welcome.js takes over */
#welcomeSplash { display: none; }
html.first-visit #welcomeSplash { display: grid; position: fixed; z-index: 1000; }

/* the first screen: a few notes falling behind it */
.wl-rain { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.wl-screen:not(.wl-first) .wl-rain { display: none; }
.wl-rain i {
  position: absolute; right: -90px; width: 64px; height: 20px; border-radius: 10px; opacity: .16;
  background: var(--right); animation: wl-slide 10s linear infinite;
}
.wl-rain i:nth-child(even) { background: var(--left); width: 110px; }
.wl-rain i:nth-child(3n) { background: var(--loop); }
.wl-rain i:nth-child(1) { top: 9%; animation-delay: -1s; }    .wl-rain i:nth-child(2) { top: 23%; animation-delay: -6s; }
.wl-rain i:nth-child(3) { top: 38%; animation-delay: -3s; }   .wl-rain i:nth-child(4) { top: 53%; animation-delay: -8s; }
.wl-rain i:nth-child(5) { top: 68%; animation-delay: -5s; }   .wl-rain i:nth-child(6) { top: 83%; animation-delay: -2s; }
.wl-rain i:nth-child(7) { top: 23%; animation-delay: -9.5s; } .wl-rain i:nth-child(8) { top: 53%; animation-delay: -4s; }
.wl-rain i:nth-child(9) { top: 9%; animation-delay: -7s; }    .wl-rain i:nth-child(10) { top: 68%; animation-delay: -0.5s; }
@keyframes wl-slide { to { transform: translateX(calc(-100vw - 240px)); } }
@media (prefers-reduced-motion: reduce) { .wl-rain { display: none; } .wl-spot { transition: none; } }

@media (max-width: 640px) {
  .wl-card { padding: 20px 18px 16px; }
  .wl-card menu { flex-direction: column-reverse; align-items: stretch; gap: 14px; }       /* the way on, a thumb's width */
  .wl-card menu button { height: 44px; justify-content: center; }
  .wl-card menu button.link { height: auto; margin: 0; align-self: center; text-align: center; }
  
  .wl-card h1 { font-size: 24px; }
  .wl-choices, .wl-paths { grid-template-columns: 1fr; }
  .wl-dots li { font-size: 0; }
}
/* a short screen (a phone on its side) or a narrow one: less padding, and the way on (the card's buttons) kept at the
   bottom of the screen while the rest scrolls */
@media (max-height: 560px) {
  .wl-screen { padding: 10px 12px; }
  .wl-card { padding: 14px 20px 0; }
  .wl-card h1 { font-size: 22px; }
  .wl-card h2 { font-size: 19px; }
  .wl-dots { margin-bottom: 8px; }
  .wl-plan { gap: 6px; margin-bottom: 10px; }
  .wl-lead { margin-bottom: 10px; font-size: 14.5px; }
     /* the low string in sight */
}
@media (max-height: 560px), (max-width: 640px) {
  .wl-card { padding-bottom: 0; }
  .wl-card menu {
    position: sticky; bottom: -1px; z-index: 1; margin: 14px -20px 0; padding: 10px 20px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--panel); border-top: 1px solid var(--line); border-radius: 0 0 14px 14px;
  }
}
@media (max-width: 640px) { .wl-card menu { margin-left: -18px; margin-right: -18px; padding-left: 18px; padding-right: 18px; } }

/* ---------- phones and small tablets (mobile.js sets body.compact) ---------- */
@supports (height: 100dvh) { body { height: 100dvh; } }      /* the screen you can see, not behind the browser's bars */
body { grid-template-columns: minmax(0, 1fr); }               /* never wider than the screen (an auto column grows to the
                                                                 toolbar's widest row: 7 px of sideways scroll at 320 px) */
html, body { overscroll-behavior: none; }
   /* taps and drags are the app's */
button, .btn, select, input, canvas { -webkit-tap-highlight-color: transparent; }
button, .btn, select { touch-action: manipulation; }        /* no double-tap zoom on a control */
#morePanel, #coach, dialog, #libraryList, #courseList, #progressBody, #dayDetail, .wl-screen, #reader, #card, #wordsBody {
  scrollbar-width: thin; scrollbar-color: #3a3b6a transparent;            /* quiet scrollbars, in the app's colours */
}
#toolbar { position: relative; }
#moreBtn { display: none; }
#morePanel[hidden] { display: none; }
.more-label, .story-now { display: none; }
.part-pick { display: contents; }                            /* the page as written, on a computer */
body.compact #toolbar > .group.emptied { display: none; }     /* everything in it went under ⋯ */

/* the toolbar: one row, and the song's name on ♫ (it opens the library, which is the song list here) */
body.compact #toolbar { flex-wrap: nowrap; gap: 6px; padding: 6px 8px; }
body.compact #toolbar > .group { flex-wrap: nowrap; gap: 6px; }
body.compact #toolbar > .group:first-child { flex: 1 1 auto; min-width: 0; }
body.compact #songUnused { display: none; }
body.compact #libraryBtn { flex: 1 1 auto; min-width: 0; }
body.compact #libraryBtn.has-story .lib-word { display: none; }
body.compact #libraryBtn .story-now { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
body.compact #libraryBtn.has-story::after { content: "▾"; margin-left: auto; padding-left: 2px; color: var(--muted); font-size: 11px; }
body.compact #play { min-width: 46px; }
body.compact #restart { min-width: 36px; justify-content: center; }
body.compact #moreBtn { display: inline-flex; justify-content: center; min-width: 40px; font-size: 18px; letter-spacing: 1px; }
body.compact #moreBtn.on { background: var(--panel-2); border-color: var(--loop); color: var(--loop); }
@media (max-width: 400px) {                                    /* the narrowest phones: room for the song's name */
  body.compact #toolbar, body.compact #toolbar > .group { gap: 4px; }
  body.compact #libraryBtn { gap: 3px; padding: 0 7px; }
  body.compact #toolbar > .group > button, body.compact #moreBtn { padding: 0 8px; }
  body.compact #play { min-width: 42px; }
  body.compact #moreBtn { min-width: 36px; }
}

/* ⋯: the rest of the controls, in sections, drawn over the notes (which dim) */
#morePanel {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 40; display: grid; gap: 12px; padding: 12px 14px 16px;
  max-height: calc(100vh - 60px); overflow: auto; overscroll-behavior: contain;
  background: var(--panel); border-bottom: 1px solid var(--line); border-radius: 0 0 16px 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55); animation: moreIn .16s ease-out;
}
@supports (height: 100dvh) { #morePanel { max-height: calc(100dvh - 60px); } }
@keyframes moreIn { from { opacity: 0; transform: translateY(-8px); } }
@media (min-width: 600px) {                                    /* a tablet, a phone on its side: a drop-down under ⋯ */
  #morePanel { left: auto; width: 440px; border-left: 1px solid var(--line); border-radius: 0 0 0 16px; }
}
@media (prefers-reduced-motion: reduce) { #morePanel { animation: none; } }
body.more-open #stage, body.more-open #overview { position: relative; }
body.more-open #stage::after, body.more-open #overview::after {
  content: ""; position: absolute; inset: 0; z-index: 30; background: rgba(4, 4, 14, .6);
}
.more-sec { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.more-sec + .more-sec { padding-top: 12px; border-top: 1px solid var(--line); }
.more-sec h3 { flex: 1 1 100%; margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.more-sec > .group, .more-sec > .group.right { flex: 1 1 100%; flex-wrap: wrap; gap: 8px; margin: 0; }
#morePanel .more-label { display: inline; }
#morePanel button, #morePanel .btn { min-height: 40px; }
/* the song: where you are, then what to do with it */
#morePanel #pos { order: -1; flex: 1 1 100%; min-width: 0; color: var(--muted); }
.more-song > button, .more-song > .btn { flex: 1 1 auto; justify-content: center; }
/* speed and look-ahead: a whole row each, the names lined up */
#morePanel .slider { display: grid; grid-template-columns: 86px 1fr 48px; align-items: center; gap: 10px; flex: 1 1 100%; }
#morePanel .slider input { width: 100%; min-width: 0; height: 28px; }
#morePanel .slider output { text-align: right; }
/* the instrument, who plays each part, while you play, sound: segments across the width */
#morePanel .part-pick { display: flex; align-items: center; gap: 10px; flex: 1 1 100%; }
#morePanel .part-pick .lbl { width: 70px; flex: none; }
#morePanel .seg { display: flex; flex: 1 1 auto; }
#morePanel .seg button { flex: 1 1 0; justify-content: center; min-height: 40px; }
.more-loop button { flex: 1 1 0; justify-content: center; }
.more-loop #loopOn { flex-grow: 2; }
#morePanel #loopOut:empty { display: none; }
#morePanel #loopOut { flex: 1 1 100%; }
/* how you answer, then settings and help */
#morePanel .connect { flex: 1 1 100%; }
#morePanel #connectBtn { width: 100%; justify-content: center; }
#morePanel #settingsBtn, #morePanel #helpBtn, #morePanel #wordsBtn, #morePanel #progressBtn { flex: 1 1 0; justify-content: center; }
#morePanel .menu { position: static; width: auto; margin-top: 8px; box-shadow: none; }
#morePanel .menu-live .slider { grid-template-columns: 1fr 1fr; }

@media (pointer: coarse) {
  button, .btn, select { min-height: 36px; }                  /* big enough for a finger */
  .seg button { min-height: 34px; }
  /* iOS zooms into a text box whose text is smaller than 16px */
  input:not([type=range]):not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px; }
}
@media (hover: none) and (pointer: coarse) {                  /* a phone or tablet: no home row to play on */
  #help .keys-only { display: none; }                          /* touch gestures, not keyboard shortcuts */
  #help table.touch-only { display: table; }
  #help h2.touch-only { display: block; }
}
#help .touch-only { display: none; }

/* dialogs: the whole screen on a phone, with Done / Close always in reach */
body.compact dialog:not(#welcome) {
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border: 0; border-radius: 0; min-width: 0;
  overflow: auto; overscroll-behavior: contain; padding: 16px 16px 0;
}
body.compact dialog:not(#welcome) > form > menu {
  position: sticky; bottom: 0; margin: 12px -16px 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--panel); border-top: 1px solid var(--line);
}
@supports (height: 100dvh) {                                  /* the screen you can see (not behind Safari's bars) */
  body.compact dialog:not(#welcome) { height: 100dvh; max-height: 100dvh; }
}
body.compact dialog menu button { min-height: 42px; padding: 0 18px; }
body.compact dialog#library, body.compact dialog#course, body.compact dialog#progress { padding: 0; }   /* outweighs dialog:not(#welcome) */
body.compact #library form { max-height: none; height: 100%; }
body.compact .lib-head { gap: 8px; padding: 10px 10px 10px 16px; }
body.compact .lib-head h2 { font-size: 17px; }
body.compact .lib-head input { max-width: none; min-width: 0; height: 40px; }
.lib-head > form { margin-left: auto; }                       /* the ✕ at the far right */
body.compact .lib-head button[value=close] { width: 42px; height: 42px; justify-content: center; font-size: 16px; }
body.compact #libraryList { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 14px; padding: 12px 12px 24px; }
body.compact .story-card { padding: 10px 12px; }
body.compact .story-card .forget { opacity: 1; width: 30px; height: 30px; }
body.compact .lib-filters {                                   /* the song groups and levels: one row that scrolls sideways */
  flex-wrap: nowrap; overflow-x: auto; padding: 8px 12px 6px; scrollbar-width: none; overscroll-behavior-x: contain;
}
body.compact .lib-filters::-webkit-scrollbar { display: none; }
body.compact .lib-filters > * { flex: none; }
body.compact #courseList, body.compact #progressBody { padding: 12px 14px 24px; }
body.compact .home-top { gap: 10px 18px; }
body.compact .home-actions button { flex: 1 1 auto; white-space: normal; text-align: left; }
body.compact .home-actions button.big { flex: 1 1 100%; }
body.compact #dayDetail { margin: 16px -14px -24px; padding: 14px 14px 18px; bottom: -24px; }
body.compact #dayDetail li { flex-wrap: wrap; }
body.compact #dayDetail li button { min-height: 32px; }
body.compact .daytiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
body.compact #settings label { margin: 12px 0; }
body.compact #settings select { display: flex; width: 100%; max-width: none; margin-top: 6px; }
body.compact #settings .slider { display: grid; gap: 6px; }
body.compact #settings .slider input { width: 100%; }
body.compact #help td:first-child { white-space: nowrap; }
body.compact #credits td, body.compact #creditsBody td:last-child, body.compact #creditsBody .what { white-space: normal; }
body.compact #creditsBody table { display: block; overflow-x: auto; }
body.compact 
@media (max-width: 760px) {
  .skill { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .skill .name { grid-column: 1; grid-row: 1; }
  .skill .val { grid-column: 2; grid-row: 1; text-align: right; }
  .skill .bar { grid-column: 1 / -1; grid-row: 2; }
  #progressBody .cards { grid-template-columns: 1fr 1fr; }
  #progressBody .card { flex-direction: column; align-items: flex-start; gap: 6px; }
  .coursemap { grid-template-columns: repeat(8, 1fr); }
}

/* the coach: under the notes when upright, a narrower side panel when the phone is on its side */
#coach { min-width: 0; overflow-x: hidden; }
#coach .choice { white-space: normal; }
#coach .dot { min-height: 0; }
@media (pointer: coarse) { #coach .dot { width: 24px; height: 24px; font-size: 11px; } }
body.compact #coach { padding: 10px 12px 0; gap: 8px; font-size: 14px; }
body.compact #coach header { gap: 4px; }
body.compact #coach header > span:first-child { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#coach header span.goal, #coach header > span:first-child span { flex: none; }   /* the day and clock get the room, not the ring */
body.compact #coach .wk, body.compact #coach header [data-act=progress] { display: none; }   /* 📈 is under ⋯ too */
body.compact #coach header .goal svg { width: 28px; height: 28px; }
body.compact #coach button.icon { flex: none; width: 34px; min-height: 34px; height: 34px; padding: 0; justify-content: center; }
body.compact #coach h2 { font-size: 17px; }
body.compact #coach .step { padding: 10px 12px; }
body.compact #coach .actions {                               /* Next is always in reach, the lesson scrolls under it */
  position: sticky; bottom: 0; z-index: 1; margin: 0 -12px; padding: 8px 12px 10px;
  background: linear-gradient(to bottom, rgba(19, 20, 42, 0), var(--panel) 10px);
}
body.compact #coach .actions button { min-height: 42px; }
/* a narrow lesson panel (a small phone, or any phone on its side): the buttons two by two, Next at the bottom right,
   under the thumb (across the whole width when there are three) */
#coach { container-type: inline-size; }
@container (max-width: 340px) {                                /* tighter buttons, still one row (a phone only: a
                                                                  computer's coach is 328 px inside, and stays as it was) */
  body.compact #coach .prompt { font-size: 28px; line-height: 1.15; }   /* "F on the low E string" in two lines, not three */
  body.compact 
  body.compact #coach .actions:not(.col) { gap: 6px; }
  body.compact #coach .actions:not(.col) button { min-width: 0; padding: 0 6px; font-size: 13px; }
}
@container (max-width: 280px) {
  body.compact #coach .actions:not(.col) { display: grid; grid-template-columns: 1fr 1fr; }
  body.compact #coach .actions:not(.col) button { padding: 0 8px; }
  body.compact #coach .actions:not(.col) button:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
body.compact #coach footer.hear { margin-top: 0; padding-bottom: 10px; }
body.compact.coaching #overview { display: none; }            /* the lesson needs the room more than the song strip */
@media (max-height: 520px) and (min-width: 600px) {
  #stage { flex-direction: row; }
  #coach { flex: 0 0 min(350px, 48vw); max-height: none; border-top: 0; border-left: 1px solid var(--line); }
  #overview { height: 44px; }
  body.compact #coach h2 { display: none; }                   /* the day's title is in the header; the room is for the lesson */
}
/* a phone: the lesson's dots in one row that scrolls sideways (each section's name above its dots), so the lesson itself
   is on the screen; mobile.js keeps the current one in view */
body.compact #coach .dots { flex: none; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding: 2px 2px 4px;
  scrollbar-width: none; scroll-behavior: smooth; }
body.compact #coach .dots::-webkit-scrollbar { display: none; }
body.compact #coach .dots .sec { flex: none; }
@media (max-width: 600px) {
  #overview { height: 52px; }
  #coach { max-height: 50%; }
}
@media (max-width: 600px) and (max-height: 700px) { #coach { max-height: 54%; } }


/* =====================================================================================================
   Spanish Trainer: the reader, the lesson's card, the exercises and games, the dictionary, My words
   ===================================================================================================== */
:root { --spC: #f6c453; --spN: #9fc2ff; --ok: #9be3ad; --bad: #ffb4b8; --es-font: 600 26px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; }
.sp-A { --sp: var(--right); } .sp-B { --sp: var(--left); } .sp-C { --sp: var(--spC); } .sp-D { --sp: #ff8fb8; } .sp-N { --sp: var(--spN); }

/* the welcome's falling words, drifting by */
.wl-rain i { width: auto !important; height: auto; padding: 0; background: none !important; border-radius: 0; font-style: normal;
  font: 700 20px/1 system-ui, sans-serif; color: var(--right); opacity: .13; white-space: nowrap; }
.wl-rain i:nth-child(even) { color: var(--left); }
.wl-rain i:nth-child(3n) { color: var(--loop); }
.wl-hola { font: 800 54px/1.1 system-ui, sans-serif; text-align: center; margin: 4px 0 16px; color: var(--loop); letter-spacing: .01em; }
.wl-hola.ok { color: var(--ok); }
.wl-voice small { flex-basis: 100%; color: var(--muted); }
.wl-voice button.on, .wl-goal button.on { border-color: var(--loop); color: var(--loop); background: #0f302c; }

/* ---------- the reader */
#board { display: flex; flex-direction: column; overflow: hidden; }
#reader {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 20px 40vh;
  scroll-padding: 30vh 0; -webkit-user-select: text; user-select: text;
}
.rd-empty { display: grid; place-items: center; height: 60%; color: var(--muted); font-size: 16px; text-align: center; }
.rd-head, .rd-lines { max-width: 860px; margin: 0 auto; }
.rd-head { padding: 4px 6px 10px; }
.rd-title { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.rd-sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.rd-lines { list-style: none; padding: 0; display: grid; gap: 6px; }
.ln {
  position: relative; padding: 10px 16px 10px 18px; border-radius: 12px; border: 1px solid transparent;
  opacity: .55; transition: opacity .25s, background .25s, border-color .25s; cursor: pointer;
}
.ln::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 2px; background: var(--sp); opacity: .8; }
.ln.now { opacity: 1; background: var(--panel); border-color: var(--line); }
.ln.done { opacity: .62; }
.ln:hover { opacity: .9; }
.ln.off { display: none; }
.ln .who { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--sp); margin-bottom: 2px; }
.ln .es { margin: 0; font: var(--es-font); color: var(--text); }
.ln .w { border-radius: 4px; transition: color .12s, background .12s; }
.ln .w:hover { background: rgba(255,255,255,.07); }
.ln.saying .w { color: #b9b6d6; }
.ln.saying .w.sung { color: #fff; text-shadow: 0 0 14px color-mix(in srgb, var(--sp) 60%, transparent); }
.ln .en { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.ln .free { margin: 2px 0 0; color: var(--loop); font-size: 14px; }
.ln .free i { font-style: normal; opacity: .85; }
#reader.en-off .ln .en { display: none; }
#reader.en-tap .ln .en { visibility: hidden; }
#reader.en-tap .ln.en-open .en { visibility: visible; }
.ln.es-hidden .es { color: transparent; text-shadow: 0 0 14px rgba(200, 196, 240, .55); -webkit-user-select: none; user-select: none; }
.ln.es-hidden .es .w { pointer-events: none; }
.ln.you::before { background: var(--loop); }
.ln.you .who::after { content: " · you"; color: var(--loop); }
.ln.yourturn { opacity: 1; border-color: var(--loop); background: #0f302c; box-shadow: 0 0 0 3px rgba(47,217,192,.18); animation: yourturn 1.6s ease-in-out infinite; }
@keyframes yourturn { 50% { box-shadow: 0 0 0 6px rgba(47,217,192,.08); } }
.ln.heard-ok { border-color: #4aa564; background: #1a2e20; }
.ln.heard-bad { border-color: #7a2a2e; background: #2a1416; }
.ln-you { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed #1d6b60; font-size: 14px; }
.ln-you[hidden] { display: none; }
.ln-you .heard { color: var(--loop); font-weight: 600; min-width: 0; }
.ln-you .heard.bad { color: var(--bad); }
.ln-you .marks { flex-basis: 100%; }
.ln-you .type-line { display: flex; gap: 6px; flex: 1 1 100%; }
.ln-you .type-line input { flex: 1; }
.ln-you button.link { margin: 0; }
.mic.live { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #0f302c; border: 1px solid var(--loop); animation: micpulse 1.2s ease-in-out infinite; }
@keyframes micpulse { 50% { box-shadow: 0 0 0 6px rgba(47,217,192,.15); } }
.timebar { flex: 1 1 120px; height: 6px; border-radius: 3px; background: #07080f; border: 1px solid var(--line); overflow: hidden; }
.timebar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--loop), #ffd24a); }

/* the strip along the bottom: every line, as long as it takes to say */
#overview { height: 56px; padding: 8px 10px; display: flex; }
#strip { flex: 1; display: flex; gap: 2px; align-items: stretch; cursor: pointer; touch-action: none; -webkit-user-select: none; user-select: none; }
.seg-l { position: relative; min-width: 6px; border-radius: 4px; background: color-mix(in srgb, var(--sp) 35%, #13142a); display: flex; align-items: flex-end; justify-content: flex-start; overflow: hidden; }
.seg-l i { font-style: normal; font-size: 10px; color: rgba(255,255,255,.55); padding: 0 3px 1px; }
.seg-l.past { background: color-mix(in srgb, var(--sp) 60%, #13142a); }
.seg-l.now { background: var(--sp); box-shadow: 0 0 0 2px #fff inset; }
.seg-l.you { background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgba(47,217,192,.35) 5px 7px); }
.seg-l.off { opacity: .25; }
.seg-l.loop { outline: 2px dashed rgba(47,217,192,.6); outline-offset: -2px; }
.seg-l.loop.on { outline-style: solid; outline-color: var(--loop); }
.seg-l.got::after, .seg-l.missed::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; }
.seg-l.got::after { background: var(--ok); } .seg-l.missed::after { background: #ff6b74; }
body.card-on #overview { opacity: .35; pointer-events: none; }

/* parts: the speakers in the toolbar */
#parts:empty { display: none; }
#parts .lbl { color: var(--sp); font-weight: 600; }
#parts .lbl::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 2px; background: var(--sp); vertical-align: -1px; }

/* ---------- the lesson's card: an exercise, drawn over the reader */
#card {
  position: absolute; inset: 0; z-index: 3; overflow-y: auto; overscroll-behavior: contain; padding: 22px 22px 40px;
  background: radial-gradient(ellipse at 50% -10%, rgba(125, 95, 232, .16), transparent 60%), var(--bg);
  display: flex; flex-direction: column; align-items: center;
}
#card[hidden] { display: none; }
#card > * { width: min(760px, 100%); }
.cd-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.cd-label { font-weight: 700; color: #ddd4ff; text-transform: uppercase; letter-spacing: .05em; font-size: 12px; }
.cd-help { color: #ffd8a8; font-size: 12.5px; }
.cd-dots { margin-left: auto; display: flex; gap: 5px; }
.cd-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.cd-dots i.now { background: var(--loop); box-shadow: 0 0 0 3px rgba(47,217,192,.25); }
.cd-dots i.ok { background: #4aa564; } .cd-dots i.bad { background: #c2464d; }
.cd-clock { margin-left: auto; font: 700 18px/1 system-ui, sans-serif; color: var(--text); font-variant-numeric: tabular-nums; }
.cd-clock.hurry { color: #ffb86b; }
.cd-prompt { display: grid; justify-items: center; gap: 10px; text-align: center; margin: 10px 0 18px; }
.cd-prompt .es.big, .cd-prompt .big { font: 700 32px/1.25 system-ui, sans-serif; color: #fff; margin: 0; }
.cd-prompt .en.big { font-weight: 600; color: var(--text); font-size: 28px; line-height: 1.3; }
.cd-prompt .en { color: var(--muted); font-size: 16px; margin: 0; }
.cd-prompt .en.tap { filter: blur(5px); cursor: pointer; transition: filter .2s; }
.cd-prompt .en.tap:hover, .cd-prompt .en.tap:active { filter: none; }
.cd-prompt .q-en { font: 600 22px/1.3 system-ui, sans-serif; }
.cd-prompt .pos { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.cd-prompt .hint { font: 600 20px/1.3 ui-monospace, monospace; letter-spacing: .06em; color: #ffd8a8; margin: 0; }
.cd-prompt .word .es.big { font-size: 40px; }
.hidden-text { color: transparent !important; text-shadow: 0 0 16px rgba(200, 196, 240, .5); -webkit-user-select: none; user-select: none; }
.hidden-text .w { pointer-events: none; }
.cd-hear { display: flex; gap: 10px; align-items: center; justify-content: center; }
.big-hear { width: 74px; height: 74px; border-radius: 50%; justify-content: center; font-size: 30px; background: #1f1c3d; border-color: #5a47b0; }
.big-hear:hover { border-color: #b8a3ff; }
.slow-hear { width: 46px; height: 46px; border-radius: 50%; justify-content: center; font-size: 20px; }
.cd-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 10px; }
.cd-options.row { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.cd-options.two { grid-template-columns: 1fr 1fr; }
.opt { height: auto; min-height: 52px; padding: 10px 14px; font-size: 16px; white-space: normal; text-align: left; justify-content: flex-start; border-radius: 12px; gap: 10px; }
.opt kbd { flex: none; opacity: .6; }
.opt:hover:not(:disabled) { border-color: #7d68d8; }
.opt.right { border-color: #4aa564; background: #1a2e20; color: #fff; }
.opt.wrong { border-color: #7a2a2e; background: #3b1113; }
.opt:disabled { cursor: default; }
.cd-options.two .opt { justify-content: center; font-size: 22px; font-weight: 700; }
.gap-line .gap { display: inline-block; min-width: 2.2em; border-bottom: 3px solid var(--loop); color: var(--loop); text-align: center; }
.gap-line .gap.right { color: var(--ok); border-color: #4aa564; } .gap-line .gap.fixed { color: #ffd8a8; border-color: #ffb86b; }
.cd-feedback { margin: 6px 0 4px; padding: 12px 14px; border-radius: 12px; font-size: 16px; line-height: 1.5;
  background: #2a1416; border: 1px solid #7a2a2e; color: #ffe1e3; }
.cd-feedback.ok { background: #1a2e20; border-color: #3f7a4c; color: #d6f5de; }
.cd-feedback.ok.accent { background: #2a2210; border-color: #6b5520; color: #ffe9bf; }
.cd-feedback:not(.ok):not(.bad) { background: var(--panel-2); border-color: var(--line); color: var(--text); }
.cd-feedback[hidden] { display: none; }
.cd-feedback .es-line { font-weight: 700; color: #fff; }
.cd-feedback small { display: block; margin-top: 4px; }
.cd-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 10px; min-height: 40px; }
.cd-actions button.primary, .cd-actions button.ready { height: 42px; padding: 0 22px; font-size: 15px; }
.cd-actions button.link { margin-right: auto; color: #b8a3ff; }
.cd-actions .slips { color: var(--muted); margin-right: auto; }
.cd-actions .selfcheck { display: flex; gap: 10px; }
.cd-actions .selfcheck button { height: 42px; padding: 0 18px; font-size: 15px; }
button.ready { background: #2b6d3d; border-color: #4aa564; color: #fff; font-weight: 600; }
.self-say { text-align: center; color: var(--muted); font-size: 16px; margin: 0; }

/* marks: each word of the right answer, as you had it */
.marks { line-height: 1.9; }
.mk { padding: 1px 5px; border-radius: 5px; font-weight: 600; }
.mk.ok { color: var(--ok); }
.mk.accent { color: #ffe08a; background: rgba(255, 210, 74, .12); }
.mk.wrong { color: #fff; background: #8a2f36; }
.mk.missing { color: #ffb4b8; border: 1px dashed #c2464d; }
.mk.extra { color: #ffb4b8; text-decoration: line-through; }

/* building a sentence from tiles */
.build-line { min-height: 62px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; margin: 0 0 12px;
  border-bottom: 2px solid var(--line); }
.build-line .ph { color: var(--muted); }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 8px; }
.tile { height: 44px; padding: 0 14px; font-size: 18px; font-weight: 600; border-radius: 10px; background: var(--panel-2);
  box-shadow: 0 2px 0 #090a17; transition: transform .08s, opacity .15s; }
.tile:active { transform: translateY(1px); }
.tile.used { opacity: .25; pointer-events: none; }
.tile.in { background: #26274a; border-color: #5a47b0; }

/* writing: the box, and the accented letters */
.type-box, .type-line { width: 100%; }
.type-box input, .type-line input, .sprint input {
  width: 100%; height: 50px; padding: 0 14px; font: 600 22px/1 system-ui, sans-serif; color: #fff; background: #0b0c1c;
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
.type-box input:focus, .type-line input:focus, .sprint input:focus { border-color: var(--loop); box-shadow: 0 0 0 3px rgba(47,217,192,.18); }
.type-box.num input { text-align: center; font-size: 34px; height: 64px; max-width: 220px; margin: 0 auto; display: block; }
.type-line input { height: 40px; font-size: 18px; }
.accents { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.accents button { height: 32px; min-width: 34px; padding: 0 8px; justify-content: center; font-size: 16px; }
.cd-answer { display: grid; gap: 6px; }

/* speaking: the microphone */
.mic-box { display: flex; gap: 16px; align-items: center; justify-content: center; padding: 8px 0; }
.mic-btn { width: 84px; height: 84px; border-radius: 50%; justify-content: center; font-size: 34px; background: #0f302c; border-color: var(--loop); }
body.listening .mic-btn:not(.idle) { animation: micpulse 1.2s ease-in-out infinite; }
.mic-btn.idle { background: var(--panel-2); border-color: var(--line); }
.mic-side { display: grid; gap: 8px; min-width: min(320px, 60vw); }
.heard-now { font: 600 20px/1.3 system-ui, sans-serif; color: var(--loop); }
.level { height: 8px; border-radius: 4px; background: #07080f; border: 1px solid var(--line); overflow: hidden; }
.level i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7d5fe8, #2fd9c0 60%, #ff8f4f); transition: width .08s; }

/* an explanation: what's being said, and the examples */
.explain p { font-size: 19px; line-height: 1.6; margin: 0 0 14px; transition: opacity .3s; }
.explain p.later { opacity: .18; }
.explain p.now { color: #fff; }
.es-inline { color: #ffcf9f; font-weight: 700; cursor: pointer; white-space: normal; }
.es-inline .w:hover { text-decoration: underline; }
.examples { width: 100%; border-collapse: separate; border-spacing: 0 6px; margin-top: 6px; transition: opacity .3s; }
.examples.later { opacity: .25; }
.examples td { padding: 8px 10px; background: var(--panel); }
.examples td:first-child { border-radius: 10px 0 0 10px; width: 46px; }
.examples td:last-child { border-radius: 0 10px 10px 0; color: var(--muted); }
.examples td.es { font: 600 20px/1.3 system-ui, sans-serif; color: #fff; }
.examples tr.now td { background: #1f1c3d; }

/* the games */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.match .col { display: grid; gap: 8px; align-content: start; }
.mt { height: auto; min-height: 50px; padding: 8px 12px; font-size: 16px; white-space: normal; justify-content: center; text-align: center; border-radius: 12px; }
.mt.es-side { font-weight: 700; color: #ffcf9f; }
.mt.sel { border-color: var(--loop); background: #0f302c; }
.mt.done { opacity: .2; border-color: #3f7a4c; }
.mt.shake { animation: shake .4s; border-color: #c2464d; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.sprint { display: grid; gap: 12px; justify-items: center; }
.sp-q { font: 700 30px/1.3 system-ui, sans-serif; text-align: center; transition: color .2s; }
.sp-q .who { color: var(--loop); } .sp-q .inf { color: #fff; } .sp-q small { display: block; font-size: 14px; color: var(--muted); font-weight: 500; }
.sp-q.flash-ok { color: var(--ok); }
.sp-score { font-size: 15px; color: var(--muted); } .sp-score b { font-size: 26px; color: #fff; }
.sprint .type-box, .sprint form { max-width: 420px; }

/* ---------- the word popover (tap any word) */
.wordpop {
  position: absolute; z-index: 30; padding: 10px 12px 12px; border-radius: 12px; background: #1a1b36; border: 1px solid #5a47b0;
  box-shadow: 0 16px 40px rgba(0,0,0,.55); font-size: 14px;
}
.wordpop[hidden] { display: none; }
.wp-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.wp-word { flex: 1; font: 700 22px/1.2 system-ui, sans-serif; color: #ffcf9f; }
.wp-head .icon { height: 28px; padding: 0 8px; }
.wp-row { padding: 6px 0; border-top: 1px solid var(--line); }
.wp-row b { color: #fff; }
.wp-en { color: var(--text); }
.wp-tag { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.wp-phrase b { color: #ffcf9f; }
.wp-none { color: var(--muted); }

/* ---------- the library */
.story-card { display: grid; gap: 2px; justify-items: start; height: auto; padding: 8px 10px; text-align: left; white-space: normal; position: relative; }
.story-card .t { font-weight: 700; padding-right: 64px; }
.story-card .c { color: var(--text); opacity: .85; font-size: 12px; }
.story-card .w { color: var(--muted); font-size: 11.5px; }
.story-card.current { border-color: var(--accent); background: #26274a; }
.story-card .lvl { position: absolute; top: 7px; right: 8px; font-size: 10px; font-weight: 700; letter-spacing: .03em; padding: 1px 6px; border-radius: 8px; background: rgba(255,255,255,0.06); }
.story-card .lvl.l1 { color: #8fd05a; } .story-card .lvl.l2 { color: #e8c547; } .story-card .lvl.l3 { color: #f08a4b; } .story-card .lvl.l4 { color: #f0605d; }
#libraryList section[data-group="Your first stories"] h3 { color: #8fd05a; }
#libraryList section[data-group="Conversations"] h3 { color: var(--right); }
#libraryList section[data-group="Stories"] h3 { color: var(--left); }
#libraryList section[data-group="Fables"] h3 { color: var(--loop); }
#libraryList section[data-group="Poems"] h3, #libraryList section[data-group="Songs"] h3 { color: #ffb86b; }
#libraryList section[data-group="Real Spanish"] h3 { color: #ff8fb8; }

/* ---------- My words */
#words { width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; }
#words[open] { display: flex; flex-direction: column; }
#wordsBody { overflow: auto; padding: 12px 18px 20px; }
.wd-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.wd-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.wd-tabs .chip { height: 28px; border-radius: 14px; font-size: 12.5px; }
.wd-tabs .chip.on { background: #2e2c58; border-color: var(--accent); }
.wd-tabs small { color: var(--muted); }
.wd-list { display: grid; gap: 4px; }
.wd-row { display: grid; grid-template-columns: 34px minmax(110px, 200px) 1fr auto auto; gap: 10px; align-items: center; padding: 5px 8px;
  border-radius: 8px; background: var(--panel-2); font-size: 14px; }
.wd-row b { color: #ffcf9f; }
.wd-row small { color: var(--muted); }
.wd-row .icon { height: 28px; padding: 0 6px; }
.wd-box { color: var(--loop); letter-spacing: 1px; font-size: 11px; }
.star.on { color: #ffd24a; }
.wd-quiz { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 10px 0; }
.wd-quiz .es.big { font: 800 36px/1.2 system-ui, sans-serif; color: #fff; }
.wd-quiz .cd-options { width: min(560px, 100%); }
.wd-fb { min-height: 1.4em; font-weight: 600; color: var(--loop); margin: 0; }
.muted { color: var(--muted); }

/* the day's words in the course */
#dayDetail .dd-words { margin-top: 6px; font-size: 13px; color: #ffcf9f; }
#dayDetail h3 small { color: var(--muted); font-weight: 400; font-size: 13px; }
.home-actions button[data-act=words] { order: 3; }

/* the coach: the extras a Spanish lesson needs */
#coach .bubble .es-inline { color: #ffcf9f; }
#coach .actions button.offer { color: #ffd24a; border-color: #6b5520; }
#coach footer.hear { flex-wrap: wrap; }
#coach footer .link { margin-left: 0; }
#coach footer .link:first-of-type { margin-left: auto; }
#coach .setup .micbox .level { height: 8px; }

/* ---------- phones */
body.compact #reader { padding: 12px 10px 40vh; }
body.compact .ln { padding: 8px 10px 8px 14px; }
body.compact .ln .es { font-size: 21px; }
body.compact .ln .en { font-size: 14px; }
body.compact #card { padding: 14px 12px 30px; }
body.compact .cd-prompt .es.big, body.compact .cd-prompt .big, body.compact .cd-prompt .en.big { font-size: 24px; }
body.compact .cd-options { grid-template-columns: 1fr; }
body.compact .cd-options.two { grid-template-columns: 1fr 1fr; }
body.compact .explain p { font-size: 17px; }
body.compact .examples td.es { font-size: 17px; }
body.compact .cd-actions { position: sticky; bottom: -30px; padding: 10px 0 12px; background: linear-gradient(to bottom, rgba(10,11,23,0), var(--bg) 12px); }
body.compact .wd-row { grid-template-columns: 34px 1fr auto; }
body.compact .wd-row > span:nth-of-type(1) { grid-column: 2; }
body.compact .wd-row .wd-box { display: none; }
body.compact #overview { height: 44px; padding: 6px 8px; }
@media (max-width: 900px) and (orientation: portrait) {
  body.coaching #stage { flex-direction: column; }
  body.coaching #board { flex: 1 1 55%; }
}
@media (prefers-reduced-motion: reduce) {
  .ln, .tile, .explain p { transition: none; }
  .ln.yourturn, .mic.live, body.listening .mic-btn { animation: none; }
}

dialog, dialog:focus, dialog:focus-visible { outline: none; }
.ln-you .last-heard { flex-basis: 100%; display: grid; gap: 2px; }
.wp-also { margin-top: 6px; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
