/* ═══════════════════════════════════════════════════════════
   RACE AUDIO — Web App Styles
   Mobile-first, app-like layout. Negro + amarillo.
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────── */
:root {
  --yellow:      #FFE600;
  --yellow-dim:  rgba(255, 230, 0, 0.12);
  --yellow-glow: rgba(255, 230, 0, 0.25);
  --black:       #0A0A0A;
  --surface:     #141414;
  --surface2:    #1C1C1E;
  --border:      rgba(255,255,255,0.1);
  --text:        #FFFFFF;
  --text-dim:    #8E8E93;
  --red:         #FF3B30;
  --green:       #34C759;
  --orange:      #FF9500;

  --hdr-h:       52px;
  --nav-h:       72px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bot:    env(safe-area-inset-bottom, 0px);
  --radius:      14px;
  --radius-sm:   8px;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--black);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body { overflow: hidden; }
input, button, audio { font-family: inherit; }
svg { display: block; flex-shrink: 0; }

/* ── App Shell ──────────────────────────────────────────── */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────── */
header {
  position: relative;
  z-index: 20;
  height: calc(var(--hdr-h) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-inline: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #FFE600 0%, #F0D300 100%);
  border-bottom: none;
  box-shadow: 0 1px 0 rgba(0,0,0,0.10), 0 4px 20px rgba(180,150,0,0.22);
  flex-shrink: 0;
}
.hdr-left  { display: flex; align-items: center; gap: 10px; }
.hdr-logo  {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: #0A0A0A;
  padding: 3px;
  object-fit: contain;
  flex-shrink: 0;
}
.hdr-title {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #0A0A0A;
}
.hdr-action {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(0,0,0,0.10);
  border: 1.5px solid rgba(0,0,0,0.14);
  color: #0A0A0A;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s;
}
.hdr-action:active { background: rgba(0,0,0,0.20); }
.hdr-action svg { width: 18px; height: 18px; }

/* ── Main ────────────────────────────────────────────────── */
#main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ── Footer Nav ─────────────────────────────────────────── */
.footer-nav {
  position: relative;
  z-index: 20;
  height: calc(var(--nav-h) + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn svg  { width: 22px; height: 22px; }
.tab-btn.active { color: var(--yellow); }
.tab-btn.active svg { stroke: var(--yellow); }

/* FAB — centro del footer */
.fab-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--yellow);
  border: none;
  color: var(--black);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 24px var(--yellow-glow), 0 4px 12px rgba(0,0,0,0.4);
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 6px;
}
.fab-btn:active { transform: scale(0.93); }
.fab-btn svg { width: 26px; height: 26px; }

/* ── Screens & Tabs ─────────────────────────────────────── */
.screen, .tab-screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.screen.active, .tab-screen.active { display: flex; }
.hidden { display: none !important; }

/* ── Scrollable areas within tabs ───────────────────────── */
.list-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 16px;
}
.teams-scroll { padding-bottom: 80px; }

/* ── Tab header ─────────────────────────────────────────── */
.tab-hdr {
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-hdr h2 { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 8px; }

/* ── Onboarding ─────────────────────────────────────────── */
.ob-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px 20px;
  gap: 28px;
  overflow-y: auto;
}
.ob-top  { text-align: center; }
.ob-logo { width: 72px; height: 72px; object-fit: contain; margin: 0 auto 16px; }
.ob-title { font-size: 32px; font-weight: 900; letter-spacing: -1px; margin-bottom: 8px; }
.ob-sub   { font-size: 15px; color: var(--text-dim); line-height: 1.4; max-width: 260px; margin: 0 auto; }

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 400px;
}
.card-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--yellow);
  margin-bottom: 14px;
  text-align: center;
}
.join-card { display: flex; flex-direction: column; gap: 12px; }

/* ── Deeplink join card ─────────────────────────────────── */
.join-card-dl { text-align: center; align-items: center; }
.dl-name-label {
  text-align: center;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--yellow);
  margin-bottom: 6px;
}

/* Name input — inherits .inp dark bg, overrides for bigger feel */
.inp-dl-name {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  padding: 18px 16px;
  letter-spacing: -0.3px;
}
.inp-dl-name::placeholder {
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
}

