/* Assonance. Silver light-first, graphite ink, and one colour system: every vowel owns a hue.

   Order: fonts, tokens, base, shared controls, header and footer, editor, scheme gutter, sound key,
   rhyme finder, overlays (menu, dialogs, sheets), settings, export, rhyme dictionary, compare,
   command palette, toast, text pages, scrollbars, then one block per screen size and the fallbacks.
   Theme colours (--bg, --ink and friends) are in themes.css, generated from js/themes.js. */

/* ------------------------------------------------------------------ fonts */

/* Bricolage Grotesque, self-hosted (SIL OFL 1.1, see /fonts/OFL.txt) */
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/fonts/bricolage-grotesque-latin-ext-opsz-normal.woff2") format("woff2-variations"), url("/fonts/bricolage-grotesque-latin-ext-opsz-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/fonts/bricolage-grotesque-latin-opsz-normal.woff2") format("woff2-variations"), url("/fonts/bricolage-grotesque-latin-opsz-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/* ----------------------------------------------------------------- tokens */

:root {
  --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  --scale: 1;
  --lh: 1.55;
  --lyric: calc(clamp(22px, 2.9vw, 38px) * var(--scale));
  --r-pill: 999px; /* scrollbar thumbs only */
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  /* one shape everywhere, taken from the wordmark: corners about 18% of the height */
  --r-button: var(--r-sm); /* buttons and the toast, about 36px tall */
  --r-chip: 6px; /* chips, toggle options, tabs, small icon buttons */
  --r-track: calc(var(--r-chip) + 3px); /* a toggle's track: concentric with its 3px-inset options */
  --chain-shade: rgba(0, 0, 0, 0.28); /* the bar under chained syllables (exports use the same) */
  --field-bg: color-mix(in srgb, var(--bg) 70%, transparent);
  --field-border: color-mix(in srgb, var(--ink) 30%, transparent); /* 3:1 against the panel */
  --scroll-thumb: color-mix(in srgb, var(--ink) 22%, transparent);
}

/* ------------------------------------------------------------------- base */

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* wins over any display a component sets */

/* the root carries the background (JS keeps it matched to the shader's top edge); body stays transparent
   so the fixed canvas at z-index -1 is never painted over */
html { -webkit-text-size-adjust: 100%; background-color: var(--bg); transition: background-color 0.6s; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: transparent;
  color: var(--ink);
  font: 450 15px/1.5 var(--font);
  transition: background-color 0.4s, color 0.4s;
}

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

#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.9s ease;
}
#bg.ready { opacity: 1; }

/* text for screen readers only */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

h2 { margin: 0; font: 650 22px/1.2 var(--font); letter-spacing: -0.02em; }
h3 { margin: 0 0 8px; font: 650 16px/1.3 var(--font); }

/* --------------------------------------------------------- shared controls */

button { font: inherit; }

.ghost, .solid {
  border: 0;
  border-radius: var(--r-button);
  padding: 8px 14px;
  font-weight: 520;
  cursor: pointer;
  transition: background-color 0.18s, transform 0.18s, opacity 0.18s;
}
.ghost { background: transparent; color: var(--ink); }
.ghost:hover { background: color-mix(in srgb, var(--ink) 9%, transparent); }
.solid { background: var(--ink); color: var(--on-ink); }
.solid:hover { opacity: 0.86; }
.solid:active, .ghost:active { transform: scale(0.97); }
.ghost.small, .solid.small { padding: 6px 12px; }
.ghost.icon { display: inline-grid; place-items: center; align-self: stretch; padding-inline: 9px; }
.ghost.icon svg { display: block; }
/* a small square button with only an icon; it always carries an aria-label */
.icon-btn {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: var(--r-chip); background: transparent; color: var(--muted); cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--glass); color: var(--ink); }
.danger { color: var(--danger); }
/* Drafts while saving fails: a dot, with the reason in its title */
#btn-drafts[data-unsaved]::after {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%;
  background: var(--danger); vertical-align: 2px;
}

/* one look for every text field and select; components only change size and type */
input[type="text"], input[type="search"], input[type="number"], select, textarea:not(.type) {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--field-border);
  border-radius: var(--r-button);
  background-color: var(--field-bg);
  color: var(--ink);
  min-width: 0;
}
input::placeholder { color: var(--muted); }
/* selects: a quiet custom arrow */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
input[type="color"] { width: 38px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-button); background: transparent; cursor: pointer; }

/* range sliders: thin ink track, round thumb, instead of the browser default */
input[type="range"] { appearance: none; -webkit-appearance: none; width: 150px; height: 22px; background: transparent; accent-color: var(--ink); }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--ink) 18%, transparent); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--ink) 18%, transparent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px var(--bg); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px var(--bg); }
output { min-width: 3ch; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

input[type="checkbox"][role="switch"] {
  appearance: none;
  flex: none;
  width: 40px;
  height: 24px;
  margin: 0;
  border-radius: var(--r-chip);
  background: color-mix(in srgb, var(--ink) 20%, transparent);
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s;
}
input[type="checkbox"][role="switch"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: calc(var(--r-chip) - 3px);
  background: var(--bg);
  transition: transform 0.2s;
}
input[type="checkbox"][role="switch"]:not(:checked) { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 45%, transparent); }
input[type="checkbox"][role="switch"]:checked { background: var(--ink); }
input[type="checkbox"][role="switch"]:checked::after { transform: translateX(16px); }

