/* ==========================================================
   Easy Violin — Design system
   Estética: escenario de concierto. Fondo cálido oscuro,
   acento dorado (resina / luces de sala), partitura en papel.
   ========================================================== */

:root {
  /* Surfaces */
  --bg: #0d0b12;
  --bg-glow: rgba(244, 193, 93, 0.07);
  --surface: #16131d;
  --surface-2: #1d1926;
  --surface-3: #262131;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);

  /* Text */
  --text: #f5f0e8;
  --text-2: #b8afc3;
  --text-3: #7f768b;

  /* Brand */
  --accent: #f4c15d;
  --accent-strong: #ffd27a;
  --accent-ink: #1c1405;
  --accent-soft: rgba(244, 193, 93, 0.12);

  /* Feedback */
  --good: #3dd68c;
  --good-soft: rgba(61, 214, 140, 0.14);
  --bad: #ff6b7d;
  --warn: #ff9f43;

  /* Strings (1 = Mi … 4 = Sol) */
  --str-1: #6d72ff;
  --str-2: #17b47e;
  --str-3: #e08a2e;
  --str-4: #ef4b5f;

  /* Paper */
  --paper: #f6efe1;
  --paper-ink: #2b2418;
  --paper-line: #e3d8c3;

  /* Shape & motion */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 40px -24px rgba(0, 0, 0, 0.7);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;

  --topbar-h: 64px;
  --gap: 16px;

  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg-glow), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
kbd {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  background: var(--surface-2);
  color: var(--text-2);
}

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

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}
.eyebrow--ink { color: #8b7d63; }

/* ---------- Scrollbars ---------- */
.scroll { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }
.scroll--x { scrollbar-color: var(--paper-line) transparent; }
.scroll--x::-webkit-scrollbar-thumb { background: var(--paper-line); }

/* ==========================================================
   Buttons
   ========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), transform .12s var(--ease), color .2s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn--lg { min-height: 48px; padding: 0 20px; font-size: 15px; border-radius: var(--r-lg); }
.btn--block { width: 100%; }

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

.btn--ghost { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn--ghost:hover { background: var(--surface-3); border-color: var(--line-strong); }

.btn--quiet { background: transparent; color: var(--text-2); padding: 0 10px; }
.btn--quiet:hover { color: var(--text); }

.btn--kofi { background: #29abe0; color: #fff; }
.btn--kofi:hover { background: #1f97c8; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: background-color .2s, color .2s, border-color .2s, transform .12s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-3); border-color: var(--line-strong); }
.icon-btn:active { transform: scale(0.94); }

/* ==========================================================
   App layout
   ========================================================== */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "top"
    "stage"
    "panel";
  gap: var(--gap);
  padding: 0 12px 24px;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
}

.topbar { grid-area: top; }
.stage { grid-area: stage; }
.panel { grid-area: panel; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -12px;
  padding: 0 12px;
  background: rgba(13, 11, 18, 0.78);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-width: 0;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(145deg, #ffd98a, #d99a2b);
  color: #3a2308;
  box-shadow: 0 6px 18px -6px rgba(244, 193, 93, 0.6);
  flex: none;
}
.brand__mark svg { width: 22px; height: 22px; }
.brand__name {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand__name em { font-style: italic; color: var(--accent); }

.topbar__actions { display: flex; align-items: center; gap: 8px; }

.mic-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .2s, border-color .2s, color .2s;
}
.mic-chip:hover { background: var(--surface-3); }
.mic-chip[aria-pressed="true"] { border-color: rgba(61, 214, 140, 0.4); background: var(--good-soft); color: #bff5da; }

.mic-chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  flex: none;
}
[aria-pressed="true"] > .mic-chip__dot {
  background: var(--good);
  box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.6);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(61, 214, 140, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 214, 140, 0); }
}

/* ==========================================================
   Stage: highway + deck + sheet
   ========================================================== */
.stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.highway {
  position: relative;
  /* Vertical: cascada + controles + partitura caben en pantalla a la vez (≈275 px bajo la cascada) */
  height: max(320px, calc(100svh - 355px));
  border-radius: var(--r-xl);
  overflow: hidden;
  background: #0f0c16;
  border: 1px solid var(--line);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  isolation: isolate;
  scroll-margin-top: calc(var(--topbar-h) + 12px);
}
.highway canvas { display: block; width: 100%; height: 100%; }

.highway__legend {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 99px;
  background: rgba(13, 11, 18, 0.6);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-3);
  backdrop-filter: blur(6px);
  pointer-events: none;
  z-index: 2;
}
.highway__legend b { color: var(--text); font-weight: 800; }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s var(--ease);
}
.overlay.active { opacity: 1; pointer-events: auto; }

.overlay--empty {
  background:
    radial-gradient(600px 300px at 50% 30%, rgba(244, 193, 93, 0.08), transparent 70%),
    linear-gradient(180deg, rgba(15, 12, 22, 0.55), rgba(15, 12, 22, 0.92));
  overflow-y: auto;
}
.empty {
  max-width: 540px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.overlay.active .empty { animation: rise .6s var(--ease) both; }
.empty__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.empty__title em { color: var(--accent); }
.empty__lead { color: var(--text-2); font-size: 15px; max-width: 46ch; }

.steps {
  list-style: none;
  margin: 6px 0 4px;
  padding: 0;
  display: grid;
  gap: 8px;
  width: 100%;
  text-align: left;
}
.steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  font-size: 14px;
  color: var(--text-2);
}
.steps b { color: var(--text); font-weight: 700; }
.steps__n {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
  flex: none;
}
.empty__cta { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 4px; }

.overlay--countdown { background: rgba(13, 11, 18, 0.55); backdrop-filter: blur(2px); }
.countdown { text-align: center; }
.countdown__num {
  font-family: var(--font-display);
  font-size: clamp(110px, 18vw, 180px);
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 60px rgba(244, 193, 93, 0.45);
  animation: beat 1s var(--ease) infinite;
}
@keyframes beat {
  0% { transform: scale(1.18); opacity: 0.4; }
  25% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.96); opacity: 0.9; }
}

