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

:root {
  --bg: #E6DCD1;
  --bg-panel: #F2E9DF;
  --fg: #291915;
  --fg-muted: #5F5048;
  --navy: #41577F;
  --red: #754B51;
  --olive: #5F6040;
  --salmon: #F99F74;
  --divider: #DCCCBB;
  --border: #DDD0C1;
  --font-display: 'Petrona', Georgia, serif;
  --font-body: 'Fustat', -apple-system, Helvetica, Arial, sans-serif;
  --w: 600px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-weight: 300;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  padding: 40px 16px 80px;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
main { max-width: var(--w); margin: 0 auto; }
a { color: inherit; text-decoration-color: var(--divider); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--fg); }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.top { display: flex; justify-content: center; margin-bottom: 40px; }
.logo { width: 120px; height: auto; display: block; }

/* Hero */
.hero { text-align: center; margin-bottom: 32px; }
h1 {
  font-family: var(--font-display); font-weight: 200; letter-spacing: -0.03em;
  font-size: clamp(2.5rem, 9vw, 4.25rem); line-height: 1.05; margin-bottom: 14px;
}
.subtitle { font-family: var(--font-display); font-style: italic; font-weight: 300; font-size: 1.35rem; margin-bottom: 8px; }
.lede { color: var(--fg-muted); font-size: 1rem; max-width: 440px; margin: 0 auto; }

.banner {
  background: var(--fg); color: var(--bg-panel); border-radius: 2px;
  padding: 14px 18px; margin-bottom: 24px; text-align: center;
  font-family: var(--font-display); font-style: italic; font-size: 1.1rem;
}

/* Form */
.card, .panel {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 2px;
  padding: 32px; width: 100%;
}
label {
  display: block; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase;
  font-weight: 500; color: var(--fg-muted); margin-bottom: 10px;
}
.note { text-transform: none; letter-spacing: 0; font-size: 0.8rem; font-weight: 300; }
.year-row { display: flex; align-items: center; gap: 20px; margin-bottom: 14px; }
input[type="number"] {
  font-family: var(--font-display); font-weight: 200; letter-spacing: -0.03em; font-size: 2.75rem;
  width: 150px; background: var(--bg); border: 1px solid var(--border); border-radius: 2px;
  color: var(--fg); padding: 6px 12px; text-align: center; -moz-appearance: textfield;
}
#birth-input { font-size: 1.5rem; width: 130px; margin-bottom: 24px; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type="number"]:focus, textarea:focus { border-color: var(--navy); outline: none; }
input[type="range"] { flex: 1; accent-color: var(--navy); cursor: pointer; min-height: 44px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.chip {
  font-family: var(--font-body); font-size: 0.85rem; font-weight: 400;
  background: transparent; color: var(--fg); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; min-height: 36px; cursor: pointer; width: auto; letter-spacing: 0; text-transform: none;
}
.chip:hover { border-color: var(--fg-muted); }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg-panel); border-color: var(--fg); }
textarea {
  font-family: var(--font-body); font-weight: 300; font-size: 1rem; line-height: 1.6; width: 100%;
  background: var(--bg); border: 1px solid var(--border); border-radius: 2px; color: var(--fg);
  padding: 12px 14px; resize: vertical; min-height: 72px; margin-bottom: 24px;
}
textarea::placeholder { color: var(--fg-muted); opacity: 0.7; }

button {
  font-family: var(--font-body); font-weight: 500; font-size: 0.8rem; letter-spacing: 0.1em;
  text-transform: uppercase; background: var(--fg); color: var(--bg-panel); border: none;
  border-radius: 2px; padding: 16px 28px; min-height: 48px; cursor: pointer; width: 100%;
}
button:hover:not(:disabled) { opacity: 0.85; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--fg); border: 1px solid var(--fg); }

/* Guess */
#guess { margin-top: 28px; }
.guess-q { font-family: var(--font-display); font-weight: 300; font-size: 1.4rem; line-height: 1.35; margin-bottom: 18px; }
.guess-val { font-family: var(--font-display); font-weight: 200; font-size: 3rem; text-align: center; }
.guess-row { display: flex; gap: 12px; margin-top: 16px; }
.guess-row button { flex: 1; }
.reveal { margin-top: 8px; }
.reveal p { font-size: 1.05rem; margin: 14px 0 0; }
.reveal strong { font-weight: 500; }

/* Dot grid */
.dots-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 18px; }
.dots-label { font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 500; color: var(--fg-muted); margin-bottom: 8px; }
.dots { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; max-width: 220px; }
.dots i { aspect-ratio: 1; border-radius: 50%; background: var(--divider); display: block; }
.dots i.on { background: var(--red); }
.dots.now i.on { background: var(--olive); }
.dots i.guess { box-shadow: inset 0 0 0 2px var(--navy); }
@media (prefers-reduced-motion: no-preference) {
  .dots i.on { animation: pop 0.25s ease both; }
  @keyframes pop { from { transform: scale(0.3); opacity: 0; } }
}

