/* ============================================================
   Click — a metronome for services
   Design tokens first, then base, then components.
   ============================================================ */

:root {
  color-scheme: dark;

  --bg:          #0A0A0C;
  --bg-elev:     #131318;
  --bg-elev-2:   #1B1B22;
  --bg-sunken:   #08080A;

  --line:        #26262E;
  --line-strong: #363641;

  --text:        #F2F2F5;
  --text-dim:    #9797A3;
  --text-faint:  #5C5C68;

  --accent:      #34D399;
  --accent-hi:   #6EE7B7;
  --accent-ink:  #04211A;
  --accent-wash: rgba(52, 211, 153, 0.13);
  --accent-line: rgba(52, 211, 153, 0.34);

  --warn:        #FBBF24;
  --warn-ink:    #2A1D00;
  --warn-wash:   rgba(251, 191, 36, 0.13);
  --warn-line:   rgba(251, 191, 36, 0.36);

  --danger:      #F87171;
  --danger-wash: rgba(248, 113, 113, 0.12);

  --shadow-sheet: 0 24px 60px rgba(0, 0, 0, 0.6);
  --shadow-pop:   0 8px 24px rgba(0, 0, 0, 0.45);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;

  --gutter: clamp(16px, 3.5vw, 32px);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text",
          "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="light"] {
  color-scheme: light;

  --bg:          #F6F6F7;
  --bg-elev:     #FFFFFF;
  --bg-elev-2:   #EFEFF2;
  --bg-sunken:   #EAEAEE;

  --line:        #E3E3E8;
  --line-strong: #CDCDD6;

  --text:        #17171B;
  --text-dim:    #6A6A76;
  --text-faint:  #9C9CA8;

  --accent:      #0E9F6E;
  --accent-hi:   #047857;
  --accent-ink:  #FFFFFF;
  --accent-wash: rgba(14, 159, 110, 0.10);
  --accent-line: rgba(14, 159, 110, 0.30);

  --warn:        #B45309;
  --warn-ink:    #FFFFFF;
  --warn-wash:   rgba(180, 83, 9, 0.10);
  --warn-line:   rgba(180, 83, 9, 0.28);

  --danger:      #DC2626;
  --danger-wash: rgba(220, 38, 38, 0.09);

  --shadow-sheet: 0 24px 60px rgba(15, 15, 25, 0.18);
  --shadow-pop:   0 8px 24px rgba(15, 15, 25, 0.10);
}

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

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1, h2, h3, p { margin: 0; }

/* Author `display` rules outrank the UA sheet, so make `hidden` win outright. */
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Slim, unobtrusive scrollbars (iPadOS overlays its own, so this is harmless there). */
.scroller, .sheet, .picker { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

.scroller::-webkit-scrollbar,
.sheet::-webkit-scrollbar,
.picker::-webkit-scrollbar { width: 10px; }

.scroller::-webkit-scrollbar-track,
.sheet::-webkit-scrollbar-track,
.picker::-webkit-scrollbar-track { background: transparent; }

.scroller::-webkit-scrollbar-thumb,
.sheet::-webkit-scrollbar-thumb,
.picker::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ---------------------------------------------------------- layout */

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.stage {
  flex: 1;
  min-height: 0;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
}

.view.is-active { display: block; }

.scroller {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page {
  max-width: 780px;
  margin: 0 auto;
  padding: 8px var(--gutter) 64px;
}

/* ---------------------------------------------------------- topbar */

.topbar {
  flex: 0 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1 1 0;
  min-width: 0;
}

.brand-mark {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  position: relative;
  flex: 0 0 auto;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 2.5px;
  border-radius: 50%;
  background: var(--accent);
}

body.is-running .brand-mark::after { animation: brandBlink 1s steps(2, end) infinite; }

@keyframes brandBlink { 50% { opacity: 0.15; } }

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

@media (max-width: 560px) { .brand-name { display: none; } }

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  flex: 0 0 auto;
}

.seg {
  padding: 6px 15px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-dim);
  transition: color 0.18s, background 0.18s;
  white-space: nowrap;
}