/* pick-one controls: a pill track with the chosen option filled */
.seg { display: inline-flex; padding: 3px; border-radius: var(--r-track); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.seg.wrap { flex-wrap: wrap; }
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 6px 12px; border-radius: var(--r-chip); font-size: 14px; font-weight: 500; white-space: nowrap; transition: background-color 0.18s, color 0.18s; }
.seg input:checked + span { background: var(--ink); color: var(--on-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

kbd { font: 560 12px/1 var(--font); padding: 4px 6px; border-radius: 6px; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); white-space: nowrap; }

/* small round "remove" buttons in lists (your words, word fixes) */
.remove { border: 0; background: transparent; color: var(--muted); cursor: pointer; min-width: 28px; min-height: 28px; border-radius: var(--r-chip); font-size: 18px; line-height: 1; }
.remove:hover { color: var(--ink); }

/* ------------------------------------------------------------------ header */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 20px max(var(--gutter), env(safe-area-inset-left));
}

.brand { margin: 0; font-size: inherit; font-weight: inherit; }

.wordmark {
  font: 650 28px/1 var(--font);
  letter-spacing: -0.025em;
  color: var(--on-fill);
  text-decoration: none;
  padding: 4px 0;
}
/* the default palette's colours for the wordmark's sounds; the editor recolours it with the user's palette */
.wordmark [data-wm="AE"] { --c: #d5d55f; }
.wordmark [data-wm="AH"] { --c: #ddac37; }
.wordmark .chain { box-shadow: 0 0 0 0.06em var(--fill), inset 0 -0.1em 0 var(--chain-shade); }

.actions { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }

.noscript { position: fixed; inset: auto 16px 16px; padding: 12px 16px; border-radius: var(--r-md); background: var(--ink); color: var(--on-ink); }

/* ------------------------------------------------------------------ editor */

.stage {
  flex: 1 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 248px;
  gap: clamp(24px, 5vw, 72px);
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px max(var(--gutter), env(safe-area-inset-right)) 96px max(var(--gutter), env(safe-area-inset-left));
}

/* no focus decoration on the editor: the caret is the cue */
.field { position: relative; isolation: isolate; --gutter-w: 0px; }

/* The textarea and the colour layer must wrap identically, so they share every text rule. */
.type {
  margin: 0;
  padding: 0;
  border: 0;
  width: 100%;
  font: 600 var(--lyric) / var(--lh) var(--font);
  letter-spacing: 0;
  font-kerning: none;
  font-variant-ligatures: none;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  tab-size: 4;
  text-align: left;
}
.field .type { padding-left: var(--gutter-w); }

#layer {
  min-height: 62vh;
  color: var(--ink);
  pointer-events: none;
  user-select: none;
}

#text {
  position: absolute;
  inset: 0;
  height: 100%;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--ink);
  outline: none;
}
#text::placeholder { color: var(--muted); -webkit-text-fill-color: var(--muted); opacity: 0.8; }
#text::selection { background: color-mix(in srgb, var(--focus) 32%, transparent); -webkit-text-fill-color: transparent; }

/* a coloured syllable */
.s {
  --mix: var(--m1);
  --fill: color-mix(in srgb, var(--c) var(--mix), transparent);
  font-style: normal;
  color: var(--on-fill);
  background-image: linear-gradient(var(--fill), var(--fill));
  background-repeat: no-repeat;
  background-size: 100% 100%;
  box-shadow: 0 0 0 0.06em var(--fill);
  border-radius: 0.22em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: opacity 0.2s, filter 0.2s;
}
.s[data-s="2"] { --mix: var(--m2); }
.s[data-s="3"], .s[data-s="4"] { --mix: var(--m3); }
/* a sound pinned or hovered in the key dims the others */
.s.dim { opacity: 0.2; filter: saturate(0.4); }

/* Name the sounds: a small tag with the sound's name on each coloured syllable's top edge */
#surface[data-labels="on"] .s[data-say] { position: relative; }
#surface[data-labels="on"] .s[data-say]::before {
  content: attr(data-say);
  position: absolute; left: 0.08em; top: -0.42em;
  padding: 0.12em 0.3em; border-radius: 0.5em;
  font-size: 0.34em; font-weight: 700; line-height: 1; letter-spacing: 0.02em; white-space: nowrap;
  background: var(--c); color: var(--on-fill); box-shadow: 0 0 0 0.12em var(--bg);
  pointer-events: none;
}

/* show only line endings, or only what rhymes inside lines */
#surface[data-show="end"] .s:not([data-end]),
#surface[data-show="internal"] .s[data-end] { opacity: 0.16; filter: saturate(0.3); }

/* your words */
.pin {
  text-decoration: underline;
  text-decoration-color: var(--pin);
  text-decoration-thickness: 0.11em;
  text-underline-offset: 0.2em;
  text-decoration-skip-ink: none;
}

/* highlight styles */
#surface[data-style="underline"] .s {
  background-image: linear-gradient(var(--c), var(--c));
  background-size: 100% 0.15em;
  background-position: 0 94%;
  box-shadow: none;
  border-radius: 0;
  color: inherit;
}
#surface[data-style="underline"][data-chains="on"] .s[data-s="2"] { background-size: 100% 0.24em; }
#surface[data-style="underline"][data-chains="on"] .s[data-s="3"],
#surface[data-style="underline"][data-chains="on"] .s[data-s="4"] { background-size: 100% 0.34em; }

#surface[data-style="text"] .s {
  background: none;
  box-shadow: none;
  color: color-mix(in oklab, var(--c) var(--text-mix), var(--ink));
}
#surface[data-style="outline"] .s {
  background: none;
  box-shadow: inset 0 0 0 0.07em var(--c);
  color: inherit;
}
#surface[data-style="text"][data-chains="on"] .s[data-s="2"],
#surface[data-style="outline"][data-chains="on"] .s[data-s="2"] { box-shadow: inset 0 -0.09em 0 var(--c); }
#surface[data-style="text"][data-chains="on"] .s[data-s="3"],
#surface[data-style="text"][data-chains="on"] .s[data-s="4"],
#surface[data-style="outline"][data-chains="on"] .s[data-s="3"],
#surface[data-style="outline"][data-chains="on"] .s[data-s="4"] { box-shadow: inset 0 -0.16em 0 var(--c); }
#surface[data-style="outline"][data-chains="on"] .s[data-s="2"] { box-shadow: inset 0 0 0 0.07em var(--c), inset 0 -0.09em 0 var(--c); }
#surface[data-style="outline"][data-chains="on"] .s[data-s="3"],
#surface[data-style="outline"][data-chains="on"] .s[data-s="4"] { box-shadow: inset 0 0 0 0.07em var(--c), inset 0 -0.16em 0 var(--c); }

