/* Rabiat Theme v2.0 · "True to Hue" tokens */
:root {
  --r-void: #0A0A0A;
  --r-obsidian: #141414;
  --r-shadow: #1E1E1E;
  --r-midnight: #2A2A2A;
  --r-bone: #F5F5F0;
  --r-pearl: #E8E8E3;
  --r-ash: #A0A09A;
  --r-slate: #5A5A55;
  --r-bloodline: #D62828;
  --r-bloodline-light: #F05454;
  --r-marrow: #6B0000;
  --r-ember: #3D0000;
  --r-teal: #5EEAD4;
  --r-teal-muted: #2A7F73;

  --bg: var(--r-void);
  --surface: var(--r-obsidian);
  --surface-2: var(--r-shadow);
  --border: var(--r-midnight);
  --text: var(--r-bone);
  --text-2: var(--r-pearl);
  --muted: var(--r-ash);
  --subtle: var(--r-slate);
  --accent: var(--r-bloodline);
  --accent-hover: var(--r-bloodline-light);
  --accent-ink: var(--r-bone);
  --teal: var(--r-teal);
  --wave: var(--r-slate);
  --wave-progress: var(--r-bloodline);
  --region: rgba(214, 40, 40, 0.22);
  --danger: var(--r-bloodline-light);

  --f-display: 'Rajdhani', 'Barlow Condensed', system-ui, sans-serif;
  --f-body: 'Lora', Georgia, serif;
  --f-mono: 'DM Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
  border-left: 6px solid var(--accent);
  min-height: 100vh;
}
main { max-width: 1120px; margin: 0 auto; padding: 8px 28px 80px; }

/* ---------- Header ---------- */
.top {
  display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  max-width: 1120px; margin: 0 auto; padding: 28px 28px 12px;
}
.brand { font-family: var(--f-display); line-height: .9; text-transform: uppercase; }
.brand .b1 { display: block; color: var(--accent); font-weight: 700; font-size: 18px; letter-spacing: .18em; }
.brand .b2 { display: block; font-weight: 700; font-size: 40px; letter-spacing: .01em; }
.tag {
  display: inline-flex; align-items: center; gap: 8px;
  font: 600 13px/1 var(--f-display); text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-2); background: var(--surface-2);
  border-radius: 999px; padding: 7px 12px 6px; margin-bottom: 4px;
}
.tag .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.tag.busy .dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.file-meta {
  flex: 1; min-width: 0; font: 13px var(--f-mono); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 6px; text-align: right;
}

/* ---------- Empty state ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-height: 380px; margin-top: 20px; padding: 48px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  cursor: pointer; transition: border-color .15s, background .15s; position: relative; overflow: hidden;
}
.dropzone::after {
  content: ''; position: absolute; right: -40px; bottom: -40px; width: 320px; height: 320px;
  background: repeating-linear-gradient(90deg, var(--r-midnight) 0 3px, transparent 3px 11px);
  mask: radial-gradient(circle at 70% 70%, #000 0 40%, transparent 70%);
  -webkit-mask: radial-gradient(circle at 70% 70%, #000 0 40%, transparent 70%);
  pointer-events: none;
}
.dropzone > * { position: relative; z-index: 1; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: #170f0f; }
.dz-title { font: 700 44px/1 var(--f-display); text-transform: uppercase; letter-spacing: .01em; }
.dz-title em { font-style: normal; color: var(--accent); }
.dz-sub { color: var(--muted); margin-top: 10px; font-size: 15px; }
.dz-actions { display: flex; gap: 10px; margin-top: 28px; flex-wrap: wrap; position: relative; z-index: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 22px 24px 24px; margin-top: 18px;
}
.card-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
h2 {
  margin: 0; font: 700 26px/1 var(--f-display); text-transform: uppercase; letter-spacing: .02em;
  display: flex; align-items: baseline; gap: 10px;
}
h2 .num { font: 500 12px var(--f-mono); color: var(--accent); letter-spacing: 0; }
h3 { margin: 0 0 12px; font: 600 16px var(--f-display); text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); }
.hint { color: var(--muted); font-size: 13.5px; }
kbd {
  font: 11px var(--f-mono); color: var(--text-2);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 3px;
  padding: 0 5px; background: var(--surface-2);
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
h2 .small, h3 .small { font: 400 12px var(--f-mono); text-transform: none; letter-spacing: 0; color: var(--muted); }

.waveform {
  background: var(--r-void); border: 1px solid var(--border); border-radius: 4px; padding: 8px 0 0;
  min-height: 190px;
}

.row { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.spacer { flex: 1; }
.time { font: 14px var(--f-mono); color: var(--muted); margin-left: 8px; }
.time span:first-child { color: var(--text); }
.zoom { display: flex; align-items: center; gap: 8px; color: var(--muted); font: 600 13px var(--f-display); text-transform: uppercase; letter-spacing: .08em; }
.label { font: 600 13px var(--f-display); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); border-radius: 4px; padding: 7px 14px 6px;
  font: 600 14px/1.2 var(--f-display); text-transform: uppercase; letter-spacing: .08em;
  cursor: pointer; transition: background .12s, border-color .12s, color .12s, opacity .12s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
a.btn { text-decoration: none; }
.btn:hover:not(:disabled) { border-color: var(--subtle); background: var(--r-midnight); }
.btn:disabled { opacity: .35; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.outline-teal { background: transparent; border-color: var(--teal); color: var(--teal); }
.btn.outline-teal:hover:not(:disabled) { background: rgba(94, 234, 212, .08); border-color: var(--teal); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { border-color: var(--accent); background: var(--r-ember); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; }
.btn.lg { padding: 11px 22px 10px; font-size: 16px; }
.btn.round { width: 44px; height: 44px; justify-content: center; border-radius: 50%; padding: 0; font-size: 14px; letter-spacing: 0; }
.btn.sm { padding: 4px 9px 3px; font-size: 12.5px; }
.btn.toggle { width: 28px; justify-content: center; padding-left: 0; padding-right: 0; }
.btn.toggle.solo.on { background: var(--teal); border-color: var(--teal); color: var(--r-void); }
.btn.toggle.mute.on { background: var(--accent); border-color: var(--accent); color: var(--r-bone); }

input[type=number] {
  width: 90px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--r-void); color: var(--text); font: 13px var(--f-mono);
}
input[type=number]:focus { outline: none; border-color: var(--teal); }
input[type=range] { accent-color: var(--accent); }
.sel-fields { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.sel-fields label, .freq label { display: flex; align-items: center; gap: 6px; color: var(--muted); font: 600 13px var(--f-display); text-transform: uppercase; letter-spacing: .08em; }
.sel-len { color: var(--muted); font: 12.5px var(--f-mono); }

/* ---------- Separation ---------- */
.split-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 32px; }
@media (max-width: 820px) { .split-grid { grid-template-columns: 1fr; } }
.split-col p { margin: 0 0 4px; }