.seg.is-on {
  color: var(--text);
  background: var(--bg-elev);
  box-shadow: var(--shadow-pop);
}

/* Balances .brand so the segmented nav stays optically centred. */
.icon-btn {
  flex: 1 1 0;
  display: flex;
  justify-content: flex-end;
  font-size: 21px;
  color: var(--text-dim);
  transition: color 0.18s;
}

.icon-btn:hover { color: var(--text); }

/* ---------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  transition: transform 0.12s var(--ease), background 0.18s, border-color 0.18s, opacity 0.18s;
}

.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.38; pointer-events: none; }

.btn-sm { padding: 8px 14px; font-size: 13px; }

.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: var(--accent-hi); }

.btn-warn { background: var(--warn); color: var(--warn-ink); }

.btn-quiet {
  background: var(--bg-elev-2);
  color: var(--text);
  border-color: var(--line);
}
.btn-quiet:hover { border-color: var(--line-strong); }

.btn-danger-quiet {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}
.btn-danger-quiet:hover { background: var(--danger-wash); }

.btn-block { width: 100%; }

/* ---------------------------------------------------------- live view */

.live {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: clamp(12px, 2vh, 26px) var(--gutter) 0;
  text-align: center;
}

/*
 * The transport lives in the centred stage; song navigation is pinned to the
 * bottom edge. Keeping real distance between them means a hurried tap on Next
 * can't stop the click mid-song.
 */
.live-stage {
  --stage-gap: clamp(14px, 2.6vh, 30px);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--stage-gap);
}

.live-head { display: grid; gap: 3px; max-width: 100%; }

/* The service name doubles as the way into the editor — heavily used at rehearsal. */
.live-service {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: center;
  margin: 0 auto 8px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  max-width: min(80vw, 420px);
  transition: color 0.16s, border-color 0.16s;
}

.live-service > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-service svg { font-size: 13px; flex: 0 0 auto; opacity: 0.75; }
.live-service:hover { color: var(--text); border-color: var(--line-strong); }
.live-service:active { transform: scale(0.97); }

/*
 * The songs either side sit next to the current one, quiet and small, and slide
 * across as you move through the service. Overflow is hidden so they can travel
 * in and out past the edges without the page ever scrolling sideways.
 */
/*
 * A three-column grid, not a centred flex row: at the first and last song only
 * one neighbour exists, and a flex row would shunt the current title off-centre
 * from the dial beneath it. Equal side columns keep it anchored either way.
 */
.song-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: baseline;
  gap: clamp(18px, 2.5vw, 30px);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  padding: 2px 0;
}

.strip-item {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.strip-current {
  grid-column: 2;
  justify-self: center;
  font-size: clamp(21px, 3.4vw, 30px);
  font-weight: 600;
  letter-spacing: -0.02em;
  padding-right: 0.02em;
  max-width: min(56vw, 460px);
}

.strip-side {
  font-size: clamp(11px, 1.5vw, 14.5px);
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--text-dim);
  opacity: 0.4;
  /* Fills its column and truncates, so a neighbour is always shown, however
     narrow the screen. The column itself is what limits the width. */
  max-width: min(100%, 200px);
}

/* Sit each neighbour hard against the title rather than out at the margins. */
.song-strip > :first-child { grid-column: 1; justify-self: end; }
.song-strip > :last-child  { grid-column: 3; justify-self: start; }

/*
 * Phones keep the neighbours. The current song takes the larger share and the
 * neighbours truncate — they only need to be recognisable at a glance.
 */
@media (max-width: 620px) {
  .strip-current { max-width: 60vw; }
  .strip-side { font-size: 11px; }
}

