:root {
  --bg: #f7f5ef;
  --ink: #151515;
  --muted: #6e6a61;
  --line: #d9d3c6;
  --paper: #fffdf8;
  --soft: #eee8db;
  --focus: #111;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button, input, textarea, select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 28px 24px;
  background: var(--paper);
}

.logo {
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 36px;
}

.nav button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  color: var(--muted);
}

.nav button.active {
  color: var(--ink);
  font-weight: 700;
}

/* Step number chip in the nav — signals Search → Queries → Paths → Report order. */
.nav .step {
  display: inline-block;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 11px;
  margin-right: 10px;
  color: var(--muted);
}

.nav button.active .step {
  border-color: var(--ink);
  color: var(--ink);
}

/* History is a meta destination, set apart from the numbered 1–4 flow. */
.nav button.nav-meta {
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* The button just above History would otherwise stack its bottom border with
   History's top border — drop it so only one divider shows. */
.nav button:has(+ .nav-meta) {
  border-bottom: 0;
}

.main {
  position: relative;
  overflow: hidden;
}

.workspace {
  padding: 34px 42px;
  max-width: 1120px;
}

.top {
  border-bottom: 1px solid var(--line);
  padding-bottom: 22px;
  margin-bottom: 30px;
}

.kicker {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
}

h1 {
  margin: 0;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -.05em;
  font-weight: 760;
}

.subhead {
  color: var(--muted);
  margin-top: 12px;
  font-size: 17px;
  max-width: 700px;
  line-height: 1.45;
}

.view { display: none; }
.view.active { display: block; }

/* When the header is immediately followed by the mode toggle, drop its divider
   so the two hairlines don't stack into a weird double rule. */
.top:has(+ .mode-row) {
  border-bottom: 0;
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.mode-row {
  display: flex;
  gap: 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
}

/* Tab-style modes: an underline indicator makes it read as a clickable toggle. */
.mode {
  cursor: pointer;
  color: var(--muted);
  padding: 4px 0 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s ease, border-color .12s ease;
}

.mode:hover {
  color: var(--ink);
}

.mode.active {
  color: var(--ink);
  font-weight: 700;
  border-bottom-color: var(--ink);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 46px;
}

.field {
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

input, textarea {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 4px 0;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 74px;
  resize: vertical;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 24px;
  margin-top: 10px;
}

.check {
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}

.check input {
  width: auto;
  margin-right: 8px;
}

.check:has(input:checked) {
  color: var(--ink);
  font-weight: 650;
}

.advanced {
  margin-top: 22px;
}

/* Only draw a divider BETWEEN stacked collapsibles — the element before the
   first one already provides a bottom border, so a top border here would
   double it (the "double hr"). */
.advanced + .advanced {
  border-top: 1px solid var(--line);
  margin-top: 0;
}

.advanced summary {
  padding: 16px 0;
  cursor: pointer;
  color: var(--muted);
}

.preview {
  border-left: 1px solid var(--line);
  padding-left: 28px;
}

.preview h2,
.section-title {
  margin: 0 0 16px;
  font-size: 20px;
  letter-spacing: -.02em;
}

.summary-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.summary-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.summary-list span {
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 26px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  padding: 10px 16px;
  cursor: pointer;
}

.btn.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.filters {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter {
  border: 1px solid var(--line);
  background: transparent;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--muted);
}

.filter.active {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--paper);
}

.results-layout {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 40px;
}

.tree {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 15px;
  line-height: 1.55;
}

.opener {
  border-bottom: 1px solid var(--line);
  padding: 18px 0 22px;
}

.opener-name {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-weight: 750;
  font-size: 22px;
  margin-bottom: 8px;
}

.opener-meta {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  color: var(--muted);
  margin-bottom: 10px;
}

.person-line {
  cursor: pointer;
  padding: 2px 0;
}

.person-line:hover {
  background: var(--soft);
}

.person-line > span:first-child {
  cursor: pointer;
}

.person-del {
  cursor: pointer;
  color: var(--muted);
  opacity: 0;
  transition: opacity .12s ease;
}

.person-line:hover .person-del {
  opacity: 1;
}

.person-del:hover {
  color: var(--ink);
}

.person-line a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
}

.person-line a:hover {
  text-decoration: underline;
}

.tree-meta {
  color: var(--muted);
}

.person-detail {
  cursor: pointer;
  color: var(--muted);
  margin-left: 4px;
}

.person-detail:hover {
  color: var(--ink);
}

/* Status badge colors — subtle, on the cream palette. */
.tag.s-toreach   { color: var(--muted); border-color: var(--line); }
.tag.s-intro     { color: #7a5b16; border-color: #d8c391; }
.tag.s-messaged  { color: #1f5130; border-color: #a9c9b3; }
.tag.s-responded { color: #14401f; border-color: #7fae8c; background: #eef5ef; }
.tag.s-not       { color: #8a8a8a; border-color: var(--line); text-decoration: line-through; }

/* Duplicate-intro warning. */
.tag.dup {
  color: #8a4b16;
  border-color: #e0b483;
  background: #fbf1e6;
  margin-left: 6px;
}

/* Door-opener name links keep the big opener heading style. */
.opener-name a {
  color: var(--ink);
  text-decoration: none;
}

.opener-name a:hover { text-decoration: underline; }

.company-row a {
  color: var(--ink);
  text-decoration: none;
}

.company-row a:hover { text-decoration: underline; }

/* Segmented status selector (drawer + dashboard). */
.status-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.seg {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 5px 9px;
  cursor: pointer;
  font-size: 13px;
}

.seg:hover { color: var(--ink); }

.seg.on {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--paper);
  font-weight: 650;
}

/* Drawer note input gets a visible box (page inputs are borderless). */
.drawer .detail-row input {
  border: 1px solid var(--line);
  padding: 8px;
  margin-top: 4px;
}

/* Outreach dashboard rows. */
.outreach-row {
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}

.outreach-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.outreach-name {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 17px;
}

.outreach-name:hover { text-decoration: underline; }

.draft {
  margin-top: 10px;
}

.draft summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
}

/* Editable intro message (drawer + dashboard). */
.intro-edit {
  width: 100%;
  min-height: 96px;
  border: 1px solid var(--line);
  padding: 10px;
  margin-top: 8px;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  resize: vertical;
}

.aside-panel {
  border-left: 1px solid var(--line);
  padding-left: 24px;
}

.company-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 11px 0;
}

.search-item {
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
}

.search-meta {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

.report-page {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 36px;
  max-width: 820px;
}

.report-page h2 {
  margin-top: 0;
  font-size: 34px;
  letter-spacing: -.04em;
}

.report-block {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 22px;
}

blockquote {
  border-left: 3px solid var(--ink);
  margin: 18px 0;
  padding-left: 18px;
  color: #333;
  white-space: pre-wrap;
}

.drawer {
  position: absolute;
  top: 0;
  right: -420px;
  width: 420px;
  height: 100%;
  background: var(--paper);
  border-left: 1px solid var(--line);
  padding: 30px;
  transition: right .22s ease;
  box-shadow: -20px 0 60px rgba(0,0,0,.06);
  z-index: 10;
  overflow-y: auto;
}

.drawer.open { right: 0; }

.drawer-close {
  border: 0;
  background: transparent;
  cursor: pointer;
  float: right;
  font-size: 18px;
}

.drawer h2 {
  font-size: 34px;
  margin: 44px 0 8px;
  letter-spacing: -.04em;
}

.drawer .role {
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 26px;
}

.detail-row {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.detail-row small {
  display: block;
  color: var(--muted);
  margin-bottom: 5px;
}

.path-stack {
  margin: 18px 0;
  line-height: 1.8;
}

/* --- additions beyond the prototype --- */

.tag {
  display: inline-block;
  font-size: 12px;
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 2px;
  color: var(--muted);
  margin-right: 6px;
}

.tag.hi { border-color: var(--ink); color: var(--ink); font-weight: 650; }

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  padding: 28px;
  text-align: center;
  background: var(--paper);
}

.capture-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
}

.capture-grid .field.full { grid-column: 1 / -1; }

.hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.matched-terms {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { display: flex; gap: 14px; flex-wrap: wrap; }
  .nav button { border-bottom: 0; width: auto; }
  .form-grid, .results-layout, .capture-grid { grid-template-columns: 1fr; }
  .preview, .aside-panel { border-left: 0; padding-left: 0; }
  .drawer { width: 100%; right: -100%; }
}

@media print {
  .sidebar, .top, .filters, .actions, .drawer, .mode-row { display: none !important; }
  .app { display: block; }
  .workspace { padding: 0; max-width: none; }
  .report-page { border: 0; padding: 0; }
  body { background: white; }
}
