/* Minutes Studio - one stylesheet, themed via [data-theme] set by theme.js. */

:root, [data-theme="light"] {
  --bg: #f4f5f8;
  --bg2: #ffffff;
  --ink: #171c26;
  --muted: #5f6a7c;
  --line: #dbdfe8;
  --accent: #28567f;
  --accent-ink: #ffffff;
  --good: #2c7a44;
  --mid: #a06a10;
  --bad: #b03434;
  --quote-bg: #eef0f4;
  --shadow: 0 1px 2px rgba(23, 28, 38, 0.06), 0 8px 24px rgba(23, 28, 38, 0.05);
}
[data-theme="dark"] {
  --bg: #101318;
  --bg2: #171c24;
  --ink: #e6e9ee;
  --muted: #96a0b0;
  --line: #2a3140;
  --accent: #8ab8dd;
  --accent-ink: #0f1620;
  --good: #6cc389;
  --mid: #d9a94a;
  --bad: #e08484;
  --quote-bg: #1f2530;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82em; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.hidden { display: none !important; }
.good { color: var(--good); }
.mid { color: var(--mid); }
.bad { color: var(--bad); }
button { font: inherit; cursor: pointer; }
a { color: var(--accent); }

/* --- Header ------------------------------------------------------------- */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
  padding: 18px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark { width: 38px; height: 38px; color: var(--accent); flex: none; }
.brand h1 { margin: 0; font-size: 1.25rem; letter-spacing: -0.01em; }
.tagline { margin: 2px 0 0; font-size: 0.82rem; color: var(--muted); }
.session { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.home-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--muted); text-decoration: none; font-size: 0.85rem;
}
.home-link svg { width: 14px; height: 14px; }
.home-link:hover { color: var(--ink); }
.ghost {
  background: none; border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 6px 12px; font-size: 0.85rem;
}
.ghost:hover { border-color: var(--muted); }
.theme-toggle::before { content: "\2600"; }
[data-theme="dark"] .theme-toggle::before { content: "\263D"; }
.credits { font-size: 0.85rem; color: var(--muted); }
.topup { font-size: 0.85rem; }

/* --- Layout ------------------------------------------------------------- */
main { max-width: 1000px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 60px; }
.klabel {
  display: inline-block;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.doc-field { margin-bottom: 4px; }
.ctx-field { margin-top: 22px; }

.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
textarea, input[type="text"], select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg2); color: var(--ink);
  padding: 10px 12px; font: inherit;
}
textarea {
  border: none; resize: vertical; display: block; border-radius: 12px;
  font-size: 0.92rem; white-space: pre-wrap; overflow-wrap: break-word;
}
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.actions { display: flex; align-items: center; gap: 14px; margin-top: 22px; flex-wrap: wrap; }
.primary {
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 10px; padding: 10px 18px; font-weight: 600;
}
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: 0.55; cursor: default; }
.big { padding: 12px 22px; font-size: 1rem; border-radius: 12px; }
button.big:not(.primary) { background: none; border: 1px solid var(--line); color: var(--ink); }
.meter { font-size: 0.8rem; color: var(--muted); }
.linkish { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; }

/* --- Number scan (free lane) ---------------------------------------------- */
.scan-panel {
  margin-top: 22px; padding: 16px 18px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
}
.lint-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 7px; }
.lint { font-size: 0.85rem; padding-left: 18px; position: relative; }
.lint::before { position: absolute; left: 0; top: 0; }
.lint.good::before { content: "\2713"; }
.lint.mid::before { content: "\26A0"; }
.lint.bad::before { content: "\2717"; }
.lint .lint-detail { display: block; color: var(--muted); font-size: 0.8rem; }
.lint .lint-where { color: var(--muted); font-size: 0.78rem; margin-left: 6px; }
.quick-note { margin: 14px 0 0; }

/* --- Progress -------------------------------------------------------------- */
.progress-panel { margin-top: 26px; padding: 18px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; }
.pp-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pp-bar { flex: 1; min-width: 120px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.pp-fill { height: 100%; width: 40%; background: var(--accent); border-radius: 2px; animation: slide 1.4s ease-in-out infinite; }
.finished .pp-fill { animation: none; width: 100%; }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.live-output {
  margin: 14px 0 0; padding: 12px 14px; max-height: 340px; overflow-y: auto;
  background: var(--quote-bg); border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted);
}

