/* The app's shared look: fonts, tokens, the page frame and the navigation. A page's own
   <style> holds only what is particular to that page. See the 2026-11-01 decisions in
   app_plan.md; the design study is linked there.

   A look is only a set of tokens, on <html data-look>. Paper is the default. Heat and
   piece colours are data and sheet music stays paper, in every look. The --m-* tokens are
   each metric's colour, the same hue as its heatmap ramp in session_view.METRICS. */

@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 500; font-display: swap;
             src: url("/fonts/newsreader.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 400 500; font-display: swap;
             src: url("/fonts/newsreader-italic.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400 600; font-display: swap;
             src: url("/fonts/instrument-sans.woff2") format("woff2"); }

:root, [data-look="paper"] {
  --bg: #F6F1E6; --surface: #FBF8F1; --sheet: #FDFBF6; --ink: #25211B; --muted: #675F50;
  --line: #DFD5C3; --line-strong: #CBBFA9; --hover: #EDE6D7;
  --accent: #1F5A57; --on-accent: #FBF8F1; --accent-soft: #DCE7E1; --danger: #982C1E; --ok: #2E6B45;
  --display: "Newsreader", Georgia, serif; --ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --title-style: italic; --title-weight: 500;
  --h0: #D8CDB7; --h1: #E4B79B; --h2: #D98F71; --h3: #C65A40; --h4: #982C1E;
  --d0: #EBE3D3; --d1: #BCD3CA; --d2: #83AFA5; --d3: #4B8780; --d4: #1F5A57;
  --m-wrong: #C2302A; --m-tempo: #2166AC; --m-rhythm: #A67D00; --m-steady: #762A83; --m-times: #1F8A70;
  color-scheme: only light;  /* "only": forced-dark modes (Samsung Internet) must leave it alone */
}
[data-look="studio"] {
  --bg: #F5F5F3; --surface: #FFFFFF; --sheet: #FFFFFF; --ink: #1C1D1F; --muted: #5F6166;
  --line: #E1E1DE; --line-strong: #C9C9C5; --hover: #ECECE9;
  --accent: #2B54C8; --on-accent: #FFFFFF; --accent-soft: #E3E9FA; --danger: #9C2B22; --ok: #2E6B45;
  --display: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --title-style: normal; --title-weight: 600;
  --h0: #DDDDD9; --h1: #EFBDA9; --h2: #E5917A; --h3: #CE5A45; --h4: #9C2B22;
  --d0: #E9E9E6; --d1: #C3D1F2; --d2: #8FA8E6; --d3: #5479D8; --d4: #2B54C8;
  --m-wrong: #C2302A; --m-tempo: #2166AC; --m-rhythm: #A67D00; --m-steady: #762A83; --m-times: #1F8A70;
  color-scheme: only light;
}
[data-look="evening"] {
  --bg: #1D1B18; --surface: #272420; --sheet: #F4EFE4; --ink: #F0EADD; --muted: #ADA597;
  --line: #3B372F; --line-strong: #544E43; --hover: #322E28;
  --accent: #8CCBBE; --on-accent: #16211F; --accent-soft: #2F3F3B; --danger: #F7A486; --ok: #8CCBA0;
  --display: "Newsreader", Georgia, serif; --ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --title-style: italic; --title-weight: 500;
  --h0: #4A453B; --h1: #7A5442; --h2: #A9634A; --h3: #D8775A; --h4: #F7A486;
  --d0: #2F2B25; --d1: #3C5A54; --d2: #55847A; --d3: #70AA9D; --d4: #8CCBBE;
  --m-wrong: #E0504A; --m-tempo: #3D93DC; --m-rhythm: #A88C10; --m-steady: #B56CE0; --m-times: #25A383;
  color-scheme: dark;
}

:root {
  --fg: var(--ink);                 /* the name every page's rules already use */
  --page-width: 1120px;
  --bar-h: 64px; --tabs-h: 0px;
}
@media (max-width: 640px) {
  :root { --bar-h: 0px; --tabs-h: calc(64px + env(safe-area-inset-bottom, 0px)); }
}

[hidden] { display: none !important; }   /* or any rule that sets display wins over the attribute */

html { background: var(--bg); }
/* Dropdowns in the app's own look, not the browser's (on Android a grey system box).
   The closed control is styled everywhere: our border, corners, colours and a drawn
   chevron. The few properties the chevron needs win over the pages' own select rules,
   which set padding of their own. Where the browser lets the open list be styled too
   (appearance: base-select — recent Chrome and Edge, desktop and Android), it gets the
   app's surface, corners and a soft highlight; elsewhere the system's list stays. */
select:not([multiple]) {
  -webkit-appearance: none; appearance: none;
  color: var(--ink); background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23675F50' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: right 10px center !important; background-size: 11px 8px !important;
  padding-right: 30px !important; cursor: pointer;
}
[data-look="evening"] select:not([multiple]) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23ADA597' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
}
select:not([multiple]):focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@supports (appearance: base-select) {
  select:not([multiple]), ::picker(select) { appearance: base-select; }
  /* In this mode a tall select puts its text at the top; centre it, as the system one did. */
  select:not([multiple]) { align-items: center; }
  select:not([multiple])::picker-icon { display: none; }       /* the drawn chevron stays */
  ::picker(select) { margin-top: 4px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 10px;
                     background: var(--surface); color: var(--ink); box-shadow: 0 10px 28px rgba(40,30,15,.18); }
  select option { padding: 8px 12px; border-radius: 6px; }
  select option:hover, select option:focus-visible { background: var(--hover); }
  select option:checked { background: var(--accent-soft); font-weight: 600; }
  select option::checkmark { display: none; }
}

