:root {
  --bg: #0f1220;
  --bg-soft: #171b2e;
  --panel: #ffffff;
  --ink: #1a1d2b;
  --ink-soft: #5b617a;
  --line: #e6e8f0;
  --brand: #4f6bed;
  --brand-dark: #3a52c8;
  --risk: #e0653a;
  --decision: #1b9e7a;
  --pri-high: #e0653a;
  --pri-mid: #d6a516;
  --pri-low: #7a8194;
  --shadow: 0 1px 2px rgba(16, 18, 32, .06), 0 8px 24px rgba(16, 18, 32, .08);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: #f4f5fa;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 20px; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(15, 18, 32, .92);
  backdrop-filter: saturate(150%) blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 9px; color: #fff; font-weight: 700; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 800;
}
.brand-name { font-size: 15.5px; letter-spacing: .2px; }
.topbar-nav { display: flex; gap: 20px; }
.topbar-nav a { color: #aab0c8; font-size: 14px; }
.topbar-nav a:hover { color: #fff; text-decoration: none; }

/* Hero */
.hero {
  background: linear-gradient(160deg, #0f1220 0%, #1b2140 60%, #242c52 100%);
  color: #fff; padding: 52px 0 40px;
}
.hero h1 { margin: 0 0 16px; font-size: 32px; line-height: 1.25; font-weight: 800; letter-spacing: -.3px; }
.hero h1 em { color: #aebcff; font-style: normal; }
.hero .sub { margin: 0; font-size: 16px; color: #c4c9dd; max-width: 720px; }
.hero .sub strong { color: #fff; font-weight: 600; }

/* Workbench */
.workbench { margin-top: -22px; padding-bottom: 48px; }

.input-card, .panel {
  background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.input-card { padding: 18px; }
.input-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.input-head label { font-weight: 700; font-size: 15px; }
.input-actions { display: flex; gap: 8px; }

textarea#notes {
  width: 100%; min-height: 180px; resize: vertical;
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 14px; font-family: var(--font); font-size: 14.5px; line-height: 1.7;
  color: var(--ink); background: #fbfbfe;
}
textarea#notes:focus { outline: none; border-color: var(--brand); background: #fff; }

.run-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.hint { color: var(--ink-soft); font-size: 13px; }

/* Buttons */
button { font-family: var(--font); cursor: pointer; border-radius: 9px; border: 1.5px solid transparent; transition: all .14s ease; }
.primary { background: var(--brand); color: #fff; font-weight: 600; padding: 11px 20px; font-size: 15px; }
.primary:hover { background: var(--brand-dark); }
.primary.small { padding: 7px 13px; font-size: 13px; }
.ghost { background: #fff; color: var(--ink); border-color: var(--line); padding: 9px 14px; font-size: 13px; font-weight: 500; }
.ghost:hover { border-color: var(--brand); color: var(--brand); }
.ghost.small { padding: 7px 12px; }
.ghost.tiny { padding: 4px 10px; font-size: 12.5px; }

.hidden { display: none !important; }

/* Results */
.results { margin-top: 18px; display: flex; flex-direction: column; gap: 16px; }
.result-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 16px;
}
.stat-pills { display: flex; gap: 8px; }
.pill { font-size: 13px; font-weight: 600; padding: 5px 11px; border-radius: 999px; }
.pill-task { background: #eaf0ff; color: var(--brand-dark); }
.pill-risk { background: #fdece4; color: var(--risk); }
.pill-decision { background: #e3f6ef; color: var(--decision); }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel { padding: 16px 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.muted { color: var(--ink-soft); font-weight: 400; font-size: 13px; }

/* Task table */
.table-scroll { overflow-x: auto; }
.task-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.task-table th {
  text-align: left; font-size: 12.5px; color: var(--ink-soft); font-weight: 600;
  padding: 6px 8px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
.task-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.col-task { width: 46%; }
.col-owner { width: 16%; }
.col-due { width: 18%; }
.col-pri { width: 14%; }
.col-del { width: 34px; }

.cell-input {
  width: 100%; border: 1px solid transparent; background: transparent;
  font-family: var(--font); font-size: 14px; color: var(--ink);
  padding: 7px 8px; border-radius: 7px;
}
.cell-input:hover { background: #f6f7fb; }
.cell-input:focus { outline: none; border-color: var(--brand); background: #fff; }
.cell-input::placeholder { color: #b6bccd; }

select.cell-input { cursor: pointer; -webkit-appearance: none; appearance: none; }
select.pri-high { color: var(--pri-high); font-weight: 600; }
select.pri-mid { color: var(--pri-mid); font-weight: 600; }
select.pri-low { color: var(--pri-low); }

.del-btn {
  border: none; background: transparent; color: #c0c5d6; font-size: 17px; line-height: 1;
  padding: 4px 7px; border-radius: 6px;
}
.del-btn:hover { background: #fdeceb; color: var(--risk); }

.empty-note { color: var(--ink-soft); font-size: 13.5px; margin: 6px 2px 0; }

/* Risk list */
.risk-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.risk-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border-radius: 10px; background: #fbf5f2; border: 1px solid #f3ddd2; }
.risk-item.is-decision { background: #f2faf6; border-color: #d3ecdf; }
.risk-tag { flex: none; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 6px; margin-top: 2px; }
.risk-tag.t-risk { background: #fbded1; color: var(--risk); }
.risk-tag.t-decision { background: #d3ecdf; color: var(--decision); }
.risk-text { flex: 1; border: 1px solid transparent; background: transparent; font-family: var(--font); font-size: 14px; color: var(--ink); padding: 2px 4px; border-radius: 6px; line-height: 1.55; }
.risk-text:focus { outline: none; border-color: var(--brand); background: #fff; }
.risk-item .del-btn { margin-top: -1px; }

/* Followup */
.followup {
  margin: 0; background: #0f1220; color: #e7eaf6; border-radius: 10px;
  padding: 16px 18px; font-size: 13.5px; line-height: 1.75; white-space: pre-wrap; word-break: break-word;
  font-family: "SF Mono", ui-monospace, "PingFang SC", monospace; max-height: 360px; overflow: auto;
}

/* How */
.how { padding: 44px 20px 24px; }
.how > h2 { font-size: 22px; margin: 0 0 22px; text-align: center; }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.how-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 18px; box-shadow: var(--shadow); }
.how-num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: #eaf0ff; color: var(--brand-dark); font-weight: 800; margin-bottom: 10px; }
.how-card h3 { margin: 0 0 6px; font-size: 16px; }
.how-card p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.privacy-note { margin: 24px auto 0; max-width: 760px; text-align: center; color: var(--ink-soft); font-size: 13.5px; background: #eef0f7; border-radius: 12px; padding: 14px 18px; }
.privacy-note code { background: #dfe3f0; padding: 1px 6px; border-radius: 5px; }

/* Footer */
.footer { border-top: 1px solid var(--line); background: #fff; padding: 22px 0; margin-top: 24px; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-soft); font-size: 13px; flex-wrap: wrap; }
.footer-dim { color: #9aa0b6; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #1a1d2b; color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: all .22s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Responsive */
@media (max-width: 720px) {
  .hero { padding: 38px 0 30px; }
  .hero h1 { font-size: 25px; }
  .how-grid { grid-template-columns: 1fr; }
  .topbar-nav { gap: 14px; }
  .col-task { width: auto; }
  .toolbar-actions { width: 100%; }
}

/* Print */
@media print {
  .topbar, .hero, .input-card, .how, .footer, .toolbar-actions, .del-btn, .empty-note, .panel-head button, #addTaskBtn, #addRiskBtn { display: none !important; }
  body { background: #fff; }
  .workbench { margin: 0; padding: 0; }
  .result-toolbar { box-shadow: none; border: none; padding: 0 0 8px; }
  .panel { box-shadow: none; border: none; padding: 0; page-break-inside: avoid; margin-bottom: 14px; }
  .followup { background: #f4f4f7; color: #1a1d2b; max-height: none; }
  .cell-input, .risk-text { color: #000 !important; }
}
