/* ==========================================================================
   Meeting Transcripts — design system
   "Quiet Professional": off-white canvas, hairline borders, no shadows,
   generous whitespace, one navy accent. CL Synergy brand: navy + cyan.
   Shared by index.html (Transcribe) and editor.html (Transcript Editor).
   ========================================================================== */

:root {
  /* Brand — taken from the CL Synergy logo */
  --navy: #2E2A80;
  --navy-hover: #241F69;
  --navy-soft: rgba(46, 42, 128, 0.07);
  --cyan: #3FBDD4;
  --cyan-soft: rgba(63, 189, 212, 0.14);

  /* Neutrals */
  --canvas: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #F2F4F7;
  --line: #E4E7EC;
  --line-strong: #D0D5DD;

  /* Ink */
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --muted-2: #98A2B3;

  /* Semantic */
  --ok: #067647;
  --ok-soft: rgba(6, 118, 71, 0.10);
  --warn: #B54708;
  --err: #B42318;
  --info: #2E2A80;

  /* Aliases kept because inline styles / JS reference them */
  --accent: var(--navy);
  --accent-hover: var(--navy-hover);
  --accent-soft: var(--navy-soft);
  --border: var(--line);
  --border-strong: var(--line-strong);
  --text: var(--ink);
  --text-soft: var(--ink-2);
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --input-bg: var(--surface);
  --bg: var(--canvas);
  --stop: var(--err);
  --stop-hover: #912018;

  --radius: 8px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute must always win. Author rules like `.key-editor {display:flex}`
   otherwise override the UA's `[hidden] {display:none}` (author origin beats UA origin), which
   left hidden panels — the key editor, the live status strip, the stats row — visible. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- App bar ---------- */
.appbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.appbar .inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.appbar .product {
  font-size: 15px;
  font-weight: 650;
  color: var(--navy);
  letter-spacing: -0.015em;
}
.appbar .grow { flex: 1; }
.appbar .env {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 32px 24px 96px; }

/* ---------- Page head ---------- */
.pagehead { margin-bottom: 24px; }
.pagehead h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.022em;
  color: var(--ink);
}
.pagehead p { margin: 0; color: var(--muted); font-size: 14px; max-width: 70ch; }
.pagehead a { color: var(--navy); font-weight: 600; text-decoration: none; }
.pagehead a:hover { text-decoration: underline; }

/* ---------- Top-level tabs ---------- */
.maintabs {
  display: flex;
  gap: 26px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--line);
}
.maintab {
  padding: 0 0 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  user-select: none;
  transition: color .15s;
}
.maintab:hover { color: var(--ink-2); }
.maintab.active { color: var(--navy); border-bottom-color: var(--navy); }

#editorFrame {
  width: 100%;
  height: calc(100vh - 210px);
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 18px;
}

/* A numbered step badge sits beside the title */
.cardhead { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.step {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--navy);
  background: var(--navy-soft);
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
  transform: translateY(-1px);
}
.section-title {
  font-size: 16px;
  font-weight: 650;
  color: var(--ink);
  letter-spacing: -0.012em;
}
.lede { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; max-width: 78ch; }
.lede:last-child { margin-bottom: 0; }

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.055em;
}
input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-soft);
}

.row { margin-bottom: 18px; }
.row:last-child { margin-bottom: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.path-row { display: flex; gap: 8px; }
.path-row input { flex: 1; }

.hint { font-size: 12.5px; color: var(--muted); margin-top: 7px; line-height: 1.55; }
.hint code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11.5px;
  color: var(--ink-2);
}

/* ---------- Choices (radio / tick) ---------- */
.choice { display: flex; flex-direction: column; gap: 8px; }
.choice.tick { flex-direction: row; flex-wrap: wrap; }
.opt {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  margin: 0;
  text-transform: none;
  letter-spacing: normal;
  transition: border-color .12s, background .12s;
}
.choice.tick .opt { flex: 0 0 auto; padding: 9px 13px; }
.opt:hover { border-color: var(--muted-2); }
.opt input[type="radio"], .opt input[type="checkbox"] {
  width: auto; margin: 0; accent-color: var(--navy);
}
.opt:has(input:checked) {
  border-color: var(--navy);
  background: var(--navy-soft);
  color: var(--ink);
}
.opt .tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--ok);
  background: var(--ok-soft);
  border-radius: 4px;
  padding: 2px 7px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.opt .muted2 { font-size: 12.5px; color: var(--muted); font-weight: 500; }
input.mini {
  width: 58px;
  display: inline-block;
  padding: 3px 7px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- Buttons ---------- */
button {
  background: var(--navy);
  color: #fff;
  border: 1px solid var(--navy);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
  font-family: inherit;
}
button:hover:not(:disabled) { background: var(--navy-hover); border-color: var(--navy-hover); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost, button.browse {
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
  font-weight: 500;
}
button.ghost:hover:not(:disabled), button.browse:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--muted-2);
}
button.stop { background: var(--err); border-color: var(--err); }
button.stop:hover:not(:disabled) { background: var(--stop-hover); border-color: var(--stop-hover); }
button.small { padding: 6px 11px; font-size: 12.5px; font-weight: 500; }

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions.spaced { margin-top: 20px; }