.presets { display: grid; gap: 8px; }
.preset {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 4px; cursor: pointer; background: var(--r-void);
  transition: border-color .12s;
}
.preset:hover { border-color: var(--subtle); }
.preset:has(input:checked) { border-color: var(--accent); background: var(--r-ember); }
.preset input { accent-color: var(--accent); margin-top: 4px; }
.preset .p-label { font: 600 17px/1.2 var(--f-display); letter-spacing: .02em; }
.preset .p-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

.status { color: var(--muted); font: 13px var(--f-mono); }
.status.error { color: var(--danger); }
.status.ok { color: var(--teal); }
.spinner {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Stems ---------- */
.downloads {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 12px 14px; margin-top: 14px; background: var(--r-void); border: 1px solid var(--border); border-radius: 4px;
}
.downloads .label { margin-right: 4px; }
.downloads .sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }

.stem {
  display: grid; grid-template-columns: 170px 1fr auto; gap: 16px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--border);
}
#stems { margin-top: 10px; }
.stem-name { display: flex; align-items: center; gap: 9px; font: 700 19px var(--f-display); text-transform: uppercase; letter-spacing: .04em; }
.stem-dot { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.stem-controls { display: flex; gap: 4px; margin-top: 8px; align-items: center; }
.stem-controls input[type=range] { width: 74px; }
.stem-wave { position: relative; height: 60px; background: var(--r-void); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; overflow: hidden; }
.stem-wave canvas { width: 100%; height: 100%; display: block; }
.stem-wave .playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--r-bone); pointer-events: none; }
.stem.silent .stem-wave canvas { opacity: .25; }
.stem-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 250px; }
@media (max-width: 820px) {
  .stem { grid-template-columns: 1fr; }
  .stem-actions { justify-content: flex-start; max-width: none; }
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--r-bone); color: var(--r-void); padding: 10px 18px; border-radius: 4px;
  font: 600 14px var(--f-display); letter-spacing: .04em; border-left: 4px solid var(--accent);
  box-shadow: 0 8px 30px rgba(0,0,0,.5); z-index: 10;
}

@media (max-width: 600px) {
  main, .top { padding-left: 16px; padding-right: 16px; }
  .brand .b2 { font-size: 30px; }
  .dropzone { padding: 28px; min-height: 300px; }
  .dz-title { font-size: 32px; }
  .file-meta { text-align: left; flex-basis: 100%; }
}

/* ---------- Browser edition: model downloads + device check ---------- */
.preset .p-meta { margin-left: auto; text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.preset .size { font: 12px var(--f-mono); color: var(--muted); white-space: nowrap; }
.preset .size.ok { color: var(--teal); }
.preset .p-meta .btn { font-size: 11.5px; padding: 3px 8px 2px; }
.dl-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; width: 110px; }
.dl-bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .15s; }
.device-check { font: 12.5px/1.5 var(--f-mono); color: var(--muted); margin-top: 10px; }
.device-check b { color: var(--text); font-weight: 500; }
.device-check .warn { color: var(--r-bloodline-light); }
.preset > div:nth-of-type(1) { flex: 1; min-width: 0; }
@media (max-width: 700px) {
  .preset { flex-wrap: wrap; }
  .preset .p-meta { flex-basis: 100%; flex-direction: row; align-items: center; justify-content: flex-start; margin-left: 26px; }
}

/* ---------- "i" info buttons: tips stay hidden until asked for ---------- */
.card, .split-col { position: relative; }
.card-head { position: static; }
.h3-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.h3-row h3 { margin: 0; }
.info {
  width: 22px; height: 22px; border-radius: 50%; flex: none; cursor: pointer; align-self: center;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  font: italic 600 13px/1 Georgia, var(--f-body); display: inline-grid; place-items: center; padding: 0;
  transition: color .12s, border-color .12s, background .12s;
}
.info:hover { color: var(--text); border-color: var(--subtle); }
.info[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--r-bone); }
.info:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.info-pop {
  position: absolute; z-index: 6; top: 62px; left: 24px; width: min(420px, calc(100% - 48px));
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 4px; padding: 12px 16px; box-shadow: 0 12px 32px rgba(0,0,0,.45);
  font: 14px/1.5 var(--f-body); color: var(--text-2);
}
.split-col .info-pop { top: 30px; left: 0; width: min(380px, 100%); }
.info-pop ul { margin: 0; padding-left: 18px; }
.info-pop li { margin: 3px 0; }
.info-pop li::marker { color: var(--accent); }
.info-pop b { color: var(--text); font-weight: 500; }
