:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --text: #1d2330;
  --muted: #6d7482;
  --border: #e4e8f0;
  --accent: #5b5bd6;
  --accent-soft: #efefff;
  --success: #1b8a5a;
  --success-soft: #eaf8f1;
  --warning: #a96b11;
  --warning-soft: #fff5df;
  --danger: #bc4551;
  --danger-soft: #fff0f1;
  --shadow: 0 10px 36px rgba(35, 42, 65, .07);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; }
.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(245, 247, 251, .9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(228, 232, 240, .88);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--text); color: white; font-weight: 800; font-size: 18px;
}
.brand strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); font-size: 11px; margin-top: -2px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.search-wrap { position: relative; width: min(360px, 42vw); }
.search-wrap input {
  width: 100%; border: 1px solid var(--border); background: var(--surface);
  border-radius: 12px; padding: 10px 48px 10px 13px; outline: none;
  transition: .15s border-color, .15s box-shadow;
}
.search-wrap input:focus { border-color: #b6b6ef; box-shadow: 0 0 0 4px rgba(91,91,214,.08); }
.search-wrap kbd {
  position: absolute; right: 10px; top: 9px; color: #8b91a0; font-size: 11px;
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; background: var(--surface-2);
}
.search-results {
  position: absolute; top: 48px; right: 0; width: min(560px, 88vw); max-height: 520px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 7px;
}
.search-item { display: block; padding: 10px 11px; border-radius: 10px; cursor: pointer; }
.search-item:hover { background: var(--surface-2); }
.search-item strong { display: block; font-size: 13px; }
.search-item span { color: var(--muted); font-size: 12px; }
.ghost-button, .primary-button {
  border: 1px solid var(--border); border-radius: 11px; padding: 9px 13px; cursor: pointer;
  background: var(--surface); color: var(--text);
}
.primary-button { background: var(--text); color: white; border-color: var(--text); }
.ghost-button:hover { background: var(--surface-2); }

.main { width: min(1320px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 70px; }
.hero { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 20px; margin: 8px 0 28px; }
.eyebrow { color: var(--accent); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
h1 { font-size: clamp(32px, 5vw, 56px); line-height: 1.03; margin: 7px 0 10px; letter-spacing: -.045em; }
.hero p { max-width: 760px; color: var(--muted); font-size: 16px; margin: 0; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.stat { min-width: 110px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.stat strong { display: block; font-size: 22px; letter-spacing: -.03em; }
.stat span { color: var(--muted); font-size: 11px; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 0 13px; }
.section-title h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.section-title span { color: var(--muted); font-size: 12px; }
.node-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stage-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.node-card {
  display: flex; flex-direction: column; min-height: 174px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: transform .16s, box-shadow .16s, border-color .16s;
}
.node-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d6d9e4; }
.card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.node-id { font-size: 11px; font-weight: 750; color: var(--accent); background: var(--accent-soft); padding: 3px 7px; border-radius: 7px; }
.type-chip { color: var(--muted); font-size: 11px; }
.node-card h3 { margin: 13px 0 7px; font-size: 18px; line-height: 1.25; letter-spacing: -.02em; }
.node-card p { color: var(--muted); font-size: 13px; margin: 0 0 16px; flex: 1; }
.card-footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 8px; font-size: 11px; background: #f2f4f8; color: #555d6c; }
.badge.assignee { background: #eef7ff; color: #356187; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #999; }
.status-planned .status-dot { background: #9ca3af; }
.status-ready .status-dot { background: #7b61d1; }
.status-in_progress .status-dot { background: #3274d9; }
.status-blocked .status-dot { background: var(--danger); }
.status-review .status-dot { background: var(--warning); }
.status-done .status-dot { background: var(--success); }
.progress-wrap { margin-top: 12px; }
.progress-line { height: 6px; background: #eef0f4; border-radius: 999px; overflow: hidden; }
.progress-line > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.progress-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; margin-top: 4px; }

.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; margin-bottom: 18px; }
.breadcrumbs a { cursor: pointer; }
.breadcrumbs a:hover { color: var(--text); }
.node-header { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
.node-heading { background: transparent; padding: 6px 0 8px; }
.node-heading h1 { font-size: clamp(30px, 4vw, 46px); margin: 8px 0 11px; }
.node-heading .summary { color: var(--muted); font-size: 16px; max-width: 780px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.owner-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px; position: sticky; top: 91px; }
.owner-panel h3 { margin: 0 0 14px; font-size: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; background: white; outline: none;
}
.field textarea { min-height: 92px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #aaaaf0; box-shadow: 0 0 0 3px rgba(91,91,214,.08); }
.save-row { display: flex; align-items: center; gap: 9px; }
.save-state { color: var(--muted); font-size: 11px; }

.acceptance-card { margin: 26px 0 18px; padding: 18px 20px; border: 1px solid #dcdcf5; border-radius: var(--radius); background: #f8f8ff; }
.acceptance-card h2 { margin: 0 0 10px; font-size: 16px; }
.content-card { margin-top: 18px; padding: 22px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.content-card > h2:first-child, .markdown-body > h2:first-child { margin-top: 0; }
.markdown-body h2 { font-size: 21px; margin: 30px 0 12px; }
.markdown-body h3 { font-size: 17px; margin: 24px 0 9px; }
.markdown-body h4 { font-size: 14px; margin: 20px 0 7px; }
.markdown-body p, .markdown-body li { color: #3f4755; }
.markdown-body ul, .markdown-body ol { padding-left: 22px; }
.markdown-body pre { overflow-x: auto; padding: 14px 16px; border-radius: 12px; background: #151821; color: #e7eaf0; }
.markdown-body code { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12.5px; }
.markdown-body :not(pre) > code { padding: 2px 5px; border-radius: 5px; background: #f1f2f6; color: #41485b; }
.markdown-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.markdown-body th, .markdown-body td { padding: 9px 10px; border: 1px solid var(--border); text-align: left; }
.markdown-body blockquote { margin: 14px 0; padding: 2px 0 2px 14px; border-left: 3px solid #c9c9ee; color: var(--muted); }
.leaf-label { display: inline-flex; margin-bottom: 10px; font-size: 11px; font-weight: 700; color: var(--success); background: var(--success-soft); padding: 5px 8px; border-radius: 8px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.hidden { display: none !important; }
.toast { position: fixed; right: 22px; bottom: 22px; background: var(--text); color: white; border-radius: 11px; padding: 10px 14px; box-shadow: var(--shadow); z-index: 100; font-size: 13px; }
.error-card { border-color: #f2cdd1; background: #fff7f8; color: var(--danger); }

@media (max-width: 980px) {
  .stage-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .node-header { grid-template-columns: 1fr; }
  .owner-panel { position: static; }
}
@media (max-width: 680px) {
  .topbar { padding: 0 14px; }
  .brand small { display: none; }
  .search-wrap { width: 48vw; }
  .search-wrap kbd { display: none; }
  .search-wrap input { padding-right: 12px; }
  #homeButton { display: none; }
  .main { width: min(100% - 24px, 1320px); padding-top: 22px; }
  .hero { grid-template-columns: 1fr; }
  .stats { justify-content: flex-start; }
  .node-grid, .stage-grid { grid-template-columns: 1fr; }
  .node-card { min-height: 152px; }
  .content-card { padding: 18px 16px; }
}
