/* じどうか工房 計算ツール 共通スタイル(スマホ優先・外部フォントなし) */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c2330;
  --muted: #5a6475;
  --line: #dbe0e8;
  --accent: #0a6b66;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ef;
  --result: #0a6b66;
  --warn-bg: #fff6e0;
  --warn-line: #f0d48a;
  --bad: #b3261e;
  --bad-soft: #fde8e6;
  --good: #1d6b34;
  --good-soft: #e3f3e7;
  --focus: #1a73e8;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151b;
    --card: #1a2028;
    --text: #e6e9ef;
    --muted: #a2abba;
    --line: #2d3541;
    --accent: #47b8af;
    --accent-ink: #0d1b1a;
    --accent-soft: #17302e;
    --result: #6fd3ca;
    --warn-bg: #2e2715;
    --warn-line: #5f4d1d;
    --bad: #ff8a80;
    --bad-soft: #3a1d1b;
    --good: #7fd69a;
    --good-soft: #17301f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11151b; --card: #1a2028; --text: #e6e9ef; --muted: #a2abba; --line: #2d3541;
  --accent: #47b8af; --accent-ink: #0d1b1a; --accent-soft: #17302e; --result: #6fd3ca;
  --warn-bg: #2e2715; --warn-line: #5f4d1d; --bad: #ff8a80; --bad-soft: #3a1d1b;
  --good: #7fd69a; --good-soft: #17301f; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ヘッダー・フッター */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .inner { max-width: 760px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { color: var(--text); text-decoration: none; font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; line-height: 1.3; }
.brand svg { width: 28px; height: 28px; flex: none; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.site-footer { margin-top: 48px; border-top: 1px solid var(--line); background: var(--card); font-size: 14px; color: var(--muted); }
.site-footer .inner { max-width: 760px; margin: 0 auto; padding: 20px 16px 32px; }
.site-footer ul { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.site-footer a { color: var(--muted); }

/* 本文 */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.crumbs { font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }
.crumbs li + li::before { content: "›"; margin: 0 6px; }
.crumbs a { color: var(--muted); }
h1 { font-size: 24px; line-height: 1.4; margin: 6px 0 8px; }
h2 { font-size: 20px; line-height: 1.45; margin: 36px 0 10px; padding-left: 10px; border-left: 4px solid var(--accent); }
h3 { font-size: 17px; margin: 22px 0 6px; }
.lead { margin: 0 0 16px; color: var(--muted); }
p { margin: 0 0 12px; }
ul, ol { padding-left: 1.4em; margin: 0 0 12px; }
li { margin: 2px 0; }

/* ツールの枠 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.tool { box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.field { margin: 0 0 14px; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.hint { display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .field { flex: 1 1 140px; min-width: 0; }
input[type="text"], input[type="date"], input[type="number"], input[type="time"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* iPhone で入力時に拡大されないように */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 46px;
}
textarea { min-height: 140px; line-height: 1.6; resize: vertical; }
input[type="date"] { min-width: 0; -webkit-appearance: none; appearance: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.unit-input { display: flex; align-items: center; gap: 6px; }
.unit-input input { flex: 1; min-width: 0; }
.unit-input span { color: var(--muted); white-space: nowrap; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices label {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); cursor: pointer; font-size: 15px; font-weight: 400;
}
.choices input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.check, .field > label.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--accent); flex: none; }
button, .btn {
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
button.sub, .btn.sub { background: transparent; color: var(--accent); }
button.small { min-height: 36px; padding: 6px 10px; font-size: 14px; }
button:disabled { opacity: .5; cursor: default; }

/* 結果 */
.result { margin-top: 8px; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); }
.result[hidden] { display: none; }
.result .big { font-size: 30px; font-weight: 700; color: var(--result); line-height: 1.3; font-variant-numeric: tabular-nums; }
.result .big small { font-size: 16px; font-weight: 600; margin-left: 2px; }
.result .label { font-size: 14px; color: var(--muted); margin: 0; }
.result dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0 0; }
.result dt { color: var(--muted); font-size: 14px; }
.result dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.result .actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.error { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 8px 12px; font-size: 15px; margin: 8px 0 0; }
.ok-box { color: var(--good); background: var(--good-soft); border-radius: 8px; padding: 8px 12px; margin: 8px 0 0; font-weight: 600; }
.note { font-size: 14px; color: var(--muted); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 10px 12px; margin: 0 0 16px; }
.note strong { color: var(--text); }

/* 表(スマホでは横にスクロール) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 14px; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--card); }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: var(--bg); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 11em; }
td.wrap .tag { margin: 1px 0; }
tr.hl td { background: var(--accent-soft); font-weight: 600; }
tr.bad td { background: var(--bad-soft); }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.tag.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.tag.good { background: var(--good-soft); color: var(--good); border-color: transparent; }

/* 説明文 */
.explain { margin-top: 8px; }
.formula { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; font-size: 15px; }
details { background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin: 0 0 8px; }
summary { cursor: pointer; padding: 10px 12px; font-weight: 600; list-style-position: outside; margin-left: 1.2em; }
details > div { padding: 0 12px 10px; }
.sources li { margin-bottom: 6px; }
.related ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.related a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; text-decoration: none; color: var(--text); }
.related a span { display: block; font-size: 13px; color: var(--muted); }
.updated { font-size: 13px; color: var(--muted); margin-top: 24px; }

/* トップページ */
.hero { padding: 20px 0 8px; }
.hero h1 { font-size: 24px; }
.search { margin: 8px 0 20px; }
.tool-list { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 8px; }
.tool-list a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; text-decoration: none; color: var(--text); }
.tool-list a:hover { border-color: var(--accent); }
.tool-list strong { display: block; font-size: 16px; }
.tool-list span { display: block; font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.cat { font-size: 18px; margin: 28px 0 10px; border: 0; padding: 0; }
.prose h2 { margin-top: 28px; }

/* 印刷 */
@media print {
  .site-header, .site-footer, .related, .actions, .note, .crumbs { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border-color: #999; }
}
@media (min-width: 640px) {
  h1 { font-size: 28px; }
  .tool-list { grid-template-columns: 1fr 1fr; }
  .related ul { grid-template-columns: 1fr 1fr; }
}
