/* === getplan.today — marketing plan service === */

:root {
  /* Neutral light palette */
  --bg:           #F5F5F7;
  --bg-2:         #EBEBED;
  --paper:        #FFFFFF;
  --ink:          #1D1D1F;
  --ink-2:        #3A3A3C;
  --muted:        #6E6E73;
  --rule:         #D1D1D6;
  --rule-soft:    #E5E5EA;
  --accent:       #0071E3;
  --accent-soft:  #C7DFFE;
  --positive:     #16A34A;
  --warn:         #D97706;
  --danger:       #DC2626;
  /* RGB triplets for rgba() usage */
  --accent-rgb:   0, 113, 227;
  --positive-rgb: 22, 163, 74;
  --warn-rgb:     217, 119, 6;
  --danger-rgb:   220, 38, 38;
  /* Typography */
  --serif: "Instrument Serif", "Source Serif Pro", Georgia, serif;
  --sans:  "Geist", "Söhne", "DM Sans", -apple-system, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #1C1C1E;
    --bg-2:         #2C2C2E;
    --paper:        #2C2C2E;
    --ink:          #F5F5F7;
    --ink-2:        #EBEBED;
    --muted:        #8E8E93;
    --rule:         #3A3A3C;
    --rule-soft:    #48484A;
    --accent:       #0A84FF;
    --accent-soft:  #003380;
    --positive:     #30D158;
    --warn:         #FF9F0A;
    --danger:       #F87171;
    --accent-rgb:   10, 132, 255;
    --positive-rgb: 48, 209, 88;
    --warn-rgb:     255, 159, 10;
    --danger-rgb:   248, 113, 113;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  height: 100%;
  overflow: hidden;
}

#root { height: 100vh; overflow: hidden; }

button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, textarea { font-family: inherit; color: inherit; border: 0; outline: 0; background: none; }

/* ===== Shell ===== */
.app {
  display: grid;
  grid-template-columns: 248px 1fr 360px;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  background: var(--bg);
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 20px 0 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: relative;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 228px;
  padding-right: 20px;
  border-right: 1px solid var(--rule);
  height: 56px;
}

.brand-mark {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--ink);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.brand-word {
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: -0.01em;
  font-weight: 400;
  line-height: 1;
  padding-top: 2px;
}
.brand-tag {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: 4px;
  border-left: 1px solid var(--rule);
  padding-left: 10px;
  height: 14px;
  display: flex;
  align-items: center;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  padding-left: 24px;
  font-size: 13px;
  color: var(--ink-2);
}
.crumbs .sep { color: var(--muted); opacity: 0.6; }
.crumbs .doc-title { color: var(--ink); }
.crumbs .doc-meta { color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em; }

.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--ink-2);
  transition: background .15s;
}
.icon-btn:hover { background: var(--bg-2); }

.btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .15s;
}
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--ink-2); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { filter: brightness(1.05); }

/* ===== Sidebar ===== */
.sidebar {
  border-right: 1px solid var(--rule);
  background: var(--bg);
  overflow-y: auto;
  padding: 18px 0 24px;
}

.side-section {
  padding: 4px 0;
  border-bottom: 1px solid var(--rule-soft);
  margin: 0 14px;
}
.side-section:last-child { border-bottom: 0; }

.side-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 6px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toc-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  position: relative;
  transition: all .12s;
  text-align: left;
  width: 100%;
}
.toc-item:hover { background: var(--bg-2); color: var(--ink); }
.toc-item.active {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 0 0 1px var(--rule);
}
.toc-item.active .toc-num { color: var(--accent); }
.toc-num {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.toc-name { letter-spacing: -0.005em; }
.toc-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.side-meta {
  padding: 6px 6px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
}
.side-meta .row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}
.side-meta .row span:last-child { color: var(--ink-2); font-family: var(--mono); font-size: 11px; }

