:root {
  color-scheme: light;
  --page: #f8fafc;
  --surface: #fff;
  --surface-soft: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #14b8a6;
  --brand-strong: #0d9488;
  --brand-deep: #0f766e;
  --brand-soft: rgba(20, 184, 166, .09);
  --on-brand: #fff;
  --placeholder: #94a3b8;
  --switch-knob: #fff;
  --danger-border: #fecaca;
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --shadow: 0 8px 26px rgba(15, 23, 42, .06);
  --brand-glow: rgba(20, 184, 166, .2);
  --radius: 18px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b1120;
  --surface: #101a2e;
  --surface-soft: #16223a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --line: #26354a;
  --brand: #2dd4bf;
  --brand-strong: #14b8a6;
  --brand-deep: #2dd4bf;
  --brand-soft: rgba(45, 212, 191, .1);
  --on-brand: #fff;
  --placeholder: #64748b;
  --switch-knob: #e2e8f0;
  --danger-border: #7f1d1d;
  --danger-bg: #351c27;
  --danger-text: #fecaca;
  --shadow: 0 12px 30px rgba(0, 0, 0, .2);
  --brand-glow: rgba(45, 212, 191, .24);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--brand-strong); outline-offset: 3px; }

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

.page-shell {
  width: min(100% - 48px, 1180px);
  margin: 0 auto;
  padding: 44px 0 64px;
  flex: 1;
}
.hero { max-width: 780px; margin: 0 auto 30px; text-align: center; }
.eyebrow { margin: 0 0 7px; color: var(--brand-deep); font-size: .72rem; font-weight: 800; letter-spacing: .12em; }
.hero h1 { margin: 0; font-size: clamp(1.75rem, 3.4vw, 2.4rem); line-height: 1.15; letter-spacing: -.035em; text-wrap: balance; }
.hero > p:not(.eyebrow) { max-width: 680px; margin: 10px auto 0; color: var(--muted); font-size: 1rem; text-wrap: balance; }
.privacy-note {
  width: fit-content;
  max-width: 100%;
  margin: 18px auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: .82rem;
}
.privacy-note svg,
.summary-note svg {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: var(--brand-deep);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, .92fr);
  align-items: start;
  gap: 20px;
}
.input-column { display: grid; gap: 16px; min-width: 0; }
.panel,
.summary-panel,
.content-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel { padding: clamp(18px, 2.8vw, 24px); }
.panel-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 19px; }
.step-number {
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: .75rem;
  font-weight: 800;
}
.panel-heading h2,
.summary-heading h2 { margin: 0; font-size: 1.12rem; letter-spacing: -.02em; }
.panel-heading p { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }

.field { margin-bottom: 16px; }
.field-label { display: block; margin-bottom: 7px; font-size: .84rem; font-weight: 700; }
.field input {
  width: 100%;
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--page);
  color: var(--text);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.field input::placeholder { color: var(--placeholder); opacity: .8; }
