:root {
  --bg: #0b0d10;
  --panel: #14171c;
  --panel-2: #191d23;
  --text: #f7f8fa;
  --muted: #8d96a3;
  --line: #252a32;
  --accent: #f7f8fa;
  --accent-text: #0b0d10;
  --ok: #52d681;
  --warn: #ffbf47;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(0,0,0,.28);
  --radius: 26px;
}
:root.light {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #eef0f3;
  --text: #14171c;
  --muted: #6d7480;
  --line: #dfe3e8;
  --accent: #111317;
  --accent-text: #ffffff;
  --shadow: 0 24px 70px rgba(20,23,28,.09);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% -10%, rgba(255,255,255,.08), transparent 30%),
    var(--bg);
  min-height: 100vh;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.shell { max-width: 780px; margin: 0 auto; min-height: 100vh; padding: 0 18px 110px; }
.topbar {
  height: 82px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(18px);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 39px; height: 39px; border-radius: 13px;
  background: var(--accent); color: var(--accent-text); font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: 2px; font-size: 11px; letter-spacing: .08em; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  color: var(--text); background: var(--panel);
}
.hero { padding: 28px 4px 20px; }
.eyebrow { color: var(--muted); font-size: 11px; letter-spacing: .18em; font-weight: 700; }
h1 { font-size: clamp(38px, 8vw, 62px); line-height: .98; letter-spacing: -.055em; margin: 8px 0 14px; }
h2 { font-size: 28px; letter-spacing: -.03em; margin: 7px 0 0; }
.hero p, .muted, .hint, .disclaimer { color: var(--muted); }
.hero p { max-width: 560px; line-height: 1.55; margin: 0; }
.scale-card, .panel {
  border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, var(--panel), var(--panel-2));
  box-shadow: var(--shadow);
}
.scale-card { padding: 24px; text-align: center; }
.scale-top { display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 6px color-mix(in srgb, var(--muted) 12%, transparent); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 6px color-mix(in srgb, var(--ok) 14%, transparent); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 6px color-mix(in srgb, var(--warn) 14%, transparent); }
.weight-wrap { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 32px 0 4px; }
.weight { font-size: clamp(72px, 18vw, 124px); font-weight: 750; line-height: .85; letter-spacing: -.075em; font-variant-numeric: tabular-nums; }
.unit { color: var(--muted); font-size: 20px; margin-bottom: 10px; }
.actions { display: grid; grid-template-columns: 1fr 120px; gap: 10px; max-width: 500px; margin: 30px auto 0; }
button.primary, button.secondary {
  border: 0; border-radius: 15px; min-height: 52px; padding: 0 18px; font-weight: 700;
}
button.primary { background: var(--accent); color: var(--accent-text); }
button.secondary { color: var(--text); background: transparent; border: 1px solid var(--line); }
button.compact { min-height: 42px; }
.hint { font-size: 12px; line-height: 1.45; max-width: 510px; margin: 18px auto 0; }
.results { padding-top: 34px; }
.hidden { display: none !important; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.metrics-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.metric {
  min-height: 122px; padding: 18px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--panel);
}
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 17px; font-size: 28px; font-weight: 720; letter-spacing: -.04em; }
.metric-unit { color: var(--muted); font-size: 13px; margin-left: 5px; }
.disclaimer { font-size: 11px; line-height: 1.5; margin: 14px 4px; }
.view { display: none; }
.view.active { display: block; }
.panel { padding: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12px; }
input, select {
  width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid var(--line);
  border-radius: 13px; color: var(--text); background: var(--bg); outline: none;
}
input:focus, select:focus { border-color: var(--muted); }
.full { grid-column: 1 / -1; }
.settings-list { display: grid; gap: 0; }
.settings-list > div { display: grid; gap: 6px; padding: 16px 2px; border-bottom: 1px solid var(--line); }
.settings-list > div:last-child { border-bottom: 0; }
.settings-list span { color: var(--muted); font-size: 13px; }
.chart-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.select { width: auto; min-width: 145px; }
.danger-link { border: 0; color: var(--danger); background: transparent; padding: 10px; }
.chart { margin-top: 18px; min-height: 250px; border-radius: 18px; background: var(--bg); overflow: hidden; }
.chart.empty { display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.chart svg { width: 100%; height: 250px; display: block; }
.history-list { margin-top: 12px; }
.history-row { display: flex; justify-content: space-between; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.history-row small { color: var(--muted); }
.bottom-nav {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom));
  width: min(calc(100% - 24px), 744px); display: grid; grid-template-columns: repeat(4,1fr); gap: 4px;
  padding: 8px; border: 1px solid var(--line); border-radius: 22px;
  background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(22px); box-shadow: var(--shadow);
}
.nav-item {
  min-height: 58px; border: 0; border-radius: 15px; color: var(--muted); background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.nav-item span { font-size: 19px; }
.nav-item small { font-size: 10px; }
.nav-item.active { background: var(--accent); color: var(--accent-text); }
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 999px; font-size: 13px; font-weight: 650;
}
@media (max-width: 520px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .scale-card, .panel { border-radius: 22px; }
  .scale-card { padding: 20px 15px; }
  .actions { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .metric { min-height: 112px; padding: 15px; }
  .metric-value { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
}
