/* ============================================================
   Audio Transcriber — design system
   Sidebar dashboard layout, light + dark themes.
   Theme is set via  <html data-theme="light|dark">.
   ============================================================ */

:root {
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 248px;

  /* light theme (default) */
  --bg: #f4f6fb;
  --bg-accent-1: rgba(79, 70, 229, .06);
  --bg-accent-2: rgba(14, 165, 233, .05);
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --surface-3: #eef1f8;
  --text: #101827;
  --text-strong: #060b16;
  --muted: #5d6b82;
  --faint: #94a1b7;
  --border: #e3e7f0;
  --border-strong: #cdd4e3;

  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --primary-soft: #eef0fe;
  --primary-border: #c7cbfa;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);

  --ok: #059669;
  --ok-soft: #e7f6f0;
  --ok-border: #b3e2d0;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --warn-border: #f0d9ac;
  --danger: #dc2626;
  --danger-soft: #fdeceb;
  --danger-border: #f5c6c1;
  --info: #0369a1;
  --info-soft: #e6f3fa;
  --info-border: #b6dcef;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, .07);
  --shadow-lg: 0 16px 44px rgba(15, 23, 42, .13);
  --focus-ring: 0 0 0 3px rgba(79, 70, 229, .25);
}

[data-theme="dark"] {
  --bg: #0b101c;
  --bg-accent-1: rgba(99, 102, 241, .09);
  --bg-accent-2: rgba(14, 165, 233, .06);
  --surface: #121a2b;
  --surface-2: #182236;
  --surface-3: #1f2a42;
  --text: #dbe2ef;
  --text-strong: #f4f7fc;
  --muted: #8b99b3;
  --faint: #64748e;
  --border: #24304a;
  --border-strong: #33415f;

  --primary: #818cf8;
  --primary-strong: #a5b0ff;
  --primary-soft: rgba(99, 102, 241, .16);
  --primary-border: rgba(129, 140, 248, .45);
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .13);
  --ok-border: rgba(52, 211, 153, .4);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --warn-border: rgba(251, 191, 36, .38);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .13);
  --danger-border: rgba(248, 113, 113, .4);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, .12);
  --info-border: rgba(56, 189, 248, .38);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 4px 18px rgba(0, 0, 0, .38);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .5);
  --focus-ring: 0 0 0 3px rgba(129, 140, 248, .35);
}

/* ---- base ---- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background:
    radial-gradient(900px 420px at 85% -10%, var(--bg-accent-1), transparent 60%),
    radial-gradient(700px 380px at -10% 30%, var(--bg-accent-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(99, 102, 241, .28); }

a { color: var(--primary); }

code {
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12.5px;
  font-family: var(--font-mono);
}

.muted { color: var(--muted); }
.small { font-size: 12.8px; }

/* ============================================================
   App shell: sidebar + main
   ============================================================ */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 16px;
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--grad);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, .35);
  flex-shrink: 0;
}
.brand-logo svg { width: 20px; height: 20px; }
.brand-name {
  font-weight: 800;
  font-size: 15.5px;
  letter-spacing: -.01em;
  color: var(--text-strong);
  line-height: 1.2;
}
.brand-tag {
  font-size: 11px;
  color: var(--faint);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.side-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 10px 10px 6px;
}

.side-nav { display: flex; flex-direction: column; gap: 3px; }

.tab {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13.8px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: background .14s, color .14s;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active {
  background: var(--primary-soft);
  color: var(--primary);
}
.tab.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--grad);
}
.nav-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
}
.nav-ico svg { width: 18px; height: 18px; }

.nav-badge {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
}
.tab.active .nav-badge { background: var(--primary); color: #fff; }

.side-spacer { flex: 1; }

.side-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.side-foot .pill { align-self: flex-start; }
.side-foot-row { display: flex; gap: 8px; }
.side-foot-row .btn { flex: 1; justify-content: center; }

/* ---- main column ---- */

.main {
  flex: 1;
  min-width: 0;
  padding: 26px clamp(16px, 4vw, 44px) 72px;
  max-width: 1060px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text-strong);
}
.page-sub { margin: 3px 0 0; font-size: 13.5px; color: var(--muted); }