.field input:hover { border-color: var(--brand); }
.field input:focus {
  border-color: var(--brand-strong);
  outline: 0;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field input[aria-invalid="true"] { border-color: var(--danger-text); }
.field-help { margin: 7px 0 0; color: var(--muted); font-size: .78rem; }

.dob-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.dob-field .field-label { margin-bottom: 9px; padding: 0; }
.dob-grid { display: grid; grid-template-columns: 88px minmax(0, 1fr) 100px; gap: 9px; }
.dob-part { min-width: 0; }
.dob-sublabel { display: block; margin-bottom: 5px; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .02em; }
.dob-grid select,
.dob-grid input {
  width: 100%;
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background-color: var(--page);
  color: var(--text);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.dob-grid select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  cursor: pointer;
}
.dob-grid select:hover,
.dob-grid input:hover { border-color: var(--brand); }
.dob-grid select:focus,
.dob-grid input:focus {
  border-color: var(--brand-strong);
  outline: 0;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.dob-grid [aria-invalid="true"] { border-color: var(--danger-text); }
.dob-grid input::-webkit-outer-spin-button,
.dob-grid input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dob-grid input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.quick-hint {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--page);
}
.quick-hint svg { width: 17px; height: 17px; flex: none; margin-top: 2px; fill: none; stroke: var(--brand-deep); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.quick-hint p { margin: 0; color: var(--muted); font-size: .78rem; }
.quick-hint + .field { margin-top: 16px; }

.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--page);
  cursor: pointer;
  user-select: none;
  transition: border-color .16s ease, background-color .16s ease;
}
.switch-row:hover { border-color: var(--brand); }
.switch-row input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  flex: none;
  margin-top: 1px;
  border-radius: 999px;
  background: var(--line);
  transition: background-color .2s ease;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--switch-knob);
  box-shadow: 0 1px 3px var(--brand-glow);
  transition: transform .2s ease;
}
.switch-row input:checked + .switch-track { background: var(--brand-strong); }
.switch-row input:checked + .switch-track::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch-track { outline: 3px solid var(--brand-strong); outline-offset: 3px; }
.switch-copy { display: grid; gap: 2px; }
.switch-copy strong { font-size: .88rem; line-height: 1.4; }
.switch-copy small { color: var(--muted); font-size: .76rem; line-height: 1.5; }
.target-field { margin: 16px 0 0; }

.input-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--danger-border);
  border-radius: 11px;
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: .84rem;
}
.input-error svg { width: 17px; height: 17px; flex: none; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.form-actions { display: flex; gap: 9px; margin-top: 18px; }
.form-actions .btn-primary { flex: 1.35; }
.form-actions .btn-outline { flex: 1; }
.actions-note { text-align: center; }

.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-size: .84rem;
  font-weight: 750;
  transition: transform .16s ease, background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: linear-gradient(135deg, var(--brand-deep), var(--brand)); color: var(--on-brand); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 7px 17px var(--brand-glow); }
.btn-outline { border-color: var(--line); background: var(--surface); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-deep); }

.summary-panel {
  position: sticky;
  top: 18px;
  scroll-margin-top: 18px;
  padding: clamp(18px, 2.8vw, 25px);
}
.summary-heading { margin-bottom: 16px; }
.summary-heading .eyebrow { margin-bottom: 4px; }
.summary-heading h2 { font-size: 1.3rem; }
.summary-period { margin: 4px 0 0; color: var(--muted); font-size: .82rem; min-height: 1.3em; }
.result-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 30px 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--page);
  text-align: center;
}
.empty-icon { display: grid; width: 50px; height: 50px; place-items: center; border-radius: 15px; background: var(--brand-soft); color: var(--brand-deep); }
.empty-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.result-empty h3 { margin: 4px 0 0; font-size: .95rem; }
.result-empty p { max-width: 290px; margin: 0; color: var(--muted); font-size: .82rem; }
.result-body { display: grid; gap: 12px; }
.age-hero {
  padding: 22px 16px 19px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(145deg, var(--surface), var(--brand-soft));
  text-align: center;
}
.age-main { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.age-number {
  color: var(--brand-deep);
  font-size: clamp(3.1rem, 9vw, 4.4rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.06em;
  font-variant-numeric: tabular-nums;
}
.age-years-label { color: var(--muted); font-size: 1rem; font-weight: 650; }
.age-secondary {
  margin: 6px 0 0;
  color: var(--text);
  font-size: .95rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.age-dot { margin: 0 4px; color: var(--muted); }

.breakdown-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.breakdown-cell {
  min-width: 0;
  padding: 11px 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--page);
  text-align: center;
}
.breakdown-value {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(.9rem, 2.5vw, 1.02rem);
  font-weight: 750;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.breakdown-label { display: block; margin-top: 2px; color: var(--muted); font-size: .62rem; font-weight: 650; letter-spacing: .02em; }
.live-value { color: var(--brand-deep); }
.live-dot { display: inline-block; width: 5px; height: 5px; margin-left: 2px; border-radius: 50%; background: var(--brand-strong); vertical-align: middle; animation: live-pulse 2s ease-in-out infinite; }
.live-note { margin: -2px 0 0; color: var(--muted); font-size: .72rem; text-align: center; }
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--brand-glow); }
  50% { box-shadow: 0 0 0 4px transparent; }
}

