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

:root {
  --bg: #0f1117; --surface: #1a1d27; --surface2: #22263a;
  --accent: #7c6af7; --accent2: #5eead4; --highlight: #fbbf24;
  --text: #e2e8f0; --muted: #8892a4; --border: #2d3148;
  --danger: #f87171; --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

/* ── Navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: #12152a;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-right { display: flex; align-items: center; gap: 10px; }
.nav-user { color: var(--muted); font-size: 0.85rem; }
.btn-nav {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-nav:hover { background: var(--border); }
.btn-logout { color: var(--danger); border-color: rgba(248,113,113,0.3); }

/* ── Layout ── */
.layout { display: flex; min-height: calc(100vh - 58px); }

/* ── Sidebar ── */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
  transition: transform 0.3s;
}
.sidebar.hidden { display: none; }
.sidebar-title { font-size: 0.9rem; color: var(--accent2); font-weight: 600; margin-bottom: 14px; }

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.history-item:hover { border-color: var(--accent); }
.history-item .h-title { font-size: 0.88rem; font-weight: 600; color: var(--text); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item .h-meta  { font-size: 0.75rem; color: var(--muted); }
.history-item .h-del   { float: right; background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.8rem; padding: 0; }

/* ── Main ── */
.main-content {
  flex: 1;
  max-width: 820px;
  margin: 28px auto;
  padding: 0 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--accent2);
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

/* ── Drop Zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 28px 20px;
  text-align: center;
  background: var(--surface2);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 14px;
}
.drop-zone.drag-over { border-color: var(--accent); background: rgba(124,106,247,0.07); }
.drop-zone.success   { border-color: var(--accent2); background: rgba(94,234,212,0.05); }
.drop-zone.error-state { border-color: var(--danger); background: rgba(248,113,113,0.05); }
.drop-icon { font-size: 2.2rem; margin-bottom: 8px; }
.drop-label { font-size: 0.95rem; color: var(--text); margin-bottom: 4px; }
.drop-label strong { color: var(--accent2); }
.drop-sub { font-size: 0.82rem; color: var(--muted); margin-bottom: 12px; }
.btn-file {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-file:hover { opacity: 0.85; }
.file-name { display: block; margin-top: 8px; color: var(--accent2); font-size: 0.83rem; min-height: 16px; }

/* ── Loader ── */
.loader-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent2);
  font-size: 0.88rem;
  margin-bottom: 10px;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Textarea ── */
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 13px;
  font-size: 0.93rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.65;
}
textarea:focus { border-color: var(--accent); }

.title-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 12px;
  font-size: 0.85rem;
  outline: none;
  width: 220px;
  transition: border-color 0.2s;
}
.title-input:focus { border-color: var(--accent); }

/* ── Duration ── */
.duration-row { display: flex; align-items: center; gap: 14px; }
.duration-row label { font-size: 0.93rem; }
.duration-row input[type="number"] {
  width: 80px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.duration-row input[type="number"]:focus { border-color: var(--accent); }
.hint { color: var(--muted); font-size: 0.82rem; margin-top: 7px; }
.muted-sm { color: var(--muted); font-size: 0.82rem; }

/* ── Buttons ── */
.btn {
  border: none; border-radius: 10px;
  padding: 11px 22px; font-size: 0.92rem; font-weight: 600;
  cursor: pointer; transition: opacity 0.2s, transform 0.1s;
}
.btn:hover:not(:disabled)  { opacity: 0.85; transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.btn.primary  { background: var(--accent); color: #fff; }
.btn.accent   { background: linear-gradient(135deg, var(--accent), #a78bfa); color: #fff; font-size: 1.05rem; padding: 13px 36px; }
.btn.control  { background: var(--surface2); color: var(--text); border: 1px solid var(--border); font-size: 0.85rem; padding: 9px 14px; }
.btn.download { background: var(--accent2); color: #0f1117; font-weight: 700; text-decoration: none; display: inline-block; }
.center { display: flex; justify-content: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }

/* ── Summary Box ── */
.summary-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  font-size: 0.93rem;
  line-height: 1.85;
  color: var(--text);
  white-space: pre-wrap;
  min-height: 60px;
}
.s-span { display: inline; border-radius: 4px; padding: 1px 3px; transition: background 0.3s, color 0.3s; }
.s-span.active { background: rgba(251,191,36,0.22); color: var(--highlight); }

/* ── Voice Mode ── */
.mode-row { display: flex; gap: 12px; flex-wrap: wrap; }
.mode-btn {
  background: var(--surface2); border: 2px solid var(--border);
  border-radius: 10px; color: var(--text);
  padding: 9px 20px; font-size: 0.9rem; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.mode-btn:hover  { border-color: var(--accent); }
.mode-btn.active { border-color: var(--accent); background: rgba(124,106,247,0.15); color: var(--accent2); }

/* ── Audio Player ── */
audio { display: none; }
.time-row {
  display: flex; justify-content: space-between;
  font-size: 0.85rem; color: var(--muted);
  margin-bottom: 6px; font-variant-numeric: tabular-nums;
}
.seek-bar {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 99px;
  background: var(--surface2); outline: none;
  cursor: pointer; margin-bottom: 16px; accent-color: var(--accent);
}
.seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
  box-shadow: 0 0 0 3px rgba(124,106,247,0.25);
}
.controls-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Subtitles ── */
.subtitle-box {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px; min-height: 68px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.subtitle-text { font-size: 1.02rem; line-height: 1.65; color: var(--highlight); text-align: center; font-style: italic; }
.sentence-track { display: flex; flex-direction: column; gap: 5px; max-height: 180px; overflow-y: auto; }
.sentence-track::-webkit-scrollbar { width: 4px; }
.sentence-track::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.track-item {
  font-size: 0.82rem; color: var(--muted);
  padding: 6px 10px; border-radius: 6px;
  border-left: 3px solid transparent; transition: all 0.25s;
}
.track-item.active { color: var(--text); border-left-color: var(--accent); background: rgba(124,106,247,0.1); }

/* ── Q&A ── */
.qa-row { display: flex; gap: 10px; margin-bottom: 12px; }
.qa-row input {
  flex: 1; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); padding: 10px 14px;
  font-size: 0.93rem; outline: none; transition: border-color 0.2s;
}
.qa-row input:focus { border-color: var(--accent); }
.qa-answer {
  background: rgba(94,234,212,0.08); border: 1px solid var(--accent2);
  border-radius: 10px; padding: 14px; font-size: 0.93rem;
  line-height: 1.65; color: var(--text); margin-bottom: 12px;
}
.qa-history { display: flex; flex-direction: column; gap: 10px; }
.qa-item { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 0.87rem; }
.qa-item .q { color: var(--accent2); font-weight: 600; margin-bottom: 4px; }
.qa-item .a { color: var(--muted); line-height: 1.55; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .sidebar { position: fixed; top: 58px; left: 0; height: calc(100vh - 58px); z-index: 50; }
  .controls-row, .mode-row, .duration-row { flex-direction: column; }
  .row-between { flex-direction: column; align-items: flex-start; }
  .title-input { width: 100%; }
}

/* ── Input Tabs ── */
.input-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.input-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  padding: 8px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: -1px;
}
.input-tab:hover  { color: var(--text); }
.input-tab.active { color: var(--accent2); border-bottom-color: var(--accent2); }

.tab-panel { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Textarea Header ── */
.textarea-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.btn-clear {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.btn-clear:hover { color: var(--danger); border-color: var(--danger); }
