/* DAWN IA — interfaz de estudio (tema oscuro) */
:root {
  --bg: #0a0c0f;
  --bg-2: #0f1216;
  --panel: #13171c;
  --panel-2: #191e25;
  --panel-3: #20262f;
  --border: #262d37;
  --border-2: #323a46;
  --text: #e7eaef;
  --muted: #8b94a3;
  --dim: #5d6573;
  --accent: #ff7a45;
  --accent-2: #ffa070;
  --accent-ink: #1a0d06;
  --ok: #3fd18b;
  --warn: #f2c14e;
  --err: #ff5d6c;
  --info: #5cb8ff;
  --radius: 10px;
  --radius-sm: 6px;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 14px; }
p { margin: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ── Layout ─────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px;
  padding: 20px 14px; background: var(--bg-2); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 17px; font-weight: 600; padding: 0 6px; }
.brand b { color: var(--accent); font-weight: 700; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav a.disabled { opacity: .4; pointer-events: none; }
.sys { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--err); }

.main { padding: 28px 32px 64px; min-width: 0; outline: none; }
.page { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 6px; }
.eyebrow { font: 500 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }

/* ── Paneles ────────────────────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; min-width: 0; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font: 500 18px/1.3 var(--mono); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v small { font-size: 12px; color: var(--muted); }

/* ── Botones y controles ───────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--panel-2);
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--panel-3); border-color: #414a58; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { color: var(--err); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 36px; padding: 0; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--dim); }
select, input[type=text], input[type=password] {
  height: 36px; padding: 0 10px; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
}
input[type=range] { accent-color: var(--accent); }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--panel-3); color: var(--muted); white-space: nowrap; }
.badge.ok { background: rgba(63,209,139,.12); color: var(--ok); }
.badge.warn { background: rgba(242,193,78,.12); color: var(--warn); }
.badge.err { background: rgba(255,93,108,.12); color: var(--err); }
.badge.info { background: rgba(92,184,255,.12); color: var(--info); }
.badge.accent { background: rgba(255,122,69,.14); color: var(--accent); }

/* ── Inicio ─────────────────────────────────────────── */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: center; padding: 28px; background: radial-gradient(120% 140% at 100% 0%, rgba(255,122,69,.10), transparent 60%), var(--panel); }
.hero h1 { font-size: 32px; }
.hero p { margin-top: 10px; color: var(--muted); max-width: 52ch; }
.hero .btn-group { margin-top: 20px; }
.hero-viz { height: 160px; }
.steps { counter-reset: s; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.step { position: relative; padding: 16px; background: var(--panel-2); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.step::before { counter-increment: s; content: '0' counter(s); font: 500 11px var(--mono); color: var(--accent); }
.step h3 { margin: 6px 0 4px; }
.step p { color: var(--muted); font-size: 13px; }

/* ── Subida ─────────────────────────────────────────── */
.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  min-height: 260px; padding: 32px; text-align: center; border: 1.5px dashed var(--border-2); border-radius: var(--radius);
  background: var(--panel); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(255,122,69,.05); }
.drop svg { width: 44px; height: 44px; stroke: var(--accent); fill: none; stroke-width: 1.6; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.progress { height: 6px; background: var(--panel-3); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: inherit; transition: width .25s; }
.progress.indeterminate > i { width: 30%; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }

.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mode { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 16px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.mode:hover { border-color: var(--border-2); }
.mode input { position: absolute; opacity: 0; }
.mode:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.mode .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 2px 7px; border-radius: 4px; background: var(--panel-3); color: var(--text); }
.chip i { width: 7px; height: 7px; border-radius: 2px; }
.mode .meta { font-size: 12px; color: var(--muted); }

/* ── Espectro / análisis ───────────────────────────── */
.spectrum { width: 100%; height: 160px; display: block; }
.bands { display: flex; flex-direction: column; gap: 8px; }
.band { display: grid; grid-template-columns: 110px 1fr 54px; gap: 10px; align-items: center; font-size: 12px; }
.band .bar { height: 8px; background: var(--panel-3); border-radius: 4px; overflow: hidden; }
.band .bar i { display: block; height: 100%; background: var(--info); border-radius: inherit; }

/* ── Procesamiento ─────────────────────────────────── */
.proc { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
.big-pct { font: 500 48px/1 var(--mono); }
.stage-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.stage-item { display: flex; gap: 10px; align-items: center; padding: 7px 0; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); }
.stage-item:last-child { border-bottom: 0; }
.stage-item.done { color: var(--text); }
.stage-item.active { color: var(--accent); }
.stage-item .ic { width: 16px; text-align: center; font-family: var(--mono); }
.logbox { height: 200px; overflow: auto; font: 12px/1.6 var(--mono); color: var(--muted); background: var(--bg-2); border-radius: var(--radius-sm); padding: 10px 12px; border: 1px solid var(--border); white-space: pre-wrap; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,122,69,.6); } 100% { box-shadow: 0 0 0 12px rgba(255,122,69,0); } }