/* ---------- Recorder ---------- */
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--err);
  display: inline-block;
  flex-shrink: 0;
  padding: 0;
  border: 0;
}
.rec-dot.live { animation: recpulse 1.1s ease-in-out infinite; }
@keyframes recpulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.rec-time {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.meter {
  height: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  flex: 1;
  max-width: 150px;
}
.meter > div { height: 100%; width: 0%; background: var(--cyan); transition: width .08s linear; }

/* ---------- API key ---------- */
.key-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
}
.key-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.key-status .dot.missing { background: var(--warn); }
.key-status .mask {
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
}
.key-status .spacer { flex: 1; }
.key-editor { display: flex; gap: 8px; margin-top: 10px; }
.key-editor input { flex: 1; }

/* ---------- Progress ---------- */
.progress { font-size: 13px; color: var(--muted); }
.bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 16px;
}
.bar > div { height: 100%; background: var(--navy); width: 0%; transition: width .3s ease; }

/* Live status strip (renamed from .live so it can't collide with .rec-dot.live) */
.livebar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-top: 14px;
  font-size: 13px;
}
.livebar .spinner {
  width: 13px; height: 13px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin .9s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.livebar .stage-label { font-weight: 600; color: var(--ink); }
.livebar .stage-detail {
  color: var(--muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.livebar .elapsed, .livebar .chars {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.livebar .elapsed { color: var(--navy); background: var(--navy-soft); }
.livebar .chars { color: var(--ok); background: var(--ok-soft); }

/* ---------- Grouping preview ---------- */
.grouping {
  margin-top: 10px;
  font-size: 13.5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
}
.grouping .summary { color: var(--ink); margin-bottom: 8px; font-weight: 600; }
.grouping ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.grouping li { margin-bottom: 3px; }
.grouping li b { color: var(--ink); font-weight: 600; }
.grouping .convo-files { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* ---------- Log ---------- */
.log {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  height: 380px;
  overflow-y: auto;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.log .line { padding: 1px 0; }
.log .ok   { color: var(--ok); }
.log .warn { color: var(--warn); }
.log .err  { color: var(--err); }
.log .info { color: var(--navy); }
.log .skip, .log .muted { color: var(--muted); }
.log .ts   { color: var(--muted-2); margin-right: 6px; }
.log::-webkit-scrollbar { width: 10px; }
.log::-webkit-scrollbar-track { background: transparent; }
.log::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; border: 2px solid var(--surface); }
.log::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

.stats {
  display: flex;
  gap: 20px;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 14px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.stats span b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Transcript Editor
   ========================================================================== */

a.back { color: var(--navy); text-decoration: none; font-size: 13px; font-weight: 600; }
a.back:hover { text-decoration: underline; }

/* Conversation list */
.conv {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.conv:hover { border-color: var(--navy); background: var(--navy-soft); }
.conv .nm { font-weight: 600; color: var(--ink); }
.conv .meta { color: var(--muted); font-size: 12.5px; margin-left: auto; font-variant-numeric: tabular-nums; }

/* Speakers */
#speakerList { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.sp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.sp-badge {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}
.sp-row .arrow { color: var(--muted-2); }
.sp-row input { flex: 1; padding: 6px 9px; font-weight: 600; }
.sp-row .cnt { font-size: 11.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Verbatim / English tabs */
.tabs { display: flex; gap: 22px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 0 0 10px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  transition: color .15s;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--navy); border-bottom-color: var(--navy); }

/* Turns */
.turn {
  display: grid;
  grid-template-columns: 56px 150px 1fr;
  gap: 10px;
  align-items: start;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.turn:last-child { border-bottom: none; }
.turn-ts {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px;
  color: var(--muted-2);
  padding-top: 10px;
  font-variant-numeric: tabular-nums;
}
.turn-sp { padding: 7px 8px; font-size: 13px; }
.turn-text { resize: vertical; min-height: 38px; overflow: hidden; }

details summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.meta-block { margin-top: 14px; }
.meta-block textarea {
  min-height: 90px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
}

/* Sticky bottom action bar */
.barbottom {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  padding: 12px 24px;
  z-index: 30;
}
.barbottom .inner {
  max-width: 1080px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
}
.status { font-size: 13px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.grow { flex: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .two-col { grid-template-columns: 1fr; }
  #speakerList { grid-template-columns: 1fr; }
  .turn { grid-template-columns: 48px 1fr; }
  .turn-text { grid-column: 1 / -1; }
  .appbar .inner, .wrap { padding-left: 16px; padding-right: 16px; }
}
