:root {
  --paper: #fbfaf6;
  --paper-2: #f3f1ea;
  --surface: #ffffff;
  --ink: #1d1b17;
  --ink-2: #4a463e;
  --muted: #8a847a;
  --line: #e6e2d8;
  --line-2: #d6d0c3;
  --focus: #2f5d8a;
  --danger: #a61b29;

  --c-hook: #c2410c;
  --c-setup: #2f5d8a;
  --c-conflict: #a61b29;
  --c-solution: #2e6b45;
  --c-cta: #8a6a00;
  --c-value: #2e6b45;
  --c-custom: #6b6358;

  --st-idea: #8a847a;
  --st-draft: #2f5d8a;
  --st-ready: #2e6b45;
  --st-shot: #8a6a00;
  --st-archived: #b8b2a6;

  --font-ui: 'Golos Text', system-ui, sans-serif;
  --font-display: 'Literata', Georgia, serif;

  --r-sm: 6px;
  --r-md: 10px;
  --shadow-1: 0 1px 0 rgba(29, 27, 23, 0.04), 0 1px 3px rgba(29, 27, 23, 0.06);
  --shadow-2: 0 12px 40px rgba(29, 27, 23, 0.16), 0 2px 6px rgba(29, 27, 23, 0.08);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sidebar-w: 272px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
::selection { background: #f2dcc4; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--paper-2); border-right: 1px solid var(--line);
  padding: 18px 12px 40px;
}
.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 28px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; min-width: 0; }
.crumbs a { text-decoration: none; padding: 2px 6px; border-radius: var(--r-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.crumbs a:hover { background: var(--paper-2); color: var(--ink); }
.save-state { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.save-state.err { color: var(--danger); }
.menu-btn { display: none; }

.page { max-width: 860px; margin: 0 auto; padding: 28px 28px 120px; }
.page.wide { max-width: 1180px; }

/* ---------- sidebar ---------- */
.brand { display: flex; align-items: baseline; gap: 8px; padding: 2px 10px 18px; text-decoration: none; }
.brand-name { font: 600 19px/1 var(--font-display); letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 10px; border: 0; background: none; border-radius: var(--r-sm);
  text-align: left; text-decoration: none; cursor: pointer; color: var(--ink-2);
  font-size: 14px; line-height: 1.35;
}
.nav-item:hover { background: rgba(29, 27, 23, 0.05); color: var(--ink); }
.nav-item.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item.sub { padding-left: 30px; font-size: 13.5px; }
.nav-item.sub .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-sec { margin: 22px 10px 6px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; }
.nav-sec button { margin-left: auto; }
.nav-group { margin: 12px 10px 2px; font-size: 12.5px; color: var(--muted); }
.avatar {
  flex: none; width: 20px; height: 20px; border-radius: 5px;
  display: grid; place-items: center;
  font: 600 11px/1 var(--font-ui); color: #fff;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface);
  cursor: pointer; font-size: 13.5px; font-weight: 500; line-height: 1.2;
  transition: background 0.15s, border-color 0.15s, transform 0.15s var(--ease);
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover { background: #000; }
.btn.primary:disabled { background: var(--line-2); border-color: var(--line-2); color: var(--muted); cursor: not-allowed; }
.btn.ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn.ghost:hover { background: rgba(29, 27, 23, 0.06); color: var(--ink); }
.btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.icon-btn {
  display: inline-grid; place-items: center; width: 26px; height: 26px;
  border: 0; border-radius: var(--r-sm); background: none; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: rgba(29, 27, 23, 0.07); color: var(--ink); }
.icon-btn svg, .btn svg { width: 15px; height: 15px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- editable text ---------- */
.title-input {
  width: 100%; border: 0; background: none; padding: 0; margin: 0;
  font: 600 38px/1.15 var(--font-display); letter-spacing: -0.02em; color: var(--ink);
  resize: none; overflow: hidden;
}
.title-input:focus { outline: none; }
.title-input::placeholder { color: var(--line-2); }
.area {
  display: block; width: 100%; border: 0; background: none; resize: none; overflow: hidden;
  padding: 0; margin: 0; line-height: 1.55; min-height: 1.55em;
}
.area:focus { outline: none; }
.area::placeholder { color: var(--muted); opacity: 0.7; }

/* ---------- page intro ---------- */
.eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.lede { font-size: 17px; color: var(--ink-2); max-width: 62ch; margin: 12px 0 0; }
h2.h { font: 600 22px/1.25 var(--font-display); letter-spacing: -0.01em; margin: 48px 0 6px; }
h3.h { font: 600 16px/1.3 var(--font-ui); margin: 28px 0 8px; }
.sub-lede { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

/* ---------- property rows (notion-like) ---------- */
.props { margin: 20px 0 8px; display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 2px 12px; font-size: 14px; }
.prop-k { color: var(--muted); padding: 6px 0; display: flex; align-items: flex-start; gap: 6px; }
.prop-v { padding: 5px 8px; border-radius: var(--r-sm); min-height: 32px; min-width: 0; }
.prop-v:hover { background: rgba(29, 27, 23, 0.035); }
.prop-v select, .prop-v input { border: 0; background: none; padding: 0; width: 100%; max-width: 100%; text-overflow: ellipsis; }
.prop-v select:focus, .prop-v input:focus { outline: none; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--paper-2); color: var(--ink-2); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; }

/* ---------- must-have (idea/action) ---------- */
.musts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0 10px; }
.must {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 16px 16px; box-shadow: var(--shadow-1);
}
.must.empty { border-color: #e7b9b0; background: #fff8f6; }
.must-k { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.must-k .req { color: var(--danger); font-weight: 500; letter-spacing: 0; text-transform: none; }
.must .area { font-size: 15px; }
.gate-note {
  margin: 8px 0 0; padding: 10px 14px; border-radius: var(--r-md);
  background: #fff8f6; border: 1px dashed #e7b9b0; color: var(--danger); font-size: 13.5px;
}

/* ---------- scenario layout ---------- */
.sc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; align-items: start; }
.final {
  position: sticky; top: 64px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 16px 18px; box-shadow: var(--shadow-1);
}
.final-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.final-head strong { font: 600 15px/1.2 var(--font-display); }
.final-head .btn { margin-left: auto; }
.final-part { margin: 0 0 12px; }
.final-part .k { font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 2px; }
.final-part p { margin: 0; white-space: pre-wrap; font-size: 14px; }
.final-part .none { color: var(--muted); font-style: italic; font-size: 13.5px; }
.progress { height: 3px; background: var(--paper-2); border-radius: 2px; overflow: hidden; margin: 0 0 14px; }
.progress i { display: block; height: 100%; background: var(--c-solution); transform-origin: left; transition: transform 0.3s var(--ease); }

/* ---------- blocks ---------- */
.block { position: relative; margin: 26px 0 0; padding-left: 18px; }
.block::before { content: ''; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; border-radius: 2px; background: var(--bc, var(--c-custom)); }
.block-head { display: flex; align-items: center; gap: 8px; }
.block-title { font: 600 19px/1.3 var(--font-display); border: 0; background: none; padding: 0; min-width: 0; flex: 1; color: var(--ink); }
.block-title:focus { outline: none; }
.block-tools { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.block:hover .block-tools, .block:focus-within .block-tools { opacity: 1; }
.block-hint { width: 100%; color: var(--muted); font-size: 13.5px; margin: 2px 0 10px; }
.variants { display: flex; flex-direction: column; gap: 6px; }
.variant {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 6px; align-items: start;
  padding: 8px 8px 8px 6px; border-radius: var(--r-md);
  border: 1px solid transparent; background: none;
  transition: background 0.15s, border-color 0.15s;
}
.variant:hover { background: var(--surface); border-color: var(--line); }
.variant.chosen { background: var(--surface); border-color: var(--bc, var(--line-2)); box-shadow: var(--shadow-1); }
.variant .area { font-size: 15px; padding-top: 1px; }
.variant .meta { display: flex; gap: 2px; align-items: center; opacity: 0; transition: opacity 0.15s; }
.variant:hover .meta, .variant:focus-within .meta { opacity: 1; }
.author { font-size: 11px; color: var(--muted); padding: 1px 6px; border-radius: 4px; background: var(--paper-2); margin-right: 4px; }
.choose {
  width: 20px; height: 20px; margin: 2px 0 0 3px; border-radius: 50%;
  border: 1.5px solid var(--line-2); background: var(--surface); cursor: pointer; padding: 0;
  display: grid; place-items: center; transition: border-color 0.15s, background 0.15s;
}
.choose:hover { border-color: var(--bc, var(--ink-2)); }
.choose svg { width: 12px; height: 12px; opacity: 0; color: #fff; }
.variant.chosen .choose { background: var(--bc, var(--ink)); border-color: var(--bc, var(--ink)); }
.variant.chosen .choose svg { opacity: 1; }
.add-variant { margin: 6px 0 0 26px; }
.empty-variants { color: var(--muted); font-size: 13.5px; margin: 0 0 0 32px; font-style: italic; }
.add-block { margin: 34px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }

.notes { margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- project page ---------- */
.brief-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 16px 18px; box-shadow: var(--shadow-1);
}
.brief-box .area { font-size: 15px; min-height: 5em; }
.pains { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.pain { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; align-items: start; padding: 6px 6px 6px 4px; border-radius: var(--r-sm); }
.pain:hover { background: var(--surface); }
.pain .num { color: var(--c-conflict); font: 600 13px/1.6 var(--font-ui); text-align: right; font-variant-numeric: tabular-nums; }
.pain .icon-btn { opacity: 0; }
.pain:hover .icon-btn, .pain:focus-within .icon-btn { opacity: 1; }

.sc-list { border-top: 1px solid var(--line); }
.sc-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 140px 90px; gap: 16px; align-items: center;
  padding: 12px 8px; border-bottom: 1px solid var(--line); text-decoration: none;
  transition: background 0.15s;
}
.sc-row:hover { background: var(--surface); }
.sc-row .t { font-weight: 500; }
.sc-row .i { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-row .n { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.status-head { display: flex; align-items: center; gap: 8px; margin: 26px 0 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.status-head .c { color: var(--muted); font-weight: 400; }
.empty-state { padding: 28px; border: 1px dashed var(--line-2); border-radius: var(--r-md); color: var(--muted); text-align: center; }

/* ---------- inspiration ---------- */
.flow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0; margin: 26px 0 10px; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.flow-step { padding: 14px 12px 16px; border-right: 1px solid var(--line); position: relative; }
.flow-step:last-child { border-right: 0; }
.flow-step .n { font: 600 12px/1 var(--font-ui); color: var(--muted); font-variant-numeric: tabular-nums; }
.flow-step .t { font: 600 15px/1.25 var(--font-display); margin: 6px 0 4px; color: var(--sc, var(--ink)); }
.flow-step .d { font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.flow-step.pre { background: var(--paper-2); }
.flow-step.pre .t { color: var(--ink); }

.example {
  margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); overflow: hidden;
}
.example-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.example-head .t { font: 600 24px/1.2 var(--font-display); letter-spacing: -0.01em; }
.example-head .s { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.example-body { padding: 4px 22px 22px; }
.ex-block { margin-top: 22px; }
.ex-block .k { font: 600 16px/1.3 var(--font-display); color: var(--bc); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.ex-block .k::before, .angle .k::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--bc); flex: none; }
.ex-var { display: grid; grid-template-columns: 20px 1fr minmax(0, 190px); gap: 10px; align-items: start; padding: 5px 0; font-size: 14.5px; }
.ex-var .mark { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-2); margin-top: 4px; }
.ex-var.chosen .mark { background: var(--bc); border-color: var(--bc); }
.ex-var.chosen .txt { font-weight: 500; }
.ex-var .why { font-size: 12.5px; color: var(--muted); line-height: 1.4; padding-top: 2px; }
.ex-reco { margin-top: 20px; padding: 12px 14px; background: var(--paper-2); border-radius: var(--r-sm); font-size: 13.5px; color: var(--ink-2); }

.angles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 10px; }
.angle { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; }
.angle .k { font: 600 15px/1.3 var(--font-display); color: var(--bc); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.angle ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-2); }
.angle li { margin: 3px 0; }

/* ---------- markdown ---------- */
.md h1 { font: 600 34px/1.15 var(--font-display); letter-spacing: -0.02em; margin: 0 0 12px; }
.md h2 { font: 600 21px/1.3 var(--font-display); margin: 36px 0 8px; }
.md p, .md li { color: var(--ink-2); max-width: 70ch; }
.md code { font-size: 0.9em; background: var(--paper-2); padding: 1px 5px; border-radius: 4px; }
.md table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 14px; background: var(--surface); }
.md th, .md td { text-align: left; padding: 8px 12px; border: 1px solid var(--line); vertical-align: top; }
.md th { background: var(--paper-2); font-weight: 600; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(29, 27, 23, 0.32); display: grid; place-items: start center; padding: 10vh 16px 16px; overflow-y: auto; animation: fade 0.18s var(--ease); }
.modal { width: min(560px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-2); padding: 22px 24px; animation: rise 0.22s var(--ease); }
.modal h3 { font: 600 22px/1.2 var(--font-display); margin: 0 0 4px; }
.modal .sub-lede { margin-bottom: 14px; }
.field { margin: 12px 0 0; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field label .req { color: var(--danger); font-weight: 500; }
.field input, .field textarea, .field select { width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--paper); }
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.field .help { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); }
.login .brand-name { font-size: 30px; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .sc-grid { grid-template-columns: minmax(0, 1fr); }
  .final { position: static; }
  .flow { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .flow-step:nth-child(4n) { border-right: 0; }
  .flow-step { border-bottom: 1px solid var(--line); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; width: min(300px, 86vw);
    transform: translateX(-100%); transition: transform 0.25s var(--ease); box-shadow: var(--shadow-2);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ''; position: fixed; inset: 0; z-index: 30; background: rgba(29, 27, 23, 0.28); }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 12px; }
  .page { padding: 18px 16px 100px; }
  .title-input { font-size: 29px; }
  .musts { grid-template-columns: 1fr; }
  .props { grid-template-columns: 96px minmax(0, 1fr); }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow-step:nth-child(4n) { border-right: 1px solid var(--line); }
  .flow-step:nth-child(2n) { border-right: 0; }
  .ex-var { grid-template-columns: 20px 1fr; }
  .ex-var .why { grid-column: 2; padding-top: 0; }
  .sc-row { grid-template-columns: minmax(0, 1fr) auto; }
  .sc-row .n { display: none; }
  .block-tools, .variant .meta, .pain .icon-btn { opacity: 1; }
  .variant .author { display: none; }
  .variant { padding-right: 2px; }
  .example-head, .example-body { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