/* Workspace editable fields */
.ws-fields { padding: 2px 0; }
.ws-row {
  cursor: text;
  border-radius: 4px;
  margin: 0 -4px;
  padding: 4px 4px;
  transition: background .12s;
}
.ws-row:hover { background: var(--bg-2); }
.ws-label { color: var(--muted); flex-shrink: 0; min-width: 52px; }
.ws-value {
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.ws-input {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 3px;
  padding: 1px 5px;
  text-align: right;
  width: 120px;
  outline: none;
}

/* ===== Main content ===== */
.main {
  overflow-y: auto;
  background: var(--bg);
  scroll-behavior: smooth;
}

.doc {
  max-width: 780px;
  margin: 0 auto;
  padding: 56px 56px 200px;
}

.brief {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 24px 28px;
  margin-bottom: 56px;
  position: relative;
}
.brief-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brief-label::before {
  content: "";
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
}
.brief h1 {
  font-family: var(--serif);
  font-size: 38px;
  line-height: 1.05;
  font-weight: 400;
  letter-spacing: -0.015em;
  margin-bottom: 16px;
  color: var(--ink);
  text-wrap: pretty;
}
.brief h1 em {
  font-style: italic;
  color: var(--accent);
}
.brief-meta {
  display: flex;
  gap: 24px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed var(--rule);
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.brief-meta b { color: var(--ink); font-weight: 500; font-family: var(--mono); font-size: 11.5px; }

/* Section blocks */
.section {
  margin-bottom: 64px;
  scroll-margin-top: 24px;
}
.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.section-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.08em;
  padding-top: 4px;
}
.section-title {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--ink);
  flex: 1;
}
.section-verdict {
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  color: var(--positive);
  padding: 4px 10px;
  background: rgba(var(--positive-rgb), 0.08);
  border-radius: 99px;
  white-space: nowrap;
  align-self: center;
}
.section-verdict.warn   { color: var(--warn);   background: rgba(var(--warn-rgb),   0.08); }
.section-verdict.danger { color: var(--danger);  background: rgba(var(--danger-rgb), 0.08); }

.lede {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.45;
  color: var(--ink-2);
  margin-bottom: 24px;
  text-wrap: pretty;
  font-style: italic;
}

p.body { color: var(--ink-2); margin-bottom: 16px; line-height: 1.6; }
p.body strong { color: var(--ink); font-weight: 500; }

/* Stat strips */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  margin: 24px 0;
}
.stat {
  background: var(--paper);
  padding: 16px 18px;
}
.stat-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.stat-value {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 4px; font-family: var(--mono); }