/* ── Inputs ─────────────────────────────────────────────── */
.inp {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.inp:focus { border-color: var(--yellow); }
.inp::placeholder { color: var(--text-dim); }
.inp-code {
  text-transform: uppercase;
  letter-spacing: 6px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
}
.inp::placeholder { text-align: center; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn-primary  { background: var(--yellow); color: var(--black); }
.btn-ghost    { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger   { background: var(--red); color: white; }
.btn-lg       { padding: 17px 20px; font-size: 17px; font-weight: 900; letter-spacing: 0.5px; }
.btn-sm       { padding: 8px 14px; width: auto; font-size: 13px; }

/* ── Divider ─────────────────────────────────────────────── */
.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-dim); font-size: 12px;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* ── Error ───────────────────────────────────────────────── */
.err-msg { color: var(--red); font-size: 13px; text-align: center; min-height: 16px; }

/* ── Auth screen ─────────────────────────────────────────── */
.auth-wrap {
  height: 100%;
  overflow-y: auto;
  padding: 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.back-btn {
  display: flex; align-items: center; gap: 4px;
  background: none; border: none; color: var(--text-dim); font-size: 15px; cursor: pointer;
  padding: 0; width: auto;
}
.back-btn svg { width: 20px; height: 20px; }
.auth-title { font-size: 26px; font-weight: 800; }
.auth-tabs  { display: flex; gap: 4px; background: var(--surface2); border-radius: 10px; padding: 4px; }
.auth-tab   {
  flex: 1; padding: 9px; border-radius: 8px; border: none; background: none;
  color: var(--text-dim); font-size: 14px; font-weight: 600; cursor: pointer;
}
.auth-tab.active { background: var(--surface); color: var(--text); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }

/* ── Race cards ──────────────────────────────────────────── */
.race-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
}
.race-card.active-border { border-color: var(--yellow); }
.race-card-hdr { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.race-card-code { font-size: 18px; font-weight: 900; letter-spacing: 2px; }
.race-status {
  font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 100px;
}
.status-active   { background: rgba(52,199,89,0.15);  color: var(--green); }
.status-waiting  { background: rgba(255,230,0,0.12);   color: var(--yellow); }
.status-ended    { background: rgba(255,255,255,0.08); color: var(--text-dim); }
.race-card-info  { display: flex; gap: 16px; margin-bottom: 12px; }
.race-info-item  { font-size: 13px; color: var(--text-dim); }
.race-info-item strong { color: var(--text); font-weight: 600; }
.race-card-actions { display: flex; gap: 8px; }
.race-card-actions .btn { flex: 1; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
}
.empty-icon { width: 52px; height: 52px; opacity: 0.3; }
.empty-state p  { font-size: 16px; }
.empty-state .btn { margin-top: 8px; width: auto; }

/* ── Texts ───────────────────────────────────────────────── */
.text-dim { color: var(--text-dim); }
.text-sm  { font-size: 12px; }
.badge-count {
  background: var(--yellow); color: var(--black);
  font-size: 11px; font-weight: 800;
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ── Teams tab ───────────────────────────────────────────── */
.teams-race-group { margin-bottom: 20px; }
.teams-group-title { font-size: 13px; font-weight: 700; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; }
.teams-runner-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.teams-runner-chip.selected {
  border-color: var(--yellow);
  background: var(--yellow-dim);
}
.chip-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.teams-runner-chip.selected .chip-check {
  background: var(--yellow); border-color: var(--yellow); color: var(--black);
}
.chip-info { flex: 1; }
.chip-code { font-size: 15px; font-weight: 700; letter-spacing: 1px; }
.chip-name { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.chip-status { font-size: 11px; }

.teams-send-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 12px 16px calc(12px + var(--safe-bot));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 10;
}
.teams-send-bar .btn { width: auto; padding: 12px 20px; display: flex; align-items: center; gap: 8px; }

/* ── Profile tab ─────────────────────────────────────────── */
.profile-section { margin-bottom: 20px; }
.profile-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 10px;
}
.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.profile-row-label { font-size: 15px; font-weight: 600; }
.profile-row-val   { font-size: 14px; color: var(--text-dim); }
.profile-row .btn  { width: auto; }

/* ── Audio list items ────────────────────────────────────── */
.audio-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.audio-item-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--yellow-dim); color: var(--yellow);
  display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0;
}
.audio-item-info { flex: 1; min-width: 0; }
.audio-item-to   { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audio-item-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.audio-item-status { flex-shrink: 0; }
.status-pill {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 100px;
}
.pill-sent      { background: rgba(255,255,255,0.08);  color: var(--text-dim); }
.pill-delivered { background: rgba(52,199,89,0.15);    color: var(--green); }
.pill-blocked   { background: rgba(255,59,48,0.12);    color: var(--red); }

/* ── MODAL: full-screen send ─────────────────────────────── */
.modal-fs {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--black);
  display: flex;
  flex-direction: column;
}
.send-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ms-hdr {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ms-hdr h2 { font-size: 20px; font-weight: 800; }
.ms-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 20px; cursor: pointer; align-self: flex-end; padding: 0; line-height: 1;
  margin-bottom: 4px;
}
.ms-back { align-self: flex-start; }
.ms-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: calc(16px + var(--safe-bot));
}

