/* ═══════════════════════════════════════════════════════════════
   BernAudio Web — app.css
   Sistema dark premium coherente con la landing
   ═══════════════════════════════════════════════════════════════ */
:root {
  --bg: #16130E;
  --panel: #201B12;
  --panel-2: #262017;
  --line: rgba(255, 162, 62, 0.2);
  --line-soft: rgba(232, 223, 197, 0.09);
  --teal: #FFA23E;
  --teal-dim: rgba(255, 162, 62, 0.75);
  --amber: #F5B04C;
  --red: #F97066;
  --txt: #EFE8D6;
  --muted: #A99F86;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--txt);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  height: 100%;
}

body { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Barra superior ─────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(31, 26, 18, 0.96), rgba(22, 19, 14, 0.98));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--txt); }
.brand > span:last-child { display: flex; flex-direction: column; }
.brand svg { display: block; }
.brand-name { font-family: 'Oswald', 'Arial Narrow', sans-serif; font-weight: 600; font-size: 17px; letter-spacing: .05em; text-transform: uppercase; }
.brand-sub { display: block; font-size: 8.5px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.brand-name em { color: var(--teal); font-style: normal; }
.badge-beta {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--amber); border: 1px solid rgba(245, 176, 76, 0.4);
  border-radius: 99px; padding: 2px 8px; text-transform: uppercase;
}
.topbar .spacer { flex: 1; }

.tb-group { display: flex; align-items: center; gap: 8px; }
.tb-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }

select, input[type="number"] {
  background: var(--panel-2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font: inherit; font-size: 13px; outline: none;
}
select:focus, input:focus { border-color: var(--teal-dim); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 9px; border: 1px solid transparent; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 14px; color: var(--txt);
  background: var(--panel-2); border-color: var(--line);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--teal-dim); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(180deg, #FFBE6B, #E8862B); border-color: #8A4E12; color: #2A1704; box-shadow: inset 0 1px 0 rgba(255,255,255,.5); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-amber { background: linear-gradient(135deg, #F5B04C, #E09B33); border-color: transparent; color: #241500; }
.btn-danger { background: rgba(249, 112, 102, 0.14); border-color: rgba(249, 112, 102, 0.45); color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 12px 26px; font-size: 15px; }

.chip {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  border: 1px solid var(--line-soft); border-radius: 7px; padding: 4px 8px;
  background: var(--panel);
}
.chip b { color: var(--teal); font-weight: 600; }

/* ── Pestañas ───────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px; padding: 8px 16px 0; overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; background: none; border: none; cursor: pointer;
  color: var(--muted); font: inherit; font-weight: 600; font-size: 13px;
  padding: 9px 14px 11px; border-radius: 10px 10px 0 0;
  border-bottom: 2px solid transparent;
  white-space: nowrap; transition: color 0.15s;
}
.tab:hover { color: var(--txt); }
.tab.active { color: var(--teal); border-bottom-color: var(--teal); }

/* ── Layout de módulos ──────────────────────────────────────── */
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.module { display: none; flex: 1; flex-direction: column; padding: 14px 16px; gap: 12px; min-height: 0; overflow-y: auto; }
.module.active { display: flex; }

.controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 10px 12px;
}
.ctl { display: flex; align-items: center; gap: 6px; }
.ctl label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }

input[type="range"] { accent-color: var(--teal); width: 110px; }

.panel {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 14px; padding: 10px; flex: 1; min-height: 240px;
  position: relative; display: flex; flex-direction: column;
}
.panel canvas { flex: 1; width: 100%; height: 100%; display: block; min-height: 220px; }
.panel-title {
  color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; padding: 2px 6px 8px;
}

/* ── Readouts SPL ───────────────────────────────────────────── */
.readouts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.ro {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 12px 14px; text-align: center;
}
.ro .v { font-family: var(--mono); font-size: 26px; font-weight: 600; color: var(--teal); line-height: 1.1; }
.ro .v.warn { color: var(--amber); }
.ro .v.hot { color: var(--red); }
.ro .l { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px; }
.ro.big { grid-column: span 2; }
.ro.big .v { font-size: 52px; }

/* ── Estado vacío / overlay de inicio ───────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(1200px 600px at 50% 30%, rgba(255, 162, 62, 0.07), transparent 60%), var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.overlay.hidden { display: none; }
.start-card {
  max-width: 520px; width: 100%;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 34px 32px; text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.start-card h1 { font-family: 'Space Grotesk', sans-serif; font-size: 26px; letter-spacing: -0.02em; margin-bottom: 10px; }
.start-card h1 em { color: var(--teal); font-style: normal; }
.start-card p { color: var(--muted); line-height: 1.6; margin-bottom: 22px; }
.start-card .hint { font-size: 12px; margin-top: 16px; color: var(--muted); }
.start-card .hint b { color: var(--amber); }
.error-box {
  display: none; margin-top: 14px; padding: 10px 12px; border-radius: 10px;
  background: rgba(249, 112, 102, 0.1); border: 1px solid rgba(249, 112, 102, 0.4);
  color: #FFB4AD; font-size: 13px; text-align: left;
}

/* ── IR resultados ──────────────────────────────────────────── */
.ir-results {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px;
}
.progressbar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progressbar > div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--amber)); transition: width 0.2s; }

