/* はやみツール：早見表と計算ツール。
   目盛り（ものさし）の帯が、このサイトの目印。ほかは静かに、読みやすさを優先する。 */

:root {
  --paper: #f3f6f9;
  --surface: #ffffff;
  --ink: #152033;
  --ink-soft: #46566c;
  --rule: #c9d3df;
  --rule-strong: #74869d;
  --accent: #1b4f8f;
  --accent-ink: #ffffff;
  --mark: #f6d54c;
  --danger: #a3262a;
  --ok: #1d6b3a;
  --measure: 44rem;
  --font-ja: "BIZ UDPGothic", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
  --font-en: "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1522;
    --surface: #152033;
    --ink: #e7edf5;
    --ink-soft: #a7b5c8;
    --rule: #2c3b52;
    --rule-strong: #6d7f97;
    --accent: #8bb8f0;
    --accent-ink: #0e1522;
    --mark: #8a7414;
    --danger: #ff9a9e;
    --ok: #7fd49a;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.8;
  font-family: var(--font-ja);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
html[lang="en"] body { font-family: var(--font-en); line-height: 1.65; }
main { flex: 1 0 auto; }
img, svg { max-width: 100%; }

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 0; }

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 1rem; }

/* 目盛りの帯 */
.ruler {
  height: 14px;
  color: var(--rule-strong);
  background-image:
    repeating-linear-gradient(to right, currentColor 0 1px, transparent 1px 8px),
    repeating-linear-gradient(to right, currentColor 0 1px, transparent 1px 40px);
  background-size: 100% 6px, 100% 12px;
  background-position: left bottom, left bottom;
  background-repeat: no-repeat;
}

/* ヘッダー */
.site-header { border-bottom: 1px solid var(--rule); background: var(--surface); }
.site-header .bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 0.6rem; padding-bottom: 0.7rem; }
.brand { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.04em; color: var(--ink); text-decoration: none; }
.brand small { font-weight: 400; font-size: 0.8rem; color: var(--ink-soft); margin-left: 0.6rem; letter-spacing: 0; }
.site-nav { display: flex; gap: 1.1rem; font-size: 0.92rem; }
.site-nav a { color: var(--ink-soft); text-decoration: none; padding: 0.35rem 0; }
.site-nav a:hover { color: var(--ink); text-decoration: underline; }
.site-nav [aria-current="page"] { color: var(--ink); font-weight: 700; }

/* 見出しと本文 */
.page-head { padding: 2rem 0 1.2rem; }
h1 { font-size: clamp(1.55rem, 4.6vw, 2.1rem); line-height: 1.3; margin: 0 0 0.7rem; letter-spacing: 0.01em; }
h2 { font-size: 1.28rem; line-height: 1.4; margin: 2.6rem 0 0.8rem; padding-top: 0.2rem; }
h3 { font-size: 1.05rem; margin: 1.8rem 0 0.4rem; }
p, ul, ol, dl { margin: 0.8rem 0; }
li { margin: 0.3rem 0; }
.lead { font-size: 1.06rem; color: var(--ink-soft); margin: 0; }
.crumbs { font-size: 0.85rem; color: var(--ink-soft); margin: 0 0 0.9rem; }
.crumbs a { color: var(--ink-soft); }
.updated { font-size: 0.85rem; color: var(--ink-soft); }
code, kbd { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.92em; background: color-mix(in srgb, var(--rule) 45%, transparent); padding: 0.05em 0.35em; border-radius: 3px; }

/* ツールの枠 */
.tool { background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; margin: 0.4rem 0 0; overflow: hidden; }
.tool .ruler { border-bottom: 1px solid var(--rule); }
.tool-body { padding: 1.2rem 1.1rem 1.4rem; }
.tool-body > :first-child { margin-top: 0; }
.fields { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.field label, .field .label, legend { font-weight: 700; font-size: 0.95rem; }
.field > .seg { align-self: flex-start; }
.hint { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.5; }
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  padding: 0.55rem 0.65rem;
  min-height: 2.75rem;
  width: 100%;
}
textarea { min-height: 5.5rem; resize: vertical; line-height: 1.5; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; }
.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; }
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 3px; overflow: hidden; }
.seg label { margin: 0; font-weight: 400; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 0.55rem 0.95rem; cursor: pointer; min-height: 2.75rem; line-height: 1.6; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -3px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.1rem; }
button, .button {
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.75rem; padding: 0.5rem 1.3rem; border-radius: 3px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink);
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button:hover, .button:hover { filter: brightness(1.08); }