#surface[data-style="fill"][data-chains="on"] .s[data-s="2"] { box-shadow: 0 0 0 0.06em var(--fill), inset 0 -0.09em 0 var(--chain-shade); }
#surface[data-style="fill"][data-chains="on"] .s[data-s="3"],
#surface[data-style="fill"][data-chains="on"] .s[data-s="4"] { box-shadow: 0 0 0 0.06em var(--fill), inset 0 -0.16em 0 var(--chain-shade); }

/* the one orchestrated moment: highlights sweep in like a marker pen after a paste or sample */
@keyframes wipe {
  from { background-size: 0% 100%; box-shadow: 0 0 0 0 transparent; color: var(--ink); }
}
@keyframes fade { from { opacity: 0.15; } }
#layer.bloom .s {
  animation: wipe 0.75s cubic-bezier(0.22, 0.9, 0.3, 1) both;
  animation-delay: calc(min(var(--i, 0), 90) * 16ms);
}
#surface:not([data-style="fill"]) #layer.bloom .s {
  animation-name: fade;
}

/* ------------------------------------------------------------ scheme gutter */

/* rhyme scheme letters sit in a gutter; both layers get the same padding so the text still lines up */
.field.with-scheme { --gutter-w: 34px; }
.scheme { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.scheme b {
  position: absolute;
  left: 0;
  /* scaled with the lyrics, within limits */
  width: calc(var(--lyric) * 0.62);
  height: calc(var(--lyric) * 0.62);
  min-width: 16px;
  min-height: 16px;
  max-width: 24px;
  max-height: 24px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  font: 650 clamp(10px, calc(var(--lyric) * 0.36), 13px)/1 var(--font);
  color: var(--on-fill);
  background: color-mix(in srgb, var(--c) var(--badge), transparent);
  transition: top 0.15s ease;
}
.scheme b.solo { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 18%, transparent); }

/* --------------------------------------------------------------- sound key */