/* Audience table */
.aud-table {
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper);
  margin: 16px 0 24px;
}
.aud-row {
  display: grid;
  grid-template-columns: 36px 1.4fr 2fr 90px 110px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule-soft);
  transition: background .12s;
  cursor: pointer;
}
.aud-row:last-child { border-bottom: 0; }
.aud-row.head {
  background: var(--bg-2);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 16px;
  cursor: default;
}
.aud-row:not(.head):hover { background: var(--bg-2); }
.aud-row .idx { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.aud-row .seg { font-weight: 500; color: var(--ink); font-size: 13px; }
.aud-row .seg .sub { color: var(--muted); font-size: 11.5px; font-weight: 400; margin-top: 2px; display: block; }
.aud-row .tam { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.aud-row .pri { display: flex; gap: 4px; align-items: center; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.red { background: #C2493A; }
.dot.orange { background: #D89034; }
.dot.yellow { background: #C7A93C; }
.pri-label { font-size: 11px; font-family: var(--mono); color: var(--ink-2); letter-spacing: 0.04em; }

/* Value prop cards */
.vp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0 24px; }
.vp-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 18px 20px;
  position: relative;
  transition: all .18s;
  cursor: pointer;
}
.vp-card:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}
.vp-card .vp-num {
  position: absolute;
  top: 14px; right: 16px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.vp-card h4 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
  padding-right: 30px;
  line-height: 1.15;
}
.vp-card p { font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }
.vp-card .vp-tag {
  display: inline-block;
  margin-top: 10px;
  font-size: 10.5px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  color: var(--accent);
  padding: 3px 8px;
  background: rgba(var(--accent-rgb), 0.08);
  border-radius: 99px;
}

/* Pull quote / messaging */
.pullquote {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.25;
  color: var(--ink);
  padding: 24px 0 24px 28px;
  border-left: 2px solid var(--accent);
  margin: 24px 0;
  letter-spacing: -0.005em;
}
.pullquote em { font-style: italic; color: var(--accent); }
.pullquote .attr {
  display: block;
  font-family: var(--sans);
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 14px;
}

/* Competitive moats */
.moats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  margin: 16px 0 24px;
}
.moat {
  background: var(--paper);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.moat-head { display: flex; justify-content: space-between; align-items: baseline; }
.moat-name { font-weight: 500; color: var(--ink); font-size: 13.5px; }
.moat-bar {
  height: 4px;
  background: var(--bg-2);
  border-radius: 99px;
  position: relative;
  overflow: hidden;
}
.moat-bar-fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  border-radius: 99px;
  width: var(--w, 50%);
}
.moat-foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
}
.moat-desc { font-size: 12px; color: var(--ink-2); line-height: 1.5; }

/* Channel phases */
.phase-tabs {
  display: flex;
  gap: 0;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 4px;
  margin: 16px 0;
}
.phase-tab {
  flex: 1;
  padding: 9px 12px;
  font-size: 12px;
  border-radius: 5px;
  color: var(--ink-2);
  font-weight: 500;
  transition: all .15s;
  text-align: left;
}
.phase-tab .ph-meta {
  display: block;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
  letter-spacing: 0.04em;
}
.phase-tab.active {
  background: var(--ink);
  color: var(--bg);
}
.phase-tab.active .ph-meta { color: rgba(128,128,128,0.8); }

.channels {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}
.ch-row {
  display: grid;
  grid-template-columns: 28px 1.3fr 2fr 60px 100px;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--rule-soft);
  gap: 12px;
  cursor: pointer;
  transition: background .12s;
}
.ch-row:last-child { border-bottom: 0; }
.ch-row.head {
  background: var(--bg-2);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 16px;
  cursor: default;
}
.ch-row:not(.head):hover { background: var(--bg-2); }
.ch-row .idx { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.ch-row .name { font-weight: 500; font-size: 13px; }
.ch-row .tac { color: var(--ink-2); font-size: 12px; line-height: 1.4; }
.ch-row .pri-badge {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 4px;
  text-align: center;
}
.pri-P0 { background: rgba(var(--danger-rgb), 0.1);  color: var(--danger); }
.pri-P1 { background: rgba(var(--warn-rgb),   0.12); color: var(--warn); }
.pri-P2 { background: rgba(var(--warn-rgb),   0.07); color: var(--muted); }
.cac-cell { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); text-align: right; }

/* CAC bars */
.cac-list {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 18px 22px;
  margin: 20px 0;
}
.cac-item {
  display: grid;
  grid-template-columns: 200px 1fr 90px;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--rule-soft);
}
.cac-item:last-child { border-bottom: 0; }
.cac-item .label { font-size: 12.5px; color: var(--ink); }
.cac-track {
  height: 6px;
  background: var(--bg-2);
  border-radius: 99px;
  position: relative;
  overflow: hidden;
}
.cac-track-fill {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--ink);
  border-radius: 99px;
  opacity: 0.85;
}
.cac-track-fill.accent { background: var(--accent); opacity: 1; }
.cac-amt { font-family: var(--mono); font-size: 11.5px; color: var(--muted); text-align: right; }