/* No paragraph ends on a single stranded word. Only the last lines are touched, and a
   browser without it wraps as before. */
p, li, figcaption, .meta, .hint { text-wrap: pretty; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--ui);
       -webkit-font-smoothing: antialiased; }
/* The padding centres the page, so nothing needs a wrapper and a wide window stops being
   empty on the right. */
body.page { box-sizing: border-box; min-height: 100vh;
            padding: calc(var(--bar-h) + 32px) max(24px, calc((100% - var(--page-width)) / 2)) 56px; }
@media (max-width: 640px) {
  body.page { padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(var(--tabs-h) + 24px); }
  /* Score pages give the music the whole screen. */
  body.page.no-tabs { padding: calc(12px + env(safe-area-inset-top, 0px)) 10px calc(24px + env(safe-area-inset-bottom, 0px)); --tabs-h: 0px; }
}

/* For screen readers only. */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* A tab page's heading. On a computer the tab bar sits right above it and already
   names the page, so the heading goes there; on a phone the tabs are at the bottom
   and the page needs its title. */
@media (min-width: 641px) {
  h1.tabhead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
h1 { font-family: var(--display); font-style: var(--title-style); font-weight: var(--title-weight);
     font-size: 30px; line-height: 1.2; letter-spacing: -.005em; margin: 0 0 6px; }
a { color: var(--accent); }
button, input, select, textarea { font-family: var(--ui); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { background: var(--surface); color: var(--ink); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- navigation: a top bar when wide, labelled tabs on a phone ------------------------
   Absolute rather than sticky: the bar scrolls away with the page, so a page's own sticky
   controls keep top: 0 and a score keeps the height. */
.appnav { position: absolute; top: 0; left: 0; right: 0; height: var(--bar-h); z-index: 50;
          box-sizing: border-box; display: flex; align-items: center; gap: 32px;
          padding: 0 max(24px, calc((100% - 1120px) / 2));
          background: var(--surface); border-bottom: 1px solid var(--line); }
.appnav .word { font-family: var(--display); font-style: var(--title-style); font-weight: var(--title-weight);
                font-size: 24px; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-item { display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 8px;
            font-size: 15px; font-weight: 500; color: var(--muted); text-decoration: none; }
.nav-item svg { display: none; }
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--ink); }
@media (max-width: 640px) {
  .appnav { position: fixed; top: auto; bottom: 0; height: var(--tabs-h); padding: 0 0 env(safe-area-inset-bottom, 0px);
            border-bottom: 0; border-top: 1px solid var(--line); gap: 0; }
  .appnav .word { display: none; }
  .nav-links { flex: 1 1 auto; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; height: 100%; }
  .nav-item { flex-direction: column; justify-content: center; gap: 3px; padding: 0; border-radius: 0; font-size: 12px; min-height: 0; }
  .nav-item svg { display: block; width: 24px; height: 24px; }
  .nav-item:hover, .nav-item.active { background: none; }
  .nav-item.active { color: var(--accent); }
  .no-tabs .appnav { display: none; }
}
/* The tabs' glyphs at text size, for naming a destination in prose. Bigger than the
   surrounding text on purpose: at 1em the fine detail reads as a smudge. */
.nav-glyph { display: inline-flex; vertical-align: -.32em; }
.nav-glyph svg { width: 1.45em; height: 1.45em; }

/* One way back from a score: the quicker one, since the Pieces tab doesn't say it leads
   back (and on print.html, which hides the tabs on a phone, the only one). */
.backlink { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; font-size: 14px; color: var(--muted); text-decoration: none; }
.backlink svg { width: 20px; height: 20px; }

/* Pages under one tab. */
.subtabs { display: inline-flex; gap: 4px; max-width: 100%; margin: 0 0 18px; overflow-x: auto; scrollbar-width: none; }
.subtabs a { flex: none; display: flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 20px; font-size: 14px; font-weight: 500;
             color: var(--muted); text-decoration: none; border: 1px solid var(--line); }
.subtabs a.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---- shared pieces --------------------------------------------------------------- */
/* Ribbon: one sliver per bar of the whole piece, by wrong notes over each bar's last 10
   plays. Hollow means never played. */
.ribbon { display: flex; height: 14px; width: 100%; border-radius: 3px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.ribbon i { flex: 1 1 0; min-width: 0; display: block; }
.r0 { background: var(--h0); } .r1 { background: var(--h1); } .r2 { background: var(--h2); }
.r3 { background: var(--h3); } .r4 { background: var(--h4); }
.rrow { display: flex; align-items: center; gap: 8px; }
.rrow .ribbon { flex: 1 1 auto; min-width: 0; }
/* A piece's colour. The ring keeps a pale one visible on Paper and a dark one on Evening. */
.psq { flex: none; width: 14px; height: 14px; border-radius: 3px; background: var(--pc);
       box-shadow: inset 0 0 0 1px rgba(0,0,0,.1), 0 0 0 1px var(--line); }
.legend-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 12.5px; color: var(--muted); }
.ramp { display: inline-flex; width: 72px; height: 9px; border-radius: 2px; overflow: hidden; }
.ramp i { flex: 1; }
.hollow { width: 16px; height: 9px; border-radius: 2px; box-shadow: inset 0 0 0 1px var(--line-strong); margin-left: 8px; }

/* Days: 13 weeks, one square a day, so an empty day is simply part of the pattern. */
.dayswrap { display: flex; gap: 6px; }
.days { flex: 1 1 auto; min-width: 0; display: grid; grid-template-rows: repeat(7, auto); grid-template-columns: repeat(13, minmax(0, 1fr)); grid-auto-flow: column; gap: 4px; }
.days i { display: block; aspect-ratio: 1; border-radius: 3px; }
.d0 { background: var(--d0); } .d1 { background: var(--d1); } .d2 { background: var(--d2); }
.d3 { background: var(--d3); } .d4 { background: var(--d4); } .dn { background: transparent; }
.dlabels { flex: 0 0 28px; display: grid; grid-template-rows: repeat(7, 1fr); gap: 4px; font-size: 11.5px; line-height: 1; color: var(--muted); align-items: center; }
.months { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 4px; font-size: 12px; color: var(--muted); margin-top: 6px; padding-left: 34px; }
.months span { white-space: nowrap; }

.statpair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.bignum { font-family: var(--display); font-size: 32px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sechead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sechead h2 { margin: 0; font-family: var(--display); font-weight: var(--title-weight); font-size: 21px; line-height: 1.25; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.mchip { flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 13px; font: inherit; font-size: 14px; color: var(--muted);
        background: transparent; border: 1px solid var(--line-strong); border-radius: 20px; cursor: pointer; }
.mchip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chips { scrollbar-width: none; }

/* Waking up (waking.js): says the wait is the server's, without blocking anything. */
.wkpill { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 18px); z-index: 1100; transform: translateX(-50%); pointer-events: none;
          display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 16px; font-size: 14px; font-weight: 500; color: var(--ink);
          white-space: nowrap; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 20px; box-shadow: 0 4px 14px rgba(40,30,15,.14); }
.wkkeys { display: inline-flex; align-items: flex-start; gap: 2px; height: 16px; }
.wkkeys i { width: 5px; height: 13px; border-radius: 0 0 2px 2px; background: var(--accent); transform-origin: top; animation: wk-key 1.2s ease-in-out infinite; }
.wkkeys i:nth-child(2) { animation-delay: .15s; }
.wkkeys i:nth-child(3) { animation-delay: .3s; }
/* Unreachable (waking.js): a real problem, so not the quiet pill but a full-width bar in
   the warning colour, like a mail app's "offline" bar. At the bottom, above the phone's
   tabs, so it never covers the navigation. Still blocks nothing. */
.wkpill.wkdown { top: auto; bottom: var(--tabs-h); left: 0; right: 0; transform: none; justify-content: center; flex-wrap: wrap;
                 min-height: 0; padding: 10px 16px; border-radius: 0; border: 0; border-top: 2px solid var(--danger);
                 white-space: normal; text-align: center; pointer-events: auto; z-index: 1150;
                 color: var(--ink); background: color-mix(in srgb, var(--danger) 14%, var(--surface));
                 box-shadow: 0 -2px 10px rgba(40,30,15,.12); }
.wkdown a { color: var(--danger); font-weight: 600; }
/* On the record page it's information, not an error (recording works, the session goes
   up later), so grey. And gone during a session and on its end screen: nothing to act
   on while practising, and the end screen says its own word about the upload. */
.wkdown.wksoft { border-top-color: var(--line-strong); background: var(--hover); }
body.recording .wkdown, body.finishing .wkdown { display: none; }
/* Newer data than the stored copy on screen (waking.js): the quiet pill, with a link. */
.wkpill.wknewer { pointer-events: auto; }
.wknewer a { color: var(--accent); font-weight: 600; }
@keyframes wk-key { 0%, 55%, 100% { transform: scaleY(.72); opacity: .55; } 25% { transform: scaleY(1.2); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .wkkeys i { animation: none; } }

/* Sheet music stays paper in every look, ink included. */
.score-page, .sheet, .stripwrap { background: var(--sheet); --ink: #25211B; --muted: #675F50; color: #25211B; }
.sechead a { font-size: 13px; color: var(--muted); }
