/* くらし計算室 共通スタイル
   方針: 公的な文書のような落ち着き。カードを並べず、罫線と余白で区切る。
   色は 紺(ink)・青(primary)・灰 だけ。「多い」を赤、「少ない」を緑にしない（良し悪しを示さないため）。
   本文フォント: 数字は IBM Plex Sans（等幅数字）、日本語は Noto Sans JP。 */

:root {
  --bg: #f3f6f9;
  --surface: #ffffff;
  --ink: #14283a;      /* 本文 */
  --sub: #4a5b6b;      /* 補足 */
  --line: #c9d5e0;     /* 罫線 */
  --field-line: #7f93a6; /* 入力欄の枠（背景に対し 3:1 以上） */
  --primary: #0a5c8f;  /* 操作・強調 */
  --primary-dark: #084a75;
  --tint: #e4eef6;     /* 選択状態などの淡い青 */
  --bar-avg: #7d8fa1;  /* 平均の棒（背景に対し 3:1 以上） */
  --err: #a3271f;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: "IBM Plex Sans", "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; color-scheme: light; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.8;
  font-feature-settings: "tnum" 1;
  word-break: auto-phrase;
  overflow-wrap: anywhere;
}
::selection { background: var(--tint); color: var(--ink); }
a { color: var(--primary); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--primary-dark); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 2px; }
.ph { display: inline-block; }

/* ---- 上部の帯 ---- */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 640px; margin: 0 auto; padding: 0 16px; min-height: 52px; display: flex; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); font-weight: 700; font-size: 17px; letter-spacing: .02em; text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand svg { flex: none; }

main { max-width: 640px; margin: 0 auto; padding: 32px 16px 24px; }
h1 { font-size: 28px; line-height: 1.45; font-weight: 700; letter-spacing: .01em; margin: 0 0 12px; text-wrap: balance; }
.lead { text-wrap: pretty; margin: 0 0 28px; color: var(--sub); font-size: 16px; line-height: 1.85; max-width: 34em; }

/* ---- 入力 ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px 20px 12px; margin-bottom: 40px; }
.field { margin: 0 0 20px; padding: 0; border: 0; min-width: 0; }
.q { display: block; font-weight: 700; font-size: 16px; line-height: 1.5; margin: 0 0 8px; padding: 0; }
.opt { font-weight: 400; color: var(--sub); font-size: 14px; }
.group { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }

.num {
  display: flex; align-items: stretch; flex: 1 1 11em; max-width: 15em;
  background: var(--surface); border: 1.5px solid var(--field-line); border-radius: 8px; overflow: hidden;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.num:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10, 92, 143, .28); }
.num input {
  flex: 1; min-width: 0; width: 100%; padding: 10px 4px 10px 14px; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 22px; font-weight: 600; line-height: 1.3; min-height: 50px; letter-spacing: .01em;
}
.num input:focus { outline: none; }
.num input::placeholder { color: #5c6d7d; font-weight: 400; }
.num .unit { display: flex; align-items: center; padding: 0 14px 0 4px; color: var(--sub); font-size: 16px; white-space: nowrap; }
.num[data-invalid="true"] { border-color: var(--err); }
.num[data-invalid="true"]:focus-within { box-shadow: 0 0 0 3px rgba(163, 39, 31, .25); }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.seg { display: inline-flex; border: 1.5px solid var(--field-line); border-radius: 8px; overflow: hidden; min-height: 50px; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg label { display: flex; align-items: center; justify-content: center; min-width: 56px; padding: 0 16px; font-size: 16px; font-weight: 500; cursor: pointer; user-select: none; background: var(--surface); transition: background-color .15s var(--ease), color .15s var(--ease); }
.seg label:hover { background: var(--tint); }
.seg input + label + input + label { border-left: 1.5px solid var(--field-line); }
.seg input:checked + label { background: var(--primary); color: #fff; font-weight: 700; }
.seg input:focus-visible + label { outline: 3px solid var(--primary); outline-offset: -5px; }
.seg input:checked:focus-visible + label { outline-color: #fff; }

.hint { font-size: 14px; color: var(--sub); line-height: 1.7; margin: 0 0 8px; }
.calc-note { font-size: 14px; color: var(--sub); margin: 8px 0 0; min-height: 1.7em; }
.calc-note:empty { min-height: 0; margin: 0; }
fieldset.field:has(details.how) { margin-bottom: 4px; }
details.how { margin-top: 2px; }
details.how .hint { padding-left: 21px; }
.err { font-size: 14px; color: var(--err); font-weight: 500; margin: 8px 0 0; }

details.more { margin: 0 0 4px; }
details.more summary, details.how summary { cursor: pointer; font-weight: 500; font-size: 15px; color: var(--primary); min-height: 44px; display: flex; align-items: center; gap: 8px; list-style: none; }
details.more summary::-webkit-details-marker, details.how summary::-webkit-details-marker { display: none; }
details.more summary::before, details.how summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .2s var(--ease); margin: 0 4px 0 2px; }
details.more[open] summary::before, details.how[open] summary::before { transform: rotate(45deg); }
details.more .field { margin: 8px 0 0; }

.clear { appearance: none; background: none; border: 0; padding: 0 2px; min-height: 44px; font: inherit; font-size: 15px; color: var(--sub); text-decoration: underline; text-underline-offset: .18em; cursor: pointer; }
.clear:hover { color: var(--ink); }
.actions { display: flex; justify-content: flex-end; margin-top: 4px; }

/* ---- 結果 ---- */
.result { margin: 0 0 8px; padding-top: 0; }
.empty { border: 1.5px dashed var(--field-line); border-radius: 12px; padding: 22px 20px; color: var(--sub); font-size: 15px; line-height: 1.8; background: transparent; }
.empty p { margin: 0; }
.answer { border-top: 2px solid var(--ink); padding-top: 20px; }
.basis { font-size: 14px; color: var(--sub); margin: -10px 0 22px; }
.verdict { font-size: 25px; line-height: 1.55; font-weight: 700; margin: 0 0 12px; text-wrap: balance; }
.verdict .n { color: var(--primary); font-size: 1.3em; letter-spacing: 0; padding: 0 .05em; }