/* Roadmap */
.roadmap {
  display: grid;
  gap: 14px;
  margin: 18px 0 24px;
}
.rm-block {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 20px 22px;
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 24px;
  position: relative;
}
.rm-when {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-transform: uppercase;
}
.rm-phase {
  font-family: var(--serif);
  font-size: 22px;
  margin-top: 6px;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.1;
}
.rm-content { display: flex; flex-direction: column; gap: 10px; }
.rm-checklist { display: flex; flex-direction: column; gap: 7px; }
.rm-item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  align-items: start;
  line-height: 1.45;
}
.rm-check {
  width: 14px; height: 14px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  margin-top: 3px;
  background: var(--bg);
  position: relative;
  cursor: pointer;
  transition: all .15s;
}
.rm-check.done {
  background: var(--accent);
  border-color: var(--accent);
}
.rm-check.done::after {
  content: "";
  position: absolute;
  left: 3px; top: 0px;
  width: 4px; height: 8px;
  border-right: 1.5px solid white;
  border-bottom: 1.5px solid white;
  transform: rotate(45deg);
}
.rm-targets {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--rule-soft);
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.rm-targets b { color: var(--accent); font-weight: 500; }

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  margin: 16px 0 24px;
}
.kpi {
  background: var(--paper);
  padding: 18px 18px;
}
.kpi-name {
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 12px;
  font-weight: 500;
}
.kpi-target {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}
.kpi-target b { color: var(--accent); font-weight: 500; }
.kpi-spark { height: 32px; width: 100%; }

/* North star callout */
.north {
  background: var(--ink);
  color: var(--bg);
  border-radius: 10px;
  padding: 28px 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}
.north-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.north-label::before {
  content: "★";
  color: var(--accent);
  font-size: 12px;
}
.north-text {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.005em;
}
.north-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* Summary checklist */
.summary {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 26px 28px;
  margin-top: 12px;
}
.summary h4 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 16px;
  letter-spacing: -0.005em;
}
.sum-list { display: flex; flex-direction: column; gap: 9px; }
.sum-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}
.sum-item::before {
  content: "✓";
  color: var(--positive);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}
.sum-item b { color: var(--ink); font-weight: 500; }

/* Footer / signature */
.doc-foot {
  margin-top: 80px;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

/* ===== Right panel: Refine ===== */
.refine {
  border-left: 1px solid var(--rule);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.refine-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--rule);
}
.refine-title {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: -0.005em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.refine-title::before {
  content: "";
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}
.refine-sub { font-size: 12px; color: var(--muted); line-height: 1.5; }

.scope-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.scope-chip {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 99px;
  background: var(--bg-2);
  color: var(--ink-2);
  font-family: var(--mono);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all .12s;
  border: 1px solid transparent;
}
.scope-chip:hover { background: var(--bg); }
.scope-chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.msg { display: flex; flex-direction: column; gap: 6px; }
.msg-meta {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--mono);
}
.msg-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
}
.msg.user .msg-body {
  background: var(--bg-2);
  padding: 11px 14px;
  border-radius: 10px 10px 4px 10px;
  align-self: flex-end;
  max-width: 90%;
}
.msg.ai .msg-body {
  padding: 11px 14px;
  border: 1px solid var(--rule);
  border-radius: 10px 10px 10px 4px;
  background: var(--bg);
  align-self: flex-start;
  max-width: 95%;
}
.msg.user { align-items: flex-end; }

.msg-diff {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.diff-chip {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(var(--positive-rgb), 0.1);
  color: var(--positive);
}
.diff-chip.minus { background: rgba(var(--danger-rgb), 0.08); color: var(--danger); }

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 20px 12px;
}
.suggestion {
  text-align: left;
  font-size: 12px;
  padding: 9px 12px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  color: var(--ink-2);
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all .12s;
  line-height: 1.4;
}
.suggestion:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.suggestion::before {
  content: "↗";
  color: var(--accent);
  font-family: var(--mono);
}