/* ============================================================
   Buttons, inputs, forms
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.btn-primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, .35);
}
.btn-primary:hover {
  background: var(--grad);
  border-color: transparent;
  filter: brightness(1.08);
  box-shadow: 0 4px 16px rgba(99, 102, 241, .45);
}

.btn-download {
  background: var(--ok-soft);
  border-color: var(--ok-border);
  color: var(--ok);
}
.btn-download:hover { background: var(--ok-soft); border-color: var(--ok); filter: brightness(1.03); }

.btn-small { padding: 6px 12px; font-size: 12.8px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-plain { padding: 6px 10px; color: var(--muted); }

.icon-btn {
  border: 1px solid transparent;
  background: none;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  opacity: .55;
  transition: opacity .14s, background .14s, border-color .14s, color .14s;
}
.icon-btn:hover { opacity: 1; background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }

/* theme toggle */
.theme-toggle svg { width: 15px; height: 15px; }
[data-theme="dark"] .ico-moon { display: none; }
html:not([data-theme="dark"]) .ico-sun { display: none; }

input[type="text"], input[type="url"], input[type="password"], select, textarea {
  padding: 9px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  font-family: inherit;
  font-size: 13.8px;
  background: var(--surface);
  color: var(--text);
  min-width: 0;
  transition: border-color .14s, box-shadow .14s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  resize: vertical;
  background: var(--surface);
}

.field-row { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; align-items: center; }
.field-row input[type="text"], .field-row input[type="url"] { flex: 1; }

.checkbox {
  display: flex;
  gap: 9px;
  align-items: center;
  margin: 12px 0;
  font-size: 13.5px;
  cursor: pointer;
}
.checkbox input, .radio input { accent-color: var(--primary); width: 15px; height: 15px; }

.file-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  background: var(--surface-2);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: border-color .14s, background .14s, color .14s;
}
.file-label:hover { border-color: var(--primary); color: var(--text); background: var(--primary-soft); }
.file-label input[type="file"] { display: none; }
.file-label.has-file { color: var(--text); border-style: solid; border-color: var(--ok-border); background: var(--ok-soft); }
.file-label-small { flex: 1 1 240px; }

.form-error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  border-radius: 9px;
  padding: 9px 13px;
  margin-top: 12px;
  font-size: 13.5px;
}

/* ============================================================
   Cards, panels, banner
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 30px;
  box-shadow: var(--shadow-sm);
}

.panel-lead { margin: 0 0 6px; color: var(--muted); font-size: 13.6px; }

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-radius: var(--radius-sm);
  border: 1px solid var(--warn-border);
  background: var(--warn-soft);
  color: var(--warn);
  padding: 11px 15px;
  margin-bottom: 18px;
  font-size: 13.5px;
  font-weight: 500;
}
.banner::before { content: "⚠"; flex-shrink: 0; }

/* ---- pills ---- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  letter-spacing: .01em;
}
.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
}
.pill-muted { color: var(--muted); }
.pill-ok { color: var(--ok); border-color: var(--ok-border); background: var(--ok-soft); }
.pill-ok::before { background: var(--ok); }
.pill-warn { color: var(--warn); border-color: var(--warn-border); background: var(--warn-soft); }
.pill-warn::before { background: var(--warn); }
.pill-err { color: var(--danger); border-color: var(--danger-border); background: var(--danger-soft); }
.pill-err::before { background: var(--danger); }
.pill-run { color: var(--primary); border-color: var(--primary-border); background: var(--primary-soft); }
.pill-run::before { background: var(--primary); animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.75); }
}

/* ---- progress bars ---- */

.upload-progress { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.progress-track {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--grad);
  border-radius: 999px;
  transition: width .25s;
}

/* ============================================================
   Jobs
   ============================================================ */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--text-strong);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}
.count-badge {
  display: inline-block;
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.job {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px 16px 22px;
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .16s, border-color .16s, transform .16s;
  animation: card-in .22s ease both;
}
.job:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

@keyframes card-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* status accent down the left edge */
.job::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--border-strong);
}
.job-running::before { background: var(--grad); }
.job-done::before { background: var(--ok); }
.job-error::before { background: var(--danger); }

.job-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.job-headline { min-width: 0; }
.job-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text-strong);
  margin: 0;
  overflow-wrap: anywhere;
}
.job-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.job-sub .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
.job-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.job-link:hover { text-decoration: underline; }
.job-meta { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.job-type { letter-spacing: .01em; font-weight: 600; }

.tag {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--muted);
}
.tag-public { background: var(--ok-soft); color: var(--ok); }
.tag-private { background: var(--surface-3); color: var(--muted); }
.tag-unlisted { background: var(--warn-soft); color: var(--warn); }
.tag-muted { background: var(--surface-3); color: var(--muted); }

/* ---- progress summary + collapsible steps ---- */