.overlay--victory { background: rgba(13, 11, 18, 0.78); backdrop-filter: blur(6px); }
.victory {
  width: min(420px, 100%);
  text-align: center;
  padding: 28px 24px 22px;
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line-strong);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.9);
}
.overlay.active .victory { animation: rise .5s var(--ease) both; }
.victory__stars { display: flex; justify-content: center; gap: 6px; margin-bottom: 10px; }
.victory__stars .icon { width: 38px; height: 38px; color: var(--surface-3); transition: color .3s, transform .3s; }
.victory__stars .icon.is-lit { color: var(--accent); filter: drop-shadow(0 0 12px rgba(244, 193, 93, 0.55)); }
.victory__stars .icon:nth-child(2) { transform: translateY(-8px) scale(1.12); }
.victory__title {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.victory__sub { color: var(--text-2); margin-top: 4px; }
.victory__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 20px 0;
}
.victory__stats div { padding: 12px 6px; border-radius: var(--r-md); background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.victory__stats dt { font-size: 10px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.victory__stats dd { margin: 4px 0 0; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.victory__cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ---------- Deck (transport) ---------- */
.deck {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 10px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.play-btn {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  flex: none;
  box-shadow: 0 10px 24px -10px rgba(244, 193, 93, 0.8);
  transition: transform .12s var(--ease), background-color .2s;
}
.play-btn:hover { background: var(--accent-strong); }
.play-btn:active { transform: scale(0.93); }
.play-btn .icon { width: 22px; height: 22px; }
.play-btn[data-state="idle"] .icon { transform: translateX(1px); }
.play-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.deck__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; padding-left: 4px; }
.deck__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.deck__titles { display: flex; flex-direction: column; min-width: 0; }
.deck__title {
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deck__meta { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck__time { font-size: 12px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.deck__state {
  display: none;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: 99px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.deck__state[data-state="playing"] { color: var(--good); border-color: rgba(61, 214, 140, 0.3); }
.deck__state[data-state="paused"] { color: var(--accent); border-color: rgba(244, 193, 93, 0.3); }

.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d99a2b, var(--accent-strong));
}

/* ---------- Sheet (paper) ---------- */
.sheet {
  border-radius: var(--r-lg);
  background: var(--paper);
  color: var(--paper-ink);
  padding: 12px 0 4px;
  box-shadow: 0 20px 40px -24px rgba(0, 0, 0, 0.8), inset 0 -2px 0 rgba(0, 0, 0, 0.05);
  overflow: hidden;
}
.sheet__head { display: flex; justify-content: space-between; align-items: center; padding: 0 18px; }
.sheet__hint { font-size: 12px; color: #9a8b70; font-weight: 600; }
.sheet__track {
  height: 132px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scroll-behavior: auto;
}
#abc-paper { min-width: 100%; }
#abc-paper svg { display: block; height: auto; }

/* ==========================================================
   Library
   ========================================================== */
.library {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 18px 14px 14px;
  min-height: 0;
}
.library__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 0 4px; }
.library__title { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text-3);
  transition: border-color .2s;
}
.search:focus-within { border-color: rgba(244, 193, 93, 0.5); color: var(--text-2); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.search input::placeholder { color: var(--text-3); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 30px;
  padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.is-active { background: var(--text); border-color: var(--text); color: var(--bg); }

.song-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 -6px;
  padding: 0 6px 4px;
}
.song-group {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 12px 6px 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.song-group:first-child { padding-top: 2px; }
.song-group span { color: var(--text-2); letter-spacing: 0.02em; text-transform: none; font-weight: 600; }

.song {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color .18s, border-color .18s;
}
.song:hover { background: var(--surface-2); }
.song.is-active { background: var(--accent-soft); border-color: rgba(244, 193, 93, 0.35); }

.song__art {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--surface-3);
  color: var(--text-2);
  flex: none;
  overflow: hidden;
}
.song__art .icon { width: 16px; height: 16px; opacity: 0; transform: scale(0.8); transition: all .18s; position: absolute; }
.song__art .song__initial { font-family: var(--font-display); font-weight: 600; font-size: 18px; transition: opacity .18s; }
.song:hover .song__art .icon,
.song.is-active .song__art .icon { opacity: 1; transform: none; }
.song:hover .song__initial,
.song.is-active .song__initial { opacity: 0; }
.song.is-active .song__art { background: var(--accent); color: var(--accent-ink); }
.song[data-level="1"] .song__art { box-shadow: inset 0 -3px 0 var(--str-2); }
.song[data-level="2"] .song__art { box-shadow: inset 0 -3px 0 var(--str-3); }
.song[data-level="3"] .song__art { box-shadow: inset 0 -3px 0 var(--str-4); }

.song__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.song__title { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song__meta { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.song__side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.level-dots { display: inline-flex; gap: 3px; }
.level-dots i { width: 5px; height: 12px; border-radius: 2px; background: var(--surface-3); }
.song[data-level="1"] .level-dots i:nth-child(-n+1),
.song[data-level="2"] .level-dots i:nth-child(-n+2),
.song[data-level="3"] .level-dots i:nth-child(-n+3) { background: var(--text-2); }
.song__best {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.song__best .icon { width: 11px; height: 11px; }

.eq { display: none; gap: 2px; align-items: flex-end; height: 12px; }
.eq i { width: 3px; background: var(--accent); border-radius: 1px; animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.6s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }
body[data-playing="true"] .song.is-active .eq { display: inline-flex; }
body[data-playing="true"] .song.is-active .level-dots { display: none; }

.song-empty { padding: 28px 12px; text-align: center; color: var(--text-3); font-size: 14px; }

/* Drawer mode (< 1400px) */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(5, 4, 8, 0.6);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease);
}
.library {
  position: fixed;
  z-index: 70;
  top: 8px;
  bottom: 8px;
  left: 8px;
  width: min(400px, calc(100vw - 16px));
  transform: translateX(calc(-100% - 24px));
  transition: transform .38s var(--ease);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9);
  visibility: hidden;
}
body[data-library="open"] .library { transform: none; visibility: visible; }
body[data-library="open"] .scrim { opacity: 1; pointer-events: auto; }

/* ==========================================================
   Control panel
   ========================================================== */
.panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card__head { display: flex; align-items: center; justify-content: space-between; }

/* ---------- Tuner ---------- */
.tuner__hz { font-size: 12px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tuner__readout { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0 2px; }
.tuner__note {
  font-family: var(--font-display);
  font-size: 58px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
  transition: color .18s, text-shadow .18s, transform .18s var(--ease);
  min-height: 58px;
}
.tuner__cents { font-size: 13px; font-weight: 700; color: var(--text-3); font-variant-numeric: tabular-nums; }

.tuner[data-state="in"] .tuner__note { color: var(--good); text-shadow: 0 0 28px rgba(61, 214, 140, 0.5); transform: scale(1.04); }
.tuner[data-state="in"] .tuner__cents { color: var(--good); }
.tuner[data-state="flat"] .tuner__cents,
.tuner[data-state="sharp"] .tuner__cents { color: var(--warn); }

.gauge {
  position: relative;
  height: 36px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  overflow: hidden;
}
.gauge__zone { position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); }
.gauge__zone--ok { width: 63%; background: linear-gradient(90deg, transparent, rgba(61, 214, 140, 0.08) 20%, rgba(61, 214, 140, 0.08) 80%, transparent); }
.gauge__zone--perfect { width: 18%; background: rgba(61, 214, 140, 0.16); border-left: 1px solid rgba(61, 214, 140, 0.35); border-right: 1px solid rgba(61, 214, 140, 0.35); }
.gauge__ticks {
  position: absolute;
  inset: 0 5%;
  background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.14) 0 1px, transparent 1px 10%);
  background-size: 100% 30%;
  background-repeat: no-repeat;
  background-position: 0 100%;
}
.gauge__ticks::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.28);
}
.gauge__needle {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 50%;
  width: 6px;
  border-radius: 99px;
  transform: translateX(-50%);
  background: var(--text-3);
  transition: left 110ms linear, background-color .16s, box-shadow .16s, opacity .2s;
  opacity: 0.5;
}
.tuner[data-state="flat"] .gauge__needle,
.tuner[data-state="sharp"] .gauge__needle { background: var(--warn); opacity: 1; box-shadow: 0 0 12px rgba(255, 159, 67, 0.6); }
.tuner[data-state="in"] .gauge__needle { background: var(--good); opacity: 1; box-shadow: 0 0 14px rgba(61, 214, 140, 0.8); }
.tuner[data-state="listening"] .gauge__needle { opacity: 0.8; background: var(--text-2); }

.gauge__labels {
  display: flex;
  justify-content: space-between;
  margin-top: -8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}
.tuner__target { text-align: center; font-size: 13px; color: var(--text-2); min-height: 20px; }
.tuner__target b { color: var(--accent); }

#micBtn[aria-pressed="true"] { background: var(--good-soft); color: #bff5da; border-color: rgba(61, 214, 140, 0.35); }
#micBtn .mic-chip__dot { background: rgba(28, 20, 5, 0.45); }
#micBtn[aria-pressed="true"] .mic-chip__dot { background: var(--good); }

.ref-strings { display: flex; flex-direction: column; gap: 8px; }
.ref-strings__label { font-size: 12px; font-weight: 600; color: var(--text-3); }
.ref-strings__row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ref-string {
  position: relative;
  height: 38px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .2s, background-color .2s, transform .12s;
}
.ref-string::before {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: var(--c);
}
.ref-string:hover { border-color: var(--c); }
.ref-string:active { transform: scale(0.95); }
.ref-string.is-ringing { background: color-mix(in srgb, var(--c) 22%, var(--surface-2)); border-color: var(--c); }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field__label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.field__hint { font-size: 12px; color: var(--text-3); line-height: 1.45; }

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 4px;
  gap: 4px;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--line);
}
.segmented--4 { grid-template-columns: repeat(4, 1fr); }
.segmented button {
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .2s, color .2s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 4px 10px -4px rgba(0, 0, 0, 0.6); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch__text { display: flex; flex-direction: column; gap: 2px; }
.switch__title { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.switch__title .icon { width: 16px; height: 16px; }
[role="switch"] {
  position: relative;
  width: 46px;
  height: 28px;
  flex: none;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: var(--surface-3);
  cursor: pointer;
  transition: background-color .2s, border-color .2s;
}
.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform .25s var(--ease), background-color .2s;
}
[role="switch"][aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
[role="switch"][aria-checked="true"] .switch__thumb { transform: translateX(18px); background: var(--accent-ink); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
}
.stat__label { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.stat__value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat__value--accent { color: var(--accent); }
.stat__value.bump { animation: bump .3s var(--ease); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.14); } 100% { transform: scale(1); } }

/* ---------- Support / about ---------- */
.support { gap: 12px; }
.support__text { font-size: 13px; color: var(--text-2); }
.ad-slot:empty { display: none; }
.ad-slot { border-radius: var(--r-md); overflow: hidden; }

.about { padding: 4px 6px; display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--text-3); }
.about h3 { font-size: 12px; font-weight: 800; color: var(--text-2); }
.kbd-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.about__links { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.about__links a { color: var(--text-2); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; padding: 3px 0; }
.about__links a:hover { color: var(--accent); }
.about a { color: var(--text-2); }
.about__credit { color: var(--text-3); opacity: 0.8; }

/* ==========================================================
   Toasts
   ========================================================== */
.toasts {
  position: fixed;
  z-index: 300;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(440px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 12px 12px 16px;
  border-radius: var(--r-lg);
  background: #221d2c;
  border: 1px solid var(--line-strong);
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.9);
  font-size: 14px;
  color: var(--text);
  pointer-events: auto;
  animation: toast-in .35s var(--ease) both;
}
.toast.is-leaving { animation: toast-out .25s var(--ease) both; }
.toast__bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--accent); flex: none; }
.toast--warn .toast__bar { background: var(--warn); }
.toast--error .toast__bar { background: var(--bad); }
.toast--good .toast__bar { background: var(--good); }
.toast__msg { flex: 1; }
.toast .btn { min-height: 34px; padding: 0 12px; font-size: 13px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* ==========================================================
   Tour
   ========================================================== */
.tour {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
}
.tour.active { display: block; }
.tour__spot {
  position: fixed;
  border-radius: var(--r-lg);
  box-shadow: 0 0 0 9999px rgba(6, 5, 10, 0.74), 0 0 0 2px var(--accent), 0 0 40px 6px rgba(244, 193, 93, 0.25);
  transition: all .45s var(--ease);
  pointer-events: none;
}
.tour__spot.is-center { top: 50% !important; left: 50% !important; width: 0 !important; height: 0 !important; box-shadow: 0 0 0 9999px rgba(6, 5, 10, 0.74); }
.tour__card {
  position: fixed;
  width: min(380px, calc(100vw - 24px));
  padding: 22px;
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line-strong);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: top .45s var(--ease), left .45s var(--ease), opacity .3s;
}
.tour__close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; }
.tour__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 6px;
}
.tour__icon .icon { width: 24px; height: 24px; }
.tour__title { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; padding-right: 30px; }
.tour__text { font-size: 14px; color: var(--text-2); }
.tour__foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.tour__dots { display: flex; gap: 6px; }
.tour__dots i { width: 6px; height: 6px; border-radius: 99px; background: var(--surface-3); transition: all .3s var(--ease); }
.tour__dots i.is-active { width: 20px; background: var(--accent); }
.tour__btns { display: flex; gap: 4px; }