/* Recipients selection */
.recipients-grid { display: flex; flex-direction: column; gap: 8px; }

/* ── Pre-race send banner ────────────────────────────────── */
.prerace-send-banner {
  background: rgba(255,214,0,0.1);
  border: 1px solid rgba(255,214,0,0.35);
  color: var(--yellow);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
  margin-bottom: 4px;
}

/* ── Recording ───────────────────────────────────────────── */
.record-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
}
.rec-to {
  font-size: 14px; color: var(--text-dim); text-align: center; font-weight: 500;
}
.rec-to strong { color: var(--yellow); }
#rec-idle { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.record-btn {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: var(--yellow);
  border: none;
  color: var(--black);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 40px var(--yellow-glow);
  animation: pulse 2s infinite;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.record-btn:active { transform: scale(0.95); animation: none; }
.record-btn svg { width: 44px; height: 44px; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 40px var(--yellow-glow); }
  50%       { box-shadow: 0 0 60px rgba(255,230,0,0.5); }
}
.rec-hint { font-size: 14px; color: var(--text-dim); text-align: center; }
#rec-recording { display: flex; flex-direction: column; align-items: center; gap: 20px; width: 100%; }
.rec-status { display: flex; align-items: center; gap: 12px; }
.rec-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--red);
  animation: blink 1s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
#rec-timer { font-size: 48px; font-weight: 200; font-variant-numeric: tabular-nums; font-family: "SF Mono", "Fira Code", monospace; }
.rec-bar {
  width: 100%; height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden;
}
#rec-fill { height: 100%; background: var(--red); transition: width 0.5s linear; border-radius: 2px; }
.rec-stop-btn { width: auto; padding: 14px 40px; }

/* ── Review ──────────────────────────────────────────────── */
.review-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
}
.preview-audio { width: 100%; max-width: 340px; filter: invert(1) hue-rotate(180deg); }
.review-btns   { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 340px; }
.review-compat-warn {
  font-size: 12px;
  color: #f0a500;
  background: rgba(240, 165, 0, 0.1);
  border: 1px solid rgba(240, 165, 0, 0.25);
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 340px;
  text-align: center;
  line-height: 1.5;
}

