:root {
  --ink: #1d1d1f;
  --soft-ink: #424245;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --surface: #ffffff;
  --wash: #f5f5f7;
  --blue: #0071e3;
  --green: #188038;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--wash);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.topbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
}

.brand img {
  width: 104px;
  display: block;
}

.source-chip {
  color: var(--soft-ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 650;
}

.intro-panel {
  padding: 46px 0 26px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 14px;
  font-size: clamp(2.35rem, 6vw, 4.8rem);
  line-height: 1.02;
  font-weight: 800;
  white-space: normal;
}

.lead {
  max-width: 720px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
  line-height: 1.58;
}

.scenario-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.scenario,
.control-panel,
.result-card,
.explain-band,
.source-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.scenario {
  min-height: 78px;
  padding: 16px;
  color: var(--ink);
  text-align: left;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.scenario span,
.result-card span,
.formula-list span,
.control-label span {
  display: block;
  color: var(--muted);
}

.scenario strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
}

.scenario:hover,
.scenario.is-active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
  transform: translateY(-1px);
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(330px, 0.84fr) minmax(0, 1.16fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.result-panel,
.result-card,
.explain-band,
.source-band {
  min-width: 0;
}

.control-panel {
  position: sticky;
  top: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.panel-heading h2,
.result-hero h2,
.explain-main h3 {
  margin-bottom: 0;
  line-height: 1.12;
}

.panel-heading h2 {
  font-size: 1.45rem;
}

.control-group {
  margin-top: 22px;
}

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

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

.control-label strong {
  color: var(--ink);
  font-size: 1rem;
  text-align: right;
}

.derived-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfbfd;
}

.derived-note span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.derived-note strong {
  color: var(--ink);
  font-size: 1rem;
  text-align: right;
}

.select-control {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfd;
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 750;
}

.select-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
  outline: none;
}

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

.range-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.range-meta strong {
  color: var(--soft-ink);
  font-size: 0.88rem;
}

.segmented,
.choice-grid,
.mini-grid {
  display: grid;
  gap: 8px;
}

.segmented {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f1f3;
}

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

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

.segmented button,
.choice-grid button,
.mini-grid button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--soft-ink);
  padding: 8px 10px;
  font-weight: 750;
}

.choice-grid button,
.mini-grid button {
  border-color: var(--line);
  background: #fbfbfd;
}

.segmented button.is-active,
.choice-grid button.is-active,
.mini-grid button.is-active {
  border-color: var(--blue);
  background: #fff;
  color: var(--blue);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.number-control {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfd;
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 750;
}

.number-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
  outline: none;
}

.divider {
  height: 1px;
  margin-top: 24px;
  background: var(--line);
}

.result-panel {
  display: grid;
  gap: 18px;
}

.result-hero {
  min-height: 136px;
  display: flex;
  flex-direction: column;
  justify-content: end;
  padding: 20px 2px 4px;
}

.result-hero h2 {
  max-width: none;
  font-size: clamp(2.15rem, 3.25vw, 3.1rem);
  white-space: nowrap;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.result-card {
  container-type: inline-size;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 26px;
  box-shadow: var(--shadow);
}

.result-card strong {
  display: block;
  margin: 18px 0;
  max-width: 100%;
  font-size: clamp(2.35rem, 19cqw, 4.2rem);
  line-height: 0.98;
  letter-spacing: 0;
  white-space: nowrap;
}

.result-card p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.annuity-card strong {
  color: var(--blue);
}

.lump-card strong {
  color: var(--green);
  font-size: clamp(2.35rem, 18cqw, 4rem);
}

.explain-band {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.explain-main h3 {
  margin-bottom: 10px;
  font-size: 1.45rem;
}

.explain-main p {
  margin: 0;
  color: var(--soft-ink);
  font-size: 1.06rem;
  line-height: 1.72;
}

.formula-list {
  display: grid;
  gap: 10px;
}

.formula-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfbfd;
}

.formula-list strong {
  text-align: right;
}

.source-band {
  padding: 16px 18px;
}

.source-band p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.62;
}

.projection-panel {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

.projection-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.projection-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.12;
}

.projection-heading p:last-child {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}

.projection-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.projection-control {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.projection-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.projection-stats > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.projection-stats > div > span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.projection-stats > div > strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  line-height: 1.05;
}

.projection-income-range {
  margin-top: 12px;
}

.projection-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.projection-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.projection-table th,
.projection-table td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: right;
  white-space: nowrap;
}

.projection-table th {
  color: var(--muted);
  background: #fbfbfd;
  font-size: 0.88rem;
  font-weight: 800;
}

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

.projection-table tbody tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 980px) {
  .tool-grid,
  .explain-band {
    grid-template-columns: 1fr;
  }

  .projection-heading,
  .projection-control-grid,
  .projection-stats {
    grid-template-columns: 1fr;
  }

  .projection-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .projection-heading p:last-child {
    text-align: left;
  }

  .control-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 24px, 560px);
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .intro-panel {
    padding-top: 30px;
  }

  .scenario-row,
  .result-grid,
  .choice-grid,
  .mini-grid {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: 1fr;
  }

  .result-card {
    min-height: 210px;
  }

  .result-hero h2 {
    white-space: normal;
  }

  .control-label {
    align-items: flex-start;
    flex-direction: column;
  }

  .derived-note {
    align-items: flex-start;
    flex-direction: column;
  }
}
