/* Japan Money Calculators — warm, friendly look.
   Light (white) by default; dark when the device is set to dark, or when the visitor picks it with the toggle. */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --soft: #fbf6f1;          /* warm off-white panels */
  --text: #2b2724;
  --muted: #6b625b;
  --border: #ece4dc;
  --input-border: #cfc4ba;
  --accent: #b54f1f;        /* kotatsu orange (5:1 on white) */
  --accent-hover: #9c4219;
  --accent-text: #ffffff;
  --accent-soft: #fdf0e7;
  --info-bg: #eef6f4;
  --info-border: #b9ddd6;
  --info-ink: #1f6b60;
  --warn-bg: #fff8ec;
  --warn-border: #f1d6a4;
  --ok: #2e7d4f;
  --placeholder-bg: #f5f2ff;
  --placeholder-border: #8b7ad6;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
  --radius: 16px;
  --max: 48rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1a18; --surface: #262320; --soft: #2b2724; --text: #f3eee8; --muted: #bcb2a8;
    --border: #3a3531; --input-border: #5a524b; --accent: #f39a64; --accent-hover: #f7b089; --accent-text: #1c1a18;
    --accent-soft: #3a2a20; --info-bg: #1f2e2b; --info-border: #2f5650; --info-ink: #8fd3c6;
    --warn-bg: #30291c; --warn-border: #5e4a24; --ok: #8fd6a8; --placeholder-bg: #262238; --placeholder-border: #a897f0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1a18; --surface: #262320; --soft: #2b2724; --text: #f3eee8; --muted: #bcb2a8;
  --border: #3a3531; --input-border: #5a524b; --accent: #f39a64; --accent-hover: #f7b089; --accent-text: #1c1a18;
  --accent-soft: #3a2a20; --info-bg: #1f2e2b; --info-border: #2f5650; --info-ink: #8fd3c6;
  --warn-bg: #30291c; --warn-border: #5e4a24; --ok: #8fd6a8; --placeholder-bg: #262238; --placeholder-border: #a897f0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  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, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.7;
}
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem 1rem; z-index: 10; border-radius: 8px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }

/* ---- header ---- */
header.site { background: var(--surface); border-bottom: 1px solid var(--border); }
header.site .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding-top: .7rem; padding-bottom: .7rem; }
header.site .brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 800; text-decoration: none; color: var(--text); margin-right: auto; line-height: 1.2;
}
.brand .logo { width: 36px; height: 36px; flex: none; }
.brand small { display: block; font-weight: 500; font-size: .75rem; color: var(--muted); }
header.site nav { display: flex; flex-wrap: wrap; gap: .4rem; font-size: .92rem; width: 100%; }
@media (min-width: 46rem) { header.site nav { width: auto; } }
header.site nav a {
  text-decoration: none; color: var(--text); background: var(--soft);
  padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--border);
}
header.site nav a:hover { border-color: var(--accent); color: var(--accent); }
header.site nav a[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.theme-toggle {
  font: inherit; font-size: .85rem; display: inline-flex; align-items: center; gap: .35rem;
  background: var(--soft); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: .3rem .75rem; cursor: pointer;
}
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: inline; }
}
.proto-banner { background: var(--warn-bg); border-bottom: 1px solid var(--warn-border); font-size: .9rem; padding: .4rem 0; }

/* ---- text ---- */
main { padding: 1.75rem 0 3rem; }
h1 { font-size: 1.8rem; line-height: 1.25; margin: .25rem 0 .6rem; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; line-height: 1.35; margin: 2.2rem 0 .6rem; }
h3 { font-size: 1.08rem; margin: 1.4rem 0 .4rem; }
.lead { color: var(--muted); margin-top: 0; font-size: 1.05rem; }
.updated { font-size: .88rem; color: var(--muted); }

/* ---- home ---- */
.hero {
  background: var(--soft); border: 1px solid var(--border); border-radius: 24px;
  padding: 1.5rem 1.25rem; margin: .25rem 0 1.5rem; display: grid; gap: 1rem; align-items: center;
}
@media (min-width: 40rem) { .hero { grid-template-columns: 1fr auto; padding: 2rem; } }
.hero h1 { margin-top: 0; }
.hero .lead { margin-bottom: .75rem; }
.hero-art { width: 150px; height: auto; justify-self: center; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 0; }
.chips li {
  font-size: .85rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: .2rem .7rem; color: var(--text);
}
.chips li::before { content: "✓ "; color: var(--ok); font-weight: 700; }