/* ==========================================================
   Responsive
   ========================================================== */
@media (min-width: 640px) {
  .app { padding: 0 20px 28px; }
  .topbar { margin: 0 -20px; padding: 0 20px; }
  .deck__state { display: inline-block; }
  .stats { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 639px) {
  .mic-chip__label { display: none; }
  .mic-chip { padding: 0 12px; }
  #libraryToggle span { display: none; }
  #libraryToggle { width: 40px; padding: 0; }
  .highway__legend { display: none; }
  .empty__lead { font-size: 14px; }
  .steps li { font-size: 13px; padding: 8px 12px; }
}

/* Desktop: stage + control panel fit the viewport */
@media (min-width: 1024px) {
  body { overflow: hidden; }
  .app {
    height: 100svh;
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-rows: var(--topbar-h) minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "stage panel";
    padding-bottom: 20px;
  }
  .stage { min-height: 0; }
  .highway { height: auto; flex: 1; min-height: 0; }
  .panel { min-height: 0; overflow-y: auto; padding-right: 4px; margin-right: -4px; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* Wide: library becomes a permanent column */
@media (min-width: 1400px) {
  .app {
    grid-template-columns: 330px minmax(0, 1fr) 340px;
    grid-template-areas:
      "top top top"
      "library stage panel";
  }
  .library {
    grid-area: library;
    position: static;
    width: auto;
    transform: none;
    visibility: visible;
    box-shadow: none;
  }
  .scrim, .only-drawer { display: none !important; }
}

/* Horizontal en móvil (y ventanas bajas): cascada fija a la izquierda, controles a la derecha */
@media (orientation: landscape) and (max-height: 540px) and (max-width: 1399px) {
  :root { --topbar-h: 52px; }
  body { overflow: auto; }
  .brand__mark { width: 30px; height: 30px; border-radius: 9px; }
  .brand__name { font-size: 18px; }
  .app {
    height: auto;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 42%);
    grid-template-rows: var(--topbar-h) auto auto auto;
    grid-template-areas:
      "top top"
      "highway deck"
      "highway sheet"
      "highway panel";
    column-gap: 12px;
    row-gap: 10px;
    padding-bottom: 16px;
  }
  /* La pila cascada/controles/partitura pasa a ser parte de la cuadrícula */
  .stage { display: contents; }
  .highway {
    grid-area: highway;
    position: sticky;
    top: calc(var(--topbar-h) + 8px);
    align-self: start;
    height: calc(100svh - var(--topbar-h) - 20px);
    min-height: 0;
    flex: none;
    border-radius: var(--r-lg);
  }
  .deck { grid-area: deck; padding: 8px 10px 8px 8px; gap: 8px; }
  .play-btn { width: 44px; height: 44px; }
  .deck__state { display: none; }
  .sheet { grid-area: sheet; }
  .panel { grid-area: panel; overflow: visible; margin-right: 0; padding-right: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .highway__legend { display: none; }

  /* Superposiciones compactas dentro de una cascada baja */
  .overlay { padding: 12px; }
  .overlay--victory { overflow-y: auto; place-items: start center; }
  .empty { gap: 10px; }
  .empty__title { font-size: 26px; }
  .empty__lead { font-size: 13px; }
  .steps { display: none; }
  .empty__cta .btn--lg { min-height: 42px; font-size: 14px; }
  .victory { padding: 16px 16px 14px; margin: auto 0; }
  .victory__stars .icon { width: 26px; height: 26px; }
  .victory__title { font-size: 24px; }
  .victory__stats { margin: 12px 0; }
  .victory__stats dd { font-size: 18px; }
  .countdown__num { font-size: min(140px, 40svh); }
}

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