:root {
  --bg: #0f1419;
  --bg-soft: #161c24;
  --panel: #1b2330;
  --panel-2: #212b3a;
  --line: #2c3848;
  --text: #e8eef6;
  --muted: #93a1b3;
  --accent: #4ea1ff;
  --must: #34d399;
  --must-bg: rgba(52, 211, 153, 0.12);
  --later: #fbbf24;
  --later-bg: rgba(251, 191, 36, 0.12);
  --never: #f87171;
  --never-bg: rgba(248, 113, 113, 0.12);
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #1c2940 0%, var(--bg) 55%) fixed;
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(15, 20, 25, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: 0.2px; }
.topnav a { color: var(--muted); text-decoration: none; margin-left: 22px; font-size: 14px; }
.topnav a:hover { color: var(--text); }

/* Hero */
.hero { padding: 46px 0 18px; }
.hero h1 { font-size: 34px; line-height: 1.25; margin: 0 0 14px; font-weight: 750; }
.hl { color: var(--accent); }
.lede { color: var(--muted); max-width: 760px; font-size: 16px; margin: 0 0 22px; }

.preset-row { display: flex; flex-wrap: wrap; gap: 10px; }
.preset-chip {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 13px;
  transition: border-color 0.15s, transform 0.05s;
}
.preset-chip:hover { border-color: var(--accent); }
.preset-chip:active { transform: translateY(1px); }
.preset-chip b { color: var(--accent); margin-right: 6px; }

/* Grid */
.grid { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); gap: 22px; margin-top: 20px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.panel-title { font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 4px 0 14px; }
.input-panel .panel-title:not(:first-child) { margin-top: 26px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; margin-bottom: 6px; color: var(--text); font-weight: 600; }
.field span em { font-style: normal; color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 12px; }
.field input {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 14px; font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--accent); }
.hint { font-size: 12.5px; color: var(--muted); margin: -4px 0 14px; }

/* Feature cards */
.feature-list { display: flex; flex-direction: column; gap: 12px; }
.feature {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.feature-head { display: flex; gap: 8px; align-items: center; }
.feature-head input[type="text"] {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 9px 10px; font-size: 14px; font-family: inherit;
}
.feature-head input[type="text"]:focus { outline: none; border-color: var(--accent); }
.del-btn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; width: 34px; height: 36px; cursor: pointer; font-size: 16px; flex: none;
}
.del-btn:hover { color: var(--never); border-color: var(--never); }

.signals { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; align-items: center; }
.sig {
  font-size: 12px; padding: 5px 10px; border-radius: 999px; cursor: pointer; user-select: none;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.sig[aria-pressed="true"] { color: #0f1419; font-weight: 600; border-color: transparent; }
.sig.core[aria-pressed="true"] { background: var(--must); }
.sig.first[aria-pressed="true"] { background: var(--accent); color: #06203f; }
.sig.replace[aria-pressed="true"] { background: var(--later); }
.sig.risk[aria-pressed="true"] { background: var(--never); color: #2a0d0d; }

.cost-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.cost-seg button {
  background: var(--panel-2); border: none; color: var(--muted); font-size: 12px;
  padding: 5px 11px; cursor: pointer; font-family: inherit;
}
.cost-seg button[aria-pressed="true"] { background: var(--accent); color: #06203f; font-weight: 600; }
.seg-label { font-size: 11px; color: var(--muted); margin-right: 2px; }

/* Buttons */
.btn {
  border-radius: 10px; padding: 11px 18px; font-size: 14px; cursor: pointer; font-family: inherit;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); transition: transform 0.05s, border-color 0.15s, background 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06203f; font-weight: 700; }
.btn.primary:hover { background: #6cb3ff; }
.btn.ghost:hover { border-color: var(--accent); }
.btn.full { width: 100%; margin-top: 12px; }
.actions { display: flex; gap: 10px; margin-top: 20px; }
.actions .primary { flex: 1; }

/* Result */
.result-panel { min-height: 420px; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 380px; color: var(--muted); text-align: center; }
.empty-emoji { font-size: 46px; margin-bottom: 12px; }

.boundary {
  background: linear-gradient(135deg, rgba(78,161,255,0.16), rgba(78,161,255,0.04));
  border: 1px solid rgba(78,161,255,0.4); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px;
  font-size: 15px;
}
.boundary b { color: var(--accent); }

.stat-row { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 80px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat .num { font-size: 22px; font-weight: 750; }
.stat .lab { font-size: 12px; color: var(--muted); }
.stat.must .num { color: var(--must); }
.stat.later .num { color: var(--later); }
.stat.never .num { color: var(--never); }

.bucket { margin-bottom: 16px; }
.bucket h3 { font-size: 14px; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.must { background: var(--must); }
.dot.later { background: var(--later); }
.dot.never { background: var(--never); }
.item { border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); }
.item.must { background: var(--must-bg); }
.item.later { background: var(--later-bg); }
.item.never { background: var(--never-bg); }
.item .name { font-weight: 650; font-size: 14px; }
.item .reason { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.item .badges { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

.metrics li { font-size: 13.5px; margin-bottom: 7px; }
.metrics li b { color: var(--accent); }
.warns { list-style: none; padding: 0; margin: 14px 0 0; }
.warns li { background: var(--never-bg); border: 1px solid rgba(248,113,113,0.4); border-radius: 8px; padding: 8px 11px; font-size: 13px; margin-bottom: 8px; }

.result-foot { display: flex; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--must); color: #06203f; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.toast.show { opacity: 1; }

.section-sub { font-size: 14px; font-weight: 600; color: var(--text); margin: 18px 0 8px; }
.tasklist { list-style: none; padding: 0; margin: 0; }
.tasklist li { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin-bottom: 7px; font-size: 13.5px; }
.tasklist .tnum { color: var(--accent); font-weight: 700; margin-right: 6px; }

/* Principles */
.principles { margin: 44px 0 20px; }
.principles h2 { font-size: 22px; margin-bottom: 18px; }
.prin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.prin-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.prin-card h3 { font-size: 15px; margin: 0 0 8px; color: var(--accent); }
.prin-card p { font-size: 13px; color: var(--muted); margin: 0; }

/* Footer */
.footer { border-top: 1px solid var(--line); margin-top: 30px; padding: 22px 0 40px; }
.footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--text); }
.muted { color: var(--muted); }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .prin-grid { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 27px; }
}
@media (max-width: 560px) {
  .prin-grid { grid-template-columns: 1fr; }
  .topnav { display: none; }
  .hero { padding-top: 30px; }
}
