/* ==========================================================================
   Music Sync — Apple design system
   Source of truth: .kombai/canvas/music-sync-apple.canvas
   (Dir 1 · Invitation-first · Phone var_badc1b7b9c62 + Desktop var_1c33463b3370
    + States board var_d75595965244)
   Single Action Blue accent, no UI shadows, surface change is the divider.
   ========================================================================== */

:root {
  /* ---- surfaces ---- */
  --canvas: #ffffff;
  --parchment: #f5f5f7;
  --pearl: #fafafc;
  --black: #000000;
  --chip-translucent: rgba(210, 210, 215, .64);

  /* ---- text ---- */
  --ink: #1d1d1f;
  --ink-80: #333333;
  --muted: #7a7a7a;
  --on-dark: #ffffff;

  /* ---- lines ---- */
  --hairline: #e0e0e0;
  --divider: rgba(0, 0, 0, .08);

  /* ---- the single interactive colour ---- */
  --blue: #0066cc;
  --blue-focus: #0071e3;
  --blue-on-dark: #2997ff; /* the same intent, carried onto a dark surface */

  /* ---- dark surfaces: the black plate, plus the micro-step when two abut ---- */
  --tile-2: #2a2a2c;
  --body-muted: #cccccc;

  /* ---- radius grammar: utility / card / pill, nothing in between ---- */
  --r-utility: 8px;
  --r-card: 18px;
  --r-pill: 9999px;

  /* ---- spacing, 8px base ---- */
  --s-xxs: 4px;
  --s-xs: 8px;
  --s-sm: 12px;
  --s-md: 17px;
  --s-lg: 24px;
  --s-xl: 32px;

  /* ---- motion ---- */
  --ease: cubic-bezier(.2, 0, 0, 1);
  --fast: 150ms;
  --normal: 240ms;

  /* ---- type ---- */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Vazirmatn", Inter, system-ui, Tahoma, sans-serif;
  --font-num: Inter, "Vazirmatn", system-ui, sans-serif;

  /* ---- layout ---- */
  --content: 640px;
}

/* ---------- reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.47;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- reusable text styles ---------- */
.t-page      { font-size: 34px; font-weight: 600; line-height: 1.1; letter-spacing: -.374px; }
.t-section   { font-size: 21px; font-weight: 600; line-height: 1.19; letter-spacing: .231px; }
.t-body      { font-size: 17px; font-weight: 400; line-height: 1.47; letter-spacing: -.374px; }
.t-body-str  { font-size: 17px; font-weight: 600; line-height: 1.24; letter-spacing: -.374px; }
.t-caption   { font-size: 14px; font-weight: 400; line-height: 1.43; letter-spacing: -.224px; }
.t-caption-str { font-size: 14px; font-weight: 600; line-height: 1.29; letter-spacing: -.224px; }
.t-fine      { font-size: 12px; font-weight: 400; line-height: 1.35; letter-spacing: -.12px; }

/* Latin / numeric runs are isolated so bidi never breaks the RTL layout.
   Persian counters stay plain RTL — isolating them reverses the word order. */
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

/* ---------- icons (Lucide webfont) ---------- */
i[class^="icon-"],
i[class*=" icon-"] {
  font-style: normal;
  display: inline-block;
  line-height: 1;
  vertical-align: -2px;
}

/* ---------- shared button grammar ---------- */
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
button:disabled:active { transform: none; }
button:active:not(:disabled) { transform: scale(.95); }
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--blue-focus);
  outline-offset: 2px;
}

/* ==========================================================================
   App bar — true black, product name only
   ========================================================================== */
.bar {
  height: 44px;
  background: var(--black);
  color: var(--on-dark);
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  padding-inline: var(--s-lg);
}
.bar i { font-size: 15px; color: var(--on-dark); }
.bar .name {
  font-size: 12px;
  line-height: 1;
  letter-spacing: -.12px;
  font-weight: 400;
}

/* ==========================================================================
   Bands — the surface change itself is the section divider
   ========================================================================== */
.stack { display: flex; flex-direction: column; }