.cards { display: grid; gap: 1rem; grid-template-columns: 1fr; margin: 1.5rem 0; }
@media (min-width: 40rem) { .cards { grid-template-columns: 1fr 1fr 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.15rem; display: flex; flex-direction: column; box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card .icon {
  width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; margin-bottom: .6rem;
}
.card .icon svg { width: 24px; height: 24px; }
.card h2 { font-size: 1.1rem; margin: 0 0 .35rem; }
.card p { margin: 0 0 .9rem; font-size: .95rem; color: var(--muted); }
.card .go {
  margin-top: auto; font-weight: 700; text-decoration: none; align-self: flex-start;
  background: var(--accent); color: var(--accent-text); padding: .45rem 1rem; border-radius: 999px;
}
.card .go:hover { background: var(--accent-hover); color: var(--accent-text); }

/* ---- forms ---- */
form.calc, .panel {
  background: var(--soft); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.15rem; margin: 1.25rem 0;
}
fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
legend { font-weight: 700; margin-bottom: .4rem; padding: 0; }
.field { margin: 0 0 1rem; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field label .hint { font-weight: 400; }
.hint { display: block; font-size: .87rem; color: var(--muted); margin-top: .25rem; line-height: 1.5; }
input[type="number"], input[type="text"], input[type="email"], select, textarea {
  width: 100%; font: inherit; padding: .6rem .75rem;
  border: 1px solid var(--input-border); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
input[type="number"], input[type="text"], select { max-width: 22rem; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 34rem) { .row2 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; gap: .55rem; align-items: flex-start; margin: .5rem 0; }
.check input { width: 1.2rem; height: 1.2rem; margin-top: .25rem; flex: none; accent-color: var(--accent); }
.radios { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.radios label { font-weight: 400; display: inline-flex; gap: .45rem; align-items: center; }
.radios input { accent-color: var(--accent); }
button.primary {
  font: inherit; font-weight: 700; background: var(--accent); color: var(--accent-text);
  border: 0; border-radius: 999px; padding: .65rem 1.5rem; cursor: pointer;
}
button.primary:hover { background: var(--accent-hover); }
button.secondary {
  font: inherit; font-weight: 700; background: var(--surface); color: var(--accent);
  border: 2px solid var(--accent); border-radius: 999px; padding: .5rem 1.2rem; cursor: pointer;
}
button.secondary:hover { background: var(--accent-soft); }

/* ---- results ---- */
.result { margin: 1.5rem 0; }
.big { font-size: 1.6rem; font-weight: 800; margin: .2rem 0; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.summary-grid div { background: var(--accent-soft); border-radius: 14px; padding: .75rem .9rem; }
.summary-grid .k { font-size: .84rem; color: var(--muted); display: block; }
.summary-grid .v { font-size: 1.3rem; font-weight: 800; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 14px; margin: .75rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { background: var(--soft); font-size: .88rem; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 800; background: var(--accent-soft); }
caption { text-align: left; font-weight: 700; padding: .6rem .75rem .2rem; }

ol.steps { padding-left: 1.3rem; }
ol.steps li { margin: .4rem 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }

/* ---- notes: calm, rounded ---- */
.note {
  border: 1px solid var(--warn-border); background: var(--warn-bg);
  padding: .75rem 1rem; border-radius: 14px; margin: 1rem 0; font-size: .95rem;
}
.note.info { border-color: var(--info-border); background: var(--info-bg); }
.note.info strong:first-child { color: var(--info-ink); }
.privacy-top { padding-left: 2.6rem; position: relative; }
.privacy-top::before {
  content: ""; position: absolute; left: .95rem; top: .95rem; width: 1.1rem; height: 1.1rem;
  background: var(--info-ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 4 5v6c0 5 3.4 9.4 8 11 4.6-1.6 8-6 8-11V5l-8-3zm-1.2 14.2-3.5-3.5 1.4-1.4 2.1 2.1 4.6-4.6 1.4 1.4-6 6z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 4 5v6c0 5 3.4 9.4 8 11 4.6-1.6 8-6 8-11V5l-8-3zm-1.2 14.2-3.5-3.5 1.4-1.4 2.1 2.1 4.6-4.6 1.4 1.4-6 6z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.tag { display: inline-block; font-size: .76rem; font-weight: 700; padding: .05rem .5rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); vertical-align: middle; }
.tag.official { border-color: var(--ok); color: var(--ok); }
.tag.typical { border-color: var(--warn-border); color: var(--muted); background: var(--warn-bg); }

.affiliate-slot {
  border: 2px dashed var(--placeholder-border); background: var(--placeholder-bg);
  border-radius: var(--radius); padding: .9rem 1rem; margin: 1.5rem 0;
}
.affiliate-slot .slot-label { font-size: .8rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--placeholder-border); }
.affiliate-slot p { margin: .35rem 0; }
.disclosure { font-size: .88rem; color: var(--muted); }

details { margin: .75rem 0; background: var(--soft); border: 1px solid var(--border); border-radius: 12px; padding: .5rem .9rem; }
summary { cursor: pointer; font-weight: 600; }

.save-row { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; margin: 0 0 1.75rem; }
.private-note { margin: 0; font-size: .88rem; color: var(--muted); flex: 1 1 18rem; }

/* ---- footer ---- */
footer.site { background: var(--soft); border-top: 1px solid var(--border); padding: 1.5rem 0 2.25rem; font-size: .9rem; color: var(--muted); }
footer.site nav { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; margin-bottom: .5rem; }
footer.site .made { display: flex; align-items: center; gap: .4rem; }
footer.site .made svg { width: 20px; height: 20px; }

.sources td:first-child { min-width: 9rem; }
.sources td { font-size: .9rem; }
.sources a { word-break: break-all; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card:hover { transform: none; } }
@media (max-width: 39.99rem) { .hero-art { order: -1; width: 120px; } }