/* ── Send result ─────────────────────────────────────────── */
.send-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}
#s4-sending { display: flex; flex-direction: column; align-items: center; gap: 20px; width: 100%; }
#s4-success, #s4-error {
  display: flex; flex-direction: column; align-items: center;
  gap: 20px; width: 100%;
}
.spinner-lg {
  width: 52px; height: 52px;
  border: 4px solid var(--border);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#s4-status { font-size: 16px; color: var(--text-dim); }
.send-prog-bar {
  width: 100%; max-width: 300px; height: 4px;
  background: var(--surface2); border-radius: 2px; overflow: hidden;
}
#send-prog-fill { height: 100%; background: var(--yellow); border-radius: 2px; transition: width 0.3s; }
.result-icon {
  width: 108px; height: 108px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  animation: result-pop 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes result-pop {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.result-icon.result-ok  { background: rgba(52,199,89,0.14);  box-shadow: 0 0 48px rgba(52,199,89,0.28);  color: var(--green); }
.result-icon.result-err { background: rgba(255,59,48,0.12);  box-shadow: 0 0 48px rgba(255,59,48,0.22);  color: var(--red);   }
.result-title-group { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.result-title-group h2 { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; margin: 0; }
.result-subtitle { font-size: 15px; color: var(--text-dim); margin: 0; }
.result-list { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 320px; }
.result-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--surface); border-radius: var(--radius-sm);
  font-size: 14px;
}
.send-result-btns { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; }

/* ── Deep link join screen ───────────────────────────────── */
.dl-hero {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 8px; padding: 8px 0 4px;
}
.dl-icon { font-size: 52px; line-height: 1; margin-bottom: 4px; }
.dl-pre  { font-size: 14px; color: var(--text-dim); margin: 0; }
.dl-runner-name {
  font-size: 28px; font-weight: 900; letter-spacing: -0.5px;
  color: var(--text); min-height: 36px;
}
.dl-race-code {
  font-size: 13px; font-weight: 700; letter-spacing: 3px;
  color: var(--yellow); font-family: var(--font-mono, monospace);
  background: rgba(255,214,0,0.08); padding: 4px 12px;
  border-radius: 20px; margin-top: 2px;
}
.dl-status-badge {
  font-size: 13px; font-weight: 600; padding: 6px 14px;
  border-radius: 20px; margin-top: 6px; text-align: center; line-height: 1.4;
}
.dl-status-badge.hidden { display: none; }
.dl-status-prerace {
  background: rgba(255,214,0,0.12);
  color: var(--yellow);
  border: 1px solid rgba(255,214,0,0.3);
}
/* ── Training-only deep link state ───────────────────────── */
.dl-training-info {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 28px 20px; text-align: center;
}
.dl-training-info.hidden { display: none; }
.dl-training-icon { font-size: 48px; line-height: 1; }
.dl-training-title {
  font-size: 18px; font-weight: 800; letter-spacing: 1px;
  color: #fff; text-transform: uppercase; margin: 0;
}
.dl-training-msg {
  font-size: 14px; color: rgba(255,255,255,0.55); line-height: 1.6;
  max-width: 280px; margin: 0;
}
.dl-status-live {
  background: rgba(0,220,100,0.12);
  color: #00dc64;
  border: 1px solid rgba(0,220,100,0.3);
}

/* ── Modal sheet (agregar carrera) ───────────────────────── */
.modal-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(24px + var(--safe-bot));
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.modal-sheet.open { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); align-self: center; margin-bottom: 4px;
}
.sheet-title { font-size: 18px; font-weight: 800; }
.backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ── Spinner (inline) ────────────────────────────────────── */
.spinner-sm {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 0; }

/* ── Mono ────────────────────────────────────────────────── */
.mono {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  letter-spacing: 1px;
}

/* ── Race card (new layout) ─────────────────────────────── */
.race-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 8px;
}
.race-name       { font-size: 17px; font-weight: 700; }
.race-code-label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.race-status-pill {
  font-size: 11px; font-weight: 700; padding: 4px 10px;
  border-radius: 100px; white-space: nowrap; flex-shrink: 0;
  background: var(--surface2);
}
.race-card.status-live  { border-color: rgba(52,199,89,0.35); }
.race-card.status-live  .race-status-pill { background: rgba(52,199,89,0.15); color: var(--green); }
.race-card.status-wait  .race-status-pill { background: rgba(255,230,0,0.12); color: var(--yellow); }
.race-card.status-end   { opacity: 0.6; }
.race-stats-row  { display: flex; gap: 16px; margin-bottom: 10px; }
.race-stat       { font-size: 13px; color: var(--text-dim); }
.race-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.race-audio-count      { font-size: 12px; color: var(--text-dim); }
.race-audio-count.at-limit { color: var(--red); }
.race-actions          { display: flex; gap: 8px; }

/* ── Audio list (new) ────────────────────────────────────── */
.audio-item-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.audio-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--yellow-dim); color: var(--yellow);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.audio-to   { font-size: 14px; font-weight: 600; }
.audio-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.audio-badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px;
  border-radius: 100px; flex-shrink: 0;
}
.badge-ok      { background: rgba(52,199,89,0.15); color: var(--green); }
.badge-pending { background: var(--surface2); color: var(--text-dim); }

