:root {
  --bg: #0f1115;
  --bg-soft: #161a22;
  --panel: #1a1f29;
  --panel-2: #20262f;
  --line: #2a313d;
  --text: #e8ecf3;
  --muted: #9aa4b2;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --good: #2ec28a;
  --warn: #ffb020;
  --bad: #ff5d5d;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(124, 92, 255, 0.14), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(79, 140, 255, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1120px, 92vw); margin: 0 auto; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(15, 17, 21, 0.72);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 26px; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topnav { display: flex; gap: 18px; }
.topnav a { color: var(--muted); text-decoration: none; font-size: 14px; transition: color .15s; }
.topnav a:hover { color: var(--text); }

/* Hero */
.hero { padding: 40px 0 18px; }
.hero h1 { font-size: clamp(26px, 4.5vw, 40px); margin: 0 0 12px; letter-spacing: -0.5px; }
.lede { font-size: 16px; color: var(--muted); max-width: 760px; margin: 0; }
.lede strong { color: var(--text); }

/* Layout */
.grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 20px; align-items: start; }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.result-panel { position: sticky; top: 76px; }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head.spaced { margin-top: 22px; }
.panel-head h2 { font-size: 17px; margin: 0; }
.hint { font-size: 12px; color: var(--muted); }

/* Fields */
.field-row { display: flex; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; margin-bottom: 14px; }
.field-sm { flex: 0 0 auto; min-width: 96px; }
.field span { font-size: 13px; color: var(--muted); }
.field input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18); }

/* Calc */
.calc { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 8px; }
.calc-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.calc-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.calc-grid .field { margin-bottom: 4px; }
.calc-out { font-size: 13px; margin-top: 10px; }
.calc-out b { color: var(--text); }
.calc-out .pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-left: 4px; }

/* Criteria */
.dim { border-top: 1px solid var(--line); padding: 14px 0; }
.dim:first-child { border-top: none; }
.dim-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.dim-title { font-weight: 600; font-size: 15px; }
.dim-weight { font-size: 12px; color: var(--muted); }
.crit { margin: 12px 0; }
.crit-label { font-size: 13.5px; color: var(--text); margin-bottom: 7px; }
.crit-label .auto-tag { font-size: 11px; color: var(--accent); margin-left: 6px; }
.scale { display: flex; gap: 6px; }
.scale button {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 9px;
  padding: 9px 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
}
.scale button:hover { border-color: var(--accent); color: var(--text); }
.scale button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.scale button.na { font-size: 12px; flex: 0 0 44px; }
.scale button.na.active { background: var(--panel-2); border-color: var(--muted); color: var(--text); }

/* Score hero */
.score-hero { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; }
.score-ring { position: relative; width: 120px; height: 120px; flex: 0 0 120px; }
.score-ring svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .6s ease, stroke .3s; }
.score-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-num span { font-size: 34px; font-weight: 800; line-height: 1; }
.score-num small { font-size: 12px; color: var(--muted); }
.score-side { flex: 1; }
.tier { display: inline-block; font-size: 22px; font-weight: 800; padding: 2px 14px; border-radius: 10px; background: var(--panel-2); }
.tier-desc { font-size: 13.5px; color: var(--muted); margin-top: 8px; }

/* Radar */
.radar-wrap { display: flex; justify-content: center; margin: 6px 0 14px; }
#radar { width: 100%; max-width: 320px; height: auto; }
.radar-axis { stroke: var(--line); stroke-width: 1; }
.radar-grid { fill: none; stroke: var(--line); stroke-width: 1; opacity: 0.5; }
.radar-area { fill: rgba(79, 140, 255, 0.22); stroke: var(--accent); stroke-width: 2; }
.radar-dot { fill: var(--accent); }
.radar-label { fill: var(--muted); font-size: 11px; }
.radar-val { fill: var(--text); font-size: 10px; font-weight: 700; }

/* Blocks */
.block { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.block h3 { font-size: 14px; margin: 0 0 8px; }
.tiny { font-size: 12px; }
.muted { color: var(--muted); }
.risk-list, .action-list { margin: 0; padding-left: 18px; }
.risk-list li { margin: 6px 0; font-size: 13.5px; }
.risk-list li.bad::marker { color: var(--bad); }
.risk-list li.warn::marker { color: var(--warn); }
.action-list li { margin: 7px 0; font-size: 13.5px; }

/* Buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .14s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.result-actions { display: flex; gap: 10px; margin-top: 16px; }
.result-actions .btn { flex: 1; }

/* Saved */
.saved-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 6px; }
.saved-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; position: relative; }
.saved-card .sc-tier { position: absolute; top: 12px; right: 12px; font-weight: 800; font-size: 16px; padding: 0 8px; border-radius: 7px; }
.saved-card .sc-name { font-weight: 600; font-size: 15px; padding-right: 36px; }
.saved-card .sc-cat { font-size: 12px; color: var(--muted); margin-top: 2px; }
.saved-card .sc-score { font-size: 28px; font-weight: 800; margin-top: 10px; }
.saved-card .sc-score small { font-size: 13px; color: var(--muted); font-weight: 500; }
.saved-card .sc-bars { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.sc-bar { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.sc-bar .track { flex: 1; height: 5px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.sc-bar .fill { height: 100%; background: var(--accent); border-radius: 3px; }
.saved-card .sc-actions { display: flex; gap: 8px; margin-top: 12px; }
.saved-card .sc-actions button { flex: 1; font-size: 12px; padding: 6px; }
.empty { color: var(--muted); font-size: 14px; padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.saved-foot { display: flex; gap: 10px; margin-top: 16px; }

/* Weights / method */
.weights-list { list-style: none; padding: 0; margin: 10px 0 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.weights-list li { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.weights-list .w-top { display: flex; justify-content: space-between; align-items: baseline; }
.weights-list .w-name { font-weight: 600; }
.weights-list .w-pct { font-weight: 800; color: var(--accent); }
.weights-list .w-desc { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Footer */
.footer { border-top: 1px solid var(--line); padding: 22px 0; margin-top: 10px; color: var(--muted); font-size: 13px; }
.footer .wrap { display: flex; gap: 10px; flex-wrap: wrap; }
.dot { opacity: 0.5; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; font-size: 14px; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Responsive */
@media (max-width: 880px) {
  .grid { grid-template-columns: 1fr; }
  .result-panel { position: static; }
  .topnav { display: none; }
  .hero { padding: 28px 0 12px; }
}
