/* Shell: chrome header + LIVE banner, start poster, settings sheet, mic-lost
   overlay, the mic-off panel for listening tools, footer. */

/* ------------------------------------------------------------ header chrome */
header.chrome {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  flex: none;
  background: var(--paper);
  padding-top: env(safe-area-inset-top);
}
.chrome-row {
  display: flex;
  align-items: center;
  gap: var(--s1);
  width: 100%;
  max-width: 480px;
  height: var(--h-header);
  margin: 0 auto;
  padding: 0 var(--s1) 0 12px;
}
.nav-back.btn--secondary {
  flex: none;
  width: 88px;
  height: var(--hit);
  min-height: var(--hit);
  padding: 0 var(--s2);
  gap: 6px;
  font: 700 var(--t-control)/1 var(--label-font);
  letter-spacing: .06em;
  box-shadow: var(--sh-ctl);
}
.nav-back .icon { width: 16px; height: 16px; }
.nav-back.is-home { visibility: hidden; }
.brand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.rc-stamp {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 26px;
  border: 2px solid var(--red-ink);
  color: var(--red-ink);
  font: 400 15px/1 var(--display-font);
  letter-spacing: .02em;
  transform: rotate(-4deg);
}
.wordmark {
  font: 700 var(--t-control)/1 var(--label-font);
  letter-spacing: .06em;
  white-space: nowrap;
}
@media (max-width: 374px) { .wordmark { display: none; } }
.chrome-row .meter {
  flex: none;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 0;
  margin-right: var(--s1); /* with the row gap, 8 px to the gear (spec R4) */
}
.chrome-row .meter.is-off { padding: 0 2px; }
.gear-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--hit);
  height: var(--hit);
  color: var(--ink);
}
.gear-btn svg { display: block; }
.chrome-hazard { position: relative; }

/* LIVE banner: replaces the row and the tape while a run counts in or plays */
header.chrome.is-live .chrome-row,
header.chrome.is-live .chrome-hazard { display: none; }
header.chrome:not(.is-live) .live { display: none; }
.live__box { flex: 0 1 auto; }
.live__meter.meter {
  min-width: 0;
  min-height: 0;
  height: 32px;
  padding: 0 var(--s2);
}

/* ------------------------------------------------------------- toast */
body:has(#settings:not(.hidden)) .toast {
  z-index: calc(var(--z-sheet) + 1);
  bottom: calc(var(--gutter) + env(safe-area-inset-bottom));
}
/* the sheet keeps room under its last row for the toast (base.css has the
   same reserve for screens), so a row it covers can be scrolled clear */
body.has-toast #settings-body { padding-bottom: calc(var(--toast-space) + var(--s2)); }

