:root {
  color-scheme: dark;
  --bg: #0d0c09;
  --panel: #15120e;
  --text: #f5f0e7;
  --muted: #aaa49a;
  --hairline: rgba(245, 240, 231, 0.14);
  --red: #d84a3a;
  --gold: #c6a15b;
  --jade: #6f9b83;
  --shadow: rgba(0, 0, 0, 0.42);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(198, 161, 91, 0.16), transparent 28rem),
    linear-gradient(180deg, #15120e 0%, var(--bg) 38%, #080807 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 0;
}

.phone-frame {
  width: min(100vw, 430px);
  min-height: 100svh;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
  box-shadow: 0 30px 80px var(--shadow);
}

.phone-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 18%, rgba(216, 74, 58, 0.1), transparent 12rem),
    radial-gradient(circle at 85% 30%, rgba(111, 155, 131, 0.1), transparent 12rem);
}

.phone-frame.results-mode .test-hero {
  min-height: 150px;
  margin-bottom: 10px;
  padding-bottom: 16px;
}

.phone-frame.results-mode .cycle-mark {
  width: 148px;
  height: 148px;
  right: -42px;
  top: -48px;
  opacity: 0.16;
}

.phone-frame.results-mode h1 {
  max-width: 13ch;
  font-size: clamp(33px, 9vw, 42px);
}

.phone-frame.results-mode .hero-copy {
  margin-top: 10px;
}

.phone-frame.results-mode .trust-row,
.phone-frame.results-mode .test-form {
  display: none;
}

.top-bar,
.test-hero,
.beta-gate,
.test-form,
.reading-panel,
.chat-panel {
  position: relative;
  z-index: 1;
}

.top-bar {
  padding: calc(18px + env(safe-area-inset-top)) 18px 10px;
  display: grid;
  place-items: center;
}

.brand-lockup {
  display: grid;
  place-items: center;
  gap: 3px;
  min-width: 0;
}

.brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0;
}

.descriptor {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-transform: lowercase;
}

.test-hero {
  margin: 4px 18px 16px;
  min-height: 320px;
  display: grid;
  align-content: end;
  padding: 22px 0;
  overflow: hidden;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.cycle-mark {
  position: absolute;
  width: 230px;
  height: 230px;
  right: -92px;
  top: -54px;
  z-index: 0;
  opacity: 0.18;
  border-radius: 50%;
  filter: saturate(0.92);
}

.eyebrow {
  position: relative;
  z-index: 1;
  margin: 0 0 16px;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 12ch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 9.7vw, 46px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 300px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.trust-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 18px;
}

.trust-row span {
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  border: 1px solid rgba(198, 161, 91, 0.24);
  border-radius: 999px;
  color: var(--text);
  background: rgba(245, 240, 231, 0.055);
  font-size: 12px;
  line-height: 1;
}

.test-form {
  display: grid;
  gap: 12px;
  margin: 0 18px 18px;
}

.return-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  margin: -4px 18px 18px;
}

.beta-gate {
  display: grid;
  gap: 10px;
  margin: -2px 18px 18px;
  padding: 12px;
  border: 1px solid rgba(198, 161, 91, 0.28);
  border-radius: 8px;
  background: rgba(245, 240, 231, 0.055);
}

