/* ── Reset & tokens ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d0f;
  --surface:   #17171a;
  --border:    #2a2a30;
  --border-hi: #3f3f48;
  --red:       #FF3B30;
  --red-dim:   #cc2f26;
  --green:     #30d158;
  --text:      #e8e8ec;
  --muted:     #7c7c8a;
  --mono:      'JetBrains Mono', monospace;
  --sans:      'Inter', system-ui, sans-serif;
  --radius:    12px;
  --radius-sm: 8px;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.header {
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

/* ── Main ───────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
}

/* ── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  margin-bottom: 2.5rem;
}

.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.625rem;
}

.subtitle {
  color: var(--muted);
  font-size: 0.975rem;
  max-width: 48ch;
}

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Mode tabs ──────────────────────────────────────────────────────────── */
.mode-tabs {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}

.mode-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-tab:hover { color: var(--text); }

.mode-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ── Fields ─────────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field label,
.field-inline label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  padding: 0.875rem 1rem;
  resize: vertical;
  transition: border-color 0.15s;
  width: 100%;
}

textarea::placeholder { color: var(--muted); opacity: 0.7; }
textarea:focus { outline: none; border-color: var(--red); }

/* ── Audio options ──────────────────────────────────────────────────────── */
.audio-opts {
  background: color-mix(in srgb, var(--red) 6%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--red) 20%, var(--border));
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
}

.field-inline {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-unit {
  display: flex;
  align-items: center;
  gap: 0;
  width: fit-content;
}

.input-unit input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  width: 90px;
  text-align: right;
}

.input-unit input[type="number"]:focus { outline: none; border-color: var(--red); }

.unit {
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.5rem 0.625rem;
}

.hint {
  color: var(--muted);
  font-size: 0.78rem;
}

/* ── Button ─────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--red);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.8rem 1.5rem;
  transition: background 0.15s, transform 0.1s;
  width: 100%;
}

.btn-primary:hover  { background: var(--red-dim); }
.btn-primary:active { transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Spinner */
.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result panel ───────────────────────────────────────────────────────── */
.result {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-inner { padding: 1.5rem; }

.progress-wrap {
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--red);
  width: 0%;
  border-radius: 99px;
  transition: width 0.4s ease;
  animation: indeterminate 1.4s ease infinite;
}

@keyframes indeterminate {
  0%   { margin-left: -30%; width: 30%; }
  50%  { margin-left: 40%; width: 50%; }
  100% { margin-left: 110%; width: 30%; }
}

.progress-bar.done {
  animation: none;
  width: 100%;
  background: var(--green);
}

.status-msg {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* File list */
.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.file-list li a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8125rem;
  padding: 0.75rem 1rem;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.file-list li a:hover {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 6%, var(--bg));
  color: var(--green);
}

.file-icon { font-size: 1rem; flex-shrink: 0; }
.file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-dl   { color: var(--muted); font-size: 0.75rem; flex-shrink: 0; }

/* Error */
.error-msg {
  background: color-mix(in srgb, var(--red) 10%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--red) 30%, var(--border));
  border-radius: var(--radius-sm);
  color: #ff6b63;
  font-size: 0.875rem;
  padding: 0.875rem 1rem;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.775rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}

.footer a { color: var(--muted); text-decoration: underline; }
.footer a:hover { color: var(--text); }

/* ── Utilities ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .card { padding: 1.25rem; }
  .mode-tab { font-size: 0.8rem; padding: 0.45rem 0.5rem; }
}