.job-progress { display: flex; align-items: center; gap: 12px; margin-top: 13px; }
.job-progress .progress-track { flex: 0 0 90px; height: 5px; }
.job-done .progress-fill { background: var(--ok); }
.job-error .progress-fill { background: var(--danger); }

.steps-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  padding: 2px 0;
  font: inherit;
  font-size: 12.8px;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.steps-toggle:hover { color: var(--text); }
.chev { display: inline-block; font-size: 10px; transition: transform .15s; color: var(--faint); }
.chev-open { transform: rotate(90deg); }

.steps { list-style: none; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px dashed var(--border); }
.step { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; font-size: 13.5px; }
.step-icon { width: 20px; text-align: center; flex-shrink: 0; }
.step-pending { color: var(--faint); }
.step-running { color: var(--primary); font-weight: 600; }
.step-done { color: var(--ok); }
.step-error { color: var(--danger); font-weight: 600; }
.step-detail { color: var(--muted); font-weight: 400; font-size: 12.8px; }
.step .progress-track { max-width: 220px; height: 6px; align-self: center; }

.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid var(--primary-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- live execution log ---- */

.job-log {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
}
.job-log-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.log-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ok);
  font-size: 11px;
}
.log-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse 1.4s ease-in-out infinite;
}
.job-log-body {
  max-height: 190px;
  overflow-y: auto;
  padding: 9px 12px;
  background: #0d1220;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: #b6c2d9;
}
[data-theme="dark"] .job-log-body { background: #090d17; }
.log-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.log-time {
  color: #5b6a85;
  margin-right: 10px;
  user-select: none;
}
.log-line.log-ok { color: #4ade80; }
.log-line.log-err { color: #f87171; }
.log-line.log-start { color: #93a7ff; }

.job-error {
  margin-top: 12px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 13px;
}

.job-actions {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.job-actions .grow { flex: 1; }
/* One deliverable = one cluster: read it, or take the PDF / .txt / regenerate.
   Without the grouping, three transcripts' worth of buttons read as one row. */
.job-act-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
}
.btn-read {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
  font-weight: 700;
}
.btn-read:hover { background: var(--primary-soft); border-color: var(--primary); filter: brightness(1.03); }
.privacy-control { display: flex; gap: 7px; align-items: center; font-size: 13px; color: var(--muted); }
.privacy-control select { padding: 5px 9px; font-size: 12.8px; }
.rename-control { display: flex; gap: 7px; align-items: center; font-size: 13px; color: var(--muted); }
.rename-control input { padding: 5px 9px; font-size: 12.8px; width: 240px; max-width: 100%; }

.empty-note { text-align: center; padding: 34px 0; }

/* ---- pagination ---- */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 20px;
}
.pager-info { font-size: 13px; color: var(--muted); }

/* ============================================================
   Settings
   ============================================================ */

.settings-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-strong);
  margin: 28px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.settings-heading:first-of-type { margin-top: 12px; }

.radio-row { display: flex; gap: 22px; flex-wrap: wrap; margin: 10px 0 4px; }
.radio { display: flex; gap: 8px; align-items: center; font-size: 13.8px; cursor: pointer; }

.provider-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 16px 14px;
  margin: 14px 0;
  background: var(--surface-2);
  opacity: .55;
  transition: opacity .15s, border-color .15s, background .15s;
}
.provider-box.provider-active {
  opacity: 1;
  border-color: var(--primary-border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.provider-box legend { font-size: 12.5px; font-weight: 700; padding: 0 7px; color: var(--muted); }
.provider-box.provider-active legend { color: var(--primary); }

.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 12.8px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.field > span em { font-style: normal; font-weight: 400; }
.field input { width: 100%; }

.prompt-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px 14px;
  margin: 14px 0;
  background: var(--surface-2);
}
.prompt-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.prompt-name { font-size: 13px; font-weight: 700; color: var(--text-strong); }
.prompt-state { flex: 1; font-size: 12px; color: var(--muted); }
.prompt-state.is-custom { color: var(--primary); font-weight: 700; }

/* ============================================================
   Clippings → PDF
   ============================================================ */

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 18px 14px;
  text-align: center;
  background: var(--surface-2);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.dropzone.drop-hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: var(--focus-ring);
}
.dropzone .file-label { justify-content: center; border: none; background: none; }
.dropzone .file-label:hover { background: none; }

.clip-order-note { font-size: 13px; color: var(--muted); margin: 14px 2px 8px; }
.clip-order-note strong { color: var(--text); }

.clip-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.clip-item {
  display: flex; align-items: center; gap: 11px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  cursor: grab;
  transition: border-color .14s, box-shadow .14s;
}
.clip-item:hover { border-color: var(--primary-border); box-shadow: var(--shadow-sm); }
.clip-item.dragging { opacity: .45; }
.clip-pos {
  flex: 0 0 auto; width: 23px; height: 23px; border-radius: 50%;
  background: var(--grad); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.clip-thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); }
