/* Tuner — a backlit needle meter with a strobe band, and a headstock of pegs.
 * One Page Toys tool family, self-contained, theme-aware (light/dark).
 * The instrument itself (the dial unit and the headstock) stays dark in both
 * themes: a backlit meter only reads as backlit against a dark case. */

@import url("https://fonts.googleapis.com/css2?family=Archivo:wght@500;600;700;800;900&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap");

:root{
  --font-display: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ink: #1f1b16;
  --bg: #f5f1ea;
  --surface: #fffdf9;
  --surface-2: #efe9df;
  --muted: #6c645a;
  --line: #e5ddd0;
  --line-strong: #d0c5b4;
  --accent: #9c5a12;
  --accent-soft: rgba(214, 140, 48, 0.16);
  --ok: #2f8a52;
  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow: 0 2px 8px rgba(40, 28, 12, 0.07);
  --shadow-md: 0 8px 22px rgba(40, 28, 12, 0.11);
  --shadow-lg: 0 18px 44px rgba(40, 28, 12, 0.16);
  --glass: rgba(255, 253, 249, 0.76);
  /* the instrument, identical in both themes */
  --case-1: #14110e;
  --case-2: #221c16;
  --case-line: rgba(255, 222, 170, 0.11);
  --cream: #f6e6c4;
  --amber: #ffb347;
  --lamp-red: #ff5b3a;
  --lamp-green: #45e284;
}
:root[data-theme="dark"]{
  --ink: #f1ebe1;
  --bg: #0f0d0b;
  --surface: #1b1814;
  --surface-2: #242019;
  --muted: #a59b8c;
  --line: #2a251f;
  --line-strong: #3d362d;
  --accent: #f0a646;
  --accent-soft: rgba(240, 166, 70, 0.15);
  --ok: #4fd486;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 10px 30px -6px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 20px 50px -10px rgba(0, 0, 0, 0.7);
  --glass: rgba(27, 24, 20, 0.66);
}