/* --- Result ---------------------------------------------------------------- */
.result { margin-top: 30px; display: grid; gap: 18px; }
.verdict-zone { padding: 20px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.verdict-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.verdict-badge {
  display: inline-block; padding: 4px 14px; border-radius: 999px;
  font-size: 0.9rem; font-weight: 700; letter-spacing: 0.01em;
  border: 1.5px solid currentColor;
}
.verdict-badge.good { color: var(--good); }
.verdict-badge.mid { color: var(--mid); }
.verdict-badge.bad { color: var(--bad); }
.conf-badge { font-size: 0.82rem; }
.tally { font-size: 0.8rem; color: var(--muted); }
.summary { margin: 14px 0 0; font-size: 1rem; overflow-wrap: anywhere; }
.consistency-note {
  margin-top: 12px; padding: 10px 14px; border-radius: 8px; font-size: 0.85rem;
  border: 1px solid var(--mid); color: var(--mid);
}
.dl-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.trunc-note {
  margin-top: 14px; padding: 10px 14px; border-radius: 8px; font-size: 0.88rem;
  border: 1px solid var(--bad); color: var(--bad);
}
.trunc-note a { color: inherit; font-weight: 700; margin-left: 6px; }

.paper {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: clamp(18px, 4vw, 34px);
  font-size: 0.97rem; overflow-wrap: anywhere;
}
.paper > :first-child { margin-top: 0; }
.paper-h { margin: 0 0 14px; font-size: 1.02rem; line-height: 1.3; }
.paper code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.86em;
  background: var(--quote-bg); border-radius: 4px; padding: 1px 5px;
}
.markdown-paper {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem; white-space: pre-wrap; margin: 0;
  max-height: 620px; overflow-y: auto;
}

/* Pitfall grid (rendered by report.js) */
.pf-grid { display: grid; gap: 12px; }
.pf-row { display: flex; gap: 12px; align-items: baseline; }
.pf-status {
  flex: none; display: inline-block; min-width: 64px; text-align: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em;
  border: 1px solid currentColor;
}
.pf-status.good { color: var(--good); }
.pf-status.mid { color: var(--mid); }
.pf-status.bad { color: var(--bad); }
.pf-body { min-width: 0; }
.pf-name { font-weight: 600; font-size: 0.95rem; }
.pf-evidence { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }

/* Prose sections (rendered by report.js) */
.rsec { margin: 0 0 6px; }
.rsec h3 { margin: 1.3em 0 0.5em; font-size: 1.02rem; line-height: 1.3; }
.rsec:first-child h3 { margin-top: 0; }
.rsec-list { margin: 0.5em 0; padding-left: 1.3em; }
.rsec-list li { margin: 0.35em 0; }
.calc-list { list-style: none; margin: 0.5em 0; padding: 0; display: grid; gap: 8px; }
.calc { display: flex; gap: 10px; align-items: baseline; }
.calc-status {
  flex: none; display: inline-block; min-width: 44px; text-align: center;
  padding: 1px 7px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em;
  border: 1px solid currentColor;
}
.calc-text { min-width: 0; font-size: 0.92rem; }

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

.raw-result { margin-top: 26px; }
.raw-output {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace;
  font-size: 0.82rem; overflow-x: auto;
}

/* --- How it works ---------------------------------------------------------- */
.how { margin-top: 44px; }
.how-lead { color: var(--muted); }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 780px) { .how-grid { grid-template-columns: 1fr; } }
.how-step { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.step-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 0.85rem;
}
.how-step h3 { margin: 10px 0 6px; font-size: 1rem; }
.how-step p { margin: 0; font-size: 0.88rem; color: var(--muted); }

/* --- Footer / toasts -------------------------------------------------------- */
footer {
  max-width: 1000px; margin: 0 auto; padding: 22px clamp(16px, 4vw, 40px) 40px;
  font-size: 0.82rem; color: var(--muted);
  display: flex; gap: 10px; flex-wrap: wrap;
}
footer a { color: var(--muted); }
footer a:hover { color: var(--ink); }
.foot-sep { user-select: none; }

.toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 40px)); }
.toast {
  background: var(--ink); color: var(--bg); border-radius: 10px;
  padding: 10px 14px; font-size: 0.88rem; box-shadow: var(--shadow);
  transition: opacity 0.5s, transform 0.5s;
}
.toast a { color: inherit; font-weight: 700; margin-left: 8px; }
.toast.err { background: var(--bad); color: #fff; }
.toast.gone { opacity: 0; transform: translateY(6px); }

/* --- Minutes Studio additions ------------------------------------------------ */
.verdict-badge + .verdict-badge { margin-left: 0; }
.result-title { margin: 14px 0 2px; font-size: 1.1rem; font-weight: 700; overflow-wrap: anywhere; }

/* Action-items table (rendered by report.js) */
.ai-table-wrap { overflow-x: auto; margin: 0.5em 0; }
.ai-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.ai-table th, .ai-table td {
  text-align: left; vertical-align: top;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.ai-table th {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted);
}
.ai-table tbody tr:last-child td { border-bottom: none; }
.ai-task { min-width: 220px; }
.ai-flag { color: var(--mid); font-style: italic; white-space: nowrap; }
.ai-status {
  display: inline-block; padding: 1px 9px; border-radius: 999px; white-space: nowrap;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  border: 1px solid currentColor; color: var(--muted);
}
.ai-status.good { color: var(--good); }
.ai-status.mid { color: var(--mid); }
.ai-status.bad { color: var(--bad); }

/* --- Code Review Desk additions ------------------------------------------ */
.rsec h3 .sec-count {
  margin-left: 8px;
  font-size: 11px;
  vertical-align: 2px;
  padding: 1px 8px;
}

/* --- PR Tour deck ---------------------------------------------------------- */
.seg-card {
  border: 1px solid var(--line, rgba(128, 128, 128, 0.25));
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin: 0.7rem 0;
  background: var(--card, transparent);
}
.seg-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.seg-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 0.8rem;
  opacity: 0.75;
}
.seg-title {
  margin: 0;
  font-size: 1.02rem;
  flex: 1 1 auto;
}
.seg-files {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}
.seg-file {
  font-size: 0.78rem;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--line, rgba(128, 128, 128, 0.25));
  overflow-wrap: anywhere;
}
.seg-screen {
  margin: 0.55rem 0 0;
}
.seg-narration {
  margin: 0.55rem 0 0;
  line-height: 1.55;
}

