/* Ask Once: shared styles for index.html and gaps.html. Light and dark themes. */

:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --fg: #1c1f24;
  --muted: #5b616a;
  --border: #dfdfd9;
  --accent: #0d6b66;
  --accent-fg: #ffffff;
  --focus: #1b74d4;
  --banner-bg: #fff6dc;
  --banner-fg: #5c4500;
  --mark-bg: #fff0b3;
  --mark-fg: #4a3a00;
  --pass: #17663a;
  --pass-bg: #e3f4e9;
  --fail: #a3261f;
  --fail-bg: #fbe6e4;

  --lane-call_now: #a3261f;   --lane-call_now-bg: #fbe6e4;
  --lane-money: #8a5200;      --lane-money-bg: #fdf0d9;
  --lane-confidential: #5b3a99; --lane-confidential-bg: #eee7fa;
  --lane-record: #1f5a99;     --lane-record-bg: #e3eefa;
  --lane-trust: #9a2d63;      --lane-trust-bg: #fae6f0;
  --lane-draft: #17663a;      --lane-draft-bg: #e3f4e9;
  --lane-repeat: #0d6b66;     --lane-repeat-bg: #ddf3f1;
  --lane-unclear: #4c535c;    --lane-unclear-bg: #ebecee;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121417;
    --surface: #1a1d21;
    --surface-2: #22262b;
    --fg: #e6e8eb;
    --muted: #a0a7b0;
    --border: #2f343a;
    --accent: #4fc2b9;
    --accent-fg: #0b1716;
    --focus: #6cb0ff;
    --banner-bg: #2e2712;
    --banner-fg: #f2dc9b;
    --mark-bg: #4a3f12;
    --mark-fg: #fbe9a8;
    --pass: #7fd8a1;
    --pass-bg: #163222;
    --fail: #ff9b92;
    --fail-bg: #3a1a18;

    --lane-call_now: #ff9b92;   --lane-call_now-bg: #3a1a18;
    --lane-money: #f2c071;      --lane-money-bg: #35280f;
    --lane-confidential: #c6aef5; --lane-confidential-bg: #2a2140;
    --lane-record: #9cc4f5;     --lane-record-bg: #172a40;
    --lane-trust: #f3a3c9;      --lane-trust-bg: #3a1a2a;
    --lane-draft: #7fd8a1;      --lane-draft-bg: #163222;
    --lane-repeat: #78d8cf;     --lane-repeat-bg: #11302d;
    --lane-unclear: #c2c8cf;    --lane-unclear-bg: #2a2e33;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417;
  --surface: #1a1d21;
  --surface-2: #22262b;
  --fg: #e6e8eb;
  --muted: #a0a7b0;
  --border: #2f343a;
  --accent: #4fc2b9;
  --accent-fg: #0b1716;
  --focus: #6cb0ff;
  --banner-bg: #2e2712;
  --banner-fg: #f2dc9b;
  --mark-bg: #4a3f12;
  --mark-fg: #fbe9a8;
  --pass: #7fd8a1;
  --pass-bg: #163222;
  --fail: #ff9b92;
  --fail-bg: #3a1a18;

  --lane-call_now: #ff9b92;   --lane-call_now-bg: #3a1a18;
  --lane-money: #f2c071;      --lane-money-bg: #35280f;
  --lane-confidential: #c6aef5; --lane-confidential-bg: #2a2140;
  --lane-record: #9cc4f5;     --lane-record-bg: #172a40;
  --lane-trust: #f3a3c9;      --lane-trust-bg: #3a1a2a;
  --lane-draft: #7fd8a1;      --lane-draft-bg: #163222;
  --lane-repeat: #78d8cf;     --lane-repeat-bg: #11302d;
  --lane-unclear: #c2c8cf;    --lane-unclear-bg: #2a2e33;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 0 48px;
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.9rem; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; margin-bottom: 0.6rem; }
h3 { font-size: 1rem; margin: 1.1rem 0 0.4rem; }
h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 1rem 0 0.35rem; }
p { margin: 0 0 0.75rem; }
ul, ol { margin: 0 0 0.75rem; padding-left: 1.3rem; }
li + li { margin-top: 0.3rem; }
code { font: 0.9em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.muted { color: var(--muted); }
.small { font-size: 0.86rem; }

/* ---------- banner and header ---------- */

.banner {
  background: var(--banner-bg);
  color: var(--banner-fg);
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  padding-block: 8px;
  padding-inline: 16px;
  text-align: center;
}
.banner strong { font-weight: 650; }

.top { padding-block: 28px 8px; }
.top .kicker { color: var(--muted); font-size: 0.86rem; margin-bottom: 0.35rem; }
.lede { color: var(--muted); max-width: 70ch; margin-top: 0.6rem; }

.result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 16px 0 24px;
}
.result-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 0.25rem; }
.headline { font-size: 1.15rem; font-weight: 600; margin: 0; }

section { margin-top: 32px; }
.section-note { color: var(--muted); max-width: 75ch; }

/* ---------- lane badges and chips ---------- */

