:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #1e3a5f;
  --primary-hover: #162c49;
  --primary-soft: #e8eff7;
  --accent: #c84b31;
  --accent-soft: #fdf0ed;
  --success: #157f56;
  --success-soft: #e6f6ef;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.07);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --max-width: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #131c31;
    --surface-alt: #1b2640;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #24324d;
    --border-strong: #36496b;
    --primary: #60a5fa;
    --primary-hover: #93c5fd;
    --primary-soft: rgba(96, 165, 250, 0.14);
    --accent: #f87171;
    --accent-soft: rgba(248, 113, 113, 0.14);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.14);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: clip;
}

a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--primary-hover);
}

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

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

/* Header & Navigation */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand:hover {
  color: var(--primary);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #1e3a5f;
  color: #ffffff;
  font-weight: 800;
  font-size: 1.05rem;
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c84b31;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.site-nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Main Layout */
main {
  flex: 1;
  padding: 28px 0 56px;
}

.breadcrumbs {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
  color: var(--primary);
}

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(1.65rem, 3.6vw, 2.35rem);
  line-height: 1.18;
  letter-spacing: -0.025em;
}

h2 {
  margin: 0 0 12px;
  font-size: clamp(1.2rem, 2.2vw, 1.45rem);
  line-height: 1.25;
  letter-spacing: -0.015em;
}

h3 {
  margin: 0 0 8px;
  font-size: 1.02rem;
  line-height: 1.3;
}

.lead {
  margin: 0;
  font-size: 1.02rem;
  color: var(--text-muted);
  max-width: 68ch;
}

.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.meta-strip span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 24px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.tool-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.tool-card--soon {
  opacity: 0.85;
  border-style: dashed;
}

.tool-card--soon:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}

.badge--live {
  background: var(--success-soft);
  color: var(--success);
}

.badge--soon {
  background: var(--surface-alt);
  color: var(--text-muted);
}

.badge--new {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn--primary {
  background: var(--primary);
  color: #ffffff;
}

@media (prefers-color-scheme: dark) {
  .btn--primary {
    color: #0b1120;
  }
}

.btn--primary:hover {
  background: var(--primary-hover);
  color: #ffffff;
}

@media (prefers-color-scheme: dark) {
  .btn--primary:hover {
    color: #0b1120;
  }
}

.btn--ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn--ghost:hover {
  background: var(--surface-alt);
  color: var(--text);
}

/* Calculator Workspace */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

.control-group {
  margin-bottom: 20px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.control-label {
  font-weight: 700;
  font-size: 0.95rem;
}

.control-value {
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary);
}

.control-hint {
  margin: 6px 0 0;
  font-size: 0.83rem;
  color: var(--text-muted);
}

/* Stepper & Slider */
.stepper-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stepper-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.stepper-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

input[type="range"] {
  width: 100%;
  height: 6px;
  accent-color: var(--primary);
  cursor: pointer;
}

.range-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Number Input with Yen Prefix */
.input-prefix-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
}

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

.input-prefix {
  padding: 0 12px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-muted);
  background: var(--surface-alt);
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  border-right: 1px solid var(--border);
}

.input-number {
  width: 100%;
  min-height: 46px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  padding: 8px 12px;
  font-family: inherit;
}

.input-number:focus {
  outline: none;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip-btn {
  min-height: 36px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.chip-btn:hover,
.chip-btn[aria-pressed="true"] {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* Segmented Radio Options */
.option-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.option-grid--2 {
  grid-template-columns: repeat(2, 1fr);
}

.option-grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.option-card {
  position: relative;
}

.option-card input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.option-card label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.option-card input:checked + label {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.option-card input:focus-visible + label {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.option-title {
  font-weight: 700;
  font-size: 0.9rem;
}

.option-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* Result Panel */
.result-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-hero {
  background: linear-gradient(135deg, #1e3a5f 0%, #142742 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-md);
}

.result-hero--warn {
  background: linear-gradient(135deg, #7c2d12 0%, #431407 100%);
}

.result-hero__label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.result-hero__figure {
  font-size: clamp(1.75rem, 4.5vw, 2.5rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.result-hero__sub {
  margin: 0;
  font-size: 0.92rem;
  color: #e2e8f0;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 16px;
}

.stat-box__label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.stat-box__value {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.stat-box__note {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 0;
}

/* Breakdown Visual Bar */
.bar-track {
  display: flex;
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-alt);
  margin: 12px 0;
}

.bar-seg {
  height: 100%;
  transition: width 0.2s ease;
}

.bar-seg--primary {
  background: var(--primary);
}

.bar-seg--success {
  background: var(--success);
}

.bar-seg--accent {
  background: var(--accent);
}

.bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  font-size: 0.84rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.compare-banner {
  background: var(--primary-soft);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.88rem;
}

/* Scenarios & Checklist */
.scenario-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scenario-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--surface);
}

.scenario-item--highlight {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.scenario-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.scenario-title {
  font-weight: 700;
  font-size: 0.93rem;
}

.scenario-cost {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
}

.scenario-detail {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checklist-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.checklist-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--success);
  flex-shrink: 0;
  cursor: pointer;
}

.checklist-item.is-done {
  background: var(--success-soft);
  border-color: var(--success);
}

.checklist-title {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
}

.checklist-detail {
  display: block;
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Monetization Slots (Hidden by default until config.json enables them) */
.monetization-slot[hidden] {
  display: none !important;
}

.partner-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.partner-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.partner-disclosure {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.ad-slot-box {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--surface-alt);
}

/* Disclaimer & Info Sections */
.disclaimer-box {
  margin-top: 12px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  border: 1px solid var(--warning);
  font-size: 0.86rem;
}

.content-section {
  margin-top: 32px;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

details.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

details.faq-item summary {
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

details.faq-item summary::-webkit-details-marker {
  display: none;
}

details.faq-item summary::after {
  content: "+";
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
}

details.faq-item[open] summary::after {
  content: "−";
}

details.faq-item p {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.93rem;
}

/* Methodology Tables */
.table-wrap {
  overflow-x: auto;
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--surface-alt);
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.formula-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 12px 0;
}

.source-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0;
  list-style: none;
}

.source-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.source-item p {
  margin: 6px 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 28px 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.privacy-note {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.84rem;
}

/* Responsive Breakpoints */
@media (max-width: 440px) {
  .option-grid--3 {
    gap: 6px;
  }

  .option-grid--3 .option-card label {
    padding: 9px 7px;
  }

  .option-grid--3 .option-title {
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .option-grid--3 .option-sub {
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .btn {
    font-size: 0.9rem;
    padding: 10px 14px;
  }

  table {
    font-size: 0.78rem;
  }

  th,
  td {
    padding: 8px 7px;
  }
}

@media (min-width: 640px) {
  .container {
    padding: 0 24px;
  }

  .tool-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .scenario-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .calc-layout {
    grid-template-columns: minmax(320px, 410px) 1fr;
    gap: 24px;
  }

  .calc-controls {
    position: sticky;
    top: 76px;
  }

  .footer-grid {
    grid-template-columns: 2fr 1fr;
    align-items: start;
  }
}