.bars { display: grid; gap: 10px; margin: 0 0 22px; }
.bar-row { display: grid; grid-template-columns: 3.6em 1fr 4.8em; align-items: center; column-gap: 10px; }
.bar-row .name { font-size: 15px; color: var(--sub); }
.bar-row.you .name { color: var(--ink); font-weight: 700; }
.track { position: relative; height: 36px; }
.fill { position: absolute; inset: 0 auto 0 0; width: 100%; transform-origin: left center; border-radius: 4px; background: var(--bar-avg); transition: transform .5s var(--ease); }
.you .fill { background: var(--primary); }
.val { text-align: right; font-weight: 700; font-size: 16px; white-space: nowrap; }
.sr { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

table.nums { width: 100%; border-collapse: collapse; font-size: 16px; margin: 0 0 6px; }
table.nums caption { text-align: left; font-weight: 700; font-size: 16px; padding: 0 0 6px; }
table.nums th, table.nums td { padding: 12px 0; border-top: 1px solid var(--line); text-align: left; font-weight: 400; vertical-align: baseline; }
table.nums tr:last-child th, table.nums tr:last-child td { border-bottom: 1px solid var(--line); }
table.nums td { text-align: right; font-weight: 700; white-space: nowrap; padding-left: 12px; }
.note { font-size: 14px; color: var(--sub); margin: 12px 0 0; line-height: 1.8; }
.src-line { font-size: 13px; color: var(--sub); margin: 12px 0 0; line-height: 1.7; }

/* ---- PR ---- */
.pr { margin: 36px 0 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.pr .tag { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--ink); background: var(--tint); padding: 1px 8px; border-radius: 4px; margin-bottom: 8px; }
.pr p { margin: 0 0 14px; font-size: 15px; line-height: 1.8; }
.pr .btn { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 52px; padding: 10px 18px; background: var(--primary); color: #fff; text-decoration: none; font-weight: 700; font-size: 16px; border-radius: 8px; transition: background-color .15s var(--ease), transform .15s var(--ease); }
.pr .btn:hover { background: var(--primary-dark); color: #fff; }
.pr .btn:active { transform: scale(.985); }
.pr small { display: block; margin-top: 12px; color: var(--sub); font-size: 13px; line-height: 1.7; }

/* ---- 出典・注記 ---- */
.about { border-top: 1px solid var(--line); margin-top: 44px; padding-top: 28px; }
.about h2 { font-size: 16px; line-height: 1.5; margin: 0 0 10px; }
.about p, .about li { font-size: 14px; color: var(--sub); line-height: 1.85; }
.about p { margin: 0 0 24px; }
.about ul { margin: 0 0 24px; padding-left: 1.2em; }
.about li { margin-bottom: 6px; }
.about a { color: var(--primary); }

.foot { border-top: 1px solid var(--line); background: var(--surface); margin-top: 32px; }
.foot-in { max-width: 640px; margin: 0 auto; padding: 24px 16px 40px; font-size: 13px; color: var(--sub); line-height: 1.8; }
.foot-in a { color: var(--sub); display: inline-flex; align-items: center; min-height: 44px; }
.foot-in p { margin: 0 0 6px; }

/* ---- 目次ページ ---- */
.tools { list-style: none; margin: 0 0 12px; padding: 0; border-top: 1px solid var(--line); }
.tools li { border-bottom: 1px solid var(--line); }
.tools a { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center; padding: 20px 12px; color: var(--ink); text-decoration: none; transition: background-color .15s var(--ease); }
.tools a:hover { background: var(--surface); color: var(--ink); }
.tools .t { font-size: 19px; font-weight: 700; line-height: 1.5; text-decoration: underline; text-decoration-color: var(--primary); text-decoration-thickness: 2px; text-underline-offset: .25em; }
.tools .d { grid-column: 1; font-size: 14px; color: var(--sub); line-height: 1.75; }
.tools .go { grid-row: 1 / span 2; grid-column: 2; width: 10px; height: 10px; border-top: 2px solid var(--primary); border-right: 2px solid var(--primary); transform: rotate(45deg); transition: transform .2s var(--ease); }
.tools a:hover .go { transform: translateX(3px) rotate(45deg); }
.rules { margin: 0; padding: 0; }
.rules dt { font-weight: 700; font-size: 16px; margin: 0 0 2px; }
.rules dd { margin: 0 0 20px; color: var(--sub); font-size: 15px; line-height: 1.85; }
h2.sec { font-size: 18px; line-height: 1.5; margin: 40px 0 12px; }

@media (min-width: 640px) {
  main { padding-top: 48px; }
  h1 { font-size: 32px; }
  .panel { padding: 28px 28px 24px; }
}

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