/* ── VARIABLES (Bootstrap 5 palette) ─────────────────────── */
:root {
  --font:           system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg:             #f8f9fa;
  --white:          #ffffff;
  --border:         #dee2e6;
  --text:           #212529;
  --muted:          #6c757d;
  --mono:           "SFMono-Regular", "Menlo", "Consolas", monospace;

  --blue:           #0d6efd;
  --blue-bg:        #e7f1ff;
  --blue-border:    #b6d4fe;
  --green:          #198754;
  --green-bg:       #d1e7dd;
  --green-border:   #a3cfbb;
  --red:            #dc3545;
  --red-bg:         #f8d7da;
  --red-border:     #f1aeb5;

  --radius:         0.5rem;
  --shadow:         0 1px 4px rgba(0,0,0,.08);
}

/* ── RESET ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html   { height: 100%; background: var(--bg); }
body   {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
ul     { list-style: none; }
button { appearance: none; background: none; border: none; cursor: pointer; font: inherit; color: inherit; }
svg    { display: block; }

/* ── NAVBAR ───────────────────────────────────────────────── */
.navbar {
  background: #212529;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  position: sticky;
  top: 0;
  z-index: 20;
}

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

/* Status pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.8);
  transition: background .3s, color .3s, border-color .3s;
}
.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .5;
  flex-shrink: 0;
}

.status-pill.is-loading { color: #ffc107; border-color: rgba(255,193,7,.4); }
.status-pill.is-loading .pill-dot { animation: blink 1.3s ease infinite; opacity: 1; }
.status-pill.is-ready   { color: #75b798; border-color: rgba(117,183,152,.4); }
.status-pill.is-ready   .pill-dot { opacity: 1; }
.status-pill.is-offline { color: #ffc107; border-color: rgba(255,193,7,.4); }
.status-pill.is-offline .pill-dot { opacity: 1; }

@keyframes blink { 0%,100%{ opacity:1 } 50%{ opacity:.2 } }

/* ── LAYOUT ───────────────────────────────────────────────── */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px max(40px, calc(env(safe-area-inset-bottom, 0px) + 40px));
}

/* ── STOP CARDS ───────────────────────────────────────────── */
.stop-list { display: flex; flex-direction: column; gap: 8px; }

.stop-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

/* Card main row */
.stop-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 14px 14px 16px;
  min-height: 72px;
}

/* Number badge */
.stop-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f0f0f0;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
}

/* Body */
.stop-body {
  flex: 1;
  min-width: 0;
}
.stop-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sub-row: eq bars + time — or checkmark — or error
   Collapsed in idle state so the title stays vertically centered with the badge */
.stop-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  max-height: 0;
  overflow: hidden;
  margin-top: 0;
  transition: max-height .2s ease, margin-top .2s ease;
}

.stop-card.is-playing .stop-sub,
.stop-card.is-paused  .stop-sub,
.stop-card.is-done    .stop-sub,
.stop-card.is-error   .stop-sub {
  max-height: 22px;
  margin-top: 5px;
}

/* Equalizer */
.eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  opacity: 0;
  transition: opacity .2s;
  flex-shrink: 0;
}
.eq-b {
  width: 3px;
  border-radius: 1.5px;
  background: var(--blue);
  animation: eq var(--d,.7s) ease-in-out infinite alternate;
  animation-play-state: paused;
}
.eq-b:nth-child(1) { --d:.55s; height:30%; }
.eq-b:nth-child(2) { --d:.80s; height:70%; animation-delay:.10s; }
.eq-b:nth-child(3) { --d:.62s; height:50%; animation-delay:.22s; }
.eq-b:nth-child(4) { --d:.45s; height:90%; animation-delay:.05s; }
.eq-b:nth-child(5) { --d:.70s; height:60%; animation-delay:.16s; }
.eq-b:nth-child(6) { --d:.90s; height:40%; animation-delay:.08s; }
.eq-b:nth-child(7) { --d:.58s; height:75%; animation-delay:.28s; }