.band {
  padding-block: var(--s-lg);
  padding-inline: max(var(--s-lg), calc((100% - var(--content)) / 2));
}
.band-parchment { background: var(--parchment); }
.band-light     { background: var(--canvas); }
.band-flush-top { padding-top: 0; }

/* ==========================================================================
   1 · Room region
   ========================================================================== */
.room { display: flex; flex-direction: column; gap: var(--s-sm); }

.status {
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  font-size: 14px;
  line-height: 1.29;
  letter-spacing: -.224px;
  min-height: 18px;
}
#dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--blue);
}
#dot.ok  { background: var(--blue); }
#dot.bad { background: var(--muted); }
/* connecting: no peer path yet — a quiet pulse, never a status hue */
#dot:not(.ok):not(.bad) { animation: pulse 1.4s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* real labelled fields, not generic status pills */
.facts { display: flex; align-items: stretch; min-height: 36px; }
.fact {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding-inline-start: var(--s-sm);
  margin-inline-start: var(--s-sm);
  border-inline-start: 1px solid var(--divider);
}
.fact:first-child { padding-inline-start: 0; margin-inline-start: 0; border-inline-start: 0; }
.f-label {
  font-size: 10px;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
}
.f-val {
  font-size: 13px;
  line-height: 1;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.08px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* the value itself stays LTR, but sits under its RTL label */
.f-val.ltr { text-align: right; }

.field-label {
  display: block;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  margin-bottom: var(--s-xs);
}
.invite { display: flex; align-items: center; gap: var(--s-xs); }

#link {
  flex: 1;
  min-width: 0;
  height: 44px;
  border-radius: var(--r-pill);
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--ink);
  padding-inline: 16px;
  font-size: 12px;
  direction: ltr;
  text-align: left;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ghost pill — the second CTA grammar */
.pill-ghost {
  flex: none;
  height: 44px;
  padding-inline: 16px;
  border-radius: var(--r-pill);
  background: transparent;
  border: 1px solid var(--blue);
  color: var(--blue);
  font-size: 14px;
  line-height: 1.29;
  letter-spacing: -.224px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform var(--fast) var(--ease);
}
.pill-ghost i { font-size: 14px; }

/* ==========================================================================
   2 · Now playing
   ========================================================================== */
/* bounded container: one hairline, never a shadow */
.card,
.player {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: var(--s-lg);
  width: 100%;
}
#nowBox { display: flex; align-items: center; gap: var(--s-sm); min-width: 0; }

.eq { display: flex; align-items: flex-end; gap: 3px; height: 28px; width: 26px; flex: none; }
.eq i {
  display: block;
  width: 3px;
  border-radius: var(--r-pill);
  background: var(--hairline);
  transform-origin: bottom;
  animation: none;
}
.eq i:nth-child(1) { height: 10px; }
.eq i:nth-child(2) { height: 22px; }
.eq i:nth-child(3) { height: 15px; }
.eq i:nth-child(4) { height: 26px; }
/* bars encode the playback boolean only */
.playing .eq i { background: var(--blue); animation: eq 1.1s var(--ease) infinite; }
.playing .eq i:nth-child(2) { animation-delay: .16s; }
.playing .eq i:nth-child(3) { animation-delay: .32s; }
.playing .eq i:nth-child(4) { animation-delay: .48s; }
@keyframes eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }

.meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
#title {
  font-size: 21px;
  font-weight: 600;
  line-height: 1.19;
  letter-spacing: .231px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#roleText {
  font-size: 14px;
  line-height: 1.43;
  letter-spacing: -.224px;
  color: var(--muted);
}

/* transport is always LTR, as in the shipped app */
#player {
  direction: ltr;
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  margin-top: var(--s-lg);
}
#playBtn {
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: var(--r-utility);
  background: var(--blue);
  color: var(--on-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--fast) var(--ease);
}
#playBtn i { font-size: 17px; }
.time {
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-num);
  flex: none;
  min-width: 34px;
  text-align: center;
}

