:root {
  color-scheme: light;
  --bg: #fcfcfb;
  --surface: #ffffff;
  --line: #e4e3df;
  --grid: #ecebe7;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #8a8984;
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --up: #b4361f;
  --down: #1c6e4a;
  --good-bg: #e6f4ec;
  --warn-bg: #fdf1e3;
  --band: #cde2fb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141413;
    --surface: #1a1a19;
    --line: #34332f;
    --grid: #2a2a27;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e88;
    --accent: #5598e7;
    --accent-ink: #0b0b0b;
    --series-1: #3987e5;
    --series-2: #d95926;
    --up: #f08a74;
    --down: #6cc79a;
    --good-bg: #183225;
    --warn-bg: #3a2a17;
    --band: #184f95;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141413; --surface: #1a1a19; --line: #34332f; --grid: #2a2a27;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e88; --accent: #5598e7; --accent-ink: #0b0b0b;
  --series-1: #3987e5; --series-2: #d95926; --up: #f08a74; --down: #6cc79a;
  --good-bg: #183225; --warn-bg: #3a2a17; --band: #184f95;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.75 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 1.6rem; line-height: 1.4; margin: 1.2em 0 .6em; }
h2 { font-size: 1.2rem; margin: 2em 0 .6em; padding-top: .6em; border-top: 1px solid var(--line); }
small { font-size: .78em; }

.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 1.25rem; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.logo small { font-weight: 500; color: var(--muted); margin-left: .5em; font-size: .7rem; }
nav { display: flex; gap: 16px; font-size: .92rem; }
nav a { color: var(--text-2); text-decoration: none; }
nav a:hover { color: var(--accent); }

.hero { padding: 8px 0 4px; }
.hero h1 { font-size: 2rem; margin-bottom: .3em; }
.hero p { color: var(--text-2); }
.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px;
  padding: .7em 1.3em; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.tile .k { font-size: .82rem; color: var(--text-2); }
.tile .v { font-size: 1.9rem; font-weight: 800; line-height: 1.3; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: .9rem; font-weight: 600; margin-left: .2em; color: var(--text-2); }
.tile .v.small { font-size: 1.1rem; line-height: 1.5; padding: .3em 0; }
.tile .s { font-size: .8rem; color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.cap { font-size: .82rem; color: var(--muted); }
.crumb { font-size: .85rem; color: var(--muted); margin-top: 1em; }

.chartbox { position: relative; margin: 8px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 8px 4px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .line.s1 { stroke: var(--series-1); }
.chart .line.s2 { stroke: var(--series-2); }
.chart .dot { stroke: var(--surface); stroke-width: 2; cursor: pointer; }
.chart .dot.s1 { fill: var(--series-1); }
.chart .dot.s2 { fill: var(--series-2); }
.chart .dot.on { r: 6; }
.legend { display: flex; gap: 16px; font-size: .82rem; color: var(--text-2); padding: 0 8px 4px; flex-wrap: wrap; }
.key i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.key.s1 i { background: var(--series-1); }
.key.s2 i { background: var(--series-2); }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: .82rem; line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0,0,0,.12); white-space: nowrap; z-index: 2;
}
.tip b { font-variant-numeric: tabular-nums; }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { font-size: .8rem; color: var(--text-2); font-weight: 600; line-height: 1.35; vertical-align: bottom; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.note { font-size: .85rem; color: var(--text-2); }
td small { color: var(--muted); }
.muted { color: var(--muted); }
table.list tbody tr:hover { background: var(--grid); }

.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; align-items: end;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.form label { display: flex; flex-direction: column; font-size: .85rem; color: var(--text-2); gap: 4px; }
.form select, .form input { font: inherit; font-size: 1rem; padding: .5em .6em; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); width: 100%; }
.in { display: flex; align-items: center; gap: 6px; }
.in i { font-style: normal; color: var(--text-2); white-space: nowrap; }

#out { margin: 20px 0; }
.result { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.result .verdict { font-size: 1.3rem; font-weight: 800; margin: 0 0 .2em; }
.result.good { background: var(--good-bg); }
.result.warn { background: var(--warn-bg); }
.range { width: 100%; height: auto; display: block; margin: 8px 0 4px; }
.range .band { fill: var(--band); }
.range .mid { stroke: var(--series-1); stroke-width: 2; }
.range .me { fill: var(--text); }
.range text { fill: var(--text-2); font-size: 12px; }
.notes ul, main ul { padding-left: 1.2em; }
.notes li { margin: .3em 0; color: var(--text-2); font-size: .92rem; }
.formula { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; font-size: .95rem; }

.foot { margin-top: 48px; border-top: 1px solid var(--line); padding: 16px 0 32px; font-size: .78rem; color: var(--muted); }
.foot a { color: var(--muted); }

@media (max-width: 560px) {
  h1, .hero h1 { font-size: 1.4rem; }
  .tile .v { font-size: 1.6rem; }
  th, td { padding: 6px 6px; }
}