/* 結果の表示 */
.result { margin-top: 1.4rem; border-top: 1px solid var(--rule); padding-top: 1.1rem; }
.result[hidden] { display: none; }
.answer { font-size: clamp(1.7rem, 6vw, 2.5rem); font-weight: 700; line-height: 1.25; margin: 0 0 0.3rem; font-variant-numeric: tabular-nums; }
.answer span { background: linear-gradient(to bottom, transparent 60%, var(--mark) 60%); padding: 0 0.15em; }
.answer-sub { color: var(--ink-soft); margin: 0 0 0.8rem; }
.readout { display: grid; grid-template-columns: 1fr auto; margin: 0.6rem 0 0; font-variant-numeric: tabular-nums; }
.readout dt, .readout dd { margin: 0; padding: 0.45rem 0; border-bottom: 1px dotted var(--rule-strong); }
.readout dd { text-align: right; font-weight: 700; padding-left: 1rem; }
.error { color: var(--danger); font-weight: 700; margin: 0; }
.status { color: var(--ink-soft); font-size: 0.9rem; margin: 0.8rem 0 0; }

/* 表 */
.table-wrap { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); }
.table-wrap:focus-visible { outline-offset: 0; }
table.data { border-collapse: collapse; width: 100%; font-size: 0.93rem; font-variant-numeric: tabular-nums; line-height: 1.5; }
table.data caption { text-align: left; font-weight: 700; padding: 0.7rem 0.8rem 0.3rem; }
table.data th, table.data td { padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
table.data thead th { border-bottom: 2px solid var(--ink); white-space: nowrap; font-size: 0.88rem; }
table.data tbody tr:last-child td, table.data tbody tr:last-child th { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
table.data tbody th { font-weight: 700; white-space: nowrap; }
table.data tr.hit td, table.data tr.hit th { background: color-mix(in srgb, var(--mark) 40%, transparent); }

/* 注意書き・よくある質問 */
.note { border-left: 4px solid var(--accent); background: var(--surface); padding: 0.7rem 1rem; margin: 1.2rem 0; font-size: 0.95rem; }
.note p { margin: 0.3rem 0; }
details.faq { border-top: 1px solid var(--rule); }
details.faq:last-of-type { border-bottom: 1px solid var(--rule); }
details.faq summary { cursor: pointer; font-weight: 700; padding: 0.8rem 1.6rem 0.8rem 0; list-style: none; position: relative; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; position: absolute; right: 0.2rem; top: 0.6rem; font-size: 1.3rem; font-weight: 400; color: var(--ink-soft); }
details.faq[open] summary::after { content: "−"; }
details.faq > :not(summary) { margin-top: 0; padding-bottom: 0.2rem; }
.sources { font-size: 0.9rem; color: var(--ink-soft); }
.sources a { color: var(--ink-soft); }

/* ほかのツール（索引） */
.index { list-style: none; margin: 1rem 0; padding: 0; border-top: 1px solid var(--rule-strong); }
.index li { margin: 0; border-bottom: 1px solid var(--rule); }
.index a { display: block; padding: 0.9rem 0.2rem; text-decoration: none; color: var(--ink); }
.index a:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.index strong { display: block; font-size: 1.08rem; color: var(--accent); text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
.index span { display: block; color: var(--ink-soft); font-size: 0.93rem; margin-top: 0.15rem; }

/* フッター */
.site-footer { margin-top: 3.5rem; border-top: 1px solid var(--rule); background: var(--surface); font-size: 0.88rem; color: var(--ink-soft); }
.site-footer .wrap { padding-top: 1.4rem; padding-bottom: 1.8rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; margin-bottom: 0.8rem; }
.site-footer a { color: var(--ink-soft); }
.site-footer p { margin: 0.3rem 0; }

/* 言語の入口ページ */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.gate-inner { max-width: 30rem; width: 100%; }
.gate h1 { margin-bottom: 1.2rem; }
.gate .index strong { font-size: 1.3rem; }

@media (max-width: 34rem) {
  .brand small { display: none; }
  .site-header .bar { flex-wrap: wrap; }
  .page-head { padding-top: 1.4rem; }
}

@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .site-header, .site-footer, .no-print, .tool form, .actions, .related, .skip { display: none !important; }
  .tool { border: 0; }
  .table-wrap { border: 0; overflow: visible; }
  a { color: #000; text-decoration: none; }
  h2 { break-after: avoid; }
  table.data { font-size: 10pt; }
  table.data tr { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
