:root {
  color-scheme: light;
  --bg: #f6f9ff;
  --surface: #ffffff;
  --surface-blue: #eef5ff;
  --line: #dce7f7;
  --line-strong: #bfd4ef;
  --text: #102033;
  --muted: #65758b;
  --blue: #1463ff;
  --blue-deep: #0b4fc7;
  --blue-soft: #dbe9ff;
  --green: #00a884;
  --amber: #ffb020;
  --danger: #d94841;
  --shadow: 0 18px 45px rgba(20, 82, 160, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  line-height: 1.5;
}

button,
input,
a {
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.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;
}

.hero {
  min-height: 100svh;
  padding: 18px 18px 28px;
  background:
    radial-gradient(circle at 18% 10%, rgba(20, 99, 255, 0.14), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.topbar {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.08rem;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #1463ff 0%, #6ea2ff 58%, #00a884 100%);
  box-shadow: 0 10px 22px rgba(20, 99, 255, 0.22);
}

.test-badge,
.eyebrow {
  margin: 0;
  color: var(--blue-deep);
  font-weight: 800;
  font-size: 0.78rem;
}

.test-badge {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
}

.hero-grid {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  gap: 22px;
  align-items: end;
}

.hero-copy {
  padding-top: 56px;
}

.hero h1 {
  margin: 12px 0 14px;
  font-size: 2.45rem;
  line-height: 1.12;
  font-weight: 850;
}

.hero-sub {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 650;
}

.hero-actions {
  margin-top: 28px;
}

.primary-button,
.ghost-button {
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  min-height: 54px;
  padding: 0 20px;
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 16px 32px rgba(20, 99, 255, 0.25);
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button:active,
.ghost-button:active {
  transform: translateY(0);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.compact {
  min-height: 48px;
  width: 100%;
}

.preview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  padding: 18px;
  overflow: hidden;
}

.preview-top,
.preview-meta,
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-top span,
.preview-meta,
.metric-card p,
.metric-card span,
.chart-head p,
.cta-panel p {
  color: var(--muted);
}

.preview-top strong {
  color: var(--green);
  font-size: 0.86rem;
}

.preview-age {
  margin-top: 18px;
}

.preview-age span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.preview-age strong {
  display: block;
  margin-top: 2px;
  font-size: 3.3rem;
  line-height: 1;
}

.preview-bars {
  height: 118px;
  margin: 18px 0 14px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: end;
  gap: 8px;
}

.preview-bars span {
  display: block;
  min-height: 22px;
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, #5b8cff 0%, #d8e6ff 100%);
}

.preview-meta {
  font-size: 0.85rem;
  font-weight: 750;
}

main {
  background: #ffffff;
}

.calculator {
  padding: 46px 18px 26px;
}

.section-head {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto 18px;
}

.section-head h2 {
  margin: 6px 0 0;
  font-size: 1.56rem;
  line-height: 1.24;
}

.workbench {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.input-panel,
.result-panel,
.chart-panel,
.cta-panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.input-panel {
  padding: 16px;
  display: grid;
  gap: 18px;
  box-shadow: 0 12px 34px rgba(30, 79, 145, 0.08);
}

.control-block {
  display: grid;
  gap: 10px;
}

.control-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.control-head label,
.segmented-field legend {
  color: var(--text);
  font-weight: 820;
}

.control-head small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 720;
}

output {
  color: var(--blue-deep);
  font-weight: 850;
  font-size: 1rem;
  white-space: nowrap;
}

output.editable-value {
  min-height: 44px;
  padding: 4px 2px 5px;
  border-bottom: 1px solid rgba(20, 99, 255, 0.24);
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
  line-height: 1.2;
  transition: border-color 160ms ease, background 160ms ease;
}

output.editable-value:hover {
  border-bottom-color: rgba(20, 99, 255, 0.48);
  background: rgba(238, 245, 255, 0.54);
}

output.editable-value:focus-visible {
  outline: 3px solid rgba(20, 99, 255, 0.22);
  outline-offset: 3px;
  border-radius: 6px;
}

.value-editor {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.value-editor input {
  width: min(112px, 38vw);
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--blue-deep);
  font-weight: 850;
  text-align: right;
}

.value-editor input:focus {
  outline: 3px solid rgba(20, 99, 255, 0.18);
  outline-offset: 1px;
}

.value-editor-unit {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 820;
  white-space: nowrap;
}

.budget-summary {
  margin: -2px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f0faf7;
  color: var(--green);
  font-size: 0.88rem;
  font-weight: 820;
}

.budget-summary.negative {
  background: #fff4f3;
  color: var(--danger);
}

input[type="range"] {
  width: 100%;
  height: 28px;
  margin: 0;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue) var(--fill, 50%), #e7eef9 var(--fill, 50%));
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: #e7eef9;
}

input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--blue);
}

input[type="range"]::-webkit-slider-thumb {
  width: 24px;
  height: 24px;
  margin-top: -8px;
  appearance: none;
  border: 4px solid #ffffff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 6px 18px rgba(20, 99, 255, 0.28);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 4px solid #ffffff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 6px 18px rgba(20, 99, 255, 0.28);
}

.inline-range {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.ghost-button {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--surface-blue);
  color: var(--blue-deep);
  font-weight: 800;
}

.segmented-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 10px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: 8px;
  background: #edf3fb;
}