/* audio unlock lives in the player, not among the source actions */
.unlock {
  width: 100%;
  min-height: 48px;
  margin-top: var(--s-lg);
  border: 0;
  border-radius: var(--r-pill);
  background: var(--blue);
  color: var(--on-dark);
  font-size: 17px;
  line-height: 1.24;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-xs);
  transition: transform var(--fast) var(--ease);
}
.unlock i { font-size: 17px; }

/* ---------- range inputs ---------- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 24px;
  flex: 1;
  min-width: 0;
  direction: ltr;
  cursor: pointer;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: var(--r-pill);
  background: linear-gradient(to right, var(--blue) 0 var(--fill, 0%), var(--hairline) var(--fill, 0%) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  margin-top: -9.5px;
}
input[type="range"]::-moz-range-track { height: 3px; border-radius: var(--r-pill); background: var(--hairline); }
input[type="range"]::-moz-range-progress { height: 3px; border-radius: var(--r-pill); background: var(--blue); }
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  background: var(--canvas);
}
input[type="range"]:disabled { opacity: .4; cursor: default; }

/* ==========================================================================
   3 · Sources — one primary action, two secondary rows
   ========================================================================== */
.sources { display: flex; flex-direction: column; gap: var(--s-sm); }

.pill-primary {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--blue);
  color: var(--on-dark);
  font-size: 17px;
  line-height: 1.24;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-xs);
  transition: transform var(--fast) var(--ease);
}

.rows { display: flex; flex-direction: column; }
.row {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  background: none;
  border: 0;
  border-top: 1px solid var(--divider);
  font-size: 17px;
  line-height: 1.24;
  letter-spacing: -.374px;
  color: var(--blue);
  text-align: start;
  padding: 0;
  transition: transform var(--fast) var(--ease);
}
.rows > .row:first-child { border-top: 0; }
.row i { font-size: 17px; color: var(--blue); flex: none; }
.row .row-sub {
  display: block;
  font-size: 12px;
  line-height: 1.35;
  letter-spacing: -.12px;
  color: var(--muted);
  margin-top: 2px;
}
.row-text { min-width: 0; }

/* collapsible capture instructions — off the main screen until asked for */
.note-box {
  border: 1px solid var(--hairline);
  border-radius: var(--r-utility);
  background: var(--pearl);
  padding: var(--s-sm) var(--s-md);
  margin-top: var(--s-xs);
}
.note-box summary {
  cursor: pointer;
  font-size: 14px;
  line-height: 1.29;
  letter-spacing: -.224px;
  color: var(--blue);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.note-box summary::-webkit-details-marker { display: none; }
.note-box summary::before {
  content: "";
  width: 0;
  height: 0;
  border-inline-start: 4px solid transparent;
  border-inline-end: 4px solid transparent;
  border-top: 5px solid var(--blue);
  transition: transform var(--fast) var(--ease);
}
.note-box[open] summary::before { transform: rotate(180deg); }
.note-box p {
  margin: var(--s-sm) 0 0;
  font-size: 14px;
  line-height: 1.43;
  letter-spacing: -.224px;
  color: var(--ink-80);
}

/* ---------- app / device source panel ---------- */
.setup { display: flex; flex-direction: column; gap: var(--s-md); }
.setup-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-xs);
}
.setup-steps li {
  display: flex;
  gap: 10px;
  font-size: 14px;
  line-height: 1.43;
  letter-spacing: -.224px;
  color: var(--ink-80);
}
.setup-steps .n {
  flex: none;
  width: 16px;
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.setup-row { display: flex; align-items: center; gap: var(--s-xs); }

select {
  flex: 1;
  min-width: 0;
  height: 44px;
  font: inherit;
  font-size: 14px;
  letter-spacing: -.224px;
  color: var(--ink);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  padding-inline: 16px;
  direction: ltr;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid var(--hairline);
  border-radius: var(--r-utility);
  background: var(--canvas);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--fast) var(--ease);
}
.icon-btn i { font-size: 16px; }

.check {
  display: flex;
  align-items: flex-start;
  gap: var(--s-xs);
  font-size: 14px;
  line-height: 1.43;
  letter-spacing: -.224px;
  color: var(--ink-80);
}
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--blue); flex: none; }