@media (max-width: 380px) {
  .song-strip { gap: 7px; }
  .strip-current { max-width: 58vw; }
  .strip-side { font-size: 10.5px; }
}

.live-pos {
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------ dial + nudges */

.dial-row {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2.6vw, 30px);
}

.nudge {
  display: grid;
  gap: clamp(6px, 1.1vh, 11px);
}

.nudge-btn {
  width: clamp(58px, 11vmin, 84px);
  height: clamp(44px, 8vmin, 60px);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: clamp(15px, 2.3vmin, 19px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: transform 0.1s var(--ease), background 0.16s, border-color 0.16s;
}

.nudge-btn:hover { border-color: var(--line-strong); background: var(--bg-elev-2); }
.nudge-btn:active { transform: scale(0.94); background: var(--accent-wash); border-color: var(--accent-line); }
.nudge-btn[disabled] { opacity: 0.3; pointer-events: none; }

.dial {
  position: relative;
  width: clamp(190px, 33vmin, 320px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.dial-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background:
    radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--bg-elev) 90%, transparent), var(--bg-sunken));
  transition: border-color 0.3s;
}

body.is-running .dial-ring { border-color: var(--accent-line); }
body.is-dirty  .dial-ring { border-color: var(--warn-line); }

.dial-pulse {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2.5px solid var(--accent);
  opacity: 0;
  pointer-events: none;
}

body.is-dirty .dial-pulse { border-color: var(--warn); }

.dial-inner { display: grid; gap: 0; place-items: center; z-index: 1; }

/*
 * letter-spacing is applied after the last character as well, so the text box is
 * one whole letter-space narrower than the ink it holds. Centring the box would
 * therefore sit the digits right of true centre. Padding the trailing edge back
 * on makes box and ink agree. Same trick on .bpm-sub, mirrored, because its
 * tracking is positive and throws it the other way.
 */
.bpm {
  font-size: clamp(58px, 13.5vmin, 116px);
  font-weight: 300;
  letter-spacing: -0.045em;
  padding-right: 0.045em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  transition: color 0.25s;
}

body.is-dirty .bpm { color: var(--warn); }

.bpm-sub {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  padding-left: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 6px;
}

body.is-transitioning .bpm-sub { color: var(--accent); }

/* ------------------------------------------------ modified banner */

/* ------------------------------------------------ tap tempo */

.tap-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 17px 8px 14px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: transform 0.1s var(--ease), background 0.18s,
              border-color 0.18s, color 0.18s;
}

.tap-btn:hover { color: var(--text); border-color: var(--line-strong); }
.tap-btn:active { transform: scale(0.95); }

.tap-btn.is-tapping {
  background: var(--accent-wash);
  border-color: var(--accent-line);
  color: var(--accent);
}

.tap-glyph {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  flex: 0 0 auto;
}

.tap-btn.is-tapping .tap-glyph { opacity: 1; }

/* the same control, sitting beside the stepper in a sheet */
.field-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/*
 * The banner opens and closes by animating its own row height (0fr -> 1fr), so
 * the dial and transport above and below it glide rather than jump. While it is
 * closed the negative margin cancels the flex gap the empty slot would add.
 */
.dirty-slot {
  display: grid;
  grid-template-rows: 0fr;
  justify-items: center;
  width: 100%;
  margin-top: calc(-1 * var(--stage-gap));
  transition: grid-template-rows 0.34s var(--ease), margin-top 0.34s var(--ease);
}

.dirty-slot.is-open {
  grid-template-rows: 1fr;
  margin-top: 0;
}

.dirty-clip { overflow: hidden; min-height: 0; }

.dirty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 15px;
  border-radius: 999px;
  background: var(--warn-wash);
  border: 1px solid var(--warn-line);
  font-size: 13.5px;
  color: var(--text);
  opacity: 0;
  transform: translateY(7px) scale(0.97);
  visibility: hidden;
  transition: opacity 0.22s var(--ease), transform 0.3s var(--ease),
              visibility 0s linear 0.34s;
}