/* ── Teams (new) ─────────────────────────────────────────── */
.teams-gate {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 16px;
  padding: 60px 24px 40px;
}
.teams-gate-icon {
  width: 88px; height: 88px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.teams-gate-title {
  font-size: 17px; font-weight: 700; margin: 0;
}
.teams-gate .btn { width: 100%; max-width: 300px; margin-top: 4px; }

.teams-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.team-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.team-row input[type="checkbox"] { display: none; }
.team-row.team-row-sel {
  border-color: var(--yellow);
  background: var(--yellow-dim);
}
.team-info      { flex: 1; }
.team-name      { font-size: 15px; font-weight: 600; }
.team-code      { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.team-status-icon { font-size: 18px; }

/* ── Profile (new) ───────────────────────────────────────── */
.profile-user-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
/* keep old class working too */
.profile-user-row { display: flex; align-items: center; gap: 14px;
  padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); }
.avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--yellow); color: var(--black);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 900; flex-shrink: 0;
}
.profile-name  { font-size: 17px; font-weight: 700; }
.profile-email { font-size: 13px; margin-top: 2px; }

/* Action card (reset password + sign out) */
.profile-actions-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  margin-bottom: 24px;
}
.profile-action-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 15px 16px; background: none; border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text); font-size: 15px; font-weight: 500;
  cursor: pointer; text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}
.profile-action-row:last-child { border-bottom: none; }
.profile-action-row:active     { background: var(--surface2); }
.profile-action-row.danger     { color: var(--red); }
.profile-action-row svg        { color: var(--text-dim); flex-shrink: 0; }
.profile-action-row.danger svg { color: var(--red); opacity: 0.6; }

/* Past races list */
.profile-section { margin-bottom: 24px; }
.section-title {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-dim);
  margin-bottom: 8px; padding: 0 2px;
}
.past-race-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.past-race-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,214,0,0.15); color: var(--yellow);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; flex-shrink: 0;
}
.past-race-info    { flex: 1; min-width: 0; }
.past-race-runner  { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.past-race-meta    { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.profile-empty     { padding: 8px 2px; }
.row-label { font-size: 14px; font-weight: 600; }
.row-sub   { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ── Recipients (send modal S1) ─────────────────────────── */
.recip-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 40px 20px; text-align: center;
}
.recip-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.recip-card input[type="checkbox"] { display: none; }
.recip-card.recip-sel {
  border-color: var(--yellow);
  background: var(--yellow-dim);
}
.recip-info       { flex: 1; }
.recip-name       { font-size: 15px; font-weight: 600; }
.recip-code       { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.recip-check-icon {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
  color: transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.recip-card.recip-sel .recip-check-icon {
  background: var(--yellow); border-color: var(--yellow); color: var(--black);
}

/* ── Race card links row (mapa / tracker) ───────────────── */
.race-links-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.race-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.1s;
}
.race-link-btn:active { opacity: 0.65; }
.race-link-btn.btn-map {
  color: var(--yellow);
  border-color: rgba(255, 230, 0, 0.3);
  background: rgba(255, 230, 0, 0.06);
}

/* ── Map modal ───────────────────────────────────────────── */
#modal-map {
  z-index: 210;
}
.map-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}
.map-runner-title {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#map-container {
  flex: 1;
  min-height: 0;
  background: #1a2030; /* visible placeholder while tiles load */
  width: 100%;
}
.map-no-location {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text);
  font-size: 15px;
  padding: 24px;
  text-align: center;
}
.map-no-location span { font-size: 52px; line-height: 1; }
.map-no-location p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.5; }
.map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-bot));
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 44px;
}
.map-footer-dist { font-size: 14px; font-weight: 600; }

/* Runner pin on map */
.runner-map-pin {
  width: 36px;
  height: 36px;
  background: var(--yellow);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid rgba(0,0,0,0.35);
  box-shadow: 0 2px 14px rgba(255,230,0,0.45), 0 0 0 4px rgba(255,230,0,0.15);
  animation: pin-pulse 2s ease-out infinite;
}
@keyframes pin-pulse {
  0%   { box-shadow: 0 2px 14px rgba(255,230,0,.45), 0 0 0 0   rgba(255,230,0,.25); }
  70%  { box-shadow: 0 2px 14px rgba(255,230,0,.45), 0 0 0 10px rgba(255,230,0,0); }
  100% { box-shadow: 0 2px 14px rgba(255,230,0,.45), 0 0 0 0   rgba(255,230,0,0); }
}