.segmented-control label {
  min-width: 0;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  min-height: 42px;
  padding: 0 8px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 820;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.segmented-control input:checked + span {
  background: #ffffff;
  color: var(--blue-deep);
  box-shadow: 0 8px 18px rgba(32, 86, 159, 0.12);
}

.result-panel {
  padding: 0;
  border: 0;
  display: grid;
  gap: 12px;
  background: transparent;
}

.result-grid {
  display: grid;
  gap: 12px;
}

.metric-card {
  min-height: 152px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 12px 34px rgba(30, 79, 145, 0.08);
}

.primary-metric {
  background: linear-gradient(180deg, #f7fbff 0%, #eef5ff 100%);
  border-color: var(--line-strong);
}

.metric-card p,
.metric-card span {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
}

.metric-card .metric-action {
  margin-top: 8px;
  color: var(--green);
  font-weight: 850;
}

.metric-card .metric-action[hidden] {
  display: none;
}

.metric-card strong {
  display: block;
  margin: 14px 0 10px;
  font-size: 2rem;
  line-height: 1.08;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.primary-metric strong {
  color: var(--blue-deep);
  font-size: 2.45rem;
}

.chart-panel {
  padding: 16px;
  box-shadow: 0 12px 34px rgba(30, 79, 145, 0.08);
}

.chart-head {
  align-items: flex-start;
  margin-bottom: 14px;
}

.chart-head h3,
.cta-panel h3,
.modal h2 {
  margin: 0;
  line-height: 1.25;
}

.chart-head h3 {
  font-size: 1.12rem;
}

.chart-head p,
.cta-panel p {
  margin: 4px 0 0;
  font-size: 0.85rem;
  font-weight: 650;
}

#chartStatus {
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--surface-blue);
  color: var(--blue-deep);
  font-size: 0.75rem;
  font-weight: 850;
}

.chart-wrap {
  width: 100%;
  aspect-ratio: 1.45 / 1;
  min-height: 248px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.legend {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

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

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot.low {
  background: #7a8aa0;
}

.dot.base {
  background: var(--blue);
}

.dot.high {
  background: var(--green);
}

.cta-panel {
  padding: 18px;
  display: grid;
  gap: 14px;
  background: linear-gradient(135deg, #f5f9ff 0%, #ffffff 62%);
  box-shadow: 0 12px 34px rgba(30, 79, 145, 0.08);
}

.maker-note {
  padding: 8px 18px 32px;
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 650;
  background: #ffffff;
}

.assumptions {
  padding: 0 18px 28px;
  background: #ffffff;
}

.assumptions details {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbff;
}

.assumptions summary {
  min-height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  color: var(--text);
  font-weight: 840;
  cursor: pointer;
}

.assumptions ul {
  margin: 0;
  padding: 0 16px 16px 34px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.assumptions li + li {
  margin-top: 10px;
}

.assumptions a {
  color: var(--blue-deep);
  font-weight: 780;
}

.footer {
  padding: 22px 18px 30px;
  border-top: 1px solid var(--line);
  background: #f9fbff;
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 650;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: 18px;
  display: grid;
  place-items: center;
  background: rgba(12, 24, 42, 0.34);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(100%, 430px);
  position: relative;
  padding: 24px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(12, 24, 42, 0.24);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #edf3fb;
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal h2 {
  margin-top: 8px;
  font-size: 1.45rem;
}

.modal-actions {
  margin-top: 22px;
  display: grid;
  gap: 10px;
}

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

.subscribe-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.subscribe-row input {
  min-width: 0;
  min-height: 54px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-weight: 720;
}

.subscribe-row input::placeholder {
  color: var(--muted);
}

.subscribe-submit {
  min-width: 104px;
}

.subscribe-message,
.subscribe-success {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 720;
}

.subscribe-message {
  color: var(--danger);
}

.subscribe-message:empty {
  display: none;
}

.subscribe-success {
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-blue);
  color: var(--blue-deep);
}

.secondary-link {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue-deep);
  font-weight: 820;
  text-decoration: none;
}

:focus-visible {
  outline: 3px solid rgba(20, 99, 255, 0.35);
  outline-offset: 3px;
}

@media (min-width: 720px) {
  .hero {
    min-height: auto;
    padding: 22px 28px 54px;
    justify-content: flex-start;
    gap: 44px;
  }

  .hero-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    align-items: center;
  }

  .hero-copy {
    padding-top: 0;
  }

  .hero h1 {
    font-size: 3.25rem;
  }

  .hero-sub {
    font-size: 1.18rem;
  }

  .calculator {
    padding: 58px 28px 32px;
  }

  .workbench {
    grid-template-columns: 370px minmax(0, 1fr);
    align-items: start;
  }

  .input-panel {
    position: sticky;
    top: 20px;
  }

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

  .metric-card strong {
    font-size: 1.75rem;
  }

  .primary-metric strong {
    font-size: 2.15rem;
  }

  .cta-panel {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .compact {
    width: auto;
  }
}

@media (max-width: 420px) {
  .subscribe-row {
    grid-template-columns: 1fr;
  }

  .subscribe-submit {
    width: 100%;
  }
}

@media (min-width: 1040px) {
  .hero h1 {
    font-size: 4rem;
  }

  .primary-metric strong {
    font-size: 2.45rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
