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

:root {
  --bg:      #1A1A1A;
  --surface: #232323;
  --surface2:#2A2A2A;
  --border:  #383838;
  --accent:  #CE5E05;
  --accent2: #E06B00;
  --text:    #F5F5F5;
  --muted:   #888888;
  --radius:  12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  padding: 120px 16px 80px;
}

.app { max-width: 900px; margin: 0 auto; }

/* ── Header ── */
header { text-align: center; margin-bottom: 32px; }
header h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  background: linear-gradient(135deg, #CE5E05, #E06B00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}
header p { color: var(--muted); margin-top: 8px; font-size: .95rem; }

.badge {
  display: inline-block;
  background: #CE5E0520;
  border: 1px solid #CE5E0540;
  color: var(--accent);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: .75rem;
  font-weight: 600;
  margin: 4px 3px 0;
  letter-spacing: .3px;
}
.badge.muted {
  color: var(--muted);
  border-color: var(--border);
  background: var(--surface2);
}

.section-label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

/* ── Mode selector ── */
#mode-section { margin-bottom: 14px; }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 10px;
}
.mode-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.mode-card input[type=radio] { display: none; }
.mode-card:hover { border-color: #3a3a3a; }
.mode-card.active {
  border-color: var(--accent);
  background: #CE5E050a;
}
.mode-icon {
  width: 32px; height: 32px;
  color: var(--muted);
  margin-bottom: 4px;
  flex-shrink: 0;
}
.mode-card.active .mode-icon { color: var(--accent); }
.mode-title { font-weight: 700; font-size: .88rem; }
.mode-desc { font-size: .74rem; color: var(--muted); line-height: 1.4; }
.mode-card.active .mode-title { color: var(--accent); }

/* ── Upload section / tabs ── */
#upload-section { margin-bottom: 0; }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 4px;
  margin-bottom: 10px;
}
.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px #0004;
}
.tab.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── File Drop Zone ── */
#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
#drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, #CE5E0505 0%, transparent 70%);
  pointer-events: none;
}
#drop-zone:hover, #drop-zone.over {
  border-color: var(--accent);
  background: #CE5E0508;
}
#drop-zone.over { transform: scale(1.01); }
#drop-zone .dz-icon { width: 44px; height: 44px; margin-bottom: 12px; opacity: .45; }
#drop-zone h2 { font-size: 1rem; font-weight: 600; margin-bottom: 5px; }
#drop-zone p { color: var(--muted); font-size: .85rem; }
#file-input { display: none; }
.formats { margin-top: 12px; }

/* ── YouTube Tab ── */
#tab-youtube {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 44px 24px 34px;
  text-align: center;
  background: var(--surface);
}
.yt-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 1rem;
  font-weight: 700;
}
#tab-youtube > p { color: var(--muted); font-size: .85rem; margin-bottom: 20px; }

.yt-input-wrap {
  display: flex;
  gap: 8px;
  max-width: 580px;
  margin: 0 auto;
}
#yt-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 14px;
  color: var(--text);
  font-size: .87rem;
  outline: none;
  transition: border-color .15s;
  min-width: 0;
  font-family: inherit;
}
#yt-input::placeholder { color: var(--muted); }
#yt-input:focus { border-color: var(--accent); }

#yt-fetch-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #ff4444, #cc1111);
  border: none;
  border-radius: 9px;
  color: #fff;
  font-size: .87rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s, transform .1s;
  flex-shrink: 0;
  font-family: inherit;
}
#yt-fetch-btn:hover { opacity: .88; transform: translateY(-1px); }
#yt-fetch-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }

.yt-hint { margin-top: 10px; font-size: .75rem; color: var(--muted); }
.yt-server-note {
  margin-top: 14px;
  padding: 10px 14px;
  background: #CE5E0510;
  border: 1px solid #CE5E0530;
  border-radius: 8px;
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.5;
}
.yt-server-note strong { color: var(--accent); }

#yt-spinner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  font-size: .84rem;
  color: var(--muted);
}
#yt-spinner.active { display: flex; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner-ring {
  width: 15px; height: 15px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  flex-shrink: 0;
}

/* ── File Info ── */
#file-info {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 14px;
}
.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.file-name { font-weight: 700; font-size: .92rem; flex: 1; min-width: 160px; word-break: break-all; }
.meta-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 11px;
  font-size: .76rem;
  color: var(--muted);
  white-space: nowrap;
}
.meta-chip span { color: var(--text); font-weight: 600; }

/* ── Room visualization ── */
#room-section {
  display: none;
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
}
#room-section h3 {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
}
.room-wrap { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
#room-canvas {
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.channel-legend { display: flex; flex-wrap: wrap; gap: 8px; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: .78rem;
  font-weight: 500;
}
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Custom channel picker ── */
#channel-select {
  display: none;
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.ch-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.ch-check {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: .84rem;
  font-weight: 600;
  transition: all .15s;
  user-select: none;
}
.ch-check input { display: none; }
.ch-check.checked {
  border-color: var(--accent);
  background: #CE5E0510;
  color: var(--accent);
}
.ch-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Mode warning ── */
#mode-warning {
  display: none;
  margin-top: 14px;
  background: #fbbf2415;
  border: 1px solid #fbbf2440;
  border-radius: 10px;
  padding: 11px 16px;
  color: #fbbf24;
  font-size: .83rem;
}