/* ------------------------------------------------------- start poster */
.poster {
  position: relative;
  min-height: 100dvh;
  /* body bounds its height: on a phone shorter than the stack the poster
     scrolls, so TAP TO START is never out of reach */
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  padding: env(safe-area-inset-top) 0 calc(var(--s4) + env(safe-area-inset-bottom));
}
.poster > :not(.poster-dots) { position: relative; }
.poster-dots { position: absolute; pointer-events: none; }
.red-dots {
  top: 8px; right: -30px; width: 150px; height: 150px;
  background: radial-gradient(circle at 30% 30%, var(--red) 0 2px, transparent 2.5px);
  background-size: 11px 11px;
  opacity: .4;
  transform: rotate(8deg);
}
.blue-dots {
  bottom: 196px; left: -30px; width: 80px; height: 80px;
  background: radial-gradient(circle at 30% 30%, var(--blue) 0 2px, transparent 2.5px);
  background-size: 10px 10px;
  opacity: .34;
}
.poster-hazard {
  flex: none;
  height: 12px;
  background: var(--hazard);
  background-size: var(--hazard-tile) var(--hazard-tile);
  animation: hz-scroll var(--d-hazard) linear infinite;
}
.poster-masthead {
  flex: none;
  margin: 14px var(--gutter) 0;
  text-align: center;
  font: 400 var(--t-masthead)/.9 var(--display-font);
  letter-spacing: 0;
}
.mast-line { display: block; }
.mast-line.checker { color: var(--red); text-shadow: 3px 3px 0 var(--ink); }
.poster-dateline {
  flex: none;
  margin: 12px var(--gutter) 0;
  text-align: center;
  font: 600 var(--t-label)/1.2 var(--label-font);
  letter-spacing: .08em;
}
.poster-lineup {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s4) var(--gutter);
}
.poster-bills {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
}
.lineup-kicker {
  font: 600 var(--t-label)/1 var(--label-font);
  letter-spacing: .2em;
  color: var(--ink60);
}
/* sits right of TONIGHT / RUDIMENTS, never over the masthead or a bill */
.starburst {
  position: absolute;
  top: -34px;
  right: -18px;
  z-index: 1;
  width: 84px;
  height: 84px;
  pointer-events: none;
}
.starburst svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-10deg); }
.starburst-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font: 700 12px/1 var(--label-font);
  letter-spacing: 0;
  color: var(--ink);
  transform: rotate(-9deg);
}
.bill { color: var(--ink); }
.bill-1, .bill-2 > button {
  font-family: var(--display-font);
  font-weight: 400;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 6px;
}
.bill-1 {
  min-height: 64px;
  padding: 0 var(--s2);
  font-size: 58px;
  line-height: 1;
  letter-spacing: .01em;
  text-underline-offset: 8px;
}
.bill-2 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.bill-2 > button {
  min-height: 48px;
  padding: 0 var(--s1);
  font-size: 40px;
  line-height: 1;
  letter-spacing: .01em;
}
.bill-2 > b { flex: none; width: 10px; height: 10px; background: var(--red); }
.bill-1:active, .bill-2 > button:active,
.bill-1.on, .bill-2 > button.on {
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}
.bill-1.on:focus-visible, .bill-2 > button.on:focus-visible { outline: var(--focus-dark); }
.bill-3 {
  margin-top: var(--s1);
  padding: 9px 14px;
  background: var(--ink);
  color: var(--paper);
  font: 700 var(--t-control)/1 var(--label-font);
  letter-spacing: .14em;
}
.poster-denied {
  flex: none;
  margin: var(--s6) var(--gutter) var(--s4);
}
.poster-denied__title { font: 400 var(--t-title)/1 var(--display-font); letter-spacing: .01em; }
.poster-error { margin-top: var(--s2); font: 400 var(--t-body)/1.4 var(--mono-font); color: var(--ink); }
.poster-foot {
  flex: none;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: 0 var(--gutter);
}
.barcode {
  height: 26px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 3px, var(--ink) 3px 4px, transparent 4px 7px, var(--ink) 7px 9px, transparent 9px 11px);
}
.poster-priming {
  text-align: center;
  font: 400 var(--t-body)/1.4 var(--mono-font);
}
.poster-priming span { display: block; }
.poster-cta.btn--primary {
  width: calc(100% - 6px);
  min-height: 74px;
}
.poster-cta.btn--primary:not(:disabled) { box-shadow: var(--sh-poster); }
.poster-cta.is-busy .icon { display: none; }
.poster-nomic { align-self: center; min-height: var(--hit); }

/* 320 wide: CALIBRATE · HISTORY is wider than the screen at 40 px */
@media (max-width: 359px) {
  .bill-2 { gap: var(--s2); }
  .bill-2 > button { font-size: 34px; }
}
/* short phones (SE in Safari, small Androids): the stack tightens so the CTA
   stays on screen; below ~600 px tall the poster scrolls the rest */
@media (max-height: 700px) {
  /* no spare height above the lineup: the burst would climb onto the dateline */
  .starburst { top: -12px; }
}
@media (max-height: 680px) {
  .poster-masthead { font-size: 64px; }
  .bill-1 { min-height: 52px; font-size: 46px; }
  .bill-2 > button { min-height: var(--hit); font-size: 32px; }
  .poster-lineup { padding-block: var(--s2); }
}
@media (max-height: 600px) {
  .barcode { display: none; }
  .poster-cta.btn--primary { min-height: var(--h-btn); }
}

/* ----------------------------------------------- listening tool, mic off */
.nomic__card { border-top: 4px solid var(--amber); }
.nomic__head { font: 400 var(--t-title)/1 var(--display-font); letter-spacing: .01em; }
.nomic__text { margin-top: var(--s2); font: 400 var(--t-body)/1.4 var(--mono-font); }
.nomic__text:empty { display: none; }
#nomic-retry.is-busy .icon { display: none; }

/* nav() parks focus on the new screen's title, or the Home panel, when the
   tapped control went away (app.js landOnScreen). Neither is a control: no ring. */