@keyframes eq { from { transform:scaleY(.2) } to { transform:scaleY(1) } }

/* Time */
.stop-time {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--blue);
  opacity: 0;
  transition: opacity .2s;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Checkmark badge */
.stop-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
  opacity: 0;
  transition: opacity .2s;
}
.stop-check svg {
  width: 14px; height: 14px;
  stroke: var(--green);
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Error */
.stop-err {
  font-size: 12px;
  color: var(--red);
  opacity: 0;
  transition: opacity .2s;
}

/* Progress bar (slides in) */
.stop-progress {
  height: 0;
  overflow: hidden;
  transition: height .2s ease;
  padding: 0 16px;
  background: var(--white);
}
.stop-progress-track {
  height: 4px;
  background: #e9ecef;
  border-radius: 2px;
  overflow: hidden;
}
.stop-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--blue);
  border-radius: 2px;
  transition: width .1s linear;
}

/* ── PLAY/PAUSE BUTTON ────────────────────────────────────── */
.stop-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.stop-btn:active { transform: scale(.9); }
.stop-btn svg    { width: 18px; height: 18px; }
.stop-btn .i-pause { display: none; }

/* ── CARD STATES ──────────────────────────────────────────── */

/* PLAYING */
.stop-card.is-playing {
  border-color: var(--blue-border);
  background: var(--blue-bg);
  box-shadow: 0 2px 8px rgba(13,110,253,.12);
}
.stop-card.is-playing .stop-num {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.stop-card.is-playing .stop-progress {
  height: 16px;
  padding-top: 6px;
  padding-bottom: 6px;
  background: var(--blue-bg);
}
.stop-card.is-playing .eq         { opacity: 1; }
.stop-card.is-playing .eq-b       { animation-play-state: running; }
.stop-card.is-playing .stop-time  { opacity: 1; }
.stop-card.is-playing .stop-btn {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(13,110,253,.3);
}
.stop-card.is-playing .stop-btn .i-play  { display: none; }
.stop-card.is-playing .stop-btn .i-pause { display: block; }
.stop-card.is-playing .stop-progress-fill { background: var(--blue); }

/* PAUSED */
.stop-card.is-paused .stop-progress {
  height: 16px;
  padding-top: 6px;
  padding-bottom: 6px;
}
.stop-card.is-paused .eq         { opacity: 1; }
.stop-card.is-paused .eq-b       { animation-play-state: paused; }
.stop-card.is-paused .stop-time  { opacity: 1; color: var(--muted); }
.stop-card.is-paused .stop-btn {
  border-color: var(--blue);
  color: var(--blue);
}
.stop-card.is-paused .stop-btn .i-play  { display: none; }
.stop-card.is-paused .stop-btn .i-pause { display: block; }

/* DONE */
.stop-card.is-done {
  border-color: var(--green-border);
  background: var(--green-bg);
  opacity: .8;
}
.stop-card.is-done .stop-num {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.stop-card.is-done .stop-check { opacity: 1; }
.stop-card.is-done .stop-btn {
  border-color: var(--border);
  color: #adb5bd;
}

/* ERROR */
.stop-card.is-error {
  border-color: var(--red-border);
  background: var(--red-bg);
}
.stop-card.is-error .stop-err { opacity: 1; }
.stop-card.is-error .stop-btn {
  border-color: var(--red);
  color: var(--red);
}

/* ── RESET BUTTON ─────────────────────────────────────────── */
.reset-wrap {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.btn-reset {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: background .15s, border-color .15s, color .15s, opacity .2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-reset:not(:disabled):hover {
  background: #f8f9fa;
  border-color: #adb5bd;
  color: var(--text);
}
.btn-reset:not(:disabled):active { transform: scale(.97); }
.btn-reset:disabled { opacity: .4; cursor: not-allowed; }
