:root {
  --bg: #f5f3ee;
  --card: #ffffff;
  --text: #1d1c1a;
  --muted: #68655e;
  --line: #e2ded5;
  --field: #faf9f6;
  --accent: #0d6b54;
  --accent-soft: #e3f1ec;
  --income-tax: #c4553b;
  --resident-tax: #d6962a;
  --warn-soft: #fbeee9;
  --warn: #a8432b;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131311;
    --card: #1d1c19;
    --text: #edebe5;
    --muted: #a39f96;
    --line: #33312c;
    --field: #252420;
    --accent: #55c9a6;
    --accent-soft: #17332b;
    --income-tax: #e27e63;
    --resident-tax: #e8b85a;
    --warn-soft: #3a211b;
    --warn: #f0a08a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

h1, h2, p, ul, dl, dd { margin: 0; }

.site-header {
  max-width: 1040px;
  margin: 0 auto;
  padding: 40px 16px 24px;
}

.eyebrow {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

h1 {
  margin-top: 12px;
  font-size: clamp(26px, 6vw, 36px);
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.lead {
  margin-top: 8px;
  color: var(--muted);
  max-width: 34em;
}

.layout {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px 48px;
  display: grid;
  gap: 16px;
}

.results { display: grid; gap: 16px; }

/* グリッドの子は既定で中身より縮まないので、表が画面幅を押し広げないようにする */
.layout > *, .results > * { min-width: 0; }

@media (min-width: 880px) {
  .layout { grid-template-columns: 340px minmax(0, 1fr); align-items: start; gap: 24px; }
  .inputs { position: sticky; top: 16px; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

h2 {
  font-size: 17px;
  line-height: 1.4;
  margin-bottom: 14px;
}

/* 入力 */
.field + .field, .advanced, .advanced .field { margin-top: 16px; }

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
}

/* .input-wrap の display:flex が hidden 属性を打ち消さないようにする */
[hidden] { display: none !important; }

.select-wrap { position: relative; }

.select-wrap::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: inherit;
  font: inherit;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 10px 40px 10px 12px;
  cursor: pointer;
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#salaryCustom { margin-top: 8px; }

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="number"] {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 10px 0;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input::placeholder { color: var(--muted); font-weight: 400; font-size: 15px; }

.unit { color: var(--muted); font-size: 14px; white-space: nowrap; }

.hint { margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.6; }

.advanced {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.advanced summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

/* 結果 */
.hero-label { color: var(--muted); font-size: 14px; font-weight: 600; }

.hero-value {
  margin-top: 2px;
  color: var(--accent);
  font-size: clamp(40px, 11vw, 60px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.hero-sub { margin-top: 6px; color: var(--muted); font-size: 14px; }

.bar {
  display: flex;
  gap: 2px;
  height: 14px;
  margin-top: 20px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}

.seg { min-width: 4px; }
.seg-net, .dot-net { background: var(--accent); }
.seg-resident, .dot-resident { background: var(--resident-tax); }
.seg-income, .dot-income { background: var(--income-tax); }
.dot-total { background: transparent; }

.breakdown { margin-top: 14px; }

.breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 15px;
}

.breakdown-row:first-child { border-top: 0; font-weight: 600; }

.breakdown dt { display: flex; align-items: center; gap: 8px; }
.breakdown dd { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* 確定申告の判定 */
.status-label { color: var(--muted); font-size: 14px; font-weight: 600; }
.status-title { margin-top: 2px; font-size: 22px; font-weight: 700; line-height: 1.4; }
.status-body { margin-top: 6px; font-size: 15px; }

.status[data-tone="required"] { background: var(--warn-soft); border-color: transparent; }
.status[data-tone="required"] .status-title { color: var(--warn); }
.status[data-tone="ok"] { background: var(--accent-soft); border-color: transparent; }
.status[data-tone="ok"] .status-title { color: var(--accent); }

.notices, .assumptions ul { padding-left: 1.2em; }
.notices li + li, .assumptions li + li { margin-top: 8px; }
.notices { font-size: 15px; }

/* 逆算 */
.inline-field .input-wrap { max-width: 220px; }
.reverse { margin-top: 14px; font-size: 15px; }
.reverse strong { color: var(--accent); font-size: 20px; font-variant-numeric: tabular-nums; }
.reverse-note { display: block; margin-top: 6px; color: var(--muted); font-size: 14px; }

/* 早見表 */
.table-caption { margin: -8px 0 10px; color: var(--muted); font-size: 14px; }
.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 10px 8px;
  text-align: right;
  border-top: 1px solid var(--line);
  white-space: nowrap;
}

thead th { border-top: 0; color: var(--muted); font-size: 13px; font-weight: 600; }

@media (max-width: 480px) {
  table { font-size: 14px; }
  th, td { padding: 10px 4px; }
  thead th { font-size: 12px; }
}
th:first-child { text-align: left; }
tbody th { font-weight: 600; }
td.strong { color: var(--accent); font-weight: 700; }
tr.current th, tr.current td { background: var(--accent-soft); }
.table-note { margin-top: 10px; color: var(--muted); font-size: 13px; }

/* 前提 */
.assumptions { color: var(--muted); font-size: 14px; }
.assumptions h2 { color: var(--text); }
.sources { margin-top: 14px; font-size: 13px; }

.privacy-note {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* このサイトについて */
.back { font-size: 14px; }

.prose {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 32px;
  display: grid;
  gap: 16px;
  font-size: 15px;
}

.site-header:has(+ .prose), .prose + .site-footer { max-width: 720px; }

.prose h3 { margin: 16px 0 4px; font-size: 15px; }
.prose ul { padding-left: 1.2em; }
.prose li + li { margin-top: 8px; }
.prose p + p { margin-top: 10px; }

.info { margin-bottom: 12px; }
.info > div { display: flex; gap: 16px; padding: 8px 0; border-top: 1px solid var(--line); }
.info > div:first-child { border-top: 0; }
.info dt { flex: none; width: 5em; color: var(--muted); }
.info dd { overflow-wrap: anywhere; }

.site-footer p + p { margin-top: 4px; }

a { color: var(--accent); }

.site-footer {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px 40px;
  color: var(--muted);
  font-size: 13px;
}