.clip-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.clip-fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13.3px; }

.clip-report { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; font-size: 13.5px; }
.clip-report-h { font-weight: 700; margin-bottom: 8px; color: var(--text-strong); }
.clip-page { margin-bottom: 9px; }
.clip-page-h { font-weight: 700; color: var(--muted); font-size: 12.5px; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .04em; }
.clip-page-list { list-style: none; margin: 0; padding: 0 0 0 2px; }
.clip-page-list li { padding: 2px 0; }
.clip-page-list li.clip-flag { color: var(--warn); }
.clip-badge {
  display: inline-block; min-width: 20px; text-align: center;
  background: var(--surface-3); border-radius: 5px; padding: 0 6px;
  font-size: 12px; font-weight: 700; margin-right: 4px;
}
.clip-skips { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.clip-warn { margin-top: 9px; color: var(--warn); font-size: 13px; }

/* ============================================================
   Face recognition
   ============================================================ */

.face-section { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 6px; }
.face-section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.face-section-head .settings-heading { flex: 1; }
.face-section-head select { max-width: 320px; padding: 5px 9px; font-size: 12.8px; }

.face-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.face-card {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
/* A face nobody has named yet is the one thing on this page that needs the
   user, so it is the one thing that is highlighted. */
.face-card.face-new { border-color: var(--primary-border); box-shadow: var(--shadow-md); }
.face-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--surface-3); }
.face-card figcaption { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.face-name { font-weight: 700; font-size: 14px; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.face-ask { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.face-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.face-badges .tag { font-size: 11px; }
.face-name-row { display: flex; gap: 5px; }
.face-name-row input { flex: 1; min-width: 0; padding: 5px 8px; font-size: 12.8px; }
.face-score { opacity: .75; font-variant-numeric: tabular-nums; margin-left: 3px; }
.face-acts { display: flex; gap: 5px; align-items: center; margin-top: auto; }
.face-acts .btn { padding: 4px 8px; font-size: 12px; }
.face-src {
  padding: 5px 10px; border-top: 1px solid var(--border); background: var(--surface-2);
  font-size: 11.5px; color: var(--faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(276px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.person-card {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.person-thumb {
  flex: 0 0 auto; width: 62px; height: 62px; object-fit: cover;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface-3);
}
.person-thumb-empty { display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 20px; }
.person-info { min-width: 0; flex: 1; }
.person-name { font-weight: 700; font-size: 14.5px; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-acts { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; }
.person-acts .btn { padding: 4px 9px; font-size: 12px; }

.person-history-box { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.person-seen {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 66px; padding: 5px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: inherit; font: inherit; text-align: center;
  transition: border-color .14s, box-shadow .14s;
}
.person-seen:hover { border-color: var(--primary-border); box-shadow: var(--shadow-sm); }
.person-seen img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; }
.person-seen .small { font-size: 10.5px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* ============================================================
   Reader — in-app text viewer

   A centred sheet on a laptop, the whole screen on a phone. Everything a
   reader needs is reachable without leaving it: find, zoom, copy a paragraph,
   copy a highlighted run, copy the lot, and the file downloads as a last
   resort. The body font follows the script the text is actually written in —
   a Latin face cannot draw Devanagari or Gujarati, and the fallbacks are all
   system fonts so nothing has to be fetched.
   ============================================================ */

body.reader-open { overflow: hidden; }

.reader {
  position: fixed;
  inset: 0;
  z-index: 90;            /* under .toasts (100): copy confirmations sit on top */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
/* On mobile Safari `inset: 0` measures the tall viewport, so the bottom of the
   panel hides behind the URL bar; dvh is the height actually on screen. */
@supports (height: 100dvh) {
  .reader { height: 100dvh; }
}
.reader-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 22, .55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.reader-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(880px, 100%);
  max-height: min(92vh, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: reader-in .18s ease-out both;
}
@keyframes reader-in {
  from { opacity: 0; transform: translateY(12px) scale(.99); }
  to { opacity: 1; transform: none; }
}

.reader-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.reader-head-text { min-width: 0; flex: 1; }
.reader-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--text-strong);
  overflow-wrap: anywhere;
}
.reader-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.reader-close {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.reader-close:hover { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }

/* ---- toolbar ---- */

.reader-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.reader-find {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 220px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 2px 6px 2px 10px;
}
.reader-find:focus-within { box-shadow: var(--focus-ring); border-color: var(--primary-border); }
.reader-find-ico { font-size: 12px; opacity: .6; }
.reader-find input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  padding: 7px 4px;
  font-size: 13.5px;
  color: var(--text);
}
.reader-find input:focus { outline: none; box-shadow: none; }
.reader-find-count {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}
.reader-find-count.is-none { color: var(--danger); }
.reader-find-btn {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  padding: 4px 7px;
  font-size: 13px;
  line-height: 1;
}
.reader-find-btn:hover { background: var(--surface-3); color: var(--text); }

.reader-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.reader-zoom {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}
.reader-zoom-btn {
  border: none;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}
.reader-zoom-btn + .reader-zoom-btn { border-left: 1px solid var(--border); }
.reader-zoom-btn:hover { background: var(--surface-3); }

/* ---- text ---- */

.reader-body {
  --reader-font: 18px;
  --reader-line: 1.75;
  --font-read: var(--font-sans);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 48px;
  font-size: var(--reader-font);
  line-height: var(--reader-line);
}
.reader-body:focus { outline: none; }

/* Indic scripts stack matras above and below the line and need the extra
   leading; the Latin stack stays as a fallback for mixed English words. */
.reader-body[data-script="deva"] {
  --font-read: "Noto Sans Devanagari", "Nirmala UI", "Kohinoor Devanagari",
               "Mangal", "Lohit Devanagari", "Noto Serif Devanagari", var(--font-sans);
  --reader-line: 2;
}
.reader-body[data-script="gujr"] {
  --font-read: "Noto Sans Gujarati", "Nirmala UI", "Gujarati Sangam MN",
               "Shruti", "Lohit Gujarati", var(--font-sans);
  --reader-line: 2;
}
.reader-body[data-script="beng"] { --font-read: "Noto Sans Bengali", "Nirmala UI", "Vrinda", var(--font-sans); --reader-line: 2; }
.reader-body[data-script="guru"] { --font-read: "Noto Sans Gurmukhi", "Nirmala UI", "Raavi", var(--font-sans); --reader-line: 2; }
.reader-body[data-script="taml"] { --font-read: "Noto Sans Tamil", "Nirmala UI", "Latha", var(--font-sans); --reader-line: 2; }
.reader-body[data-script="telu"] { --font-read: "Noto Sans Telugu", "Nirmala UI", "Gautami", var(--font-sans); --reader-line: 2; }
.reader-body[data-script="knda"] { --font-read: "Noto Sans Kannada", "Nirmala UI", "Tunga", var(--font-sans); --reader-line: 2; }
.reader-body[data-script="mlym"] { --font-read: "Noto Sans Malayalam", "Nirmala UI", "Kartika", var(--font-sans); --reader-line: 2; }
.reader-body[data-script="arab"] { --font-read: "Noto Naskh Arabic", "Nirmala UI", "Segoe UI", var(--font-sans); --reader-line: 2.1; }

.rblock {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 44px 8px 12px;
  border-radius: 10px;
  transition: background .12s;
}
.rblock:hover { background: var(--surface-2); }
.rtext {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-family: var(--font-read);
  font-size: inherit;
  font-weight: 400;
  line-height: inherit;
  color: var(--text);
  overflow-wrap: break-word;
  -webkit-user-select: text;
  user-select: text;
}
.rblock-h { padding-top: 16px; }
.rblock-h .rtext {
  font-weight: 800;
  font-size: 1.06em;
  color: var(--text-strong);
  letter-spacing: -.01em;
}
.rnum {
  flex-shrink: 0;
  width: 1.65em;
  height: 1.65em;
  margin-top: .18em;
  border-radius: 50%;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  font-family: var(--font-sans);
  font-size: .72em;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.rcopy {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: opacity .12s, color .12s, border-color .12s;
}
.rcopy:hover { color: var(--primary); border-color: var(--primary-border); }
.rcopy-done { color: var(--ok); border-color: var(--ok-border); background: var(--ok-soft); }
/* On a mouse the button appears on hover; on touch there is no hover, so it
   stays visible (faintly) — otherwise it would be unreachable. */
@media (hover: hover) {
  .rcopy { opacity: 0; }
  .rblock:hover .rcopy, .rcopy:focus-visible { opacity: 1; }
}
@media (hover: none) {
  .rcopy { opacity: .5; }
}

.reader-body mark {
  background: var(--warn-soft);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
  box-shadow: inset 0 -2px 0 var(--warn-border);
}
/* The match you are standing on has to be findable at a glance in a wall of
   other matches, so it inverts rather than just changing tint. */
.reader-body mark.on {
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  color: #fff;
}
.reader-empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 40px 16px;
}

/* Floating copy for a highlighted run — the reachable version of the toolbar
   button once you are thumb-deep in a long transcript. */
.reader-fab {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 8px 26px rgba(79, 70, 229, .45);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  /* Fades only: the panel's keyframes end on `transform: none`, which would
     undo the translateX that centres this. */
  animation: fab-in .16s ease-out both;
}
@keyframes fab-in { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   Toasts
   ============================================================ */

.toasts {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(380px, calc(100vw - 44px));
}
.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 11px 15px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .22s ease both;
  white-space: pre-line;
}
.toast-ok { border-left-color: var(--ok); }
.toast-err { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warn); }
.toast.toast-out { animation: toast-out .25s ease both; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; transform: translateX(14px); }
}

/* ============================================================
   Login
   ============================================================ */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 38px 34px 34px;
  width: 372px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--grad);
}
.login-logo {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 15px;
  background: var(--grad);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(99, 102, 241, .4);
}
.login-logo svg { width: 26px; height: 26px; }
.login-card h1 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; color: var(--text-strong); }
.login-card p { margin: 0 0 6px; font-size: 13.5px; }
.login-card label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  margin: 16px 0 0;
}
.login-card input { width: 100%; margin-top: 6px; }
.login-card .btn { margin-top: 24px; padding: 11px 16px; font-size: 14px; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 860px) {
  .app { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
  }
  .brand { padding: 0 6px 0 0; }
  .brand-text { display: none; }
  .side-label { display: none; }
  .side-spacer { display: none; }

  .side-nav {
    flex-direction: row;
    order: 3;
    width: 100%;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 2px;
  }
  .tab { width: auto; flex-shrink: 0; padding: 7px 12px; }
  .tab.active::before { display: none; }

  .side-foot {
    flex-direction: row;
    align-items: center;
    border-top: none;
    padding-top: 0;
    margin-left: auto;
  }
  .side-foot .pill { align-self: center; }

  .main { padding: 18px 14px 60px; }
  .field-row { flex-direction: column; align-items: stretch; }
  .job-actions { gap: 8px; }
  .job-act-group { width: 100%; }
  .job-act-group .btn-read { flex: 1; }
  /* A fixed-width title box pushed its Rename button off the side of the card
     and gave the whole page a horizontal scroll. */
  .rename-control, .privacy-control { width: 100%; flex-wrap: wrap; }
  .rename-control input { width: auto; flex: 1 1 150px; }
}

/* The reader takes the whole phone screen: a sheet with margins wastes the
   only thing that matters here, which is lines of text on screen. */
@media (max-width: 700px) {
  .reader { padding: 0; }
  .reader-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    border: none;
    border-radius: 0;
    animation: none;
    /* Keep the bar and the last paragraph clear of the home indicator. */
    padding-bottom: env(safe-area-inset-bottom);
  }
  .reader-head { padding: 12px 14px 10px; }
  .reader-title { font-size: 15.5px; }
  .reader-close { width: 38px; height: 38px; }   /* thumb-sized */
  .reader-tools {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 9px 12px;
    gap: 8px;
  }
  .reader-find { flex-basis: 100%; }
  .reader-actions { width: 100%; }
  .reader-actions .btn { flex: 1 1 auto; }
  .reader-body { padding: 8px 4px 96px; }
  .rblock { padding: 8px 8px 8px 10px; gap: 8px; }
  /* No hover on a phone: the per-paragraph button moves under the text as a
     full-width tap target instead of hiding in the corner. */
  .rcopy {
    position: static;
    align-self: flex-start;
    width: 36px;
    height: 36px;
    opacity: .65;
  }
  .reader-fab {
    bottom: calc(16px + env(safe-area-inset-bottom));
    padding: 13px 24px;
    font-size: 14.5px;
  }
}

/* A phone in landscape has almost no height — give the text all of it. */
@media (max-width: 900px) and (max-height: 480px) {
  .reader-head { padding: 8px 14px 6px; }
  .reader-sub { display: none; }
  .reader-body { padding-bottom: 60px; }
}
