:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2329;
  --muted: #5b6672;
  --line: #dde2e8;
  --accent: #1f5f8b;
  --accent-soft: #e6f0f7;
  --warn-bg: #fff4e0;
  --warn-text: #7a4a00;
  --error: #b42318;
  --c1: #1f7a4d;
  --c2: #d1495b;
  --c3: #f2b84b;
  --c4: #8a94a0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --surface: #1d232a;
    --text: #e6eaee;
    --muted: #9aa6b2;
    --line: #2f3741;
    --accent: #6fb0e0;
    --accent-soft: #1c3243;
    --warn-bg: #3a2c12;
    --warn-text: #f5d08a;
    --error: #ff8a80;
    --c1: #4cc38a;
    --c2: #ef6f80;
    --c3: #f2c66b;
    --c4: #74808c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: 1.75;
  font-size: 16px;
}
a { color: var(--accent); }
.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; }
.nav-link { font-size: 14px; text-decoration: none; }

.crumbs { font-size: 13px; color: var(--muted); margin-top: 16px; }
.crumbs a { color: var(--muted); }
h1 { font-size: clamp(22px, 5vw, 28px); line-height: 1.4; margin: 16px 0 8px; }
h2 { font-size: 20px; line-height: 1.5; margin: 32px 0 8px; }
.lead { color: var(--muted); margin: 0 0 20px; }

.tool, .explain, .faq, .related, .cross, .ad {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0;
}
.explain h2:first-child, .faq h2, .related h2, .cross h2 { margin-top: 0; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field.wide { grid-column: 1 / -1; }
.field label, .field legend { font-weight: 600; font-size: 14px; padding: 0; }
.help { color: var(--muted); font-size: 12px; line-height: 1.5; }
.input-unit { display: flex; align-items: stretch; }
.input-unit input { flex: 1; min-width: 0; }
.input-unit span {
  display: flex; align-items: center; padding: 0 10px;
  border: 1px solid var(--line); border-left: 0; border-radius: 0 8px 8px 0;
  background: var(--bg); color: var(--muted); font-size: 13px; white-space: nowrap;
}
input[type="text"], textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.input-unit input { border-radius: 8px 0 0 8px; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.radios { display: flex; gap: 20px; flex-wrap: wrap; }
.radios label { font-weight: 400; display: flex; align-items: center; gap: 6px; }

.actions { margin-top: 14px; }
button {
  font: inherit; font-size: 14px; cursor: pointer;
  border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
button.ghost { background: transparent; color: var(--accent); }
button.small { font-size: 13px; padding: 6px 12px; }

.result-box { margin-top: 20px; padding: 18px; border-radius: 10px; background: var(--accent-soft); }
.result-title { font-size: 15px; margin: 0 0 8px; color: var(--muted); }
#result.is-error p { color: var(--error); font-weight: 600; margin: 0; }
.big { display: flex; flex-direction: column; margin-bottom: 12px; }
.big-label { font-size: 14px; color: var(--muted); }
.big-value { font-size: 40px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.big-value small { font-size: 18px; margin-left: 4px; font-weight: 600; }
.big-note { font-size: 14px; color: var(--muted); }
.rows { margin: 0 0 12px; }
.rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.warn { background: var(--warn-bg); color: var(--warn-text); padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.sub { font-size: 14px; margin: 16px 0 6px; }

.stack { display: flex; height: 18px; border-radius: 6px; overflow: hidden; background: var(--line); }
.seg { display: block; height: 100%; }
.c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); } .c4 { background: var(--c4); }
.legend { list-style: none; padding: 0; margin: 8px 0 12px; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

.lb { position: relative; display: flex; align-items: flex-end; gap: 8px; height: 160px; margin: 24px 0 8px; padding-bottom: 22px; }
.lb-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.lb-col span { position: absolute; bottom: -22px; font-size: 12px; color: var(--muted); }
.lb-bar { width: 100%; max-width: 48px; background: var(--accent); border-radius: 4px 4px 0 0; opacity: 0.75; }
.lb-bar.hot { opacity: 1; }
.lb-bar.over { background: var(--c2); }
.lb-takt { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--c2); z-index: 1; }
.lb-takt span { position: absolute; right: 0; top: -20px; font-size: 12px; color: var(--c2); background: var(--accent-soft); padding: 0 4px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
.explain table th, .explain table td { text-align: left; white-space: normal; }

.formula { background: var(--bg); border-radius: 8px; padding: 12px 12px 12px 32px; }
.faq details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; }

.cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.cards a {
  display: flex; flex-direction: column; gap: 4px; height: 100%;
  padding: 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); text-decoration: none;
}
.cards a:hover { border-color: var(--accent); }
.cards strong { color: var(--accent); }
.cards span { font-size: 13px; color: var(--muted); line-height: 1.6; }
#tools section h2 { margin-top: 28px; }

.cross ul { margin: 0; padding-left: 20px; }
.ad { text-align: center; padding: 8px; }

.site-footer { margin-top: 40px; padding: 24px 0 40px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 8px 0; }
.site-footer .copy { margin: 0; }
