:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --text: #24211d;
  --muted: #6b645b;
  --line: #e4ded5;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fff1e8;
  --good: #15803d;
  --bad: #b91c1c;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1816;
    --surface: #24211e;
    --text: #eeeae4;
    --muted: #a9a198;
    --line: #3a3530;
    --accent: #fb923c;
    --accent-ink: #1a1816;
    --accent-soft: #33261c;
    --good: #4ade80;
    --bad: #f87171;
  }
}
* { 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", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.7;
  font-size: 16px;
}
a { color: var(--accent); }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; min-height: 52px; }
.site-name { font-weight: 700; color: var(--text); text-decoration: none; font-size: 15px; }
h1 { font-size: 1.5rem; line-height: 1.4; margin: 28px 0 8px; }
h2 { font-size: 1.2rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 20px 0 8px; }
.lead { color: var(--muted); margin: 0 0 8px; }
.privacy { font-size: 14px; color: var(--muted); margin: 0 0 20px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 16px;
  margin: 0 0 20px;
}
.step { display: inline-block; background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 13px; padding: 0 10px; margin-right: 6px; vertical-align: 2px; }
label { font-size: 14px; color: var(--muted); }
input[type="number"], input[type="text"], select {
  font: inherit;
  font-size: 16px; /* iOS で拡大されないように */
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  min-height: 44px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  font: inherit;
  font-size: 15px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
button.icon { min-width: 44px; padding: 0; color: var(--muted); }
.items { display: grid; gap: 10px; margin-bottom: 12px; }
.item-row { display: grid; grid-template-columns: 1fr 1fr 44px; gap: 8px; align-items: end; }
.item-row .name { grid-column: 1 / -1; }
.item-row > div { min-width: 0; }
.item-row + .item-row { border-top: 1px dashed var(--line); padding-top: 10px; }
@media (min-width: 560px) {
  .item-row { grid-template-columns: 2fr 1fr 1fr 44px; }
  .item-row .name { grid-column: auto; }
  .item-row + .item-row { border-top: 0; padding-top: 0; }
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--accent); font-size: 15px; min-height: 44px; display: flex; align-items: center; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.error { color: var(--bad); font-size: 14px; }
.result-total { font-size: 1.6rem; font-weight: 700; margin: 4px 0; }
.result-total small { font-size: 14px; font-weight: 400; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: 13px; color: var(--muted); font-weight: 400; }
td input[type="number"] { min-width: 56px; text-align: right; }
th:first-child, td:first-child, .nw { white-space: nowrap; }
#quick-card table { font-size: 14px; }
#quick-card th, #quick-card td { padding: 8px 4px; }
#quick-card td:first-child { white-space: normal; }
#count-table td { padding: 6px 4px; }
#count-table td:first-child { vertical-align: middle; }
.table-scroll { overflow-x: auto; }
.note { font-size: 14px; color: var(--muted); }
.ok { color: var(--good); font-weight: 700; }
.ng { color: var(--bad); font-weight: 700; }
.breakdown { font-size: 13px; color: var(--muted); display: block; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.guide {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  margin: 28px 0;
}
.guide p { margin: 0 0 6px; }
.guide .guide-title { font-weight: 700; }
.explain h2 { margin-top: 8px; }
.explain p, .explain li { font-size: 15px; }
.site-footer { border-top: 1px solid var(--line); padding: 20px 0 40px; font-size: 13px; color: var(--muted); }
.tool-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.tool-list a { display: block; text-decoration: none; color: inherit; }
.tool-list .tool-name { color: var(--accent); font-weight: 700; }
.badge { font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; color: var(--muted); margin-left: 6px; }

@media print {
  body { background: #fff; color: #000; font-size: 12pt; }
  .site-header, .site-footer, .guide, .explain, .no-print, #prep-card, #settle-card, h1, .lead, .privacy { display: none !important; }
  #quick-card { border: 0; padding: 0; }
  .breakdown { color: #333; }
}