main > .mode[tabindex="-1"]:focus,
main > .mode h1[tabindex="-1"]:focus { outline: none; }

/* --------------------------------------------------------- settings sheet */
#settings.sheet { box-shadow: 0 -4px 0 var(--ink); border-left: var(--border); border-right: var(--border); }
.sheet__head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) var(--s2) var(--s2) var(--gutter);
  border-bottom: var(--border);
}
#settings-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s3) var(--gutter) var(--s6);
}
.set-group + .set-group { margin-top: var(--s6); }
.set-group > .sec-head { margin-bottom: var(--s1); }
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-height: 56px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
}
.set-row--stack { flex-direction: column; align-items: stretch; gap: var(--s2); padding: 10px 0 12px; }
.set-row--data { flex-direction: column; align-items: flex-start; gap: var(--s2); padding: 10px 0 12px; }
.set-label {
  font: 600 var(--t-control)/1.2 var(--label-font);
  letter-spacing: .03em;
  color: var(--ink);
}
.set-text { min-width: 0; flex: 1 1 auto; }
.set-row--data .set-text { flex: none; }
.set-hint {
  margin-top: 3px;
  font: 400 var(--t-caption)/1.35 var(--mono-font);
  color: var(--ink60);
}
.set-group > .set-hint { margin: var(--s2) 0 var(--s1); }
.set-link.btn--quiet { flex: none; min-height: var(--hit); padding: 0; justify-content: flex-end; }
.set-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.set-note {
  margin-top: var(--s3);
  font: 400 var(--t-label)/1.4 var(--mono-font);
  color: var(--ink60);
}
.set-reset.btn--danger { width: 100%; margin-top: var(--s4); }
.set-foot {
  margin-top: var(--s3);
  font: 400 var(--t-caption)/1.3 var(--mono-font);
  color: var(--ink60);
}
.set-preview { margin: var(--s2) 0; display: flex; flex-direction: column; gap: var(--s3); }
.set-preview p { font: 400 var(--t-body)/1.4 var(--mono-font); }
.set-preview .btn--danger { width: 100%; }

/* grade-words switch: the button is the full 52 x 44 hit box, the track is drawn inside it */
#settings .switch { height: var(--hit); border: 0; background: none; box-shadow: none; }
#settings .switch::before {
  content: '';
  position: absolute;
  inset: 7px 0;
  border: var(--border);
  background: var(--white);
  box-shadow: var(--sh-ctl);
}
#settings .switch[aria-checked="true"]::before { background: var(--ink); }
#settings .switch__knob { top: 12px; left: 5px; }
#settings .switch[aria-checked="true"] .switch__knob { left: auto; right: 5px; }

/* kit rows */
#kit-list { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s2); }
.kit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px var(--hit);
  align-items: center;
  gap: var(--s2);
}
.kit-row input.kit-name {
  width: 100%;
  min-width: 0;
  height: var(--hit);
  padding: 0 10px;
  font: 600 var(--t-control)/1 var(--label-font);
  letter-spacing: .02em;
}
.kit-targets {
  font: 400 var(--t-caption)/1.3 var(--mono-font);
  color: var(--ink60);
  text-align: right;
}
.kit-del {
  display: grid;
  place-items: center;
  width: var(--hit);
  height: var(--hit);
  border: var(--border);
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--sh-ctl);
}
.kit-del .icon { width: 18px; height: 18px; }
.kit-add.btn--secondary { margin-top: var(--s3); align-self: flex-start; }

/* ------------------------------------------------------------ mic lost */
.mic-lost {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--paper);
  padding-top: env(safe-area-inset-top);
}
.mic-lost__hazard {
  flex: none;
  height: 12px;
  background: var(--hazard);
  background-size: var(--hazard-tile) var(--hazard-tile);
}
.mic-lost__body {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--s3) var(--gutter) var(--s4);
}
.mic-lost__card p { font: 400 var(--t-body)/1.4 var(--mono-font); }
.mic-lost__card p + p { margin-top: var(--s2); }
.mic-lost__card .mic-lost__run { font-weight: 700; }

/* ------------------------------------------------------------- footer */
footer { padding: var(--s1) var(--gutter) calc(var(--s1) + env(safe-area-inset-bottom)); }
.diag { font: 400 var(--t-axis)/1.3 var(--mono-font); color: var(--ink); }
footer:has(.diag:empty) { display: none; }