/* ── Pie ────────────────────────────────────────────────────── */
.statusbar {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  padding: 8px 16px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 11px; font-family: var(--mono);
}
.statusbar a { color: var(--teal); text-decoration: none; }
.statusbar .dot { width: 7px; height: 7px; border-radius: 99px; background: var(--red); display: inline-block; }
.statusbar .dot.on { background: var(--teal); box-shadow: 0 0 8px var(--teal); }

/* ── Móvil ──────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .tb-label { display: none; }
  .module { padding: 10px; }
  .ro.big { grid-column: span 1; }
  .ro.big .v { font-size: 40px; }
  input[type="range"] { width: 90px; }
  .panel { min-height: 200px; }
}

/* ── Calibración / Ayuda / notas ────────────────────────────── */
.file-btn { position: relative; overflow: hidden; }
.ro .v.small { font-size: 17px; line-height: 1.5; padding-top: 5px; }

.note {
  color: var(--muted); font-size: 12px; line-height: 1.6;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 10px 12px;
}
.note b { color: var(--txt); }

code {
  font-family: var(--mono); font-size: 11.5px;
  color: var(--teal); background: rgba(255, 162, 62, 0.1);
  border-radius: 5px; padding: 1px 5px;
}

.help-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 12px; align-content: start;
  overflow-y: auto; flex: 1; min-height: 0;
}
.help-card {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 14px; padding: 16px 18px;
  color: var(--muted); font-size: 13px; line-height: 1.65;
}
.help-card h4 { color: var(--teal); font-size: 14px; margin-bottom: 8px; letter-spacing: -0.01em; }
.help-card b { color: var(--txt); }
.help-card ul { padding-left: 18px; display: grid; gap: 5px; }
.help-card li::marker { color: var(--teal-dim); }

/* ── Barra legal (Model 80 · Alicelabs LLC) ───────────────────── */
.app-legalbar {
  display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--bg));
  font-size: 11px; color: var(--muted);
}
.app-legalbar a { color: var(--muted); text-decoration: none; transition: color .15s ease; }
.app-legalbar a:hover { color: var(--teal); }
.alb-left, .alb-right { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.alb-brand { font-family: 'Oswald', 'Arial Narrow', sans-serif; font-size: 15px; font-weight: 600; letter-spacing: .02em; color: var(--txt); }
.alb-brand em { font-style: normal; color: var(--teal); }
.alb-by { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; opacity: .75; }
.alb-madeby { letter-spacing: .06em; text-transform: uppercase; font-size: 10px; }
.alb-madeby b { color: var(--teal); }
.alb-copy { opacity: .8; }
@media (max-width: 720px) {
  .app-legalbar { justify-content: center; text-align: center; }
  .alb-copy { width: 100%; text-align: center; }
}

/* Instrument workspace: stable plot geometry and keyboard/touch controls. */
:root { --bg:#101214; --panel:#191c20; --panel-2:#23272c; --txt:#f0f2f4; --muted:#b2bac4; --line:rgba(255,162,62,.24); }
#workspace { display:flex; flex-direction:column; min-height:100dvh; width:100%; min-width:0; }
.eyebrow { font:10px var(--mono); letter-spacing:.18em; color:var(--teal); margin-bottom:14px; }
.start-card { max-width:600px; text-align:left; border-radius:16px; }
.start-card h1 { font-size:40px; }
.start-btns { display:flex; flex-wrap:wrap; gap:12px; }
.start-card p { margin-bottom:16px; }
.overlay { overflow-y:auto; }
.measurement-notice { padding:12px 20px 6px; color:#f7c788; background:#1b1b1a; font-size:12px; line-height:1.6; }
.hardware-note { color:var(--muted); font-size:11px; padding:6px 20px 10px; background:#1b1b1a; line-height:1.5; }
main,.module,.controls,.panel { min-width:0; }
.panel { flex:none; min-height:0; }
.panel canvas { flex:none; height:clamp(240px,42vh,520px); min-height:0; max-width:100%; }
#mod-cal .panel canvas { height:300px; }
#selInput { max-width:230px; }
input[type="file"] { max-width:100%; font-size:12px; }
input[type="checkbox"] { width:24px; height:24px; accent-color:var(--teal); }
.btn,.tab,select { min-height:42px; }
.ctl { max-width:100%; flex-wrap:wrap; }
.controls .note { width:100%; border:0; padding:4px 0; }
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible { outline:3px solid #ffb45d; outline-offset:3px; }
#stQuality { color:var(--amber); }
.help-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,270px),1fr)); }
@media(max-width:720px) {
  .topbar { position:static; }
  .topbar .spacer { display:none; }
  .brand { margin-right:auto; }
  .tb-group { flex:1 1 42%; min-width:0; }
  .tb-group select { width:100%; max-width:100%; }
  .tb-label { display:inline; font-size:10px; }
  .tabs { position:sticky; top:0; z-index:40; background:var(--bg); padding-left:8px; }
  .controls { align-items:flex-start; gap:12px; }
  .readouts { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .ro.big { grid-column:span 2; }
  .ir-results { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .start-card { padding:24px; }
  .overlay { align-items:flex-start; }
  .ro { padding:12px 8px; }
  .ro .v { font-size:23px; overflow-wrap:anywhere; }
  .statusbar { gap:10px; }
  .start-btns .btn { width:100%; }
}
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { transition:none!important; animation:none!important; scroll-behavior:auto!important; } }
