:root {
  --bg: #0b1020;
  --bg-soft: #121a30;
  --panel: #151d33;
  --panel-2: #1b2540;
  --line: #26314f;
  --ink: #eef2fb;
  --ink-soft: #aab4cf;
  --ink-mute: #707b9a;
  --accent: #5b8cff;
  --green: #34d399;
  --yellow: #fbbf24;
  --orange: #fb923c;
  --red: #f43f5e;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  --r: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 700px at 80% -10%, #1a2547 0%, var(--bg) 55%) fixed;
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 32px; line-height: 1; }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: 0.3px; }
.tag { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); max-width: 60ch; }
.topbar-actions { display: flex; gap: 10px; }

/* buttons */
.btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; }
.btn.primary {
  background: linear-gradient(180deg, #5b8cff, #3f6fe6);
  border-color: transparent;
  font-weight: 600;
}
.btn.add {
  width: 100%;
  border-style: dashed;
  background: transparent;
  color: var(--ink-soft);
  margin-top: 6px;
}

/* layout */
.layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 20px;
  padding: 22px clamp(16px, 4vw, 40px) 8px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.inputs { padding: 4px 18px 18px; }
.result { padding: 18px; position: sticky; top: 18px; }

.block { padding: 16px 0; border-bottom: 1px solid var(--line); }
.block:last-child { border-bottom: none; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.block-head h2 { font-size: 15px; margin: 0; }
.hint { font-size: 12px; color: var(--ink-mute); }

/* holdings table */
.table-head, .holding-row {
  display: grid;
  grid-template-columns: 1.5fr 1.1fr 0.7fr 0.7fr 32px;
  gap: 8px;
  align-items: center;
}
.table-head { font-size: 11px; color: var(--ink-mute); padding: 0 2px 6px; }
.holding-row { margin-bottom: 8px; }
.holding-row input, .holding-row select {
  font: inherit;
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 9px;
  min-width: 0;
}
.holding-row input:focus, .holding-row select:focus { outline: none; border-color: var(--accent); }
.holding-row input::placeholder { color: var(--ink-mute); }
.del-btn {
  background: transparent;
  border: none;
  color: var(--ink-mute);
  cursor: pointer;
  font-size: 18px;
  border-radius: 8px;
  padding: 4px;
}
.del-btn:hover { color: var(--red); }

.weight-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-soft);
}
.weight-status strong { font-size: 15px; color: var(--ink); }
.flag { font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.flag.ok { background: rgba(52,211,153,.15); color: var(--green); }
.flag.warn { background: rgba(251,191,36,.15); color: var(--yellow); }

/* factors */
.factors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.factor {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.factor:hover { border-color: var(--accent); }
.factor.on { border-color: var(--orange); background: rgba(251,146,60,.08); }
.factor input { margin: 2px 0 0; accent-color: var(--orange); flex: none; }
.factor .pts { color: var(--ink-mute); font-size: 11px; }

/* gauge */
.gauge-card { display: flex; gap: 18px; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.thermo { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.thermo-track {
  position: relative;
  width: 26px;
  height: 170px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.thermo-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, var(--red), var(--orange) 35%, var(--yellow) 65%, var(--green));
  transition: height .5s cubic-bezier(.2,.8,.2,1);
}
.thermo-tick {
  position: absolute; left: 0; right: 0;
  bottom: var(--at);
  height: 1px;
  background: rgba(255,255,255,.18);
}
.thermo-scale {
  display: flex; flex-direction: column-reverse;
  justify-content: space-between;
  height: 170px;
  font-size: 10px;
  color: var(--ink-mute);
}
.thermo { flex-direction: row; }
.score-readout { flex: 1; }
.score-num { font-size: 56px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.score-band { font-size: 16px; font-weight: 700; margin-top: 4px; }
.score-line { font-size: 13px; color: var(--ink-soft); margin: 8px 0 0; }

.band-cold { color: var(--green); }
.band-mild { color: var(--yellow); }
.band-warm { color: var(--orange); }
.band-hot  { color: var(--red); }

/* breakdown */
.breakdown { padding: 14px 0; border-bottom: 1px solid var(--line); }
.breakdown h3, .actions-card h3 { font-size: 14px; margin: 0 0 10px; }
.actions-card .sub { font-size: 11px; color: var(--ink-mute); font-weight: 400; }
.breakdown-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.bk-item { display: grid; grid-template-columns: 110px 1fr 40px; gap: 10px; align-items: center; font-size: 12.5px; }
.bk-item .bk-name { color: var(--ink-soft); }
.bk-bar { height: 7px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.bk-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .4s; }
.bk-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

/* actions */
.actions-card { padding-top: 14px; }
.action-list { margin: 0; padding-left: 18px; display: grid; gap: 9px; font-size: 13px; }
.action-list li { line-height: 1.45; }
.action-list .tagx { display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 999px; margin-right: 6px; vertical-align: middle; }
.tag-hi { background: rgba(244,63,94,.16); color: var(--red); }
.tag-mid { background: rgba(251,146,60,.16); color: var(--orange); }
.tag-lo { background: rgba(91,140,255,.16); color: var(--accent); }
.actions-foot { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.copy-ok { font-size: 12px; color: var(--green); }

.muted { color: var(--ink-mute); }

/* footer */
.foot {
  padding: 22px clamp(16px, 4vw, 40px) 40px;
  font-size: 12px;
  color: var(--ink-mute);
  max-width: 90ch;
}
.foot p { margin: 4px 0; }
.foot a { color: var(--ink-soft); }
.foot strong { color: var(--ink-soft); }

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .result { position: static; }
  .factors { grid-template-columns: 1fr; }
  .score-num { font-size: 48px; }
}