.badge {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--lane-unclear);
  background: var(--lane-unclear-bg);
}
.lane-call_now { color: var(--lane-call_now); background: var(--lane-call_now-bg); }
.lane-money { color: var(--lane-money); background: var(--lane-money-bg); }
.lane-confidential { color: var(--lane-confidential); background: var(--lane-confidential-bg); }
.lane-record { color: var(--lane-record); background: var(--lane-record-bg); }
.lane-trust { color: var(--lane-trust); background: var(--lane-trust-bg); }
.lane-draft { color: var(--lane-draft); background: var(--lane-draft-bg); }
.lane-repeat { color: var(--lane-repeat); background: var(--lane-repeat-bg); }
.lane-unclear { color: var(--lane-unclear); background: var(--lane-unclear-bg); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.chips li + li { margin-top: 0; }
.chip {
  font: inherit;
  font-size: 0.86rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}
.chip .count { font-weight: 700; font-variant-numeric: tabular-nums; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip .dot.lane-call_now { background: var(--lane-call_now); }
.chip .dot.lane-money { background: var(--lane-money); }
.chip .dot.lane-confidential { background: var(--lane-confidential); }
.chip .dot.lane-record { background: var(--lane-record); }
.chip .dot.lane-trust { background: var(--lane-trust); }
.chip .dot.lane-draft { background: var(--lane-draft); }
.chip .dot.lane-repeat { background: var(--lane-repeat); }
.chip .dot.lane-unclear { background: var(--lane-unclear); }

/* ---------- inbox: list + detail ---------- */

.list-wrap { max-height: 26rem; overflow: auto; }

.inbox {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (min-width: 900px) {
  .inbox { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  .detail { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
  .list-wrap { max-height: calc(100vh - 24px); overflow: auto; }
}

.list-wrap, .detail, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 0;
}
.list { list-style: none; margin: 0; padding: 0; }
.list li + li { margin-top: 0; border-top: 1px solid var(--border); }
.mail {
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 10px 14px;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
}
.mail:hover { background: var(--surface-2); }
.mail[aria-current="true"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.mail .meta { color: var(--muted); font-size: 0.8rem; grid-column: 1 / 2; }
.mail .subject { font-weight: 600; grid-column: 1 / 2; overflow-wrap: anywhere; }
.mail .badge { grid-column: 2 / 3; grid-row: 1 / span 2; align-self: center; }
.list-empty { padding: 14px; color: var(--muted); }

.detail { padding: 18px; }
.detail h3:first-child { margin-top: 0; }
.detail .who { color: var(--muted); font-size: 0.86rem; margin-bottom: 0.75rem; }
.email-body {
  margin: 0 0 0.75rem;
  padding: 10px 14px;
  border-left: 3px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  overflow-wrap: anywhere;
}
.decision { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.reason { margin: 0.5rem 0 0; font-weight: 500; }
.phrase {
  display: inline-block;
  font-size: 0.8rem;
  padding: 2px 8px;
  margin: 0 6px 6px 0;
  border-radius: 6px;
  background: var(--mark-bg);
  color: var(--mark-fg);
  overflow-wrap: anywhere;
}
.scores { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.scores li { display: flex; justify-content: space-between; gap: 12px; }
.scores .score { font-variant-numeric: tabular-nums; font-weight: 700; }
.fired { padding-left: 1.1rem; }

.reply { border: 1px solid var(--border); border-radius: 8px; margin-top: 0.5rem; overflow: hidden; }
.reply-head {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 0.86rem;
}
.reply-head .title { font-weight: 600; }
.reply pre {
  margin: 0;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 0.9rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.reply .person-note { padding: 12px; margin: 0; color: var(--muted); }

.btn {
  font: inherit;
  font-size: 0.84rem;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
}
.btn-quiet { background: transparent; color: var(--accent); }

/* ---------- checks, tables ---------- */

.card { padding: 16px 18px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rules-table td:nth-child(2) { min-width: 18rem; }
.shots td:nth-child(2), .shots td:nth-child(3), .shots td:nth-child(4) { min-width: 11rem; }

.checks-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.edge { list-style: none; padding: 0; margin: 0; }
.edge li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.edge li:first-child { border-top: 0; }
.edge li + li { margin-top: 0; }
.edge .detail-line { grid-column: 2; color: var(--muted); font-size: 0.86rem; }
.pf { font-size: 0.74rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; align-self: start; }
.pf.pass { color: var(--pass); background: var(--pass-bg); }
.pf.fail { color: var(--fail); background: var(--fail-bg); }

details { margin-top: 0.5rem; }
summary { cursor: pointer; color: var(--accent); }
details .phrase-group { margin: 0.5rem 0; }

.questions li { max-width: 75ch; }

/* ---------- gaps page ---------- */

.whatif {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 16px 0;
}
.whatif p { margin: 0; }
.whatif .headline { font-size: 1.05rem; }
.whatif .tally { color: var(--muted); font-size: 0.88rem; margin-top: 0.25rem; }

.cluster { margin-top: 20px; }
.cluster-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: baseline; }
.rank {
  display: inline-grid; place-items: center;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--lane-repeat-bg); color: var(--lane-repeat); font-weight: 700;
}
.cluster-head .meta { grid-column: 2; color: var(--muted); font-size: 0.88rem; margin: 0; }
.cluster-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 24px; }
@media (min-width: 900px) { .cluster-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.example { margin: 0 0 10px; }
.example .email-body { margin-bottom: 4px; }
.example .src { font-size: 0.82rem; color: var(--muted); }
.outline dt { font-weight: 600; font-size: 0.86rem; }
.outline dd { margin: 0 0 0.5rem; }
mark.check { background: var(--mark-bg); color: var(--mark-fg); border-radius: 4px; padding: 0 3px; }

.toggle-row {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
}
.toggle { display: inline-flex; gap: 10px; align-items: center; cursor: pointer; font-weight: 600; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.effect { margin: 0; color: var(--muted); font-size: 0.9rem; flex: 1 1 16rem; min-width: 0; }
.effect.on { color: var(--fg); }

/* ---------- footer ---------- */

.foot {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between;
  color: var(--muted); font-size: 0.88rem;
}

@media (max-width: 480px) {
  h1 { font-size: 1.55rem; }
  .headline { font-size: 1.05rem; }
  .detail, .card { padding: 14px; }
  .mail { padding: 10px 12px; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
