/* ---- Theme tokens ---- */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --text: #14181f;
  --muted: #6b7280;
  --border: #e6e8ec;
  --accent: #4f46e5;
  --accent-fg: #ffffff;
  --accent-soft: #eef0fe;
  --green: #16a34a;
  --green-soft: #e7f6ec;
  --red: #dc2626;
  --red-soft: #fdecec;
  --amber: #b45309;
  --amber-soft: #fdf2e3;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1014;
    --surface: #161a20;
    --surface-2: #1d222a;
    --text: #e7eaee;
    --muted: #9aa3af;
    --border: #272d36;
    --accent: #7c7bff;
    --accent-fg: #0d1014;
    --accent-soft: #1f2030;
    --green: #34d399; --green-soft: #16271f;
    --red: #f87171; --red-soft: #2a1a1a;
    --amber: #fbbf24; --amber-soft: #2a2113;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-fg);
  box-shadow: var(--shadow-sm);
}
.brand-text h1 { font-size: 17px; }
.tagline { font-size: 12.5px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---- Auth ---- */
.auth-card { max-width: 380px; margin: 40px auto; padding: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .field input { width: 100%; box-sizing: border-box; }
.auth-form .btn { justify-content: center; margin-top: 4px; }
.auth-msg { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

.container { max-width: 860px; margin: 0 auto; padding: 26px 22px 80px; }

/* ---- Buttons ---- */
.btn, .ghost-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 9px 16px; font-weight: 550; cursor: pointer;
  text-decoration: none; transition: all .15s ease; white-space: nowrap;
}
.btn { background: var(--accent); color: var(--accent-fg); }
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.ghost-btn {
  background: var(--surface); color: var(--text); border-color: var(--border);
  box-shadow: var(--shadow-sm); font-size: 13px; padding: 7px 13px;
}
.ghost-btn:hover { background: var(--surface-2); }
.btn.danger { background: var(--red); color: #fff; }
.btn.subtle { background: var(--surface-2); color: var(--text); }

/* ---- Cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; margin-bottom: 12px;
}

/* ---- Upload ---- */
.upload { padding: 20px; margin-bottom: 26px; }
.dropzone {
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  padding: 26px 18px; text-align: center; cursor: pointer;
  transition: all .15s ease; background: var(--surface-2);
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-icon { color: var(--accent); margin-bottom: 8px; }
.dropzone .dz-main { font-weight: 550; }
.dropzone .dz-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.file-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 7px 5px 12px; font-size: 13px; max-width: 100%;
}
.pill .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.pill .x { cursor: pointer; border: none; background: transparent; color: var(--muted); padding: 2px 4px; border-radius: 50%; line-height: 1; }
.pill .x:hover { background: var(--border); color: var(--text); }

.upload-row { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 550; }
.field input, .field select {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 11px; outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field.grow { flex: 1; min-width: 160px; }
.upload-actions { margin-left: auto; }

/* ---- Recordings list ---- */
.list-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.rec {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; transition: all .15s ease;
}
.rec:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow); transform: translateY(-1px); }
.rec .rec-main { min-width: 0; flex: 1; }
.rec .rec-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec .rec-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.rec .chev { color: var(--muted); flex-shrink: 0; }

/* ---- Status badge ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  white-space: nowrap;
}
.badge.wait { background: var(--surface-2); color: var(--muted); }
.badge.work { background: var(--accent-soft); color: var(--accent); }
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.fail { background: var(--red-soft); color: var(--red); }
.spinner {
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Empty / loading ---- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 30px; margin-bottom: 8px; }

/* ---- Detail ---- */
.back { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); background: none; border: none; cursor: pointer; padding: 4px 0; margin-bottom: 16px; font-weight: 550; }
.back:hover { color: var(--text); }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 6px; }
.detail-head h2 { font-size: 21px; word-break: break-word; }
.detail-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; display: flex; gap: 12px; flex-wrap: wrap; }
.detail-actions { display: flex; gap: 8px; flex-shrink: 0; }

.panel { padding: 18px; margin-bottom: 20px; }

/* structured note (category cards) */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

/* AF / EN language toggle — a split pill with a divider; active side is coloured. */
.lang-toggle {
  display: inline-flex; border: 1px solid var(--border); border-radius: 999px;
  overflow: hidden; background: var(--surface-2); flex-shrink: 0;
}
.lang-opt {
  border: none; background: transparent; color: var(--muted);
  padding: 6px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s;
}
.lang-opt + .lang-opt { border-left: 1px solid var(--border); }  /* the line in the middle */
.lang-opt:hover:not(.active):not(:disabled) { color: var(--text); }
.lang-opt.af.active { background: var(--green); color: #fff; }
.lang-opt.en.active { background: #0ea5e9; color: #fff; }
.lang-opt:disabled { cursor: default; opacity: .7; }

.cats { display: flex; flex-direction: column; gap: 14px; }
.cat { display: flex; flex-direction: column; gap: 6px; }
.cat-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cat-title { font-weight: 650; font-size: 14px; }
.cat-sub { font-size: 11.5px; color: var(--muted); }
.cat-text {
  width: 100%; resize: vertical; min-height: 44px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; outline: none;
  line-height: 1.55; transition: border-color .15s;
}
.cat-text:focus { border-color: var(--accent); background: var(--surface); }
.cat-para { margin: 0; line-height: 1.6; color: var(--text); }
.cat-para.empty { color: var(--muted); }
.note-hint { font-size: 12px; color: var(--muted); margin-top: 12px; }
.save-bar { margin-top: 10px; display: flex; justify-content: flex-end; }

/* transcript (collapsible raw text) */
.transcript summary { cursor: pointer; list-style: none; }
.transcript summary::-webkit-details-marker { display: none; }
.transcript summary::before { content: "▸ "; color: var(--muted); }
.transcript[open] summary::before { content: "▾ "; }
.transcript-text { margin-top: 12px; color: var(--text); white-space: pre-wrap; line-height: 1.6; }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(10px);
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 550;
  box-shadow: var(--shadow); opacity: 0; transition: all .2s ease; z-index: 50; pointer-events: none;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); color: #fff; }

@media (max-width: 560px) {
  .upload-actions { margin-left: 0; width: 100%; }
  .upload-actions .btn { width: 100%; justify-content: center; }
  .detail-head { flex-direction: column; }
}