.dirty-slot.is-open .dirty {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition: opacity 0.26s var(--ease) 0.07s, transform 0.34s var(--ease) 0.05s,
              visibility 0s;
}

.dirty-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  flex: 0 0 auto;
}

.dirty-text { color: var(--text-dim); white-space: nowrap; }
.dirty-text i { color: var(--text-faint); font-style: normal; margin: 0 2px; }
.dirty-text b { color: var(--text); font-variant-numeric: tabular-nums; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(6px); }
}

/* ------------------------------------------------ transport */

.transport {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: clamp(200px, 32vmin, 280px);
  padding: 16px 34px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1.5px solid transparent;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.01em;
  transition: transform 0.12s var(--ease), background 0.22s, color 0.22s, border-color 0.22s;
}

.transport:active { transform: scale(0.975); }
.transport[disabled] { opacity: 0.35; pointer-events: none; }

.transport-glyph {
  width: 13px;
  height: 15px;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  transition: clip-path 0.2s, border-radius 0.2s;
}

body.is-running .transport {
  background: var(--bg-elev);
  color: var(--text);
  border-color: var(--line-strong);
}

body.is-running .transport-glyph {
  clip-path: inset(0 0 0 0 round 2px);
  width: 13px;
  height: 13px;
  background: var(--accent);
}

/* ------------------------------------------------ live nav */

.live-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  width: min(620px, 100%);
  margin: clamp(28px, 6vh, 72px) auto 0;
  padding-bottom: clamp(14px, 2.5vh, 26px);
}

.navbtn {
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
  /* Wide enough for "Next 64 beats" so the label can change without the row resizing. */
  min-width: 160px;
  justify-content: center;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 600;
  transition: transform 0.1s var(--ease), border-color 0.16s, color 0.16s, opacity 0.2s;
}

.navbtn svg { font-size: 17px; flex: 0 0 auto; }
.navbtn:hover:not([disabled]) { color: var(--text); border-color: var(--line-strong); }
.navbtn:active:not([disabled]) { transform: scale(0.97); }
.navbtn[disabled] { opacity: 0.32; pointer-events: none; }

/* Everything except the progress fill sits above it. */
.navbtn > :not(.navbtn-fill) { position: relative; z-index: 1; }

.navbtn-title {
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}

/* The transition length, carried inline so the button never grows taller. */
.navbtn-title i {
  font-style: normal;
  font-weight: 500;
  opacity: 0.55;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

/* Mid-ramp: the button turns into "Skip" and fills as the tempo travels. */
#btnNext.is-ramping {
  border-color: var(--accent-line);
  color: var(--accent);
}

#btnNext.is-ramping .navbtn-title { color: var(--accent); }

.navbtn-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: var(--accent-wash);
  pointer-events: none;
}

/* ---------------------------------------------------------- empty states */

.empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px var(--gutter);
  text-align: center;
}

.empty.inline {
  height: auto;
  padding: 56px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  margin-top: 12px;
}

.empty h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.015em; }
.empty p { color: var(--text-dim); font-size: 14.5px; max-width: 40ch; }
.empty .btn { margin-top: 8px; }

.empty-art {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  position: relative;
  margin-bottom: 4px;
}

.empty-art::after {
  content: "";
  position: absolute;
  inset: 26px;
  border-radius: 50%;
  background: var(--line-strong);
}

/* ---------------------------------------------------------- page furniture */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 0 16px;
}

.page-head h2 {
  font-size: clamp(24px, 4vw, 30px);
  font-weight: 650;
  letter-spacing: -0.028em;
}

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 16px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
}

.backlink svg { font-size: 17px; }
.backlink:hover { color: var(--text); }

.title-input {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid transparent;
  padding: 18px 0 10px;
  font-size: clamp(24px, 4vw, 30px);
  font-weight: 650;
  letter-spacing: -0.028em;
  transition: border-color 0.18s;
}