/* ── Controls ── */
#controls {
  display: none;
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
}
.ctrl-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.ctrl-label { font-size: .84rem; color: var(--muted); font-weight: 500; white-space: nowrap; }
.bitrate-group { display: flex; gap: 6px; flex-wrap: wrap; }
.bitrate-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: .84rem;
  cursor: pointer;
  transition: all .15s;
  font-weight: 600;
  font-family: inherit;
}
.bitrate-btn.active, .bitrate-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #CE5E0510;
}
.process-btn {
  margin-top: 12px;
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #CE5E05, #A84B04);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .3px;
  transition: opacity .15s, transform .15s;
  font-family: inherit;
}
.process-btn:hover { opacity: .9; transform: translateY(-1px); }
.process-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ── Progress ── */
#progress-section {
  display: none;
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
}
.prog-label { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: .85rem; }
.prog-label span:first-child { color: var(--muted); }
.prog-label span:last-child { font-weight: 700; color: var(--accent); }
.progress-bar { background: var(--surface2); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #CE5E05, #E06B00);
  border-radius: 99px;
  width: 0%;
  transition: width .2s ease;
}
.prog-step { margin-top: 10px; font-size: .76rem; color: var(--muted); }

/* ── Results ── */
#results-section { display: none; margin-top: 14px; }
#results-section > h3 {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
}
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color .2s;
}
.result-card:hover { border-color: var(--accent); }
.card-header { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.card-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.card-name { font-weight: 700; font-size: .88rem; }
.card-sub { font-size: .7rem; color: var(--muted); margin-top: 1px; }
.card-wave {
  width: 100%; height: 44px; border-radius: 6px;
  background: var(--surface2); display: block; margin-bottom: 9px;
}
.card-size {
  margin-left: auto;
  font-size: .68rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.card-audio { width: 100%; margin-bottom: 9px; accent-color: var(--accent); }
.card-dl-btn {
  width: 100%; padding: 9px 12px;
  background: #ffffff0d;
  border: 1.5px solid #ffffff22;
  border-radius: 8px;
  color: var(--ch-color);
  font-size: .82rem; font-weight: 700;
  cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  letter-spacing: .2px;
  font-family: inherit;
}
.card-dl-btn:hover {
  background: #ffffff18;
  border-color: var(--ch-color);
  transform: translateY(-1px);
}

.dl-all-btn {
  margin-top: 12px; width: 100%; padding: 11px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--accent); font-size: .88rem; font-weight: 700;
  cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit;
}
.dl-all-btn:hover { background: #CE5E0510; border-color: var(--accent); }

/* ── Error ── */
#error-box {
  display: none; margin-top: 12px;
  background: #ff5a5a15; border: 1px solid #ff5a5a50;
  border-radius: 10px; padding: 12px 16px; color: #ff8080; font-size: .84rem; line-height: 1.5;
}

/* ── Reset ── */
#reset-btn {
  display: none; margin-top: 10px; background: none; border: none;
  color: var(--muted); font-size: .78rem; cursor: pointer; text-decoration: underline; padding: 0;
  font-family: inherit;
}
#reset-btn:hover { color: var(--text); }

/* ── Creator footer ── */
.creator-footer {
  margin-top: 56px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.creator-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color .15s;
}
.creator-footer a:hover { color: var(--text); }

/* ── Back nav ── */
.back-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  width: fit-content;
  transition: color .15s;
}
.back-nav:hover { color: var(--accent); }
.back-nav svg { flex-shrink: 0; }

/* ── Mobile mode trigger ── */
.mode-trigger-mobile {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s;
  font-family: inherit;
  margin-bottom: 0;
}
.mode-trigger-mobile:hover { border-color: var(--accent); }
.mode-trigger-mobile svg { color: var(--muted); flex-shrink: 0; }

/* ── Bottom sheet overlay ── */
#mode-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  align-items: flex-end;
}
#mode-sheet-overlay.open { display: flex; }

#mode-sheet {
  width: 100%;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border);
  padding: 12px 0 32px;
  animation: sheet-up .22s cubic-bezier(.32,1,.44,1);
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 99px;
  margin: 0 auto 16px;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.sheet-header span { font-weight: 700; font-size: .95rem; }
#sheet-close {
  background: none; border: none;
  color: var(--muted); cursor: pointer; padding: 4px;
  display: flex; align-items: center;
  border-radius: 8px;
  transition: color .15s, background .15s;
}
#sheet-close:hover { color: var(--text); background: var(--surface2); }

.sheet-options { display: flex; flex-direction: column; }

.sheet-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background .12s;
}
.sheet-option:hover { background: var(--surface2); }
.sheet-option.active { background: #CE5E050d; }

.sheet-opt-icon {
  width: 28px; height: 28px;
  color: var(--muted);
  flex-shrink: 0;
}
.sheet-option.active .sheet-opt-icon { color: var(--accent); }

.sheet-opt-text { flex: 1; min-width: 0; }
.sheet-opt-title { font-size: .88rem; font-weight: 700; }
.sheet-opt-desc  { font-size: .74rem; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.sheet-option.active .sheet-opt-title { color: var(--accent); }

.sheet-opt-check { flex-shrink: 0; color: var(--accent); opacity: 0; }
.sheet-option.active .sheet-opt-check { opacity: 1; }

@media (max-width: 600px) {
  .mode-trigger-mobile { display: flex; }
  .mode-grid { display: none; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CE5E05; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #994704; }
* { scrollbar-width: thin; scrollbar-color: #CE5E05 transparent; }