/* ── Estudio / reproductor ─────────────────────────── */
.transport {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 16px;
  background: rgba(19,23,28,.92); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: var(--radius);
}
.play-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); border: 0; color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.play-btn:hover { background: var(--accent-2); }
.play-btn svg { width: 18px; height: 18px; fill: currentColor; }
.time { font: 500 20px/1 var(--mono); min-width: 168px; }
.time small { color: var(--muted); font-size: 13px; }
.tbtn { height: 32px; min-width: 32px; padding: 0 10px; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid var(--border-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.tbtn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tbtn.on { background: rgba(255,122,69,.15); border-color: var(--accent); color: var(--accent); }
.master { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.master input { width: 120px; }
.meter { width: 8px; height: 32px; background: var(--panel-3); border-radius: 2px; position: relative; overflow: hidden; }
.meter i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(0deg, var(--ok) 0%, var(--ok) 70%, var(--warn) 85%, var(--err) 100%); background-size: 100% 32px; background-position: bottom; }
.meters { display: flex; gap: 2px; }

.ruler { position: relative; height: 26px; margin-left: var(--head-w); cursor: pointer; user-select: none; touch-action: none; }
.ruler canvas { width: 100%; height: 100%; display: block; }
.tracks { --head-w: 260px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.tracks .ruler { border-bottom: 1px solid var(--border); background: var(--bg-2); }
.track { display: grid; grid-template-columns: var(--head-w) 1fr; min-height: 76px; border-bottom: 1px solid var(--border); }
.track:last-child { border-bottom: 0; }
.track-head { display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 10px 12px; background: var(--panel-2); border-right: 1px solid var(--border); border-left: 3px solid var(--c); min-width: 0; }
.track-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.track-title b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-ctl { display: flex; align-items: center; gap: 6px; }
.track-ctl input[type=range] { flex: 1; min-width: 0; }
.ms { width: 26px; height: 24px; border-radius: 4px; border: 1px solid var(--border-2); background: var(--panel-3); font: 700 11px var(--mono); cursor: pointer; padding: 0; flex: none; }
.ms.m.on { background: var(--err); border-color: var(--err); color: #1a0508; }
.ms.s.on { background: var(--warn); border-color: var(--warn); color: #1a1405; }
.vol-val { font: 11px var(--mono); color: var(--muted); width: 50px; text-align: right; flex: none; }
.track-wave { position: relative; min-width: 0; cursor: pointer; touch-action: none; }
.track-wave canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.track.silent .track-wave { opacity: .35; }
.kind { font-size: 10px; padding: 1px 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; flex: none; }
.kind.source { background: rgba(63,209,139,.12); color: var(--ok); }
.kind.family { background: rgba(92,184,255,.12); color: var(--info); }
.kind.residual { background: rgba(139,148,163,.15); color: var(--muted); }
.kind.original { background: rgba(255,122,69,.14); color: var(--accent); }

.loading-tracks { padding: 40px; text-align: center; color: var(--muted); }

/* ── Tablas ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
td.wrap { white-space: normal; }
tr:hover td { background: rgba(255,255,255,.015); }
.matrix td:first-child { font-weight: 500; }

/* ── Descargas ─────────────────────────────────────── */
.dl-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.dl-row:last-child { border-bottom: 0; }
.dl-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.swatch { width: 10px; height: 28px; border-radius: 3px; flex: none; }

/* ── Vacío / toasts ────────────────────────────────── */
.empty { padding: 48px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty svg { width: 40px; height: 40px; stroke: var(--dim); fill: none; stroke-width: 1.5; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--border-2); border-left: 3px solid var(--info); border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: tin .2s ease-out; }
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.notice { padding: 12px 14px; border-radius: var(--radius-sm); background: rgba(92,184,255,.07); border: 1px solid rgba(92,184,255,.25); color: #bcdcf7; font-size: 13px; }
.notice.warn { background: rgba(242,193,78,.07); border-color: rgba(242,193,78,.3); color: #f3dea6; }
.kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--border-2); border-radius: 4px; background: var(--panel-2); }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .proc { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .hero-viz { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 20; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row;
    padding: 6px; border-right: 0; border-top: 1px solid var(--border); gap: 0;
  }
  .brand, .sys { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-between; }
  .nav a { flex-direction: column; gap: 3px; padding: 6px 2px; font-size: 10px; flex: 1; justify-content: center; }
  .nav a.active { box-shadow: inset 0 2px 0 var(--accent); }
  .main { padding: 20px 16px 96px; }
  .grid-2, .grid-3, .modes, .steps { grid-template-columns: 1fr; }
  .tracks { --head-w: 150px; }
  .track-head { padding: 8px; }
  .vol-val { display: none; }
  .time { min-width: 0; font-size: 16px; }
  .master { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .master input { flex: 1; }
  h1 { font-size: 22px; }
  .hero h1 { font-size: 24px; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .tracks { --head-w: 118px; }
  .track-title .kind { display: none; }
  .dl-row { grid-template-columns: 1fr; }
}

/* Evita que el contenido ensanche las columnas de las rejillas */
.grid > * { min-width: 0; }
.diag td { white-space: normal; word-break: break-word; }

/* Móvil: el fader de cada pista ocupa su propia línea bajo M/S */
@media (max-width: 860px) {
  .track-ctl { flex-wrap: wrap; row-gap: 8px; }
  .track-ctl input[type=range] { order: 3; flex: 1 1 100%; }
}

/* ── Tablatura ─────────────────────────────────────── */
.tab-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 14px; align-items: end; }
.tab-sheet { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; overflow-x: auto; }
.tab-pre { font: 13px/1.45 var(--mono); margin: 0 0 14px; color: var(--muted); white-space: pre; }
.tab-num { color: var(--dim); font-size: 11px; }
.tab-m { color: var(--text); cursor: pointer; border-radius: 3px; transition: background .1s; }
.tab-m:hover { background: rgba(255,255,255,.04); }
.tab-m.cur { background: rgba(255,122,69,.10); color: #fff; }
.tab-m.inloop { background: rgba(92,184,255,.10); }
.tab-m.cur.inloop { background: rgba(255,122,69,.16); }
.tc.now { background: var(--accent); color: var(--accent-ink); border-radius: 2px; }
.tab-transport { flex-direction: column; align-items: stretch; gap: 10px; }
.tt-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tt-row .master { margin-left: auto; width: auto; }
input.num { width: 58px; height: 32px; padding: 0 6px; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm); font: 13px var(--mono); }
.tbtn:disabled, input:disabled { opacity: .4; cursor: not-allowed; }
.tab-link { font: 700 10px var(--mono); padding: 1px 6px; border-radius: 3px; border: 1px solid var(--border-2); color: var(--muted); text-decoration: none; margin-left: auto; flex: none; }
.tab-link:hover { color: var(--accent); border-color: var(--accent); }
@media (max-width: 860px) {
  .tab-controls { grid-template-columns: 1fr 1fr; }
  .tab-pre { font-size: 11px; }
}
.tab-controls > * { min-width: 0; }
.field select { width: 100%; max-width: 100%; min-width: 0; }
@media (max-width: 520px) { .tab-controls { grid-template-columns: 1fr; } }