.title-input:focus {
  outline: none;
  border-bottom-color: var(--accent-line);
}

.search {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text-faint);
  margin-bottom: 14px;
  transition: border-color 0.18s;
}

.search:focus-within { border-color: var(--accent-line); }
.search svg { font-size: 17px; flex: 0 0 auto; }

.search input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  font-size: 15px;
  -webkit-appearance: none;
}

.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ---------------------------------------------------------- lists */

.list { display: grid; gap: 8px; }

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 16px;
  border-radius: var(--r-md);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  text-align: left;
  transition: border-color 0.16s, transform 0.1s var(--ease);
}

.row:hover { border-color: var(--line-strong); }
.row:active { transform: scale(0.995); }

/*
 * A just-added song pops in, then cools back to a normal row over two seconds —
 * the re-render that drops the highlight lands after the colour has already gone,
 * so the change is never seen to snap.
 */
.row.is-new {
  animation: rowPop 0.42s var(--ease), rowCool 2s var(--ease) forwards;
}

@keyframes rowPop {
  0%   { transform: scale(0.96) translateY(-8px); opacity: 0; }
  55%  { transform: scale(1.012) translateY(0); opacity: 1; }
  100% { transform: none; }
}

@keyframes rowCool {
  0%, 45% { background: var(--accent-wash); border-color: var(--accent-line); }
  100%    { background: var(--bg-elev); border-color: var(--line); }
}

.row.is-new .pill { animation: pillFade 2s var(--ease) forwards; }

@keyframes pillFade {
  0%, 55% { opacity: 1; transform: none; }
  100%    { opacity: 0; transform: scale(0.9); }
}

.row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }

.row-title {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.012em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.row-bpm {
  font-size: 19px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
  flex: 0 0 auto;
}

.row-bpm small {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-left: 4px;
  text-transform: uppercase;
}

.row-chev { color: var(--text-faint); font-size: 18px; flex: 0 0 auto; display: flex; }

.pill {
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: var(--accent-wash);
  color: var(--accent);
  border: 1px solid var(--accent-line);
}

/* ---------------------------------------------------------- row card / stepper */

.row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 15px 16px;
  border-radius: var(--r-md);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  margin-bottom: 22px;
}

.row-card-main { display: grid; gap: 2px; }
.row-card-label { font-size: 15px; font-weight: 600; }
.row-card-hint { font-size: 12.5px; color: var(--text-dim); }

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.stepper button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 500;
  color: var(--text-dim);
  display: grid;
  place-items: center;
  transition: background 0.16s, color 0.16s;
}

.stepper button:hover { background: var(--bg-elev); color: var(--text); }

.stepper input {
  width: 52px;
  background: none;
  border: 0;
  outline: none;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.stepper-unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  padding-right: 12px;
  padding-left: 2px;
}

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

.editor-items { display: grid; }

.ed-block { position: relative; }

.ed-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 14px 10px;
  border-radius: var(--r-md);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  transition: border-color 0.16s, box-shadow 0.2s, background 0.16s;
}

/* Drag handle. `touch-action: none` stops iPadOS scrolling instead of dragging. */
.ed-grip {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 34px;
  color: var(--text-faint);
  cursor: grab;
  touch-action: none;
  opacity: 0.55;
  transition: opacity 0.16s, color 0.16s;
}

.ed-grip:hover { opacity: 1; color: var(--text-dim); }
.ed-grip svg { width: 14px; height: 14px; stroke: none; fill: currentColor; }