*, *::before, *::after{ box-sizing: border-box; }
html, body{ height: 100%; -webkit-tap-highlight-color: transparent; }
body{
  margin: 0; min-height: 100%;
  display: flex; flex-direction: column;
  font-family: var(--font-sans); color: var(--ink);
  /* no-repeat: a body background is painted on the whole canvas, and a repeating
     gradient restarts one viewport down as a visible seam */
  background-color: var(--bg);
  background-image: radial-gradient(60% 44% at 50% 0%, var(--accent-soft), transparent 70%);
  background-repeat: no-repeat;
  overflow-x: hidden; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.sr-only{ position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
button{ font: inherit; -webkit-tap-highlight-color: transparent; }

/* ---------- Top bar ---------- */
.topbar{
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 14px clamp(16px, 4vw, 30px);
  padding-top: max(14px, env(safe-area-inset-top));
  padding-left: max(clamp(16px, 4vw, 30px), env(safe-area-inset-left));
  padding-right: max(clamp(16px, 4vw, 30px), env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand{ display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 0.86rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink); text-decoration: none; }
.brand__mark{ width: 1.1em; height: 1.1em; border: 1.5px solid var(--ink); border-radius: 6px; background: linear-gradient(90deg, var(--ink) 0 50%, var(--surface) 50% 100%); }
.topbar__right{ display: inline-flex; align-items: center; gap: 12px; }
.topbar__tag{ font-family: var(--font-display); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.iconbtn{ appearance: none; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; font-size: 1rem; line-height: 1; border: 1.5px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: var(--shadow); transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease; }
.iconbtn:hover{ transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--ink); }
.iconbtn:focus-visible{ outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px var(--accent-soft); }
.theme-toggle__sun, .theme-toggle__moon, .theme-toggle__auto{ display: none; }
:root[data-theme-mode="system"] .theme-toggle__auto{ display: inline; }
:root[data-theme-mode="light"] .theme-toggle__sun{ display: inline; }
:root[data-theme-mode="dark"] .theme-toggle__moon{ display: inline; }

/* ---------- Stage ---------- */
.stage{
  position: relative; z-index: 2; flex: 1 0 auto;
  display: flex; flex-direction: column; align-items: center;
  gap: 22px;
  padding: clamp(18px, 4vw, 36px) 16px clamp(48px, 6vw, 72px);
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(clamp(48px, 6vw, 72px), env(safe-area-inset-bottom));
}
.tn{ width: 100%; max-width: 560px; text-align: center; }
.eyebrow{ margin: 0 0 4px; font-family: var(--font-display); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.headline{
  margin: 0 0 16px; font-family: var(--font-display); font-weight: 900;
  font-size: clamp(1.7rem, 6.6vw, 2.6rem); line-height: 1.05; letter-spacing: -0.02em; color: var(--ink);
}

/* ---------- Chips (instrument, tuning) ---------- */
.tn-kinds, .tn-tunings{ display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.tn-kinds{ margin-bottom: 16px; }
.tn-chip{
  appearance: none; min-height: 44px; padding: 8px 13px;
  font-family: var(--font-display); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.01em;
  color: var(--muted); background: var(--surface); border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-pill); cursor: pointer; box-shadow: var(--shadow);
  transition: transform 150ms ease, color 150ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.tn-chip:hover{ color: var(--ink); border-color: var(--ink); transform: translateY(-1px); }
.tn-chip[aria-checked="true"]{ color: var(--bg); background: var(--ink); border-color: var(--ink); }
.tn-chip:focus-visible{ outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px var(--accent); }
.tn-chip--sm{ min-height: 44px; padding: 6px 12px; font-size: 0.78rem; }
.tn-chip.is-on{ color: var(--ink); border-color: var(--accent); }

/* ---------- The unit: a dark case with the meter behind glass ---------- */
.tn-unit{
  position: relative; width: 100%;
  padding: 12px clamp(12px, 3.2vw, 20px) 16px;
  border-radius: var(--radius);
  border: 1px solid var(--case-line);
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 190, 110, 0.07), transparent 60%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px),
    linear-gradient(175deg, var(--case-2), var(--case-1) 72%);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 236, 200, 0.08), inset 0 -2px 0 rgba(0, 0, 0, 0.4);
  color: var(--cream);
  overflow: hidden;
  isolation: isolate;
}
.tn-unit__top{ display: flex; align-items: center; justify-content: space-between; min-height: 30px; margin-bottom: 8px; padding: 0 2px; }
.tn-plate{
  margin-left: auto;
  font-family: var(--font-display); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(246, 230, 196, 0.42);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.6);
}
.tn-live{
  appearance: none; display: inline-flex; align-items: center; gap: 8px;
  min-height: 32px; padding: 4px 10px 4px 9px; border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 222, 170, 0.16); background: rgba(0, 0, 0, 0.28);
  color: rgba(246, 230, 196, 0.8); font-family: var(--font-display); font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.tn-live:hover{ border-color: rgba(255, 222, 170, 0.4); }
.tn-live:focus-visible{ outline: 2px solid var(--amber); outline-offset: 2px; }
.tn-live[hidden]{ display: none; }
.tn-live__dot{ width: 8px; height: 8px; border-radius: 50%; background: var(--lamp-red); box-shadow: 0 0 8px var(--lamp-red); animation: tn-pulse 1.6s ease-in-out infinite; }
.tn-live.is-paused .tn-live__dot{ background: #6b5a48; box-shadow: none; animation: none; }
@keyframes tn-pulse{ 0%, 100%{ opacity: 1; } 50%{ opacity: 0.35; } }
.tn-vu{ display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.tn-vu i{ display: block; width: 3px; border-radius: 1px; background: rgba(246, 230, 196, 0.16); transition: background 80ms linear; }
.tn-vu i:nth-child(1){ height: 4px; } .tn-vu i:nth-child(2){ height: 6px; } .tn-vu i:nth-child(3){ height: 8px; } .tn-vu i:nth-child(4){ height: 10px; } .tn-vu i:nth-child(5){ height: 12px; }
.tn-vu i.on{ background: var(--amber); }
.tn-vu i.on.hot{ background: var(--lamp-red); }

.tn-face{ position: relative; border-radius: 16px; }
.tn-dial{ display: block; width: 100%; aspect-ratio: 16 / 9.2; touch-action: manipulation; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.tn-strobe-wrap{ margin-top: 10px; }
.tn-strobe{ display: block; width: 100%; height: 46px; border-radius: 10px; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }

/* readout: lamps flank the big note */
.tn-read{ display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 12px; }
.tn-lamp{ display: inline-flex; align-items: center; gap: 7px; justify-self: center; }
.tn-lamp i{
  display: block; width: 22px; height: 18px;
  background: #3b1810;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
  transition: background 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}
.tn-lamp--flat i{ clip-path: polygon(0 0, 100% 50%, 0 100%); }
.tn-lamp--sharp{ flex-direction: row-reverse; }
.tn-lamp--sharp i{ clip-path: polygon(100% 0, 0 50%, 100% 100%); }
.tn-lamp b{ font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: rgba(246, 230, 196, 0.32); transition: color 160ms ease; }
.tn-lamp.on i{ background: var(--lamp-red); filter: drop-shadow(0 0 7px rgba(255, 91, 58, 0.9)); }
.tn-lamp.on b{ color: rgba(255, 170, 140, 0.95); }

.tn-note{ position: relative; display: flex; align-items: baseline; justify-content: center; min-width: 3.2em; padding-top: 10px; font-family: var(--font-display); line-height: 1; color: var(--cream); transition: color 200ms ease, text-shadow 200ms ease; }
.tn-note__name{ font-size: clamp(3.6rem, 17vw, 5.4rem); font-weight: 800; letter-spacing: -0.03em; }
.tn-note__acc{ font-size: clamp(1.8rem, 8vw, 2.6rem); font-weight: 700; align-self: flex-start; margin-top: 0.12em; margin-left: 0.04em; }
.tn-note__oct{ font-size: clamp(1.2rem, 5vw, 1.6rem); font-weight: 700; opacity: 0.6; margin-left: 0.06em; }
.tn-note__jewel{
  position: absolute; top: 0; left: 50%; width: 11px; height: 11px; margin-left: -5.5px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2c5a3c, #0f2617 70%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.7);
  transition: background 140ms ease, box-shadow 140ms ease;
}
.tn-unit.is-in .tn-note__jewel{ background: radial-gradient(circle at 35% 30%, #d8ffe6, var(--lamp-green) 55%, #1d8a47); box-shadow: 0 0 14px rgba(69, 226, 132, 0.95), 0 0 28px rgba(69, 226, 132, 0.45); }
.tn-unit.is-in .tn-note{ color: #e9ffef; text-shadow: 0 0 18px rgba(69, 226, 132, 0.55); }
.tn-unit.is-idle .tn-note{ color: rgba(246, 230, 196, 0.34); }
.tn-unit.is-hold .tn-note{ color: rgba(246, 230, 196, 0.62); }

.tn-nums{ display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: baseline; margin-top: 8px; font-family: var(--font-mono); font-size: 0.86rem; font-weight: 500; color: rgba(246, 230, 196, 0.72); font-variant-numeric: tabular-nums; }
.tn-num:first-child{ text-align: left; padding-left: 4px; }
.tn-num:last-child{ text-align: right; padding-right: 4px; }
.tn-num--mid{ font-family: var(--font-display); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(246, 230, 196, 0.5); white-space: nowrap; }
.tn-unit.is-idle .tn-nums{ color: rgba(246, 230, 196, 0.3); }
.tn-say{ margin: 10px 0 0; min-height: 1.3em; font-size: 0.84rem; font-weight: 500; color: rgba(246, 230, 196, 0.72); }
.tn-say b{ color: var(--cream); font-weight: 700; }

/* the start panel covers the readout until the mic is on; the dial and the
   strobe stay in view, dimmed, so the instrument is on show from the start */
.tn-lower{ position: relative; }
.tn-start, .tn-done{
  position: absolute; left: calc(-1 * clamp(12px, 3.2vw, 20px)); right: calc(-1 * clamp(12px, 3.2vw, 20px)); bottom: -16px; top: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 18px 22px 22px;
  background: linear-gradient(180deg, rgba(18, 15, 12, 0.7) 0%, rgba(18, 15, 12, 0.94) 30%, rgba(18, 15, 12, 0.97));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  transition: opacity 320ms ease, transform 320ms ease;
  z-index: 4;
}
.tn-start.is-gone, .tn-done.is-gone{ opacity: 0; transform: translateY(10px); pointer-events: none; }
.tn-start[hidden], .tn-done[hidden]{ display: none; }
.tn-go{
  appearance: none; display: inline-flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 12px 26px; border-radius: var(--radius-pill);
  border: 0; cursor: pointer;
  font-family: var(--font-display); font-size: 1rem; font-weight: 800; letter-spacing: 0.01em;
  color: #2a1704;
  background: linear-gradient(180deg, #ffd08a, #f39a2c);
  box-shadow: 0 8px 26px -6px rgba(243, 154, 44, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -2px 0 rgba(120, 60, 0, 0.25);
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}
.tn-go:hover{ transform: translateY(-2px); filter: brightness(1.05); }
.tn-go:active{ transform: translateY(0); }
.tn-go:focus-visible{ outline: none; box-shadow: 0 0 0 3px var(--case-1), 0 0 0 6px var(--amber); }
.tn-go svg{ width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tn-go[disabled]{ opacity: 0.6; cursor: wait; }
.tn-start__note{ margin: 0; max-width: 32em; font-size: 0.8rem; line-height: 1.45; color: rgba(246, 230, 196, 0.72); }
.tn-start__note b{ color: var(--cream); }

.tn-done{ background: linear-gradient(180deg, rgba(10, 24, 16, 0.78) 0%, rgba(12, 26, 18, 0.95) 30%, rgba(12, 24, 17, 0.98)); }
.tn-done__k{ margin: 0; font-family: var(--font-display); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.22em; text-transform: uppercase; color: var(--lamp-green); }
.tn-done__v{ margin: -4px 0 0; font-family: var(--font-display); font-size: clamp(1.5rem, 6.4vw, 2rem); font-weight: 900; color: #eafff1; letter-spacing: -0.01em; }
.tn-done__sub{ margin: -6px 0 2px; font-size: 0.86rem; color: rgba(220, 245, 228, 0.75); }
.tn-again{
  appearance: none; min-height: 44px; padding: 10px 20px; border-radius: var(--radius-pill);
  border: 1.5px solid rgba(69, 226, 132, 0.5); background: rgba(69, 226, 132, 0.08);
  color: #dfffe9; font-family: var(--font-display); font-size: 0.86rem; font-weight: 700; cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.tn-again:hover{ background: rgba(69, 226, 132, 0.16); border-color: var(--lamp-green); }
.tn-again:focus-visible{ outline: 2px solid var(--lamp-green); outline-offset: 3px; }
.tn-unit.is-done .tn-done:not(.is-gone){ animation: tn-rise 520ms cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes tn-rise{ from{ opacity: 0; transform: translateY(16px) scale(0.98); } to{ opacity: 1; transform: none; } }

/* ---------- The headstock: pegs on dark rosewood ---------- */
.tn-neck{ margin-top: 18px; }
.tn-tunings{ margin-bottom: 12px; }
.tn-tunings:empty{ display: none; }
.tn-pegs, .tn-pipe{
  position: relative;
  padding: 16px clamp(10px, 3vw, 18px) 14px;
  border-radius: 18px;
  background:
    repeating-linear-gradient(176deg, rgba(255, 210, 160, 0.035) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(183deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 11px),
    linear-gradient(180deg, #3a2418, #26170f 60%, #1d120c);
  border: 1px solid rgba(255, 210, 160, 0.1);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 220, 180, 0.1), inset 0 -3px 8px rgba(0, 0, 0, 0.35);
}
.tn-pegs{ display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: 6px; }
.tn-pegs[hidden], .tn-pipe[hidden]{ display: none; }
.tn-col{ position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 2px; }
/* the string runs through each column, its gauge set by its pitch */
.tn-col::before{
  content: ""; position: absolute; top: -16px; bottom: -14px; left: 50%;
  width: var(--gauge, 1.4px); margin-left: calc(var(--gauge, 1.4px) / -2);
  background: linear-gradient(90deg, #6d6a64, #e9e4da 45%, #8c877d);
  opacity: 0.55; z-index: 0;
  transition: opacity 200ms ease, box-shadow 200ms ease;
}
.tn-col.is-target::before{ opacity: 1; box-shadow: 0 0 10px rgba(255, 179, 71, 0.75); }
.tn-col.is-ring::before{ animation: tn-ring 90ms linear infinite; opacity: 0.95; }
@keyframes tn-ring{ 0%{ transform: translateX(-0.8px); } 50%{ transform: translateX(0.8px); } 100%{ transform: translateX(-0.8px); } }
.tn-peg{
  position: relative; z-index: 1;
  appearance: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: min(56px, 100%); aspect-ratio: 1; min-height: 44px; padding: 0;
  border-radius: 50%; cursor: pointer; border: 0;
  color: #241a10;
  background:
    radial-gradient(circle at 34% 28%, #ffffff 0%, #e6e1d8 18%, #b5aea2 52%, #8a8378 78%, #6a645a 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 -2px 3px rgba(0, 0, 0, 0.25), inset 0 2px 2px rgba(255, 255, 255, 0.6);
  transition: transform 180ms cubic-bezier(.3, 1.4, .5, 1), box-shadow 180ms ease;
}
/* the hit area reaches past the knob, so a narrow phone still gets a 44px target */
.tn-peg::after{ content: ""; position: absolute; inset: -5px; border-radius: 50%; }
.tn-peg:hover{ transform: translateY(-2px) rotate(-8deg); }
.tn-peg:active{ transform: scale(0.95) rotate(-24deg); }
.tn-peg:focus-visible{ outline: none; box-shadow: 0 0 0 3px #1d120c, 0 0 0 6px var(--amber), 0 4px 10px rgba(0, 0, 0, 0.5); }
.tn-peg__n{ font-family: var(--font-display); font-size: clamp(0.95rem, 4.2vw, 1.2rem); font-weight: 800; line-height: 1; letter-spacing: -0.01em; }
.tn-peg__n small{ font-size: 0.58em; font-weight: 700; opacity: 0.6; margin-left: 1px; }
.tn-col.is-target .tn-peg{ box-shadow: 0 0 0 2.5px var(--amber), 0 0 18px rgba(255, 179, 71, 0.55), 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 2px 2px rgba(255, 255, 255, 0.6); }
.tn-col.is-tuned .tn-peg{ box-shadow: 0 0 0 2.5px var(--lamp-green), 0 0 16px rgba(69, 226, 132, 0.5), 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 2px 2px rgba(255, 255, 255, 0.6); }
.tn-col.is-pop .tn-peg{ animation: tn-pop 460ms cubic-bezier(.3, 1.6, .5, 1); }
@keyframes tn-pop{ 0%{ transform: scale(1); } 35%{ transform: scale(1.16) rotate(14deg); } 100%{ transform: scale(1); } }
.tn-led{ position: relative; z-index: 1; width: 7px; height: 7px; border-radius: 50%; background: #1b2a20; box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.7); transition: background 160ms ease, box-shadow 160ms ease; }
.tn-col.is-tuned .tn-led{ background: var(--lamp-green); box-shadow: 0 0 8px var(--lamp-green); }
.tn-col.is-target:not(.is-tuned) .tn-led{ background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.tn-sn{ position: relative; z-index: 1; font-family: var(--font-display); font-size: 0.56rem; font-weight: 700; letter-spacing: 0.12em; color: rgba(255, 225, 190, 0.45); }

/* chromatic: a pitch pipe of twelve keys and an octave */
.tn-pipe__keys{ display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.tn-key{
  appearance: none; min-height: 44px; border-radius: 12px; cursor: pointer;
  border: 1px solid rgba(255, 225, 190, 0.14);
  font-family: var(--font-display); font-size: 0.92rem; font-weight: 800; color: #f3e5cf;
  background: linear-gradient(180deg, rgba(255, 230, 200, 0.12), rgba(255, 230, 200, 0.03));
  box-shadow: inset 0 1px 0 rgba(255, 240, 220, 0.14), 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}
.tn-key small{ font-size: 0.66em; opacity: 0.6; font-weight: 700; }
.tn-key:hover{ border-color: rgba(255, 225, 190, 0.4); transform: translateY(-1px); }
.tn-key:active{ transform: scale(0.96); }
.tn-key:focus-visible{ outline: 2px solid var(--amber); outline-offset: 2px; }
.tn-key.is-target{ border-color: var(--amber); background: linear-gradient(180deg, rgba(255, 179, 71, 0.32), rgba(255, 179, 71, 0.1)); box-shadow: 0 0 14px rgba(255, 179, 71, 0.35); }
.tn-key.is-sharp{ color: #e2d0b4; background: linear-gradient(180deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.16)); }
.tn-oct{ display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.tn-oct__v{ min-width: 6.5em; font-family: var(--font-display); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255, 225, 190, 0.75); }
.tn-oct .tn-step{ color: #f3e5cf; background: rgba(255, 230, 200, 0.08); border-color: rgba(255, 225, 190, 0.2); box-shadow: none; }
.tn-neck__hint{ margin: 10px 0 0; min-height: 1.4em; font-size: 0.78rem; color: var(--muted); transition: color 200ms ease; }
.tn-neck__hint.is-news{ color: var(--ink); }
.tn-neck__hint b{ color: var(--accent); }

/* ---------- Reference pitch ---------- */
.tn-ref{
  margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px;
  padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tn-ref__k{ font-family: var(--font-display); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.tn-ref__ctl{ display: inline-flex; align-items: center; gap: 10px; }
.tn-ref__v{ min-width: 7.4em; font-family: var(--font-mono); font-size: 0.95rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.tn-ref__quick{ display: inline-flex; gap: 6px; }
.tn-step{
  appearance: none; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; line-height: 1;
  color: var(--ink); background: var(--surface); border: 1.5px solid var(--line-strong); cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 140ms ease, border-color 140ms ease;
}
.tn-step:hover{ border-color: var(--ink); transform: translateY(-1px); }
.tn-step:active{ transform: scale(0.94); }
.tn-step:focus-visible{ outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px var(--accent); }
.tn-step[disabled]{ opacity: 0.4; cursor: default; transform: none; }

/* ---------- Tips ---------- */
.tn-tips{
  margin-top: 18px; text-align: left;
  padding: 4px 18px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.tn-tips summary{
  cursor: pointer; list-style: none; padding: 12px 0;
  font-family: var(--font-display); font-size: 0.86rem; font-weight: 700; color: var(--ink);
}
.tn-tips summary::-webkit-details-marker{ display: none; }
.tn-tips summary::after{ content: "+"; float: right; color: var(--muted); font-weight: 700; }
.tn-tips[open] summary::after{ content: "−"; }
.tn-tips summary:focus-visible{ outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.tn-tips ul{ margin: 0 0 14px; padding-left: 1.1em; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }
.tn-tips li + li{ margin-top: 6px; }

/* share.js mounts its pill here; the theme token keeps it readable in light and dark */
.share-row{ display: flex; justify-content: center; margin: -4px 0 -6px; }
.share-row[hidden]{ display: none; }
.share-row .opt-share{ --ops-fg: var(--ink); }
.backlink{ font-family: var(--font-display); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); text-decoration: none; border-bottom: 1px solid transparent; transition: color 140ms ease, border-color 140ms ease; }
.backlink:hover{ color: var(--ink); border-bottom-color: var(--accent); }

/* the shared tip jar and full-screen badges sit at right-center by default,
   which on a phone is on top of the dial; dock them bottom-right instead */
@media (max-width: 760px){
  .opt-tipjar.opt-tipjar{ top: auto; bottom: max(14px, env(safe-area-inset-bottom)); transform: none; }
  .opt-fs.opt-fs{ top: auto; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 50px); transform: none; }
  .opt-tipjar.opt-tipjar.tj-nudge{ animation: none; }
}
@media (max-width: 380px){
  .tn-chip{ padding: 7px 11px; font-size: 0.78rem; }
  .tn-lamp b{ display: none; }
  .tn-nums{ font-size: 0.78rem; }
  .tn-pegs{ gap: 2px; padding-left: 6px; padding-right: 6px; }
}
@media (min-width: 640px){
  .tn-pipe__keys{ grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; }
}
@media (prefers-reduced-motion: reduce){
  .tn-chip, .tn-step, .tn-peg, .tn-go, .tn-lamp i, .tn-note, .tn-start, .tn-done, .tn-col::before{ transition: none; }
  .tn-live__dot, .tn-col.is-ring::before, .tn-col.is-pop .tn-peg, .tn-unit.is-done .tn-done:not(.is-gone){ animation: none; }
  .tn-peg:hover, .tn-peg:active{ transform: none; }
}
