:root {
  --bg: #eef3f1;
  --paper: #fbfcfb;
  --panel: #ffffff;
  --panel-2: #f3f7f5;
  --ink: #17211e;
  --ink-soft: #394743;
  --muted: #65736f;
  --line: #d7dfdc;
  --line-strong: #b9c6c2;
  --accent: #267451;
  --accent-ink: #ffffff;
  --blue: #365f91;
  --warn: #9a6a20;
  --red: #b4483f;
  --shadow: 0 1px 2px rgba(23, 33, 30, 0.06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); height: 100%; }
body {
  font-family: ui-sans-serif, -apple-system, "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
}

.app-header {
  display: flex; align-items: baseline; gap: 18px;
  padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: rgba(251, 252, 251, 0.94); backdrop-filter: blur(8px); flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
  font-weight: 800; font-size: 18px; letter-spacing: 0;
}
.brand-mark-img { display: block; width: 34px; height: 34px; border-radius: 8px; }
.brand-wordmark span { color: var(--accent); }
.brand-tag {
  color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 6px;
  padding: 2px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2);
}
.brand-sub { color: var(--muted); font-size: 13px; }
.brand-meta {
  color: var(--muted); font-size: 12px;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

.demo-scenarios {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
}
.demo-scenarios label {
  color: var(--muted); font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.demo-scenarios select {
  width: 240px; font-size: 13px; padding: 6px 8px;
}

/* ---- Blank-slate intake ---- */
.intake-block {
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(38, 116, 81, 0.04), transparent 70%),
    var(--paper);
  display: flex; flex-direction: column; gap: 10px;
  transition: padding 0.2s ease, opacity 0.2s ease;
}
.intake-block.is-collapsed {
  padding: 8px 28px;
  opacity: 0.55;
}
.intake-block.is-collapsed .intake-textarea,
.intake-block.is-collapsed .intake-actions,
.intake-block.is-collapsed .intake-label {
  display: none;
}
.intake-block.is-collapsed .intake-kicker::after {
  content: " — intake in progress below";
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.intake-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.intake-label {
  color: var(--ink);
  font-size: 18px;
  font-weight: 750;
  line-height: 1.25;
}
.intake-textarea {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  resize: vertical;
  min-height: 96px;
}
.intake-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(38, 116, 81, 0.12);
}
.intake-actions {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.intake-submit {
  width: auto; min-width: 180px; padding: 11px 22px;
}
.intake-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.intake-hint.is-nudge {
  color: var(--warn);
  font-weight: 600;
}

main {
  display: grid; grid-template-columns: minmax(240px, 280px) minmax(440px, 1fr) minmax(360px, 430px);
  gap: 1px; background: var(--line); flex: 1; min-height: 0;
}
.pane { background: var(--paper); padding: 20px 24px; display: flex; flex-direction: column; min-height: 0; }
.context-pane {
  background: #f6f8f7;
  gap: 14px;
}
.pane.results-pane {
  background:
    linear-gradient(90deg, rgba(38, 116, 81, 0.05) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(0deg, rgba(54, 95, 145, 0.04) 1px, transparent 1px) 0 0 / 28px 28px,
    #f8faf8;
  overflow-y: auto;
}
.pane.chat-pane { min-height: calc(100vh - 140px); }
.section-label {
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em;
  font-size: 11px; font-weight: 700; margin-bottom: 14px;
}
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.section-head .section-label {
  margin-bottom: 4px;
}
.section-head h1 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.25;
}
.chat-status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
}
.chat-status-pill.is-ready {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

select {
  padding: 8px 10px; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
  box-shadow: var(--shadow);
}

/* ---- Household file ---- */
.context-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 10px 12px;
  margin-top: auto;
}

/* Progress bar */
.checklist-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}
.checklist-progress-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.checklist-count {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
}
.checklist-progress-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.checklist-progress-bar {
  height: 6px;
  background: var(--line-soft, #edf2f0);
  border-radius: 999px;
  overflow: hidden;
}
.checklist-progress-fill {
  height: 100%;
  background: var(--accent, #267451);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.checklist-need-note {
  color: var(--warn, #9a6a20);
  font-size: 11px;
  line-height: 1.4;
  font-weight: 600;
  margin-top: 2px;
}

/* Checklist */
.household-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.checklist-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.checklist-item.is-known {
  border-color: color-mix(in srgb, var(--accent, #267451) 40%, var(--line));
  background: color-mix(in srgb, var(--accent, #267451) 5%, var(--panel));
}
.checklist-item.is-unknown {
  background: var(--panel-2);
}
.checklist-icon {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  display: inline-flex;
  justify-content: center;
  color: var(--muted);
}
.checklist-item.is-known .checklist-icon {
  color: var(--accent, #267451);
}
.checklist-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.checklist-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.checklist-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}
.checklist-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.checklist-badge.is-employer {
  background: #e8f0ec;
  color: #1c5a3f;
  border-color: #c8ddd1;
}
.checklist-badge.is-chat {
  background: #eef1f7;
  color: #3a4a6a;
  border-color: #d4dceb;
}
.checklist-value {
  font-size: 12px;
  color: var(--ink-soft, #394743);
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.checklist-value.is-missing {
  color: var(--muted);
  font-style: italic;
}
.persona-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.persona-kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.persona-card .name {
  font-weight: 800;
  font-size: 22px;
  line-height: 1.1;
}
.persona-card .facts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.persona-card .facts span {
  color: var(--muted);
  font-size: 11px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.file-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.file-row span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.file-row b {
  color: var(--ink);
  font-size: 14px;
}
.persona-desc {
  margin: 0;
  color: var(--ink-soft, #394743);
  font-size: 13px;
  line-height: 1.55;
}

/* ---- Chat ---- */
.chat-log {
  flex: 1; overflow-y: auto; padding: 10px 2px 12px;
  display: flex; flex-direction: column; gap: 12px; min-height: 220px;
}
.chat-log:empty::before {
  content: "Type your household below, or pick a demo scenario in the header. Matchbook will only ask follow-ups that change the election.";
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 16px;
  max-width: 420px;
}
.msg {
  max-width: 74%; padding: 10px 14px; border-radius: 8px;
  font-size: 14px; line-height: 1.5; white-space: pre-wrap;
  box-shadow: var(--shadow);
}
.msg.assistant {
  background: var(--panel); border: 1px solid var(--line);
  align-self: flex-start; border-left: 3px solid var(--blue);
}
.msg.user {
  background: var(--accent); color: var(--accent-ink);
  align-self: flex-end;
}
.msg-meta {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.msg.user .msg-meta {
  color: rgba(255, 255, 255, 0.72);
}
.msg-body {
  white-space: pre-wrap;
}
.msg.typing { opacity: 0.6; font-style: italic; }

.msg.assistant .msg-body { white-space: normal; }
.msg.assistant .chat-msg-p { margin: 0 0 8px; }
.msg.assistant .chat-msg-p:last-child { margin-bottom: 0; }
.msg.assistant .msg-body ul {
  margin: 4px 0 8px; padding-left: 20px;
}
.msg.assistant .msg-body ul:last-child { margin-bottom: 0; }
.msg.assistant .msg-body li { margin: 2px 0; }
.msg.assistant .msg-body code {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 0.92em;
  background: var(--panel-2, #f1f3f2);
  padding: 1px 4px; border-radius: 3px;
}

.chat-cta { margin: 8px 0; }

.quick-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0 12px;
}
.quick-options-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.quick-options-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.quick-option {
  appearance: none;
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  padding: 9px 11px;
  text-align: left;
  box-shadow: var(--shadow);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}
.quick-option:hover,
.quick-option:focus-visible {
  background: #f6f9f8;
  border-color: var(--line-strong);
  outline: none;
}
.quick-option:active {
  transform: translateY(1px);
}

.chat-input {
  display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line);
}
.chat-input input {
  flex: 1; padding: 12px 14px; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
  box-shadow: var(--shadow);
}
.chat-input input:disabled { opacity: 0.5; }
.chat-input button {
  padding: 10px 18px; background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 8px; font-weight: 700; font-size: 14px; cursor: pointer;
}
.chat-input button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- Results ---- */
.result-empty {
  color: var(--muted); font-size: 13px; padding: 20px;
  border: 1px dashed var(--line-strong); border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  line-height: 1.55;
}

.run-btn {
  width: 100%; padding: 12px; background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 8px; font-size: 15px; font-weight: 700;
  cursor: pointer;
}
.run-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.result-headlines {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px;
}
.headline {
  background: rgba(255, 255, 255, 0.88); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 14px 16px; box-shadow: var(--shadow);
}
.headline.hero {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, rgba(38, 116, 81, 0.08), rgba(255, 255, 255, 0.94));
  border-left-width: 4px;
}
.headline-kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.hero-plan {
  color: var(--accent);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
}
.hero-reason {
  color: var(--ink-soft, #394743);
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.45;
}
.headline .n {
  font-size: 30px; font-weight: 700; letter-spacing: 0; color: var(--accent);
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
}
.headline .l { color: var(--muted); font-size: 12px; margin-top: 4px; }
.headline.secondary { border-left-color: var(--blue); }
.headline.secondary .n { color: var(--blue); font-size: 22px; }
.headline.tertiary { border-left-color: var(--warn); }
.headline.tertiary .n { color: var(--warn); font-size: 22px; }

.headline-lever {
  background: rgba(38, 116, 81, 0.08);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 12px 16px; margin-bottom: 14px;
  font-size: 14px; font-weight: 600;
}
.narrative {
  color: var(--ink); line-height: 1.6; font-size: 14px;
  padding: 12px 0; margin-bottom: 12px;
}

.elections {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 14px 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.elections summary {
  cursor: pointer; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700;
}
.elections-title {
  color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.1em; font-weight: 800;
  margin-bottom: 10px;
}
.elections-grid {
  display: grid; grid-template-columns: 1fr; gap: 8px;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 12px;
}
.elections-grid div {
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft, #edf2f0);
}
.elections-grid div:last-child { border-bottom: none; }
.elections-grid b { color: var(--ink); font-weight: 600; }

.timings {
  color: var(--muted); font-size: 11px; margin-top: 8px;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

/* In-chat recommendation + confirmation variants */
.msg.assistant.is-recommendation {
  border-left: 3px solid var(--accent, #267451);
  background: color-mix(in srgb, var(--accent, #267451) 4%, var(--panel));
  max-width: 86%;
}
.msg.assistant.is-recommendation .msg-body {
  font-family: ui-sans-serif, -apple-system, "Inter", sans-serif;
  white-space: pre-wrap;
}
.msg.assistant.is-confirmation {
  border-left: 3px solid #2a7948;
  background: #eaf6ef;
}

/* Confirm & send to HR */
.result-confirm {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.confirm-btn {
  background: var(--accent, #267451);
  color: #fff;
  font-weight: 700;
}
.confirm-btn:hover:not(:disabled) {
  filter: brightness(1.06);
}
.confirm-btn.is-sent {
  background: #2a7948;
  color: #fff;
  cursor: default;
  opacity: 1;
}
.confirm-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 960px) {
  main { grid-template-columns: 1fr; }
  .pane.chat-pane { min-height: 60vh; }
  .context-note { margin-top: 0; }
  .result-headlines { grid-template-columns: 1fr; }
}
