:root {
  --color-primary: #399aa0;
  --color-primary-dark: #247078;
  --color-primary-light: #e8f6f5;
  --color-accent: #f0b65b;
  --color-warning: #e96e61;
  --color-danger: #c84e43;
  --color-bg: #f8fcfb;
  --color-surface: #ffffff;
  --color-text: #263238;
  --color-muted: #637579;
  --color-border: #d6eaec;
  --shadow-soft: 0 20px 60px rgba(42, 85, 88, 0.12);
  font-family:
    "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(232, 246, 245, 0.72), transparent 360px),
    var(--color-bg);
  color: var(--color-text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.top-screen,
.panel-page,
.result-page {
  display: grid;
  gap: 24px;
}

.hero,
.result-hero,
.step-card,
.chart-card,
.timeline-card,
.talk-card,
.hint-card,
.article-card,
.table-card,
.summary-card,
.validation-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.hero {
  min-height: 420px;
  padding: clamp(32px, 7vw, 72px);
  display: grid;
  align-content: center;
  gap: 18px;
}

.eyebrow {
  margin: 0;
  color: var(--color-primary);
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 1.12;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
}

h3 {
  margin-bottom: 8px;
}

.hero-copy,
.lead,
.muted,
.chart-note,
.disclaimer {
  color: var(--color-muted);
  line-height: 1.8;
}

.hero-copy {
  max-width: 660px;
  font-size: 1.04rem;
}

.button {
  min-height: 48px;
  padding: 0 20px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
}

.button-primary {
  color: white;
  background: var(--color-primary);
}

.button-primary:hover {
  background: var(--color-primary-dark);
}

.button-secondary {
  color: var(--color-primary-dark);
  background: white;
  border-color: var(--color-border);
}

.button-ghost {
  color: var(--color-muted);
  background: transparent;
  border-color: var(--color-border);
}

.button-row {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.feature-grid,
.summary-grid,
.kpi-grid,
.article-grid {
  display: grid;
  gap: 16px;
}

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

.feature-grid article,
.kpi-card,
.article-grid a {
  padding: 20px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}

.feature-grid span,
.kpi-card span,
.article-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--color-primary);
  font-size: 0.82rem;
  font-weight: 700;
}

.timeline-card,
.chart-card,
.talk-card,
.hint-card,
.article-card,
.table-card,
.result-hero,
.step-card {
  padding: clamp(20px, 4vw, 32px);
}

.timeline-card.compact {
  box-shadow: none;
  margin-top: 20px;
}

.timeline {
  position: relative;
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--color-border);
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: start;
  padding-left: 34px;
  min-height: 32px;
}

.timeline-item strong {
  color: var(--color-primary-dark);
}

.timeline-item small {
  grid-column: 2 / -1;
  color: var(--color-muted);
}

.timeline-item button {
  border: none;
  background: transparent;
  color: var(--color-muted);
  text-decoration: underline;
}

.timeline-dot {
  position: absolute;
  left: 2px;
  top: 6px;
  z-index: 1;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--color-primary);
  box-shadow: 0 0 0 4px white;
}

.category-housing,
.category-car {
  background: var(--color-warning);
}

.category-education {
  background: var(--color-accent);
}

.category-retirement {
  background: #7e8bd4;
}

.step-progress {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.step-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-muted);
  background: white;
  font-size: 0.9rem;
  font-weight: 700;
}

.step-pill span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 0.76rem;
}

.step-pill.active {
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
}

.form-grid,
.event-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.form-field {
  display: grid;
  gap: 8px;
}

.form-field.full,
.full {
  grid-column: 1 / -1;
}

.form-field label,
.form-field > span {
  font-weight: 700;
}

.form-field input,
.form-field select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: white;
  color: var(--color-text);
}

.form-field small {
  color: var(--color-muted);
  line-height: 1.6;
}

.number-control {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: stretch;
}

.number-control > button {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-size: 1.25rem;
  font-weight: 700;
}

.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 48px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.input-with-unit input {
  border: 0;
  height: 46px;
  min-width: 0;
}