.ed-index {
  width: 18px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

/* --- while a row is being dragged --- */

.editor-items.is-dragging { cursor: grabbing; }
.editor-items.is-dragging .ed-grip { cursor: grabbing; }

.ed-block.is-shifting { transition: transform 0.2s var(--ease); }

.ed-block.is-lifted {
  position: relative;
  z-index: 5;
}

.ed-block.is-lifted .ed-item {
  border-color: var(--accent-line);
  background: var(--bg-elev-2);
  box-shadow: var(--shadow-sheet);
  transform: scale(1.015);
}

.ed-block.is-lifted .ed-junction { opacity: 0; }

.ed-main { flex: 1; min-width: 0; display: grid; gap: 2px; }

.ed-title {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.012em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ed-bpm {
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.ed-tools { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }

.ed-tool {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font-size: 17px;
  color: var(--text-faint);
  transition: background 0.16s, color 0.16s;
}

.ed-tool:hover { background: var(--bg-elev-2); color: var(--text); }
.ed-tool[disabled] { opacity: 0.25; pointer-events: none; }

/* Removal reads as destructive at rest, not only on hover. */
.ed-tool.is-danger { color: var(--danger); opacity: 0.8; }
.ed-tool.is-danger:hover { background: var(--danger-wash); color: var(--danger); opacity: 1; }

/* the transition lives in the gap between two songs */
.ed-junction {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 46px;
  padding-left: 27px;
}

.ed-junction::before {
  content: "";
  position: absolute;
  left: 15px;
  top: -1px;
  bottom: -1px;
  width: 2px;
  background: repeating-linear-gradient(
    to bottom,
    var(--line-strong) 0 4px,
    transparent 4px 9px
  );
}

.junction-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  transition: border-color 0.16s, color 0.16s;
}

.junction-chip:hover { border-color: var(--line-strong); color: var(--text); }
.junction-chip svg { font-size: 15px; }
.junction-chip b { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }

.junction-chip.is-custom {
  border-color: var(--accent-line);
  background: var(--accent-wash);
  color: var(--accent);
}

.junction-chip.is-custom b { color: var(--accent); }

/* The "add one here" state stays quiet: transitions are the exception. */
.junction-chip.is-add {
  background: transparent;
  border-color: transparent;
  color: var(--text-faint);
  font-weight: 500;
  opacity: 0.75;
}

.junction-chip.is-add:hover {
  opacity: 1;
  border-color: var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
}

.editor-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.danger-zone {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
}

/* ---------------------------------------------------------- sheets */

.sheet-host {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}

.sheet-host[hidden] { display: none; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } }

.sheet {
  position: relative;
  width: min(540px, 100%);
  max-height: min(86dvh, 760px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sheet);
  padding: 26px;
  animation: sheetIn 0.28s var(--ease);
}

@keyframes sheetIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
}

@media (max-width: 620px) {
  .sheet-host { place-items: end center; padding: 0; }
  .sheet {
    width: 100%;
    max-height: 90dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0;
    padding: 24px 20px calc(28px + env(safe-area-inset-bottom));
  }
  @keyframes sheetIn { from { transform: translateY(100%); } }
}

.sheet h3 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.022em;
  margin-bottom: 4px;
}

.sheet-lede {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 26px;
}

.sheet-actions .btn { flex: 1; }

.field { display: grid; gap: 7px; margin-bottom: 18px; }

.field-label {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.field-hint { font-size: 12.5px; color: var(--text-dim); }

.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  outline: none;
  font-size: 16px;
  transition: border-color 0.18s;
}

.input:focus { border-color: var(--accent-line); }

textarea.input {
  height: 140px;
  padding: 12px 14px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

/* option groups (sounds, theme) */

.options { display: grid; gap: 7px; }

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  text-align: left;
  width: 100%;
  transition: border-color 0.16s, background 0.16s;
}

.option:hover { border-color: var(--line-strong); }

.option.is-on {
  border-color: var(--accent-line);
  background: var(--accent-wash);
}

.option-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.option-title { font-size: 15px; font-weight: 600; }
.option > .option-title { flex: 1; min-width: 0; }  /* label with no sub-line */
.option-hint { font-size: 12.5px; color: var(--text-dim); }

