:root {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #161616;
  background: #f7f7f5;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --red: #e44332;
  --black: #161616;
  --muted: #70706b;
  --line: #dcdcd7;
  --paper: #f7f7f5;
  --white: #fff;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }

.app {
  width: min(100%, 780px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 24px) max(18px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 28px) max(18px, env(safe-area-inset-left));
}

.hero { padding: 18px 0 30px; }
.hero-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.brand-mark {
  width: 30px;
  height: 30px;
  border: 1px solid var(--black);
  border-radius: 50%;
  position: relative;
  display: inline-block;
}
.brand-mark::before, .brand-mark::after, .brand-mark i {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 1px; height: 21px;
  background: var(--black);
  transform-origin: 50% 50%;
}
.brand-mark::before { transform: translate(-50%, -50%); }
.brand-mark::after { transform: translate(-50%, -50%) rotate(60deg); }
.brand-mark i { transform: translate(-50%, -50%) rotate(-60deg); }
.edition { color: var(--muted); font-size: .68rem; letter-spacing: .16em; }

h1, h2 { margin: 0; font-family: Georgia, 'Times New Roman', serif; font-weight: 400; }
h1 { font-size: clamp(3rem, 15vw, 6rem); line-height: .94; letter-spacing: -.055em; }
h1 em { display: block; color: var(--red); font-weight: 400; }
.tagline { margin: 16px 0 0; color: #575752; font-size: 1rem; letter-spacing: .02em; }

.date-section {
  padding: 22px 0 26px;
  border-top: 1px solid var(--black);
  border-bottom: 1px solid var(--line);
}
.birth-date-field > label {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.date-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.date-input-wrap { position: relative; min-width: 0; }
.date-controls input[type="text"] {
  width: 100%;
  min-width: 0;
  height: 54px;
  padding: 0 52px 0 12px;
  border: 1px solid #c7c7c2;
  border-radius: 0;
  background: var(--white);
  color: var(--black);
  font-size: 1rem;
  -webkit-appearance: none;
}
.date-controls input[type="text"]:focus { outline: 2px solid var(--red); outline-offset: -2px; }
.calendar-button {
  position: absolute;
  z-index: 2;
  top: 1px;
  right: 1px;
  width: 50px;
  height: 52px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--white);
  cursor: pointer;
}
.calendar-button svg { width: 21px; height: 21px; fill: none; stroke: var(--black); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.calendar-button:active svg { stroke: var(--red); }
.calendar-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  right: 24px;
  bottom: 0;
  opacity: 0;
  pointer-events: none;
}
.primary-button {
  min-height: 54px;
  padding: 12px 17px;
  border: 1px solid var(--black);
  border-radius: 0;
  background: var(--black);
  color: var(--white);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
}
.primary-button:active { background: var(--red); border-color: var(--red); }
.field-error { margin: 9px 0 0; color: var(--red); font-size: .8rem; }
.privacy-note { margin: 12px 0 0; color: #8b8b86; font-size: .7rem; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--black); }
.tabs button {
  min-height: 52px;
  padding: 12px 6px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
}
.tabs button.is-active { border-bottom-color: var(--red); color: var(--black); }

.mode-tabs { display: flex; gap: 8px; padding: 18px 0 0; }
.mode-tabs button {
  min-height: 40px;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
}
.mode-tabs button.is-active { border-color: var(--black); background: var(--black); color: var(--white); }

.compass-section { padding: 34px 0 0; }
.section-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.section-label-row h2, .portrait-heading h2 { font-size: 1.45rem; letter-spacing: -.02em; }
.section-label-row > span { color: var(--red); font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.interaction-hint { margin: 8px 0 10px; color: var(--muted); font-size: .78rem; }

.compass-wrap {
  width: calc(100% + 24px);
  max-width: 560px;
  margin: 0 -12px;
  touch-action: none;
}
.compass { display: block; width: 100%; height: auto; overflow: visible; user-select: none; -webkit-user-select: none; }
.compass-disc { fill: #fff; stroke: #1b1b1b; stroke-width: 1; }
.compass.is-interactive .sector { cursor: pointer; }
.sector-outline { fill: #fafaf8; stroke: #cfcfca; stroke-width: .7; }
.sector-fill { fill: #969690; stroke: none; }
.sector.is-target .sector-outline { fill: #f5d5d0; stroke: var(--red); stroke-width: 1.2; }
.sector.is-target .sector-fill { fill: #969690; }
.sector text { fill: #252525; font: 600 9px -apple-system, BlinkMacSystemFont, sans-serif; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.sector.is-target text { fill: var(--red); font-weight: 700; }
.purpose-marker { fill: #fff; stroke: #343432; stroke-width: 1.6; pointer-events: none; }
.compass-inner { fill: #f7f7f5; stroke: #c1c1bc; stroke-width: .8; }
.compass-center-kicker { fill: #777772; font: 600 6px -apple-system, BlinkMacSystemFont, sans-serif; letter-spacing: 2px; text-anchor: middle; }
.compass-center-title { fill: #222; font: 400 17px Georgia, serif; text-anchor: middle; }
.compass-center-note { fill: #8a8a85; font: 500 6px -apple-system, BlinkMacSystemFont, sans-serif; letter-spacing: .6px; text-anchor: middle; }
.triple-arrow { pointer-events: none; }
.arrow-line { fill: none; stroke-linecap: round; }
.arrow-secondary { stroke: #979792; fill: #979792; stroke-width: 1.5; }
.arrow-primary { stroke: #343432; fill: #343432; stroke-width: 1.8; }
.arrow-target { stroke: var(--red); fill: var(--red); stroke-width: 2.4; }
.arrow-pivot { fill: #fff; stroke: #1a1a1a; stroke-width: 2; }
.arrow-pivot-core { fill: var(--red); }

.results-section { padding-top: 8px; }
.selection-panel { border-top: 1px solid var(--black); }
.selection-primary { display: flex; justify-content: space-between; align-items: center; gap: 14px; min-height: 78px; border-bottom: 1px solid var(--line); }
.selection-primary > span { color: var(--red); font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.selection-primary strong { display: flex; align-items: baseline; gap: 8px; text-align: right; font-size: .8rem; }
.selection-primary .state-number { color: var(--red); font-family: Georgia, serif; font-size: 2rem; }
.supports-grid { display: grid; grid-template-columns: 1fr 1fr; margin: 0; }
.supports-grid div { min-height: 92px; padding: 18px 9px 14px 0; border-bottom: 1px solid var(--line); }
.supports-grid div:nth-child(odd) { border-right: 1px solid var(--line); }
.supports-grid div:nth-child(even) { padding-left: 14px; }
.supports-grid dt { color: #81817c; font-size: .66rem; line-height: 1.25; }
.supports-grid dd { display: flex; align-items: flex-start; gap: 8px; min-width: 0; margin: 12px 0 0; font-size: .72rem; line-height: 1.25; }
.supports-grid dd > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.supports-grid .state-number { color: var(--black); font-family: Georgia, serif; font-size: 1.35rem; }

.portrait-section { padding: 48px 0 20px; }
.portrait-heading { margin-bottom: 22px; }
.eyebrow { display: block; margin-bottom: 8px; color: var(--red); font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.portrait-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--black); }
.portrait-list li { min-height: 76px; display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 9px; align-items: center; border-bottom: 1px solid var(--line); }
.portrait-list li.is-purpose { background: #eeeeea; position: relative; }
.portrait-list li.is-purpose::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: #777772; }
.position-index { color: #92928d; font-size: .66rem; letter-spacing: .1em; }
.position-name { font-size: .84rem; font-weight: 600; }
.position-value { display: grid; justify-items: end; gap: 2px; color: #6f6f6a; font-size: .68rem; }
.position-value .state-number { color: var(--black); font-family: Georgia, serif; font-size: 1.55rem; line-height: 1; }

footer { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); color: #8b8b86; font-size: .68rem; }

.compatibility-page { padding-top: 28px; }
.compatibility-inputs { display: grid; gap: 22px; }
.date-controls.no-button { grid-template-columns: 1fr; }
.compatibility-calculate { width: 100%; margin-top: 2px; }
.comparison-section { padding-top: 48px; }
.comparison-section h2, .personal-comparison h2 { margin-bottom: 20px; font-size: 1.45rem; }
.comparison-table { border-top: 1px solid var(--black); overflow: hidden; }
.comparison-row { display: grid; grid-template-columns: minmax(92px, 1.35fr) repeat(3, minmax(64px, 1fr)); border-bottom: 1px solid var(--line); }
.comparison-row > span { min-width: 0; padding: 12px 5px; border-right: 1px solid var(--line); overflow-wrap: anywhere; }
.comparison-row > span:last-child { border-right: 0; }
.comparison-head { color: var(--muted); font-size: .61rem; font-weight: 700; text-transform: uppercase; }
.comparison-row:not(.comparison-head) > span:first-child { font-size: .7rem; font-weight: 600; }
.comparison-row b { display: block; font-family: Georgia, serif; font-size: 1.25rem; font-weight: 400; }
.comparison-row small { display: block; margin-top: 3px; color: var(--muted); font-size: .56rem; line-height: 1.15; }
.comparison-row.is-purpose { background: #eeeeea; box-shadow: inset 3px 0 0 #777772; }
.personal-comparison { padding-top: 48px; }
.mini-compasses { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-compasses figure { min-width: 0; margin: 0; }
.mini-compasses figcaption { margin-top: 8px; color: var(--muted); font-size: .7rem; text-align: center; }
.mini-compasses .compass { width: 100%; }
.combined-compass-section { padding-top: 52px; }

.current-compass-page { padding-top: 34px; }
.scan-heading h2, .scan-comparison h2 { font-size: 1.65rem; }
.scan-heading > p { margin: 10px 0 20px; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.scan-progress { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-top: 1px solid var(--black); border-bottom: 1px solid var(--line); }
.scan-progress span { color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.scan-progress strong { color: var(--red); font-family: Georgia, serif; font-size: 1.35rem; font-weight: 400; }
.scan-list { margin: 0; padding: 0; list-style: none; }
.scan-question { padding: 24px 0; border-bottom: 1px solid var(--line); }
.scan-question-title { display: grid; grid-template-columns: 30px 1fr auto; align-items: baseline; gap: 8px; }
.scan-question-title > span { color: var(--red); font-family: Georgia, serif; font-size: 1rem; }
.scan-question-title > strong { font-size: .9rem; }
.scan-question-title > b { min-width: 28px; color: var(--red); font-family: Georgia, serif; font-size: 1.45rem; font-weight: 400; text-align: right; }
.scan-question > p { min-height: 42px; margin: 10px 0 14px 38px; color: #565651; font-size: .82rem; line-height: 1.45; }
.score-scale { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; }
.score-scale button {
  min-width: 0;
  height: 34px;
  padding: 0;
  border: 1px solid #cfcfca;
  background: var(--white);
  color: var(--muted);
  font-size: .68rem;
  cursor: pointer;
}
.score-scale button.is-selected { border-color: var(--red); background: var(--red); color: var(--white); font-weight: 700; }
.build-scan-button { position: sticky; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 3; width: 100%; margin-top: 22px; box-shadow: 0 6px 22px rgba(0,0,0,.15); }
.primary-button:disabled { border-color: #c6c6c1; background: #c6c6c1; color: #f4f4f2; cursor: not-allowed; box-shadow: none; }
.current-result { padding-top: 0; }
.secondary-button {
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  border: 1px solid var(--black);
  background: transparent;
  color: var(--black);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
}
.edit-scan-button { margin-top: 24px; }
.scan-comparison { padding-top: 52px; }
.scan-comparison-grid { display: grid; grid-template-columns: 1fr; gap: 26px; margin-top: 20px; }
.scan-comparison figure { margin: 0; }
.scan-comparison figcaption { margin-top: 8px; color: var(--muted); font-size: .75rem; text-align: center; }
.scan-comparison .compass { width: min(100%, 360px); margin: 0 auto; }

@media (max-width: 370px) {
  .date-section .date-controls { grid-template-columns: 1fr; }
  .primary-button { width: 100%; }
  .comparison-row { grid-template-columns: minmax(82px, 1.25fr) repeat(3, minmax(58px, 1fr)); }
}

@media (min-width: 700px) {
  .app { padding-left: 44px; padding-right: 44px; }
  .hero { padding-top: 34px; }
  h1 em { display: inline; }
  .date-controls { max-width: 560px; }
  .compass-wrap { margin-left: auto; margin-right: auto; }
  .portrait-list li { padding: 0 18px; }
  .compatibility-inputs { grid-template-columns: 1fr 1fr; }
  .compatibility-calculate { grid-column: 1 / -1; max-width: 560px; }
  .scan-comparison-grid { grid-template-columns: 1fr 1fr; gap: 18px; }
}

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