:root {
  --bg: #0f1115;
  --bg-soft: #161922;
  --panel: #1b1f2a;
  --panel-2: #212636;
  --line: #2b3142;
  --line-soft: #232838;
  --txt: #e8ebf2;
  --txt-dim: #9aa3b8;
  --txt-faint: #6b7488;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --green: #41c98a;
  --amber: #f0b34a;
  --red: #f06a6a;
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", Roboto, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(91, 140, 255, 0.10), transparent 60%),
    var(--bg);
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  line-height: 1.5;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 17, 21, 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 8px;
  font-size: 18px;
}
.brand-name { font-weight: 650; letter-spacing: 0.2px; }
.topnav { display: flex; gap: 8px; flex-wrap: wrap; }

.ghost-btn {
  background: transparent;
  color: var(--txt-dim);
  border: 1px solid var(--line);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.ghost-btn:hover { color: var(--txt); border-color: var(--accent); background: var(--accent-soft); }

/* Layout */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.6fr);
  gap: 0;
  min-height: 0;
}

/* Input pane */
.input-pane {
  border-right: 1px solid var(--line);
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-soft);
}
.pane-head h1 { font-size: 22px; font-weight: 680; line-height: 1.3; }
.lede { color: var(--txt-dim); font-size: 14px; margin-top: 8px; }
.lede strong { color: var(--txt); font-weight: 600; }

#docInput {
  flex: 1;
  min-height: 280px;
  resize: vertical;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--txt);
  padding: 16px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
  outline: none;
  transition: border-color 0.15s ease;
}
#docInput:focus { border-color: var(--accent); }
#docInput::placeholder { color: var(--txt-faint); }

.input-actions { display: flex; align-items: center; gap: 14px; }
.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s ease, transform 0.05s ease;
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: translateY(1px); }
.hint { color: var(--txt-faint); font-size: 12.5px; }

.micro-feats {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.micro-feats li {
  font-size: 12px;
  color: var(--txt-dim);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  padding: 4px 10px;
  border-radius: 999px;
}
.micro-feats li::before { content: "✓ "; color: var(--green); }

/* Canvas pane */
.canvas-pane {
  padding: 24px;
  overflow-y: auto;
  min-height: 0;
}

.empty-state {
  height: 100%;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--txt-faint);
  gap: 10px;
}
.empty-icon { font-size: 46px; opacity: 0.5; }
.empty-state h2 { color: var(--txt-dim); font-weight: 600; font-size: 18px; }
.empty-state p { font-size: 14px; max-width: 360px; }

/* Summary bar */
.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-width: 96px;
}
.stat .num { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 11.5px; color: var(--txt-faint); margin-top: 2px; }
.stat.warn .num { color: var(--amber); }

/* Gaps panel */
.gaps-panel {
  background: linear-gradient(180deg, rgba(240, 179, 74, 0.08), transparent);
  border: 1px solid rgba(240, 179, 74, 0.35);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.gaps-panel h3 { font-size: 14px; color: var(--amber); margin-bottom: 10px; display: flex; align-items: center; gap: 7px; }
.gaps-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.gaps-list li {
  font-size: 13px;
  color: var(--txt);
  padding-left: 18px;
  position: relative;
  line-height: 1.55;
}
.gaps-list li::before { content: "!"; position: absolute; left: 0; top: 0; color: var(--amber); font-weight: 700; }
.gaps-list li .why { color: var(--txt-faint); font-size: 12px; }

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
}
.stage-col {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.stage-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel-2);
}
.stage-head .st-idx {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px 7px;
  flex-shrink: 0;
}
.stage-head h3 { font-size: 14.5px; font-weight: 640; flex: 1; }
.stage-head .st-count { font-size: 12px; color: var(--txt-faint); flex-shrink: 0; }

.task-list { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.task-card {
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  transition: border-color 0.15s ease;
}
.task-card:hover { border-color: var(--line); }
.task-top { display: flex; gap: 9px; align-items: flex-start; }
.task-check {
  width: 16px; height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.task-body { flex: 1; min-width: 0; }
.task-title {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--txt);
  outline: none;
  border-radius: 4px;
}
.task-title:focus { background: var(--panel-2); box-shadow: 0 0 0 2px var(--accent-soft); }
.task-card.done .task-title { text-decoration: line-through; color: var(--txt-faint); }

.task-meta { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.meta-row { display: flex; gap: 7px; align-items: baseline; font-size: 12px; }
.meta-row .k { color: var(--txt-faint); flex-shrink: 0; width: 42px; }
.meta-row .v { color: var(--txt-dim); outline: none; border-radius: 4px; flex: 1; }
.meta-row .v:focus { background: var(--panel-2); box-shadow: 0 0 0 2px var(--accent-soft); color: var(--txt); }
.meta-row.accept .v { color: #b8d9c6; }

.dep-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.dep-tag {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--txt-dim);
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 2px 7px;
}
.dep-tag.blocked { color: var(--amber); border-color: rgba(240, 179, 74, 0.3); }

.task-flag {
  display: inline-block;
  font-size: 11px;
  color: var(--amber);
  margin-top: 7px;
  padding-left: 16px;
  position: relative;
}
.task-flag::before { content: "⚑"; position: absolute; left: 0; }

/* Toast */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--txt);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  z-index: 50;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Footer */
.sitefoot {
  border-top: 1px solid var(--line);
  padding: 14px 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--txt-faint);
  font-size: 12.5px;
}
.sitefoot a { color: var(--txt-dim); text-decoration: none; }
.sitefoot a:hover { color: var(--accent); }
.sitefoot .dot { opacity: 0.5; }

/* Responsive */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .input-pane { border-right: none; border-bottom: 1px solid var(--line); }
  #docInput { min-height: 200px; }
  .canvas-pane { padding: 18px 16px; }
  .board { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .topbar { padding: 12px 14px; }
  .brand-name { font-size: 14px; }
  .ghost-btn { padding: 6px 9px; font-size: 12px; }
  .pane-head h1 { font-size: 19px; }
}