.key {
  position: sticky;
  top: 20px;
  align-self: start;
  padding: 8px;
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.key-sounds { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.key-sounds button[data-v] {
  position: relative; /* contains the screen-reader-only text */
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.18s;
}
.key-sounds button[data-v]:hover, .key-sounds button[aria-pressed="true"] { background: var(--glass); }
.key-sounds .sw { width: 22px; height: 22px; border-radius: 7px; background: var(--c); }
.key-sounds .txt { min-width: 0; }
.key-sounds .name { font-weight: 620; line-height: 1.2; }
.key-sounds .ex { display: block; color: var(--muted); font-size: 13px; font-weight: 450; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-sounds .n { color: var(--muted); font-variant-numeric: tabular-nums; }

/* the six strongest sounds show on wide screens; the rest are one click away */
.key-more { display: none; }
.key-more button { display: inline-block; width: auto; border: 0; background: none; padding: 6px 9px 6px 41px; /* lines up with the sound names */ color: var(--muted); font: 520 13px/1.2 var(--font); cursor: pointer; border-radius: var(--r-sm); }
.key-more button:hover { color: var(--ink); background: var(--glass); }

/* the stats line, with the beat grid's button at its end */
.key-foot { display: flex; align-items: flex-start; gap: 6px; margin: 14px 4px 0 9px; }
.stats { flex: 1; min-width: 0; margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.key-foot .icon-btn { margin-top: -5px; }
.key.blank :is(#btn-beat, #btn-stats) { display: none; }
/* the credits and privacy link, behind an icon in the bottom right corner of the window;
   opening it grows a one-line bar out to the left of the icon, which stays where it is */
.about {
  position: fixed;
  right: calc(max(12px, env(safe-area-inset-right)) - 5px); /* less the padding and border, so the icon sits 12px in */
  bottom: calc(12px + env(safe-area-inset-bottom) - 5px);
  z-index: 2;
  display: flex;
  align-items: center;
  max-width: calc(100vw - 14px);
  padding: 4px;
  border: 1px solid transparent;
  border-radius: var(--r-button);
  color: var(--muted);
  font-size: 13.5px;
  transition: background-color 0.22s, border-color 0.22s;
}
.about.open {
  border-color: var(--line);
  background: var(--panel);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
}
.about-text { display: grid; grid-template-columns: 0fr; justify-content: end; visibility: hidden; transition: grid-template-columns 0.22s ease, visibility 0s 0.22s; }
.about.open .about-text { grid-template-columns: 1fr; visibility: visible; transition: grid-template-columns 0.22s ease, visibility 0s; }
/* the text is pinned to the icon's side, so the bar's left edge moves away from the icon and uncovers it */
.about-text p { display: flex; justify-content: flex-end; min-width: 0; overflow: hidden; margin: 0; white-space: nowrap; }
.about-line { flex: none; padding: 0 8px 0 10px; } /* inside the clip, so a closed bar is only the icon */
.about a { color: var(--ink); }
.about-dot { margin: 0 8px; }
.about.open .icon-btn { color: var(--ink); }
@media (max-width: 480px) { .about-pre { display: none; } } /* one line on a phone: the dictionary's name says enough */
@media (prefers-reduced-motion: reduce) { .about, .about-text, .about.open .about-text { transition: none; } }
.empty-key { margin: 0 9px; padding: 6px 0; color: var(--muted); }

/* the sound variety tip: the sound most lines end on, and sounds to try instead */
.variety { margin: 10px 9px 0; font-size: 13.5px; line-height: 1.75; }
.variety button {
  position: relative; /* contains the screen-reader-only text */
  display: inline-flex; align-items: center; gap: 5px; vertical-align: baseline;
  border: 0; border-radius: var(--r-chip); padding: 0 7px 0 5px;
  background: var(--glass); color: inherit; font: 620 13px/1.6 var(--font); cursor: pointer;
  transition: background-color 0.15s;
}
.variety button:hover, .variety button[aria-pressed="true"] { background: color-mix(in srgb, var(--ink) 14%, transparent); }
.variety .sw { width: 11px; height: 11px; border-radius: 4px; background: var(--c); }
.empty-key .ghost { margin-left: 4px; padding: 4px 10px; }

/* ------------------------------------------------------------ song sections */

.sections { margin: 12px 0 0; padding: 12px 9px 2px; border-top: 1px solid var(--line); }
.sections-list { list-style: none; margin: 6px -6px 0; padding: 0; display: grid; gap: 1px; }
.sections-list button {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px; width: 100%;
  border: 0; border-radius: var(--r-chip); padding: 5px 6px; background: transparent; color: var(--ink);
  font: 560 14px/1.3 var(--font); text-align: left; cursor: pointer; transition: background-color 0.15s;
}
.sections-list button:hover { background: var(--glass); }
.sec-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-meta { flex: none; color: var(--muted); font-size: 12.5px; font-weight: 450; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- rhyme finder */

.finder { margin: 12px 0 0; padding: 12px 9px 2px; border-top: 1px solid var(--line); }
.finder-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.finder-title { margin: 0; font: 650 15px/1.2 var(--font); }
.finder-sound { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.finder-sound i { width: 11px; height: 11px; border-radius: 4px; background: var(--c); }
.finder-fix { border: 0; background: none; min-height: 24px; padding: 4px 6px; border-radius: var(--r-sm); color: var(--muted); font: 500 12.5px/1.2 var(--font); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.finder-fix:hover { color: var(--ink); }
.finder-more { margin-left: auto; padding: 4px 10px; font-size: 13px; }
.finder-form { margin: 8px 0 2px; }
.finder-form input { width: 100%; font: 500 14px/1.3 var(--font); padding: 6px 11px; }
.finder-results h3 { margin: 10px 0 5px; font: 520 12px/1.3 var(--font); color: var(--muted); }
.finder-results .help { margin: 6px 0; }
.finder-results .chips { display: flex; flex-wrap: wrap; gap: 3px; }
.finder-results .chips button {
  border: 0; border-radius: var(--r-chip); padding: 3px 9px; min-height: 26px;
  background: var(--glass); color: inherit; font: 520 13px/1.2 var(--font); cursor: pointer;
  transition: background-color 0.15s;
}
.finder-results .chips button:hover { background: color-mix(in srgb, var(--ink) 12%, transparent); }

/* the Stats panel under Rhymes: score ring and rank, three meters, a bar per line */
.scorecard {
  display: grid; grid-template-rows: 0fr; margin: 0; border-top: 1px solid transparent;
  opacity: 0; transform: translateY(-8px); visibility: hidden;
  transition: grid-template-rows 0.34s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.22s ease, transform 0.34s cubic-bezier(0.2, 0.8, 0.2, 1), margin 0.34s ease, border-color 0.34s ease, visibility 0s 0.34s;
}
.scorecard[data-open="true"] {
  grid-template-rows: 1fr; margin-top: 12px; border-top-color: var(--line); opacity: 1; transform: none; visibility: visible;
  transition-delay: 0s;
}
.sc-clip { min-height: 0; overflow: hidden; }
.sc-inner { padding: 12px 9px 4px; }
#btn-stats[aria-expanded="true"] { background: var(--glass); color: var(--ink); }
.sc-enter .sc-arc { animation: sc-ring 0.9s 0.12s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.sc-enter .sc-bar i { animation: sc-fill 0.7s 0.18s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.sc-enter .sc-meters li:nth-child(2) .sc-bar i { animation-delay: 0.26s; }
.sc-enter .sc-meters li:nth-child(3) .sc-bar i { animation-delay: 0.34s; }
.sc-enter .sc-lines rect { transform-box: fill-box; transform-origin: bottom; animation: sc-rise 0.45s calc(0.3s + var(--i) * 14ms) cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes sc-ring { from { stroke-dasharray: 0 132; } }
@keyframes sc-fill { from { width: 0; } }
@keyframes sc-rise { from { transform: scaleY(0); } }
.sc-top { display: flex; align-items: center; gap: 12px; margin: 10px 0 12px; }
.sc-dial { position: relative; width: 50px; height: 50px; flex: none; }
.sc-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.sc-ring circle { fill: none; stroke-width: 4.5; }
.sc-track { stroke: color-mix(in srgb, var(--ink) 10%, transparent); }
.sc-arc { stroke: var(--c); stroke-linecap: round; transition: stroke-dasharray 0.5s ease; }
.sc-score { position: absolute; inset: 0; display: grid; place-items: center; font: 680 16px/1 var(--font); font-variant-numeric: tabular-nums; }
.sc-rank { display: grid; gap: 2px; min-width: 0; }
.sc-name { font: 650 17px/1.15 var(--font); letter-spacing: -0.01em; }
.sc-place { color: var(--muted); font-size: 13px; line-height: 1.3; }
.sc-meters { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.sc-meters li { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; font-size: 13px; line-height: 1.2; }
.sc-label { color: var(--muted); }
.sc-pct { font-weight: 620; font-variant-numeric: tabular-nums; }
.sc-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 10%, transparent); overflow: hidden; }
.sc-bar i { display: block; height: 100%; border-radius: inherit; background: var(--c); transition: width 0.5s ease; }
.sc-lines { margin: 14px 0 0; }
.sc-lines svg { display: block; width: 100%; height: 34px; }
.sc-lines rect.off { fill: color-mix(in srgb, var(--ink) 18%, transparent); }
.sc-lines figcaption { margin-top: 5px; color: var(--muted); font-size: 12px; }
@media (prefers-reduced-motion: reduce) {
  .scorecard, .sc-arc, .sc-bar i { transition: none; }
  .sc-enter :is(.sc-arc, .sc-bar i, .sc-lines rect) { animation: none; }
}

/* phones: a chip at the front of the key bar opens the finder in a sheet */
.rhymes-li { display: none; }
.rhymes-chip { display: inline-block; border: 0; border-radius: var(--r-button); padding: 6px 12px; min-height: 36px; background: var(--ink); color: var(--on-ink); font: 520 14px/1.2 var(--font); white-space: nowrap; cursor: pointer; }
.rhymes-chip b { font-weight: 650; display: inline-block; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.rhymes-sheet .finder { margin: 0; padding: 0; border: 0; }
.rhymes-sheet .finder-head .finder-title { display: none; }
.rhymes-sheet .finder-results .chips { gap: 4px; }
.rhymes-sheet .finder-results .chips button { padding: 6px 12px; min-height: 34px; font-size: 15px; }
.rhymes-sheet .finder-form input { font-size: 16px; } /* no iOS zoom */

/* --------------------------------------------------------------- overlays */

/* the Drafts menu */
.menu {
  position: fixed;
  max-height: calc(100dvh - 120px);
  overflow: auto;
  inset: 64px auto auto max(var(--gutter), 12px);
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  min-width: 290px;
  max-width: min(360px, calc(100vw - 24px));
}
.menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; font-weight: 500; }
.menu button:hover, .menu button:focus-visible { background: var(--glass); }
.menu-label { margin: 8px 12px 4px; color: var(--muted); font-size: 12.5px; font-weight: 520; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.draft-list { list-style: none; margin: 0; padding: 0; max-height: 40vh; overflow: auto; }
.draft { display: flex; align-items: center; border-radius: 10px; }
.draft:hover, .draft:focus-within { background: var(--glass); }
.menu .draft button[data-draft] { flex: 1; min-width: 0; display: grid; gap: 1px; background: transparent; }
.menu .draft button[data-draft]:hover { background: transparent; }
.draft .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 560; }
.draft .when { color: var(--muted); font-size: 12px; font-weight: 450; }
.draft.here .t::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--ink); vertical-align: 1px; }
.menu .draft .del { width: auto; flex: none; padding: 6px 10px; color: var(--muted); font-size: 18px; line-height: 1; opacity: 0; transition: opacity 0.15s; }
.draft:hover .del, .draft:focus-within .del, .menu .draft .del:focus-visible { opacity: 1; }
@media (hover: none) { .menu .draft .del { opacity: 0.7; } }

dialog {
  color: var(--ink);
  background: var(--panel);
  backdrop-filter: blur(26px) saturate(1.3);
  -webkit-backdrop-filter: blur(26px) saturate(1.3);
  border: 1px solid var(--line);
  padding: 0;
}
dialog::backdrop { background: rgba(10, 10, 14, 0.22); transition: opacity 0.25s; }

/* side sheets (settings, phone rhymes) */
.sheet {
  margin: 0 0 0 auto;
  height: 100dvh;
  max-height: none;
  width: min(420px, 100vw);
  max-width: none;
  border-width: 0 0 0 1px;
  padding: 0 24px 40px;
  overflow: auto;
  transform: translateX(28px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.22, 0.9, 0.3, 1), opacity 0.25s, overlay 0.3s allow-discrete, display 0.3s allow-discrete;
}
.sheet[open] { transform: none; opacity: 1; }
@starting-style { .sheet[open] { transform: translateX(28px); opacity: 0; } }

/* centred dialogs (export, rhyme dictionary, compare) */
.modal {
  width: min(1060px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  margin: auto;
  padding: 0 24px 24px;
  border-radius: 22px;
  overflow: auto;
  opacity: 0;
  transform: translateY(14px) scale(0.985);
  transition: transform 0.3s cubic-bezier(0.22, 0.9, 0.3, 1), opacity 0.25s, overlay 0.3s allow-discrete, display 0.3s allow-discrete;
}
.modal[open] { opacity: 1; transform: none; }
@starting-style { .modal[open] { opacity: 0; transform: translateY(14px) scale(0.985); } }

/* dialog headers stay reachable while the body scrolls, clear of the notch */
.sheet-head, .modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 0 10px;
  margin: 0;
  background: var(--panel);
  background: rgb(from var(--panel) r g b / 1); /* the panel colour made opaque, so nothing scrolls through behind it */
}

/* ---------------------------------------------------------------- settings */

.group { padding: 14px 0 6px; border-top: 1px solid var(--line); }
.group:first-of-type { border-top: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 7px 0; }
.row.stack { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 8px; } /* wrapping a column makes grids inside size as one long column */
.label { font-weight: 520; }
.help { margin: 0 0 6px; color: var(--muted); font-size: 13.5px; line-height: 1.45; max-width: 36ch; }
.help a { color: inherit; }
.help.warn { color: inherit; font-weight: 520; }
.help.warn:empty { display: none; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px -14px 0; }

/* theme picker: small live previews, a few to a row */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; margin-top: 6px; }
.theme { position: relative; }
.theme input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.theme span { display: grid; gap: 5px; padding: 4px 4px 5px; border-radius: var(--r-md); border: 1.5px solid transparent; font-size: 12.5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme i {
  position: relative; display: block; height: 36px; border-radius: var(--r-sm);
  background: radial-gradient(circle at 18% 15%, var(--t1), transparent 65%), radial-gradient(circle at 90% 95%, var(--t2), transparent 70%), var(--tb);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 14%, transparent);
}
.theme i::before { content: "Aa"; position: absolute; left: 8px; bottom: 6px; font: 650 14px/1 var(--font); font-style: normal; color: var(--ti); }
.theme i::after { content: ""; position: absolute; right: 8px; bottom: 8px; width: 20px; height: 9px; border-radius: 3px; background: var(--tc); }
.theme input:checked + span { border-color: var(--ink); }
.theme input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.theme:hover i { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 30%, transparent); }

/* colour palettes */
.palettes { display: grid; grid-template-columns: repeat(2, auto); gap: 4px 8px; justify-content: end; }
.pal { position: relative; }
.pal input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.pal span { display: grid; gap: 4px; padding: 6px; border-radius: var(--r-md); font-size: 12.5px; text-align: center; border: 1.5px solid transparent; }
.pal i { display: flex; height: 14px; border-radius: 5px; overflow: hidden; width: 64px; }
.pal i b { flex: 1; }
.pal input:checked + span { border-color: var(--ink); }
.pal input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* your words */
.pin-form { display: flex; gap: 8px; align-items: center; }
.pin-form input[type="text"] { flex: 1; }
.pins { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pins li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: var(--r-chip); background: var(--glass); box-shadow: inset 0 -3px 0 var(--pin); }

/* how words sound */
.pron-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: 8px; align-items: center; }
.pron-preview { min-height: 1.45em; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.pron-preview i { width: 11px; height: 11px; border-radius: 4px; background: var(--c); }
.pron-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.pron-list li { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: var(--r-md); background: var(--glass); }
.pron-list li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pron-list li em { font-style: normal; color: var(--muted); }

/* ------------------------------------------------------------------ export */

.export-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.preview {
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 16px;
  background:
    repeating-conic-gradient(color-mix(in srgb, var(--ink) 7%, transparent) 0% 25%, transparent 0% 50%) 50% / 20px 20px;
}
.preview canvas { display: block; max-width: 100%; max-height: min(68dvh, 760px); width: auto; height: auto; border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18); }
.export-actions { display: flex; gap: 8px; padding-top: 10px; }

.video-progress { display: flex; align-items: center; gap: 10px; padding-top: 10px; }
.video-progress progress { flex: 1; height: 8px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 4px; background: color-mix(in srgb, var(--ink) 12%, transparent); overflow: hidden; }
.video-progress progress::-webkit-progress-bar { background: transparent; }
.video-progress progress::-webkit-progress-value { background: var(--ink); border-radius: 4px; }
.video-progress progress::-moz-progress-bar { background: var(--ink); border-radius: 4px; }
.video-progress span { min-width: 3.5ch; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.embed-actions { flex-direction: column; align-items: stretch; }
.embed-actions > .solid { align-self: flex-start; }
.embed-out { display: grid; gap: 8px; }
.embed-out textarea { width: 100%; font: 12.5px/1.45 ui-monospace, "SF Mono", Menlo, monospace; padding: 10px 12px; resize: vertical; }
#embed-preview { width: 100%; max-width: 640px; height: min(62dvh, 560px); border: 0; border-radius: 16px; background: transparent; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18); }
.embed-placeholder { padding: 40px 16px; text-align: center; }

/* -------------------------------------------------------- rhyme dictionary */

.lex-search { display: grid; gap: 6px; margin: 4px 0 10px; }
.lex-search input { font: 520 20px/1.2 var(--font); padding: 10px 14px; }
.lex-info { margin: 0; color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; min-height: 1.4em; }
.lex-info i { width: 12px; height: 12px; border-radius: 4px; background: var(--c); }
.lex-tabs { display: inline-flex; flex-wrap: wrap; gap: 0; padding: 3px; margin-bottom: 10px; border-radius: var(--r-track); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.lex-tabs button { border: 0; background: transparent; color: inherit; border-radius: var(--r-chip); padding: 6px 12px; font: 500 14px/1.2 var(--font); cursor: pointer; transition: background-color 0.18s, color 0.18s; }
.lex-tabs button span { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 2px; }
.lex-tabs button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.lex-tabs button[aria-pressed="true"] span { color: inherit; opacity: 0.7; }
.lex-tabs button:disabled { opacity: 0.4; cursor: default; }
.lex-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 12px; }
.lex-toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; }
.lex-toggle input[role="switch"] { order: 1; }
.lex-toggle select { padding: 6px 30px 6px 10px; }
.lex-head, .lex-list button { display: grid; grid-template-columns: minmax(0, 1fr) 150px 120px 80px; gap: 12px; align-items: center; }
.lex-head { padding: 0 12px 6px; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line); }
.lex-results { max-height: min(56dvh, 620px); overflow: auto; overscroll-behavior: contain; }
.lex-results > .help { padding: 16px 12px; }
.lex-list { list-style: none; margin: 0; padding: 4px 0; }
.lex-list button { width: 100%; padding: 8px 12px; border: 0; border-radius: 10px; background: transparent; color: inherit; text-align: left; font: inherit; cursor: pointer; }
.lex-list button:hover, .lex-list button:focus-visible { background: var(--glass); }
.lex-w { font: 600 17px/1.25 var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lex-score { display: flex; align-items: center; gap: 8px; }
.lex-score i { flex: 1; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--ink) var(--v), color-mix(in srgb, var(--ink) 12%, transparent) var(--v)); opacity: 0.8; }
.lex-score b { width: 2.4em; text-align: right; font-weight: 520; font-variant-numeric: tabular-nums; }
.lex-meter { color: var(--muted); font-size: 13px; letter-spacing: 0.02em; }
.lex-pop { display: flex; gap: 3px; }
.lex-pop i { width: 8px; height: 8px; border-radius: 2px; background: color-mix(in srgb, var(--ink) 14%, transparent); }
.lex-pop i.on { background: var(--ink); opacity: 0.75; }

/* ----------------------------------------------------------------- compare */

.compare { width: min(900px, calc(100vw - 24px)); }
.cmp-pick { display: grid; gap: 8px; margin-bottom: 14px; }
.cmp-pick select { padding: 8px 30px 8px 10px; max-width: 420px; }
.cmp-pick textarea { font: 500 15px/1.5 var(--font); padding: 10px 12px; resize: vertical; }
.cmp-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cmp-table th, .cmp-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.cmp-table thead th { color: var(--muted); font-size: 12.5px; font-weight: 520; }
.cmp-table tbody th { font-weight: 520; color: var(--muted); width: 34%; }
.cmp-table td { font-weight: 560; }
.cmp-table td.win::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--ink); vertical-align: 2px; }
.cmp-table td.mono { letter-spacing: 0.06em; }
.cmp-table td.none { color: var(--muted); }
.cmp-help { display: block; font-size: 12px; font-weight: 450; color: var(--muted); }
.cmp-previews { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.cmp-prev { white-space: pre-wrap; overflow-wrap: break-word; font: 600 15px/1.6 var(--font); padding: 12px 14px; border-radius: 14px; background: var(--glass); max-height: 320px; overflow: auto; }
.cmp-prev .help { font-weight: 450; }

/* -------------------------------------------------------------------- beat */

.beat { width: min(980px, calc(100vw - 24px)); }
.beat-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 10px; }
.beat-play { min-width: 86px; }
.beat-tempo { display: inline-flex; align-items: center; gap: 6px; }
.beat-tempo input { width: 4.4em; padding: 7px 6px; text-align: center; font-variant-numeric: tabular-nums; appearance: textfield; -moz-appearance: textfield; }
.beat-tempo input::-webkit-inner-spin-button, .beat-tempo input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.beat-tempo .ghost { min-width: 34px; padding: 6px 10px; font-size: 17px; line-height: 1; }
.beat-sounds { display: inline-flex; flex-wrap: wrap; gap: 10px 18px; }
.beat-help { max-width: 72ch; }
.beat-summary { margin: 4px 0 12px; font-weight: 560; }
.beat-summary:empty { display: none; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; --num: 2.4em; }
.bar { padding: 4px 8px 10px; border-radius: var(--r-md); transition: background-color 0.15s; scroll-margin: 80px 0 16px; }
.bar.gap { margin-top: 16px; }
.bar.playing, .bar.start { background: var(--glass); }
.bar-head {
  display: grid; grid-template-columns: var(--num) minmax(0, 1fr) auto; gap: 8px; align-items: baseline;
  width: 100%; padding: 4px 0 6px; border: 0; border-radius: var(--r-sm);
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.bar-head:hover .bar-line { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.bar-n { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.bar-line { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-meta { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding-left: calc(var(--num) + 8px); }
.steps + .steps { margin-top: 6px; }
.bt { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
.st {
  display: grid; place-items: center; min-width: 0; height: 34px;
  border-radius: var(--r-chip); background: color-mix(in srgb, var(--ink) 5%, transparent);
  font: 480 13px/1 var(--font); transition: outline-color 0.08s;
  outline: 2px solid transparent; outline-offset: 2px;
}
.st.onbeat { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.st b { max-width: 100%; padding: 0 2px; overflow: hidden; white-space: nowrap; font-weight: inherit; }
.st.syl { background: color-mix(in srgb, var(--ink) 17%, transparent); }
.st.stressed { font-weight: 700; }
.st.rhyme { background: var(--c); color: var(--on-fill); }
.st.hit { box-shadow: inset 0 0 0 2px var(--ink); } /* a rhyme on the beat */
.st.now { outline-color: var(--ink); }

/* --------------------------------------------------------- command palette */

.cmdk {
  width: min(560px, calc(100vw - 32px));
  margin: 14vh auto auto;
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28), 0 0 0 1px var(--line);
  overflow: hidden;
}
.cmdk::backdrop { background: rgba(10, 10, 14, 0.28); }
.cmdk input[type="text"] { /* outranks the phone font-size rule: 17px never triggers iOS zoom */
  width: 100%;
  padding: 16px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font: 500 17px/1.3 var(--font);
  outline: none;
}
.cmdk ul { list-style: none; margin: 0; padding: 6px; max-height: min(420px, 52vh); overflow: auto; }
.cmdk li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; font-size: 15px; cursor: pointer; }
.cmdk li[aria-selected="true"] { background: color-mix(in srgb, var(--ink) 9%, transparent); }
.cmdk-group { color: var(--muted); font-size: 12.5px; font-weight: 520; min-width: 52px; }
.cmdk-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-none { color: var(--muted); cursor: default; }

/* ------------------------------------------------------------------- toast */

/* a manual popover, so it sits in the top layer above any open dialog */
#toast {
  position: fixed;
  inset: auto auto calc(28px + env(safe-area-inset-bottom)) 50%;
  margin: 0;
  border: 0;
  overflow: visible;
  transform: translate(-50%, 16px);
  padding: 10px 18px;
  border-radius: var(--r-button);
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 520;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { border: 0; border-radius: var(--r-chip); padding: 4px 12px; background: var(--on-ink); color: var(--ink); font-weight: 600; cursor: pointer; }

/* -------------------------------------------------------------- text pages */

/* privacy and 404 */
.doc { max-width: 40rem; margin: 0 auto; padding: 8px var(--gutter) 80px; font-size: 17px; line-height: 1.65; }
.doc h1 { font: 650 40px/1.1 var(--font); letter-spacing: -0.025em; margin: 12px 0 4px; }
.doc h2 { font-size: 20px; margin: 32px 0 6px; }
.doc p, .doc li { max-width: 62ch; }
.doc a:not(.solid) { color: inherit; }
.doc .solid { margin-top: 16px; }
a.solid { display: inline-block; text-decoration: none; }
.lost-main { min-height: 100dvh; display: grid; place-content: center; gap: 8px; padding: 24px; text-align: center; }

/* -------------------------------------------------------------- scrollbars */

/* thin, rounded, ink-tinted scrollbars on everything that scrolls inside the page */
.menu, .draft-list, dialog, .lex-results, .cmp-prev, .cmdk ul {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
:is(.menu, .draft-list, dialog, .lex-results, .cmp-prev, .cmdk ul)::-webkit-scrollbar { width: 10px; height: 10px; }
:is(.menu, .draft-list, dialog, .lex-results, .cmp-prev, .cmdk ul)::-webkit-scrollbar-track,
:is(.menu, .draft-list, dialog, .lex-results, .cmp-prev, .cmdk ul)::-webkit-scrollbar-corner { background: transparent; }
:is(.menu, .draft-list, dialog, .lex-results, .cmp-prev, .cmdk ul)::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--ink) 20%, transparent);
  border-radius: var(--r-pill);
  border: 3px solid transparent; /* inset the thumb so it floats inside its track */
  background-clip: padding-box;
}
:is(.menu, .draft-list, dialog, .lex-results, .cmp-prev, .cmdk ul)::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--ink) 35%, transparent); }