/* Results */
#results { margin-top: 36px; }
.result-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.result-year { font-family: var(--font-display); font-weight: 200; letter-spacing: -0.03em; font-size: 3rem; line-height: 1; }
.personal { color: var(--fg-muted); font-style: italic; font-size: 1rem; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 2px; padding: 20px; }
.stat.stat-hero { grid-column: 1 / -1; }
.stat-label { font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 500; color: var(--fg-muted); margin-bottom: 10px; }
.stat-values { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; }
.stat-then, .stat-now { font-family: var(--font-display); font-weight: 200; letter-spacing: -0.02em; font-size: 1.6rem; line-height: 1.1; white-space: nowrap; }
.stat-hero .stat-then, .stat-hero .stat-now { font-size: 2.2rem; }
.stat-then { color: var(--red); }
.stat-now { color: var(--olive); }
.stat-arrow { color: var(--fg-muted); }
.stat-sub { font-size: 0.9rem; color: var(--fg-muted); margin-top: 4px; }
.stat-delta { font-size: 0.9rem; font-weight: 500; margin-top: 8px; }
.stat-delta.good { color: var(--olive); }
.stat-delta.bad { color: var(--red); }
.stat-src { font-size: 0.78rem; color: var(--fg-muted); margin-top: 8px; display: inline-block; }
.caveat { color: var(--fg-muted); font-style: italic; font-size: 0.95rem; margin: 16px 2px 32px; }

.story {
  background: var(--bg-panel); border: 1px solid var(--border); border-left: 3px solid var(--red);
  border-radius: 2px; padding: 26px 28px; font-size: 1.05rem; line-height: 1.8; min-height: 90px;
}
.story:empty { display: none; }
.story sup a { font-size: 0.7rem; color: var(--navy); text-decoration: none; padding: 0 1px; }
.story .err { color: var(--red); font-style: italic; display: block; margin-top: 10px; }
.story .err button { display: inline; width: auto; min-height: 0; padding: 6px 12px; margin-left: 8px; font-size: 0.7rem; }
.cursor { display: inline-block; width: 1.5px; height: 1em; background: var(--red); margin-left: 2px; vertical-align: text-bottom; animation: blink 0.9s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.footnotes { font-size: 0.8rem; color: var(--fg-muted); margin: 12px 0 0 22px; line-height: 1.5; }
.footnotes li { margin-bottom: 4px; }
.ai-note { font-size: 0.75rem; color: var(--fg-muted); text-align: right; margin-top: 8px; }

.lenses { margin: 18px 0 8px; }
.lenses .eyebrow { margin-bottom: 10px; }
.lenses .chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.lenses .chip { white-space: nowrap; }

.eyebrow { font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 500; color: var(--fg-muted); }
.honesty { margin-top: 32px; padding: 20px 24px; border: 1px dashed var(--divider); border-radius: 2px; }
.honesty .eyebrow { margin-bottom: 8px; }
.honesty p { font-size: 0.98rem; }

.close { margin-top: 24px; padding: 26px 28px; background: var(--fg); color: var(--bg-panel); border-radius: 2px; }
.close-line { font-family: var(--font-display); font-style: italic; font-weight: 200; font-size: 1.6rem; line-height: 1.3; letter-spacing: -0.01em; }
.byline { margin-top: 12px; font-size: 0.9rem; opacity: 0.85; }
.byline a { text-decoration-color: rgba(242,233,223,0.4); }

.share { margin-top: 24px; }
.share .eyebrow { margin-bottom: 12px; }
.share-card { width: 100%; border: 1px solid var(--border); border-radius: 2px; display: block; margin-bottom: 12px; }
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share-row button { font-size: 0.72rem; padding: 14px 10px; }
.challenge { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--divider); }
.challenge input { font-family: var(--font-body); font-size: 1rem; width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 2px; background: var(--bg-panel); margin-bottom: 10px; color: var(--fg); }
.toast { font-size: 0.85rem; color: var(--olive); margin-top: 8px; min-height: 1.2em; }

.popular { margin-top: 28px; text-align: center; color: var(--fg-muted); font-size: 0.95rem; }
.popular strong { font-family: var(--font-display); font-weight: 300; font-size: 1.3rem; color: var(--fg); }
.again { margin-top: 28px; }

.method { margin-top: 48px; color: var(--fg-muted); font-size: 0.9rem; }
.method summary { cursor: pointer; font-weight: 500; }
.method p { margin-top: 10px; }

/* Tester feedback */
.feedback { position: fixed; right: 16px; bottom: 16px; z-index: 10; max-width: 340px; width: calc(100% - 32px); }
.feedback > button { width: auto; float: right; font-size: 0.7rem; padding: 12px 16px; box-shadow: 0 4px 16px rgba(41,25,21,0.2); }
.fb-panel { clear: both; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 2px; padding: 18px; margin-bottom: 10px; box-shadow: 0 8px 24px rgba(41,25,21,0.18); max-height: 70vh; overflow: auto; }
.fb-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--divider); font-size: 0.9rem; }
.fb-row .chip { padding: 4px 10px; min-height: 30px; }
.fb-panel textarea { margin: 12px 0; min-height: 60px; }

@media (max-width: 520px) {
  body { padding-top: 28px; }
  .card, .panel { padding: 22px 18px; }
  .year-row { gap: 12px; }
  input[type="number"] { width: 120px; font-size: 2.25rem; }
  .stats { grid-template-columns: 1fr; }
  .story { padding: 20px; }
  .dots-pair { gap: 14px; }
}