.birthday-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--page);
}
.birthday-header { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; color: var(--muted); font-size: .72rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.birthday-header svg { width: 17px; height: 17px; fill: none; stroke: var(--brand-deep); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.birthday-days { display: flex; align-items: baseline; gap: 7px; margin: 0; }
.birthday-days strong { color: var(--brand-deep); font-size: 1.8rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.birthday-days span { color: var(--text); font-size: .84rem; font-weight: 650; }
.birthday-date { margin: 4px 0 0; color: var(--muted); font-size: .8rem; }

.detail-list { display: grid; gap: 0; padding: 4px 14px; border: 1px solid var(--line); border-radius: 13px; }
.detail-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 0; font-size: .82rem; }
.detail-row + .detail-row { border-top: 1px solid var(--line); }
.detail-row span { color: var(--muted); }
.detail-row strong { text-align: right; font-weight: 700; }

.copy-btn { width: 100%; margin-top: 14px; }
.copy-status { min-height: 1.2em; margin: 7px 0 0; color: var(--brand-deep); font-size: .76rem; text-align: center; }
.summary-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .72rem;
  text-align: center;
}
.summary-note svg { width: 14px; height: 14px; }

.content-section { margin-top: 24px; padding: clamp(20px, 3vw, 28px); }
.section-heading { margin-bottom: 17px; }
.section-heading .eyebrow { margin-bottom: 4px; }
.section-heading h2 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.6rem); letter-spacing: -.03em; }
.steps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.steps-grid li { display: flex; gap: 11px; padding: 14px; border-radius: 13px; background: var(--page); }
.steps-grid li > span { color: var(--brand-deep); font-size: .74rem; font-weight: 800; }
.steps-grid h3 { margin: 0 0 4px; font-size: .89rem; }
.steps-grid p, .faq-section details p { margin: 0; color: var(--muted); font-size: .83rem; }
.faq-section details { border-top: 1px solid var(--line); }
.faq-section summary { padding: 13px 2px; cursor: pointer; font-weight: 700; }
.faq-section details p { padding: 0 2px 14px; }
.faq-section summary::marker { color: var(--brand-deep); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(310px, .9fr); gap: 14px; }
  .summary-panel { top: 12px; }
  .steps-grid { grid-template-columns: 1fr; }
  .breakdown-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .page-shell { width: min(100% - 32px, 560px); padding-top: 32px; }
  .workspace { grid-template-columns: 1fr; }
  .summary-panel { position: static; }
  .breakdown-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 440px) {
  .page-shell { width: min(100% - 24px, 400px); padding-top: 25px; }
  .dob-grid { grid-template-columns: 72px minmax(0, 1fr) 84px; gap: 7px; }
  .hero { margin-bottom: 22px; }
  .hero > p:not(.eyebrow) { font-size: .96rem; }
  .privacy-note { align-items: flex-start; border-radius: 12px; font-size: .76rem; }
  .panel, .summary-panel { padding: 17px; }
  .form-actions { flex-direction: column; }
  .breakdown-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .age-number { font-size: clamp(2.9rem, 17vw, 4rem); }
  .detail-row { font-size: .79rem; }
}

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

@media print {
  .panel, .content-section, .privacy-note, .summary-note, .copy-btn { display: none !important; }
  .page-shell { width: 100%; padding: 0; }
  .workspace { display: block; }
  .summary-panel { position: static; box-shadow: none; border: 0; }
  .result-empty { display: none !important; }
}
