/* Chord practice. Built to be read from 1–2 m away on a phone propped up on a table or the floor. */
:root {
  --bg: #fbf8f3;
  --panel: #ffffff;
  --ink: #1d1b19;
  --muted: #6b645c;
  --line: #2a2622;
  --wood: #efe3cf;
  --fret: #9a8f80;
  --string: #4a443d;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --anchor: #1d4ed8;
  --skin: #f3dcc6;
  --skin-edge: #5b4636;
  --btn: #ece6dc;
  --btn-on: #1d1b19;
  --btn-on-ink: #fbf8f3;
  --yes: #15803d;
  --no: #ece6dc;
  --border: #e2dbd0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312; --panel: #1c1a18; --ink: #f4efe8; --muted: #a79f95; --line: #f4efe8;
    --wood: #2b241d; --fret: #8d8273; --string: #d9d1c6; --accent: #fb923c; --accent-ink: #141312;
    --anchor: #60a5fa; --skin: #d8b89c; --skin-edge: #f4efe8; --btn: #2a2724; --btn-on: #f4efe8;
    --btn-on-ink: #141312; --yes: #22c55e; --no: #2a2724; --border: #34302c;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top));
  min-height: 52px;
}
.topbar h1 { flex: 1; margin: 0; font-size: 20px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { font-size: 26px; line-height: 1; min-width: 44px; padding: 6px 10px; }

/* ---------- Main area ---------- */
#screen { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 4px 16px 24px; overflow-x: hidden; }
#screen.fill { max-width: none; display: flex; flex-direction: column; min-height: 0; padding-bottom: 12px; }
section { margin: 14px 0 22px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.center { text-align: center; justify-content: center; }
.big { font-size: 22px; font-weight: 600; }
.huge-num { font-size: 72px; font-weight: 800; margin: 20px 0 0; }

/* ---------- Buttons ---------- */
button, select {
  font: inherit; font-weight: 600;
  border: 0; border-radius: 12px;
  padding: 10px 16px; min-height: 48px;
  background: var(--btn); color: var(--ink);
  cursor: pointer;
}
select { padding-right: 10px; max-width: 40%; }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.small { min-height: 38px; padding: 6px 12px; font-size: 15px; }
button.wide { width: 100%; }
button.danger { background: transparent; color: #b91c1c; border: 2px solid currentColor; }
button[aria-pressed="true"] { background: var(--btn-on); color: var(--btn-on-ink); }
button:focus-visible, select:focus-visible { outline: 3px solid var(--anchor); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

/* ---------- Home ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 8px 14px; border-radius: 999px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 18px 0; }
.tile { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; padding: 14px; min-height: 84px; background: var(--panel); border: 1px solid var(--border); }
.tile strong { font-size: 20px; }
.tile span { font-weight: 400; font-size: 14px; color: var(--muted); }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; background: var(--panel); border: 1px solid var(--border); }
.list-item span { font-weight: 400; color: var(--muted); font-size: 15px; text-align: right; }

/* ---------- Chord names and pictures ---------- */
.cname { font-weight: 800; line-height: 1; letter-spacing: -0.02em; white-space: nowrap; }
.cname small { display: block; font-size: 0.28em; font-weight: 600; letter-spacing: 0; color: var(--muted); margin-top: 0.2em; }
.cname.small { font-size: 30px; }
.cname.big { font-size: clamp(44px, 10vmin, 80px); }
.cname.huge { font-size: clamp(64px, min(19vw, 13vh), 160px); }
.pic { flex: 1; align-self: stretch; min-height: 0; min-width: 0; display: flex; justify-content: center; align-items: center; }
.pic svg { width: 100%; height: 100%; overflow: hidden; display: block; }
.pic { overflow: hidden; } /* the drawn hand may reach past the chord drawing, but not past its box */

/* ---------- Practice screens (portrait: chord on top, next + controls below) ---------- */
.drill { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.practice, .chord-page { flex: 1; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.now-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.now { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 0; }
.now .pic { width: 100%; }
.side { display: grid; grid-template-columns: 38% 1fr; grid-template-rows: auto 1fr auto; gap: 6px 12px; }
.beats { display: flex; gap: 8px; justify-content: center; align-items: center; min-height: 26px; }
.beats i { width: 22px; height: 22px; border-radius: 50%; background: var(--btn); }
.beats i.past { background: var(--fret); }
.beats i.on { background: var(--accent); transform: scale(1.25); }
.controls { display: flex; flex-direction: column; gap: 6px; }
.start { font-size: 22px; min-height: 56px; }
.tempo { flex-wrap: nowrap; }
.tempo button { min-width: 52px; font-size: 24px; padding: 4px 0; }
.tempo .num { font-size: 26px; font-weight: 800; min-width: 2.2em; text-align: center; display: inline-block; }
.tempo small { color: var(--muted); font-weight: 400; font-size: 13px; }


/* Flashcards */
.learn { flex: 1; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.count { text-align: center; color: var(--muted); font-weight: 700; }
.card { flex: 1; min-height: 0; display: flex; background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 12px; cursor: pointer; }
.card-front { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0; }
.card-front > .pic { height: 100%; }
.card .cname.huge { font-size: clamp(96px, min(34vw, 22vh), 220px); }
.both { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 0; }
.both .pic { width: 100%; }
.flipbar { height: 8px; border-radius: 4px; background: var(--btn); overflow: hidden; }
.flipbar i { display: block; height: 100%; width: 0; background: var(--accent); }
.answer { display: flex; gap: 10px; }
.answer button { flex: 1; min-height: 64px; font-size: 22px; }

/* Chord book */
.book { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.book-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; height: 150px; background: var(--panel); border: 1px solid var(--border); }
.book-item.mine { border: 3px solid var(--accent); }
.bname { font-size: 20px; font-weight: 800; line-height: 1; }
.bname small { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.book-item .pic { width: 100%; }
.chord-page .side { display: block; }
.chord-page .now-wrap { min-height: 46vh; }

/* Tune */
.strings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 18px; }
.string-btn { display: flex; flex-direction: column; align-items: center; padding: 14px 6px; min-height: 110px; background: var(--panel); border: 1px solid var(--border); }
.string-btn strong { font-size: 48px; line-height: 1; }
.string-btn span { font-size: 14px; font-weight: 400; color: var(--muted); }
.string-btn.on { background: var(--accent); color: var(--accent-ink); }
.string-btn.on span { color: var(--accent-ink); }

/* ---------- Phone on its side (or any wide screen): chord on the left, the rest on the right ---------- */
@media (orientation: landscape) {
  .practice, .chord-page { flex-direction: row; }
  .now { flex-direction: row; align-items: center; }
  .now .cname.huge { min-width: 1.3em; text-align: center; font-size: clamp(64px, min(30vh, 13vw), 180px); }
  .side { width: min(40%, 340px); grid-template-columns: 1fr; grid-template-rows: auto; align-content: start; overflow-y: auto; }
  .chord-page .side { width: min(42%, 380px); }
  .chord-page .now-wrap { min-height: 0; }
  .both { flex-direction: row; }
  .both .cname.big { min-width: 1.4em; text-align: center; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .topbar { min-height: 40px; padding-top: 2px; padding-bottom: 2px; }
  .topbar h1 { font-size: 17px; }
  .icon, .topbar button { min-height: 36px; }
  #screen { padding-top: 0; }
  .start { min-height: 46px; font-size: 19px; }
  .answer button { min-height: 52px; }
}

/* ---------- Redesign 2026-11-22: home with streak, Select chords, Play along setup, Help ---------- */
.row.end { justify-content: flex-end; }
.seg.lang { margin: 0; }
.seg.lang button { min-height: 36px; padding: 4px 12px; font-size: 15px; }
.streak { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px 10px; margin-top: 8px; }
.streak-top { display: flex; align-items: baseline; gap: 10px; }
.streak-num { font-size: 56px; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.streak-label { font-size: 18px; font-weight: 700; }
.streak p { margin: 0 0 4px; }
.tiles.small .tile { min-height: 64px; padding: 10px 14px; }
.tiles.small .tile strong { font-size: 17px; }
.chip.static { display: inline-flex; align-items: center; background: var(--btn); }
.book-item { height: auto; cursor: default; }
.book-pic { width: 100%; height: 112px; padding: 0; background: none; border: 0; min-height: 0; }
.book-sel { width: 100%; min-height: 38px; padding: 4px 6px; font-size: 14px; }
.sticky-foot { padding: 10px 0; border-top: 1px solid var(--border); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.field select { max-width: none; min-width: 120px; color: var(--ink); }
.list-item[aria-pressed="true"] span { color: inherit; opacity: 0.8; }
.help p { font-size: 17px; }
.help-pic { height: 240px; display: flex; max-width: 360px; }
.prog-list .list-item { flex-direction: column; align-items: flex-start; gap: 2px; }
.prog-list .list-item span { text-align: left; }

/* ---------- Fixed picture box shapes (owner's ratios, 2026-11-22) ----------
   Upright: square for both views. On the side: 392 : 277 for the diagram, 366 : 277 for the player's view.
   .shape-room takes the free space; the picture inside is the biggest box of its shape that fits. */
.shape-room { flex: 1; align-self: stretch; min-height: 0; min-width: 0; container-type: size; display: flex; align-items: center; justify-content: center; }
.pic.shaped { --r: 1; flex: none; align-self: center; aspect-ratio: var(--r); width: min(100cqw, 100cqh * var(--r)); height: auto; }
@media (orientation: landscape) {
  .pic.shaped.v-diagram { --r: 1.4152; }
  .pic.shaped.v-player { --r: 1.3213; }
}
/* On the side, the controls column gives the picture its room (hand sheet: controls at least 210 wide). */
@media (orientation: landscape) {
  .practice .side { width: clamp(210px, 26%, 300px); flex: none; }
}
/* Chord page on the side: a narrower text column, so the picture gets its room. */
@media (orientation: landscape) {
  .chord-page .side { width: clamp(220px, 30%, 320px); flex: none; overflow-y: auto; }
}
@media (orientation: landscape) {
  .chord-page .side button { min-height: 40px; padding: 6px 10px; font-size: 15px; }
  .chord-page .side .seg { margin-bottom: 6px; }
  .chord-page .side p { font-size: 15px; margin: 6px 0; }
}
/* Flashcards on the side: count and button in a narrow column on the right, so the card gets the height. */
@media (orientation: landscape) {
  .learn { display: grid; grid-template-columns: 1fr clamp(150px, 22%, 220px); grid-template-rows: auto 1fr auto; gap: 8px 12px; }
  .learn .count { grid-column: 2; grid-row: 1; }
  .learn .card { grid-column: 1; grid-row: 1 / 3; padding: 8px; }
  .learn .flipbar { grid-column: 1; grid-row: 3; }
  .learn .answer { grid-column: 2; grid-row: 2 / 4; align-self: end; }
}

/* Home: My chords is one big button into Select chords. */
.my-chords { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; width: 100%; margin-top: 18px; padding: 12px 14px 14px; text-align: left; font-weight: 400; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; }
.my-chords h2 { margin: 0; }
.my-chords .tap-hint { text-transform: none; letter-spacing: 0; font-weight: 400; }
.my-chords .chip { min-height: 36px; padding: 6px 12px; font-weight: 700; }
.tiles.small.three { grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 0; }
.tiles.small.three .tile { padding: 10px; }

/* ---------- 2026-11-22, owner's test notes ---------- */
/* Language flags */
.seg.lang button { padding: 4px 8px; min-width: 52px; }
.seg.lang button[aria-pressed=false] { opacity: 0.55; }
.flag { display: inline-flex; width: 34px; height: 17px; border-radius: 2px; overflow: hidden; box-shadow: 0 0 0 1px #8885; }
.flag svg { width: 100%; height: 100%; display: block; }

/* (The top-bar Hand button was removed 2026-11-22: the hand is set on the setup screens.) */

/* Chord names in a slot of fixed size: the name never pushes anything around. The slot is 1.4 em wide (the
   longest names get a smaller font inside it) and always has its label line. */
.cname { display: flex; flex-direction: column; align-items: center; flex: none; }
.cname .cn { display: flex; align-items: center; justify-content: center; width: 1.4em; height: 1em; overflow: visible; }
.cname .cn > span { line-height: 1; white-space: nowrap; }
.cname small { display: block; height: 1.25em; line-height: 1.25em; white-space: nowrap; margin-top: 0.2em; }
@media (orientation: landscape) {
  .now .cname.huge, .both .cname.big, .both .cname.huge { min-width: 0; }
}

/* Flashcards: the hidden picture is a question mark in the same box. */
.pic-q { display: flex; align-items: center; justify-content: center; font-size: clamp(64px, 20vmin, 140px); font-weight: 800; color: var(--muted); border: 2px dashed var(--border); border-radius: 12px; }
.both .cname.big { font-size: clamp(44px, 10vmin, 80px); }

/* Flashcard timer menu */
.timer-sel { max-width: none; font-size: 18px; min-height: 44px; padding: 6px 10px; border-radius: 10px; }
.secs-row { flex-direction: row; align-items: center; gap: 8px; }
.secs { width: 5em; font-size: 18px; min-height: 44px; padding: 6px 10px; border-radius: 10px; }
/* Play along on the side: no room for the ring line (Help explains the ring). */

/* Language buttons with flag and name (Settings) */
.seg.lang.with-text button { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; min-height: 44px; font-size: 16px; }
.seg.lang.with-text button[aria-pressed=false] { opacity: 1; }
.seg.lang.with-text button[aria-pressed=false] .flag { opacity: 0.6; }

/* Show hand toggle (chord page, Settings): looks pressed while on */
.hand-toggle[aria-pressed=true] { background: var(--btn-on); color: var(--btn-on-ink); }

/* Chord page: Select under the picture, as in Select chords; the picture leads back to Select chords */
.now .page-sel { flex: none; width: min(220px, 60%); min-height: 44px; font-size: 16px; }
.pic.go-back { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.show-row { align-items: center; gap: 8px; }
.chord-page .side .row { margin-bottom: 6px; }

/* Home tiles without subtitles */
.tiles.small.three .tile { min-height: 52px; justify-content: center; }
.pic-col { flex: 1; align-self: stretch; display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 0; min-width: 0; }

/* Settings: picture style and Show hand on one line */
.pics-row { align-items: center; gap: 8px 18px; }
.pics-row .seg { margin: 0; }

/* Chord page: the accent outline when the chord is selected (as in Select chords); a clear one otherwise, so
   nothing moves when it changes. */
.chord-box { border: 3px solid transparent; border-radius: 14px; padding: 6px; }
.chord-box.mine { border-color: var(--accent); }

/* ---------- Play along drill (owner's design, 2026-11-22) ----------
   "Get ready to play" above the big chord (the one for the next strum); below or beside it: the beat dots
   counting down to that strum, the chord after it (small), and Stop. No settings here. */
.practice.play .now-wrap { flex-direction: column; gap: 4px; }
.get-ready { text-align: center; font-size: 22px; font-weight: 700; color: var(--muted); line-height: 1.2; }
.play-side { display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "dots dots" "after stop"; gap: 10px 12px; align-items: end; }
.play-side .beats { grid-area: dots; min-height: 30px; }
.play-side .beats i { width: 26px; height: 26px; }
.play-side .after { grid-area: after; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.play-side .after .label { font-size: 13px; color: var(--muted); }
.after-chord { display: flex; align-items: center; gap: 6px; height: 88px; min-width: 0; }
.after-chord .pic { flex: 1; height: 100%; min-width: 0; }
.play-side .start { grid-area: stop; align-self: end; min-height: 64px; font-size: 22px; }
@media (orientation: landscape) {
  .practice.play .play-side { width: clamp(210px, 26%, 300px); flex: none; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
  .practice.play .play-side .start { margin-top: auto; }
  .practice.play .after-chord { height: 96px; }
  .get-ready { font-size: 18px; }
}
@media (orientation: landscape) { .practice.play .play-side .start { align-self: stretch; } }
.pics-row { gap: 8px 12px; }
.pics-row .seg button, .pics-row .hand-toggle { padding-left: 12px; padding-right: 12px; }

/* One Practice mode (owner, 2026-11-22): one big button on home; three choices in one row on the setup. */
.tiles.one { grid-template-columns: 1fr; }
.tiles.one .tile { min-height: 88px; align-items: center; justify-content: center; text-align: center; padding: 14px;
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #fff); }
.tiles.one .tile strong { font-size: 26px; }
.seg.kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg.kinds button { padding: 8px 4px; line-height: 1.15; white-space: normal; min-width: 0; font-size: 15px;
  overflow-wrap: anywhere; hyphens: auto; }

/* Streak as a staff (owner, 2026-11-22): today's step in the accent colour, rests red; while the tune plays, the
   note sounding now is lit instead. Tapping the bar or ♪ opens the explanation. */
:root { --rest: #dc2626; }
@media (prefers-color-scheme: dark) { :root { --rest: #f87171; } }
.streak-staff { display: block; max-width: 100%; height: auto; color: var(--ink); }
.streak-staff .lit, .streak-staff .now { color: var(--accent); fill: var(--accent); stroke: var(--accent); }
.streak-staff .rest { color: var(--rest); fill: var(--rest); stroke: var(--rest); }
.streak-staff.playing .lit { color: var(--ink); fill: var(--ink); stroke: var(--ink); }
.streak-staff.playing .now { color: var(--accent); fill: var(--accent); stroke: var(--accent); }
.staff-btn { display: block; width: 100%; background: none; border: 0; padding: 4px 0; margin: 4px 0 2px; min-height: 0;
  border-radius: 8px; color: inherit; text-align: left; cursor: pointer; }
.streak-top .streak-info { margin-left: auto; align-self: center; width: 40px; height: 40px; min-height: 40px; padding: 0;
  border-radius: 50%; font-size: 20px; line-height: 1; }
.streak-info[aria-expanded=true] { background: var(--btn-on); color: var(--btn-on-ink); }
.streak-more { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 10px; }
.streak-more p { margin: 0 0 8px; font-size: 15px; }
.streak-more .play-tune { margin-bottom: 10px; }

/* Start that can't start (owner, 2026-11-23): greyed out, but a tap shows why just above it. */
button.primary.not-ready { opacity: 0.45; }
.why { margin: 4px 0 8px; padding: 10px 12px; border-radius: 10px; background: var(--btn); font-weight: 600; }
.why.flash { animation: why-flash 0.6s ease-out; }
@keyframes why-flash { from { background: var(--accent); color: var(--accent-ink); } }
@media (prefers-reduced-motion: reduce) { .why.flash { animation: none; } }

/* Home: My chords now sits above the small buttons (2026-11-23), so they need a gap. */
.my-chords + .tiles.small { margin-top: 14px; }

/* The three Practice choices stand out (owner, 2026-11-23): the chosen one in the accent colour (like the Practice
   button), the others in a soft yellow. */
:root { --pick: #fdecb4; --pick-ink: #6b3d08; }
@media (prefers-color-scheme: dark) { :root { --pick: #4a3a12; --pick-ink: #fde7a6; } }
.seg.kinds button { background: var(--pick); color: var(--pick-ink); font-weight: 700; }
.seg.kinds button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