.composer {
  border-top: 1px solid var(--rule);
  padding: 12px 16px 14px;
  background: var(--bg);
}
.composer-box {
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color .15s;
}
.composer-box:focus-within { border-color: var(--ink); }
.composer textarea {
  width: 100%;
  resize: none;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  min-height: 60px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.composer-tools { display: flex; gap: 6px; }
.composer-tool {
  width: 26px; height: 26px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}
.composer-tool:hover { background: var(--bg-2); color: var(--ink); }
.send-btn {
  background: var(--accent);
  color: white;
  height: 28px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.send-btn:hover { filter: brightness(1.05); }

.refine-foot {
  padding: 8px 16px;
  border-top: 1px solid var(--rule-soft);
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--muted);
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
  background: var(--bg);
}

/* Inline cite */
.cite {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  background: var(--bg-2);
  color: var(--ink-2);
  padding: 1px 5px;
  border-radius: 3px;
  margin: 0 2px;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

/* ===== Workspace setup page ===== */
.ws-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.ws-topbar {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 40px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

.ws-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 72px 24px 120px;
}

.ws-hero {
  max-width: 560px;
  width: 100%;
  text-align: center;
  margin-bottom: 48px;
}
.ws-hero-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ws-hero-label::before {
  content: "";
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
}
.ws-hero-title {
  font-family: var(--serif);
  font-size: 52px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 20px;
}
.ws-hero-title em { font-style: italic; color: var(--accent); }
.ws-hero-sub {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 440px;
  margin: 0 auto;
}

.ws-form {
  max-width: 560px;
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 32px 36px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ws-form-row { display: flex; flex-direction: column; gap: 7px; }
.ws-form-row--full { width: 100%; }
.ws-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}

.ws-form-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.ws-required { color: var(--accent); }

.ws-field-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 10px 13px;
  font-size: 14px;
  color: var(--ink);
  font-family: var(--sans);
  transition: border-color .15s, background .15s;
  outline: none;
  appearance: none;
}
.ws-field-input:focus {
  border-color: var(--ink);
  background: var(--paper);
}
.ws-field-input::placeholder { color: var(--muted); }
.ws-field-textarea { resize: none; line-height: 1.55; }
.ws-field-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236E6E73' d='M0 0h10L5 6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
@media (prefers-color-scheme: dark) {
  .ws-field-select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%238E8E93' d='M0 0h10L5 6z'/></svg>");
  }
}

.ws-form-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 4px;
}
.ws-submit {
  height: 42px;
  padding: 0 22px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all .15s;
  border: 0;
  cursor: pointer;
  font-family: var(--sans);
}
.ws-submit:hover { background: var(--ink-2); }
.ws-submit--disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.ws-submit--disabled:hover { background: var(--ink); }
.ws-submit-note {
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

/* URL import */
.url-import {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 4px;
}
.url-import-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.url-import-input {
  flex: 1;
  min-width: 0;
}
.url-import-btn {
  height: 42px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .15s;
  white-space: nowrap;
}
.url-import-btn:hover:not(:disabled) { opacity: .88; }
.url-import-btn:disabled { opacity: .45; cursor: not-allowed; }
.url-import-btn--loading { pointer-events: none; }
.gen-spinner--sm {
  width: 14px;
  height: 14px;
  border-color: rgba(255,255,255,.35);
  border-top-color: #fff;
}
.url-import-error {
  font-size: 12px;
  color: var(--danger);
  font-family: var(--mono);
}
.url-import-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--mono);
  letter-spacing: .04em;
}
.url-import-divider::before,
.url-import-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

/* Generation progress steps */
.gen-steps {
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gen-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-radius: 8px;
  transition: background .15s;
}
.gen-step--done    { background: var(--paper); border: 1px solid var(--rule); }
.gen-step--running { background: var(--paper); border: 1px solid var(--ink);  }
.gen-step--pending { background: transparent;  border: 1px solid transparent; opacity: .45; }
.gen-step-icon {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--positive);
}
.gen-step--running .gen-step-icon { color: var(--accent); }
.gen-step-num {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.gen-step--running .gen-step-num { color: var(--accent); }
.gen-step-name { font-size: 13.5px; color: var(--ink-2); }
.gen-step--done    .gen-step-name { color: var(--ink); }
.gen-step--running .gen-step-name { color: var(--ink); font-weight: 500; }

.gen-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gen-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--rule);
}