/* --- Speaking-time badges ---------------------------------------------------- */
.time-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}
.rsec h3 .time-badge { margin-left: 8px; vertical-align: 2px; }

/* --- Presenter mode ---------------------------------------------------------- */
body.presenting { overflow: hidden; }
.presenter {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column;
}
.pres-top {
  display: flex; align-items: center; gap: 14px;
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
}
.pres-progress { font-size: 0.9rem; color: var(--muted); }
.pres-close { margin-left: auto; }
.pres-slide {
  flex: 1; overflow-y: auto;
  max-width: 900px; width: 100%; margin: 0 auto;
  padding: clamp(20px, 5vh, 48px) clamp(16px, 4vw, 40px);
}
.pres-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pres-title { margin: 14px 0 0; font-size: clamp(1.4rem, 3.4vw, 2.1rem); line-height: 1.25; }
.pres-screen { margin: 14px 0 0; font-size: 1rem; }
.pres-narration {
  margin: 18px 0 0;
  font-size: clamp(1.1rem, 2.4vw, 1.45rem);
  line-height: 1.65;
}
.pres-hunks { margin-top: 24px; display: grid; gap: 14px; }
.pres-hunk { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg2); }
.pres-hunk-path {
  padding: 7px 12px; font-size: 0.78rem; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.pres-hunk-body {
  margin: 0; padding: 10px 0; overflow-x: auto;
  font-size: 0.8rem; line-height: 1.5; max-height: 44vh; overflow-y: auto;
}
.pres-hunk-body > div { padding: 0 12px; white-space: pre; }
.pres-hunk-body .dl-add { color: var(--good); background: rgba(60, 160, 90, 0.12); }
.pres-hunk-body .dl-del { color: var(--bad); background: rgba(200, 70, 70, 0.12); }
.pres-hunk-body .dl-ctx { color: var(--muted); }
.pres-hunk-body .dl-cut { color: var(--mid); font-style: italic; padding-top: 4px; }
.pres-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px clamp(16px, 4vw, 40px);
  border-top: 1px solid var(--line);
  background: var(--bg2);
}
.pres-nav-btn:disabled { opacity: 0.45; cursor: default; }

/* --- Recent runs (history) --------------------------------------------------- */
.history-panel {
  margin-top: 34px; padding: 16px 18px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
}
.hist-list { display: grid; gap: 8px; margin-top: 4px; }
.hist-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  width: 100%; text-align: left;
  background: none; border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); padding: 10px 14px;
}
.hist-row:hover { border-color: var(--accent); }
.hist-main { min-width: 0; }
.hist-label { font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
.hist-summary {
  margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hist-side { flex: none; display: grid; justify-items: end; gap: 2px; }
.hist-verdict { font-size: 0.72rem; color: var(--muted); }
.hist-empty { padding: 6px 2px; }

/* --- Staged progress ------------------------------------------------------- */
.stage-list {
  list-style: none; margin: 12px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px 18px;
}
.stage { display: flex; align-items: center; gap: 7px; font-size: 0.82rem; color: var(--muted); }
.stage-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--line); background: none;
}
.stage.active { color: var(--ink); }
.stage.active .stage-dot { border-color: var(--accent); background: var(--accent); }
.stage.done { color: var(--good); }
.stage.done .stage-dot { border-color: var(--good); background: var(--good); }
.stage.failed { color: var(--bad); }
.stage.failed .stage-dot { border-color: var(--bad); background: var(--bad); }

/* --- "How do I get the diff?" ---------------------------------------------- */
.get-diff { margin-top: 10px; font-size: 0.85rem; }
.get-diff > summary { cursor: pointer; color: var(--accent); }
.gd-body { padding: 10px 2px 0; }
.gd-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.gd-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.gd-list code {
  background: var(--quote-bg); border-radius: 6px; padding: 3px 7px;
  font-size: 0.82rem; overflow-wrap: anywhere;
}
.gd-url { margin-top: 16px; }
.gd-url-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 4px; }
.gd-url-row input { flex: 1; min-width: 220px; }

/* --- Result-zone notes ------------------------------------------------------ */
.delta-note {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); color: var(--muted); font-size: 0.85rem;
}
.seg-copy { font-size: 0.78rem; margin-left: auto; }
.seg-file-bad { border: 1px solid var(--bad); color: var(--bad); }
.seg-ungrounded { color: var(--bad); margin: 6px 0 0; }