.beta-status {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.test-form.locked {
  opacity: 0.48;
}

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

.field span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field input {
  color-scheme: dark;
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(245, 240, 231, 0.07);
  outline: none;
}

.field input:focus {
  border-color: rgba(198, 161, 91, 0.58);
}

.field input::placeholder {
  color: rgba(170, 164, 154, 0.72);
}

.gender-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.gender-field legend {
  margin: 0 0 8px;
  padding: 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

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

.segmented-control input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented-control span {
  min-height: 46px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(245, 240, 231, 0.055);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  text-align: center;
}

.segmented-control input:focus-visible + span {
  border-color: rgba(198, 161, 91, 0.68);
  box-shadow: 0 0 0 3px rgba(198, 161, 91, 0.16);
}

.segmented-control input:checked + span {
  color: #fff8f0;
  border-color: rgba(216, 74, 58, 0.72);
  background: rgba(216, 74, 58, 0.32);
}

.primary-button,
.secondary-button {
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.primary-button {
  margin-top: 4px;
  color: #fff8f0;
  background: var(--red);
  box-shadow: 0 16px 42px rgba(216, 74, 58, 0.24);
}

.secondary-button {
  width: 100%;
  color: #17110c;
  background: var(--text);
}

.text-button {
  justify-self: center;
  min-height: 36px;
  border: 0;
  padding: 0 6px;
  color: var(--gold);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.58;
}

.reading-panel {
  margin: 0 18px 28px;
  padding-bottom: 28px;
}

.reading-panel.has-continue,
.reading-panel:has(.continue-panel:not([hidden])) {
  padding-bottom: 28px;
}

.scan-state {
  min-height: 112px;
  display: grid;
  place-items: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
}

.scan-ring {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(198, 161, 91, 0.26);
  border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.assertions {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.assertion-card {
  display: grid;
  gap: 6px;
  padding: 12px 13px;
  border: 1px solid rgba(198, 161, 91, 0.18);
  border-radius: 8px;
  background: rgba(245, 240, 231, 0.065);
  animation: rise 0.36s ease-out both;
  cursor: pointer;
}

.assertion-card.no-animation {
  animation: none;
}

@keyframes rise {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.assertion-card span {
  color: var(--red);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.assertion-card strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.12;
  font-weight: 600;
}

.assertion-card p,
.continue-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.38;
}

.assertion-card p {
  overflow-wrap: anywhere;
}

.assertion-card.selected {
  border-color: rgba(216, 74, 58, 0.72);
  background: rgba(216, 74, 58, 0.15);
}

.assertion-card.selected span {
  color: #ffb2a7;
}

.continue-panel {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 4;
  width: min(calc(100vw - 36px), 394px);
  transform: translateX(-50%);
  display: grid;
  gap: 14px;
  margin-top: 10px;
  padding: 15px;
  border: 1px solid rgba(111, 155, 131, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(21, 18, 14, 0.96), rgba(13, 12, 9, 0.98)),
    rgba(111, 155, 131, 0.08);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
}

.continue-panel[hidden] {
  pointer-events: none;
}

.chat-panel {
  flex: 1;
  min-height: 390px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--hairline);
}

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 18px 18px 20px;
  scroll-behavior: smooth;
}

.message {
  width: fit-content;
  max-width: 86%;
  border-radius: 8px;
  padding: 13px 14px;
  line-height: 1.45;
  font-size: 15px;
  white-space: pre-wrap;
}

.message p {
  margin: 0;
}

.message.assistant {
  align-self: flex-start;
  color: var(--text);
  background: rgba(245, 240, 231, 0.07);
  border: 1px solid rgba(245, 240, 231, 0.1);
}

.message.assistant.thinking p::after {
  content: "…";
  display: inline-block;
  width: 1.1em;
  margin-left: 4px;
  animation: pulseDots 1s ease-in-out infinite;
}

@keyframes pulseDots {
  0%, 100% { opacity: 0.28; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-1px); }
}

.message.user {
  align-self: flex-end;
  color: #130f0b;
  background: var(--text);
}

.message.error {
  color: #ffd7d1;
  background: rgba(216, 74, 58, 0.16);
  border-color: rgba(216, 74, 58, 0.28);
}

.save-panel {
  display: grid;
  gap: 12px;
  margin: 0 18px 10px;
  padding: 14px;
  border: 1px solid rgba(111, 155, 131, 0.26);
  border-radius: 8px;
  background: rgba(111, 155, 131, 0.09);
}

.save-copy {
  display: grid;
  gap: 4px;
}

.save-copy strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.1;
  font-weight: 600;
}

.save-copy p,
.save-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.38;
}

.save-form,
.return-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.save-form input,
.return-form input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(245, 240, 231, 0.07);
  outline: none;
}

.save-form input:focus,
.return-form input:focus {
  border-color: rgba(198, 161, 91, 0.58);
}

.save-form input::placeholder,
.return-form input::placeholder {
  color: rgba(170, 164, 154, 0.72);
}

.save-form button,
.return-form button {
  min-width: 88px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 13px;
  color: #17110c;
  background: var(--text);
  font-weight: 800;
}

.save-form button:disabled,
.return-form button:disabled {
  opacity: 0.6;
}

.saved-readings {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(198, 161, 91, 0.18);
  border-radius: 8px;
  background: rgba(245, 240, 231, 0.055);
}

.saved-readings strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.1;
  font-weight: 600;
}

.saved-readings ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.saved-reading-button {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: rgba(13, 12, 9, 0.42);
  text-align: left;
}

.saved-reading-button span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.saved-reading-button small {
  color: var(--muted);
  font-size: 12px;
}

.composer {
  position: sticky;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 10px;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(13, 12, 9, 0), rgba(13, 12, 9, 0.92) 24%, #0d0c09 100%);
}

.composer textarea {
  width: 100%;
  max-height: 116px;
  resize: none;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 15px 14px;
  color: var(--text);
  background: rgba(245, 240, 231, 0.07);
  outline: none;
}

.composer textarea:focus {
  border-color: rgba(198, 161, 91, 0.58);
}

.composer textarea::placeholder {
  color: rgba(170, 164, 154, 0.72);
}

.composer button {
  width: 48px;
  height: 48px;
  align-self: end;
  border: 0;
  border-radius: 50%;
  background: var(--red);
  display: grid;
  place-items: center;
  position: relative;
}

.composer button:disabled {
  opacity: 0.72;
  cursor: wait;
}

.composer button:disabled svg {
  opacity: 0;
}

.send-spinner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 247, 239, 0.35);
  border-top-color: #fff7ef;
  opacity: 0;
  animation: spin 0.9s linear infinite;
}

.composer button[aria-busy="true"] .send-spinner {
  opacity: 1;
}

.composer svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: #fff7ef;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (min-width: 640px) {
  .app-shell {
    padding: 24px;
  }

  .phone-frame {
    min-height: min(900px, calc(100svh - 48px));
    border: 1px solid rgba(245, 240, 231, 0.12);
    border-radius: 30px;
  }
}