.gen-error {
  max-width: 480px;
  width: 100%;
  margin-top: 20px;
  padding: 14px 18px;
  background: rgba(var(--danger-rgb), 0.08);
  border: 1px solid rgba(var(--danger-rgb), 0.2);
  border-radius: 8px;
  font-size: 13px;
  color: var(--danger);
}

/* Breadcrumb back link */
.crumb-link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: var(--ink-2);
  cursor: pointer;
  transition: color .12s;
}
.crumb-link:hover { color: var(--accent); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-2); }
::-webkit-scrollbar-track { background: transparent; }

/* Streaming cursor */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.msg-streaming::after {
  content: "▍";
  display: inline-block;
  font-size: 11px;
  color: var(--accent);
  animation: blink .7s step-end infinite;
  margin-left: 2px;
  vertical-align: middle;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg { animation: fadeIn .25s ease-out both; }

/* Theme variations */
.theme-noir {
  --bg: #161412;
  --bg-2: #1F1C19;
  --paper: #1A1815;
  --ink: #F1ECDF;
  --ink-2: #C7C0AE;
  --muted: #807968;
  --rule: #2E2A24;
  --rule-soft: #25221D;
  --accent: #E07A56;
  --accent-soft: #4A2C20;
  --positive: #9FB97D;
  --warn: #D9B05C;
}
.theme-grove {
  --bg: #EDEFE6;
  --bg-2: #E2E5D7;
  --paper: #F5F6EF;
  --ink: #1C2418;
  --ink-2: #3A4233;
  --muted: #6B7361;
  --rule: #C9CFB8;
  --rule-soft: #DBDFCC;
  --accent: #3C6B3A;
  --accent-soft: #BFD0AE;
  --positive: #3C6B3A;
  --warn: #B58A2A;
}
.theme-ink {
  --bg: #ECECEC;
  --bg-2: #DFDFDF;
  --paper: #F5F5F5;
  --ink: #111111;
  --ink-2: #333333;
  --muted: #6E6E6E;
  --rule: #C8C8C8;
  --rule-soft: #DADADA;
  --accent: #D14A1A;
}

/* ── History page ────────────────────────────────────────────────────────── */
.hist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.hist-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 20px; background: var(--paper); border: 1px solid var(--rule);
  border-radius: 10px; text-align: left; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: var(--sans); color: var(--ink);
}
.hist-card:hover { border-color: var(--accent); box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.hist-card-product { font-size: 16px; font-weight: 600; color: var(--ink); }
.hist-card-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.hist-badge {
  font-size: 11px; font-family: var(--mono); color: var(--ink-2);
  background: var(--bg-2); border: 1px solid var(--rule-soft);
  border-radius: 4px; padding: 2px 7px;
}
.hist-card-desc {
  font-size: 12px; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hist-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--muted); margin-top: 4px;
  font-family: var(--mono);
}
.hist-card-cta { color: var(--accent); font-weight: 600; }

/* ── Export dropdown ─────────────────────────────────────────────────────── */
.export-menu { position: relative; }
.export-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--bg); border: 1px solid var(--rule);
  border-radius: 6px; padding: 4px; z-index: 200; min-width: 148px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.export-option {
  display: flex; align-items: center; width: 100%; text-align: left;
  padding: 7px 12px; font-size: 13px; background: none; border: none;
  cursor: pointer; border-radius: 4px; color: var(--ink); font-family: var(--sans);
}
.export-option:hover { background: var(--bg-2); }

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .refine, .tweaks-btn { display: none !important; }
  .app { display: block; }
  .main { overflow: visible; height: auto; padding: 0; }
  .doc { max-width: 740px; margin: 0 auto; padding: 2rem 0; }
  section { page-break-inside: avoid; }
}