.fine {
  font-size: 12px;
  line-height: 1.35;
  letter-spacing: -.12px;
  color: var(--muted);
  margin: 0;
}

/* ==========================================================================
   4 · My volume
   ========================================================================== */
.vol { display: flex; flex-direction: column; gap: var(--s-xs); }
.vol-head { display: flex; align-items: center; gap: var(--s-xs); }
.vol-head i { font-size: 17px; color: var(--ink); }
.vol-head .lbl { font-size: 17px; line-height: 1.24; letter-spacing: -.374px; font-weight: 600; }
.vol-head .val {
  margin-inline-start: auto;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-num);
}
.hint { font-size: 12px; line-height: 1.4; color: var(--muted); margin: 0; }

/* ==========================================================================
   Entry gate
   ========================================================================== */
.gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* short viewports must scroll the gate, never squeeze its rows out of shape */
  justify-content: safe center;
  overflow-y: auto;
  gap: var(--s-lg);
  padding: var(--s-xl) var(--s-lg);
  text-align: center;
}
.gate > * { flex: none; }
.gate .mark { font-size: 34px; color: var(--ink); }
.gate h1 { margin: 0; font-size: 34px; font-weight: 600; line-height: 1.1; letter-spacing: -.374px; }
.gate p {
  margin: 0;
  font-size: 17px;
  line-height: 1.47;
  color: var(--ink-80);
  max-width: 320px;
}
/* .gate p would otherwise out-specify .fine and print the note at body size */
.gate .fine { font-size: 12px; line-height: 1.35; letter-spacing: -.12px; color: var(--muted); }
.gate .pill-primary { width: auto; min-width: 236px; max-width: 100%; padding-inline: var(--s-xl); }

/* ==========================================================================
   Toast layer — the app bar's twin, rising from the bottom edge.
   Full-bleed and flat: severity is the surface inversion itself.
   ========================================================================== */
.toasts {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  pointer-events: none; /* an empty layer never blocks the page */
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  min-height: 44px;
  /* the same content column every band already uses */
  padding-inline: max(var(--s-lg), calc((100% - var(--content)) / 2));
  padding-block-start: var(--s-xs);
  padding-block-end: calc(var(--s-xs) + env(safe-area-inset-bottom, 0px));
  background: var(--black);
  color: var(--on-dark);
  font-size: 14px;
  line-height: 1.43;
  letter-spacing: -.224px;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity var(--normal) var(--ease), transform var(--normal) var(--ease);
}
.toast.in  { opacity: 1; transform: none; }
.toast.out { opacity: 0; transform: translateY(100%); }
/* older strips sit above the newest one: the documented micro-step, not a divider */
.toast:not(:last-child):not(.toast-success) { background: var(--tile-2); }

.toast-glyph { flex: none; font-size: 17px; color: var(--on-dark); }
.toast-msg { flex: 1 1 auto; min-width: 0; text-wrap: pretty; }

/* the one recoverable path, in the dark-surface link colour */
.toast-action {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue-on-dark);
  font-size: 14px;
  line-height: 1.29;
  letter-spacing: -.224px;
  font-weight: 600;
  white-space: nowrap;
}

.toast-close {
  flex: none;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--body-muted);
}
.toast-close i { font-size: 13px; }

/* an acknowledgement is paper, not hardware — inversion separates it from failure */
.toast-success {
  background: var(--pearl);
  color: var(--ink);
  border-top: 1px solid var(--hairline);
}
.toast-success .toast-glyph { color: var(--blue); }
.toast-success .toast-close { color: var(--muted); }

/* ---------- utilities ---------- */
.hidden { display: none !important; }
.mt-sm { margin-top: var(--s-sm); }

/* ---------- desktop ---------- */
@media (min-width: 834px) {
  .band { padding-block: var(--s-xl); }
  #title { max-width: 420px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .playing .eq i { animation: none; background: var(--blue); }
  #dot:not(.ok):not(.bad) { animation: none; }
  button, .note-box summary::before { transition: none; }
  button:active:not(:disabled) { transform: none; }
  .toast { transition: none; }
}
