/* ═══════════════════════════════════════════════════════════════
   Audiobook Studio — main.css
   Design: dark editorial, Cormorant Garamond + JetBrains Mono
   ═══════════════════════════════════════════════════════════════ */

/* ── Custom properties ──────────────────────────────────────── */
:root {
  --bg:        #111014;
  --surface:   #1a191f;
  --card:      #201f27;
  --border:    #2e2c38;
  --text:      #e8e4dc;
  --muted:     #6e6a7c;
  --accent:    #c9a84c;
  --accent2:   #7c6ac9;
  --green:     #4caf82;
  --red:       #c94c4c;
  --radius:    6px;
  --mono:      'JetBrains Mono', monospace;
  --serif:     'Cormorant Garamond', serif;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ── Base ───────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 17px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Subtle grain overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1000;
  opacity: 0.5;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: var(--mono);
  font-size: 0.8em;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  padding: 40px 56px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.brand-title {
  font-size: clamp(30px, 5vw, 52px);
  font-weight: 300;
  letter-spacing: -0.01em;
  line-height: 1;
}

.brand-title em {
  font-style: italic;
  color: var(--accent);
}

.brand-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 8px;
}

.pill {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 4px 14px;
  border-radius: 20px;
  color: var(--muted);
}

/* ── Main layout ────────────────────────────────────────────── */
main { flex: 1; }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 56px 80px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

@media (max-width: 820px) {
  .wrap { grid-template-columns: 1fr; padding: 28px 20px 60px; }
  .site-header { padding: 28px 20px 24px; }
}

/* ── Panel ──────────────────────────────────────────────────── */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 30px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

/* ── Drop zone ──────────────────────────────────────────────── */
.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone.over {
  border-color: var(--accent);
  background: rgba(201, 168, 76, 0.04);
}

.drop-icon { font-size: 34px; margin-bottom: 10px; }

.drop-main {
  font-size: 18px;
  font-weight: 300;
  margin-bottom: 6px;
}

.drop-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

/* ── File info badge ────────────────────────────────────────── */
.file-info {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--green);
  padding: 8px 12px;
  background: rgba(76, 175, 130, 0.08);
  border-radius: 4px;
}

/* ── Stats row ──────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 14px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-n {
  font-size: 28px;
  font-weight: 300;
  color: var(--accent);
  line-height: 1;
}

.stat-l {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ── Chapter list ───────────────────────────────────────────── */
.chapter-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.txt-btn {
  all: unset;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent2);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color 0.15s;
}

.txt-btn:hover { color: var(--accent); }
.txt-btn.muted { color: var(--muted); }

.divider { color: var(--border); }
.spacer  { flex: 1; }

.sel-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.chapter-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 260px;
  overflow-y: auto;
}

/* Scrollbar */
.chapter-list::-webkit-scrollbar { width: 4px; }
.chapter-list::-webkit-scrollbar-track { background: transparent; }
.chapter-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chapter-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 15px;
}

.chapter-item:hover { border-color: var(--accent2); background: rgba(124, 106, 201, 0.06); }
.chapter-item.selected { border-color: var(--accent2); background: rgba(124, 106, 201, 0.1); }

.chapter-item input[type="checkbox"] {
  accent-color: var(--accent2);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.chapter-idx {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  min-width: 26px;
}

.chapter-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-pages {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Form fields ────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

.field select,
.field input[type="text"],
.field input[type="password"] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 4px;
  font-family: var(--serif);
  font-size: 16px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}

.field select:focus,
.field input:focus { border-color: var(--accent); }

.field-hint {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.engine-fields { display: flex; flex-direction: column; gap: 14px; }

/* ── Speed slider ───────────────────────────────────────────── */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-edge {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
  height: 4px;
}

.slider-val {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  min-width: 42px;
  text-align: right;
}

/* ── Convert button ─────────────────────────────────────────── */
.convert-btn {
  background: var(--accent);
  color: #111;
  border: none;
  padding: 14px 32px;
  border-radius: 4px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s, transform 0.1s;
}

.convert-btn:hover:not(:disabled) {
  background: #d9b860;
  transform: translateY(-1px);
}

.convert-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Progress ───────────────────────────────────────────────── */
.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease;
}

.log-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 14px 16px;
  height: 180px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.9;
  color: #a09ab8;
}

.log-box::-webkit-scrollbar { width: 4px; }
.log-box::-webkit-scrollbar-thumb { background: var(--border); }

.log-box .ok   { color: var(--green); }
.log-box .err  { color: var(--red); }
.log-box .info { color: var(--accent); }

/* ── Audio player ───────────────────────────────────────────── */
audio {
  width: 100%;
  border-radius: 4px;
  accent-color: var(--accent);
}

.dl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 1.5px solid var(--green);
  color: var(--green);
  padding: 11px 24px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.dl-btn:hover { background: var(--green); color: #111; text-decoration: none; }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 56px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* ── Utility: hidden ────────────────────────────────────────── */
[hidden] { display: none !important; }