/* Leaflet dark mode tweaks */
.leaflet-container { background: #1a2030; font-family: inherit; }
.leaflet-control-attribution {
  background: rgba(10,10,10,0.85) !important;
  color: var(--text-dim) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--yellow) !important; }
.leaflet-bar a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-bar a:hover { background: var(--surface2) !important; }

/* ── Result rows ─────────────────────────────────────────── */
.result-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 12px;
  font-size: 15px; font-weight: 600; text-align: left;
}
.result-row svg { flex-shrink: 0; }
.result-row-text { display: flex; flex-direction: column; gap: 2px; }
.result-row-sub  { font-size: 13px; font-weight: 400; opacity: 0.72; }
.result-row.result-ok   { background: rgba(52,199,89,0.12);  color: var(--green); }
.result-row.result-err  { background: rgba(255,59,48,0.12);  color: var(--red); }
.result-row.result-warn { background: rgba(255,149,0,0.12);  color: var(--orange); }

/* ── Spinner (reusable) ──────────────────────────────────────── */
@keyframes ra-spin { to { transform: rotate(360deg); } }

.btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: ra-spin 0.65s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
  flex-shrink: 0;
}
/* On ghost/dark buttons the spinner should use yellow */
.btn-ghost .btn-spinner,
.btn-spinner-inv {
  border-color: rgba(255, 255, 255, 0.15);
  border-top-color: var(--yellow);
}
.btn:disabled { opacity: 0.65; cursor: not-allowed; }

/* ── Skeleton shimmer ────────────────────────────────────────── */
@keyframes ra-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #1c1c1e 25%, #2c2c2e 50%, #1c1c1e 75%);
  background-size: 400px 100%;
  animation: ra-shimmer 1.3s ease infinite;
  border-radius: 10px;
}
.skeleton-card {
  height: 118px;
  border-radius: 18px;
  margin-bottom: 12px;
}
.skeleton-row {
  height: 22px;
  border-radius: 6px;
  margin-bottom: 10px;
}

/* ── Toast Notifications ─────────────────────────────────── */
.toast-notification {
  position: fixed;
  top: calc(var(--safe-top) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: #1C1C1E;
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.1);
}
.toast-notification.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-notification.toast-ended {
  background: #1a1a1a;
  border-color: rgba(255,255,255,0.15);
}
.toast-notification.toast-warning {
  background: #2a1a00;
  border-color: rgba(255,149,0,0.4);
  color: #FF9500;
}

/* ── Race ended banner ───────────────────────────────────── */
.race-ended-banner {
  background: rgba(255,255,255,0.05);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  border-radius: var(--radius) var(--radius) 0 0;
  margin: -16px -16px 12px -16px;
}

/* ── Profile Past Races loading ──────────────────────────── */
.past-races-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0;
}
.spinner-sm {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,230,0,0.2);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: sh-rotate 0.8s linear infinite;
  flex-shrink: 0;
}

/* ── Past Race Cards (usuarios logueados) ────────────────── */
.past-race-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  overflow: hidden;
}
.past-race-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
}
.past-race-card-info {
  flex: 1;
  min-width: 0;
}
.past-race-runner-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.past-race-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.past-race-chip {
  background: rgba(255,255,255,0.07);
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}
.past-race-badge {
  background: var(--yellow-dim);
  color: var(--yellow);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.past-race-audios-list {
  border-top: 1px solid var(--border);
  padding: 6px 0;
}
.past-audio-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
}
.past-audio-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--yellow);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #000;
  transition: opacity 0.15s;
}
.past-audio-btn:active { opacity: 0.7; }
.past-audio-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.past-audio-dur {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}


/* Badge "pre-race" en lista de destinatarios */
.badge-prerace {
  display: inline-block;
  background: rgba(255, 230, 0, 0.12);
  color: var(--yellow);
  border: 1px solid rgba(255, 230, 0, 0.3);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  margin-top: 3px;
  letter-spacing: 0.3px;
}
.past-race-player { display: none; }