/* ----------------------------------------------------------- screen sizes */

@media (min-width: 861px) {
  .key-more { display: block; }
  .key-sounds:not([data-expanded]) li.extra { display: none; }
}

/* phones and narrow windows: one column, the key becomes a bar under the header */
@media (max-width: 860px) {
  .stage { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-bottom: 40px; }
  /* resting: transparent so the shader shows; docked at the top: frosted glass over the scrolling lyrics */
  .key {
    position: sticky; top: env(safe-area-inset-top); z-index: 2; order: -1;
    margin: 0 calc(var(--gutter) * -1); padding: 8px var(--gutter); border-radius: 0;
    background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
    transition: background-color 0.12s, box-shadow 0.12s;
  }
  .key.stuck {
    background: color-mix(in srgb, var(--bg) 45%, transparent);
    backdrop-filter: blur(22px) saturate(1.5);
    -webkit-backdrop-filter: blur(22px) saturate(1.5);
    box-shadow: 0 1px 0 var(--line);
  }
  /* a blurred strip under the status bar, so scrolled lyrics never show through above the key */
  body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto 0;
    height: env(safe-area-inset-top);
    z-index: 3;
    background: color-mix(in srgb, var(--bg) 45%, transparent);
    backdrop-filter: blur(22px) saturate(1.5);
    -webkit-backdrop-filter: blur(22px) saturate(1.5);
    pointer-events: none;
  }
  .key-sounds { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-right: 24px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
  .key-sounds::-webkit-scrollbar { display: none; }
  .key-sounds li { flex: none; }
  .key-sounds button[data-v] { grid-template-columns: 18px auto auto; padding: 6px 10px; min-height: 36px; background: var(--glass); border-radius: var(--r-button); width: auto; }
  .key-sounds .sw { width: 18px; height: 18px; border-radius: 6px; }
  .key-sounds .ex { max-width: 9ch; }
  .key-sounds .txt { display: flex; gap: 6px; align-items: baseline; }
  .rhymes-li { display: list-item; flex: none; }
  .key-sounds .empty-key { flex: 1 1 auto; min-width: 0; margin: 0 4px; padding: 0; align-self: center; } /* a message wraps instead of scrolling away */
  .key-foot { margin: 6px 0 0 2px; }
  .stats { font-size: 12.5px; }
  .key-foot .icon-btn { margin-top: -6px; }
  .variety { margin: 4px 2px 0; font-size: 12.5px; line-height: 1.7; }
  :is(.scorecard, #btn-stats, .sections) { display: none; } /* desktop only: no room in the docked key bar (the palette goes to sections) */
  #layer { min-height: 50vh; }
  .export-body { grid-template-columns: minmax(0, 1fr); }
  .preview canvas { max-height: 40dvh; }
  .row { flex-wrap: wrap; }
  input[type="range"] { width: 130px; }
  input[type="text"], select, textarea { font-size: 16px; } /* below 16px iOS zooms the page on focus */
}

@media (max-width: 640px) {
  .beat { padding: 0 14px 18px; }
  .bars { --num: 1.8em; }
  .bar { padding: 4px 4px 8px; }
  .steps { gap: 4px; padding-left: 0; }
  .bt { gap: 1px; }
  /* too narrow for syllables: the cells show the pattern, and the line above shows the words */
  .st { height: 26px; border-radius: 4px; }
  .st b { display: none; }
  .st.hit { box-shadow: inset 0 0 0 1.5px var(--ink); }
  .beat-controls { gap: 8px 12px; }
  .cmp-previews { grid-template-columns: 1fr; }
  .cmp-table tbody th { width: 46%; }
}

/* the rhyme dictionary takes the whole screen */
@media (max-width: 600px) {
  .modal.lexicon { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border-width: 0; padding: env(safe-area-inset-top) 16px calc(16px + env(safe-area-inset-bottom)); }
  .modal.lexicon[open] { display: flex; flex-direction: column; }
  .lexicon .lex-results { flex: 1; min-height: 0; max-height: none; }
  .lex-head, .lex-list button { grid-template-columns: minmax(0, 1fr) 84px 76px; }
  .lex-pop, .lex-pop-h { display: none; }
  .lex-score i { display: none; }
  .lex-search input { font-size: 18px; }
}

@media (max-width: 480px) {
  .top { padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: 6px; }
  .actions { gap: 0; margin-inline: -8px; }
  .ghost, .solid { padding: 8px 10px; font-size: 14px; }
  .field.with-scheme { --gutter-w: 28px; }
  .pron-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pron-form button { grid-column: 1 / -1; }
}

@media (pointer: coarse) { .kbd-tip { display: none; } }

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

@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .s { background-image: none; background-color: var(--c); box-shadow: none; }
  #surface[data-style="underline"] .s, #surface[data-style="outline"] .s { background-color: transparent; }
  #surface[data-style="text"] .s { background: none; color: inherit; text-decoration: underline; text-decoration-color: var(--c); text-decoration-thickness: 0.12em; }
  .key { background: var(--bg); }
}