.input-with-unit em {
  padding: 0 12px 0 8px;
  color: var(--color-muted);
  font-style: normal;
  font-size: 0.9rem;
  white-space: nowrap;
}

.template-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.template-list button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: 700;
}

.validation-box {
  box-shadow: none;
  padding: 18px 20px;
}

.validation-box p {
  margin: 0;
}

.validation-box p + p {
  margin-top: 8px;
}

.error-text {
  color: var(--color-danger);
}

.warning-text {
  color: #8b5f14;
}

.summary-grid,
.kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  box-shadow: none;
}

.summary-card button {
  align-self: start;
  border: none;
  background: transparent;
  color: var(--color-primary);
  text-decoration: underline;
}

.result-hero {
  background: linear-gradient(135deg, white, var(--color-primary-light));
}

.kpi-card strong {
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
}

.section-heading strong {
  font-size: 1.6rem;
  color: var(--color-primary-dark);
}

.chart-card svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: #edf4f4;
  stroke-width: 1;
  pointer-events: none;
}

.positive-zone {
  fill: rgba(57, 154, 160, 0.08);
  pointer-events: none;
}

.negative-zone {
  fill: rgba(233, 110, 97, 0.1);
  pointer-events: none;
}

.chart-zero {
  stroke: var(--color-warning);
  stroke-dasharray: 6 8;
  stroke-width: 2;
  pointer-events: none;
}

.asset-path {
  stroke: var(--color-primary);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.asset-point {
  fill: white;
  stroke: var(--color-primary);
  stroke-width: 2;
  pointer-events: none;
}

.event-marker {
  fill: var(--color-warning);
  stroke: white;
  stroke-width: 3;
  pointer-events: all;
}

.event-tooltip,
.axis-label,
.axis-tick,
.zero-label {
  fill: var(--color-muted);
  font-size: 13px;
  pointer-events: none;
}

.axis-label {
  font-weight: 700;
}

.zero-label {
  fill: var(--color-warning);
  font-weight: 700;
}

.y-axis-tick {
  text-anchor: end;
}

.event-marker-group {
  outline: none;
}

.event-tooltip {
  pointer-events: none;
  opacity: 0;
  paint-order: stroke;
  stroke: white;
  stroke-width: 5px;
  stroke-linejoin: round;
  font-weight: 700;
}

.event-marker-group:hover .event-tooltip,
.event-marker-group:focus .event-tooltip {
  opacity: 1;
}

.result-two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.talk-list {
  display: grid;
  gap: 12px;
}

.talk-item {
  padding: 16px;
  border-left: 4px solid var(--color-primary);
  border-radius: 8px;
  background: var(--color-primary-light);
}

.talk-item p {
  margin-bottom: 0;
  color: var(--color-muted);
}

.level-warning {
  border-left-color: var(--color-accent);
  background: #fff8e9;
}

.level-danger {
  border-left-color: var(--color-danger);
  background: #fff1ef;
}

.hint-card ul {
  margin: 0;
  padding-left: 1.4rem;
  line-height: 1.9;
}

.article-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.article-grid strong {
  display: block;
  margin-bottom: 8px;
}

.article-grid p {
  color: var(--color-muted);
  margin-bottom: 0;
  line-height: 1.6;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--color-border);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--color-muted);
  font-size: 0.84rem;
}

.row-warning {
  background: #fffaf0;
}

.row-danger {
  background: #fff1ef;
}

.disclaimer {
  margin: 0;
  padding: 18px 20px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.88rem;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 640px);
    padding-top: 16px;
  }

  .feature-grid,
  .summary-grid,
  .kpi-grid,
  .article-grid,
  .result-two-column,
  .form-grid,
  .event-form {
    grid-template-columns: 1fr;
  }

  .step-progress {
    grid-template-columns: 1fr;
  }

  .step-pill {
    justify-content: flex-start;
    padding: 0 12px;
  }

  .timeline-item {
    grid-template-columns: 76px 1fr auto auto;
  }

  .timeline-item button {
    grid-column: 2;
    justify-self: start;
  }

  .button-row {
    justify-content: stretch;
  }

  .button-row .button {
    flex: 1 1 150px;
  }
}