.option-check {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  transition: border-color 0.16s, background 0.16s;
}

.option.is-on .option-check {
  border-color: var(--accent);
  background: var(--accent);
}

.option.is-on .option-check::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-ink);
}

.seg-group {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
}

.seg-group button {
  flex: 1;
  padding: 9px 10px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  transition: background 0.16s, color 0.16s;
}

.seg-group button.is-on {
  background: var(--bg-elev-2);
  color: var(--text);
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 30px;
  background: none;
  outline: none;
}

.slider::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-elev);
  box-shadow: var(--shadow-pop);
}

.slider::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
}

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-elev);
}

.sheet-section {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.sheet-section:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }

.sheet-section > h4 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stack { display: grid; gap: 9px; }

.note {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-dim);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 15px;
}

.note b { color: var(--text); font-weight: 600; }

/* a small heading inside a settings section */
.group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  margin: 2px 0 8px;
}

.options + .group-label { margin-top: 16px; }

/* a row that opens another sheet */
.link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  text-align: left;
  transition: border-color 0.16s, background 0.16s;
}

.link-row:hover { border-color: var(--line-strong); background: var(--bg-elev-2); }
.link-row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.link-row-title { font-size: 15px; font-weight: 600; }
.link-row-sub { font-size: 12.5px; color: var(--text-dim); }

/* the bar: one button per beat */
.beat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 7px;
}

.beat {
  display: grid;
  gap: 3px;
  justify-items: center;
  padding: 11px 6px;
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  transition: transform 0.1s var(--ease), background 0.16s, border-color 0.16s, color 0.16s;
}

.beat:active { transform: scale(0.95); }

.beat-no {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.beat-role {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* The downbeat is the loud one, so it is the one that looks loud. */
.beat[data-role="accent"] {
  background: var(--accent-wash);
  border-color: var(--accent-line);
  color: var(--accent);
}

.beat[data-role="accent"] .beat-role { color: var(--accent); }

.beat[data-role="off"] { opacity: 0.45; }
.beat[data-role="off"] .beat-no { font-weight: 400; }

/* picker rows inside "add songs" */

.search-sheet {
  background: var(--bg-sunken);
  margin-top: 16px;
  margin-bottom: 12px;
}

.picker { display: grid; gap: 6px; max-height: 46dvh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }

.picker-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-dim);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
}

.picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  width: 100%;
  text-align: left;
  transition: border-color 0.16s, background 0.16s;
}

.picker-row.is-on { border-color: var(--accent-line); background: var(--accent-wash); }
.picker-row .row-main { gap: 0; }

.picker-check {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 13px;
  transition: border-color 0.16s, background 0.16s, color 0.16s;
}

.picker-row.is-on .picker-check {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

/* ---------------------------------------------------------- toasts */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
}

.toast {
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sheet);
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  animation: toastIn 0.26s var(--ease);
}

.toast.is-out { animation: toastOut 0.24s var(--ease) forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------- responsive trims */

/*
 * Short screens tighten up. The dial gives up the room rather than the gap above
 * the nav — that gap is what stops a hurried tap on Next from hitting Stop.
 * The service name stays put: it is the only way in to the editor.
 */
@media (max-height: 700px) {
  .live-stage { --stage-gap: clamp(8px, 1.4vh, 16px); }
  .live-service { padding: 3px 10px; font-size: 10.5px; }
  .dial { width: clamp(140px, 27vmin, 230px); }
  .bpm { font-size: clamp(44px, 11vmin, 78px); }
  .nudge-btn { height: clamp(38px, 6.5vmin, 52px); }
  .transport { padding: 12px 28px; font-size: 16px; }
  .live-nav { margin-top: max(30px, 5vh); }
}

@media (max-width: 420px) {
  .live-nav { gap: 8px; }
  .navbtn { padding: 12px 14px; min-width: 0; flex: 1 1 0; }
}

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