@property --ring-sweep {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

html {
  color-scheme: dark;
}

body {
  --bg: #06100e;
  --panel: rgba(8, 17, 16, 0.96);
  --line: rgba(125, 255, 215, 0.16);
  --ink: #e6fff6;
  --muted: #87aaa0;
  --accent: #7dffd7;
  --accent-soft: rgba(125, 255, 215, 0.12);
  --blue-month: rgba(89, 188, 255, 0.62);
  --red-month: rgba(255, 119, 119, 0.58);
  --future: rgba(130, 151, 145, 0.32);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
  background:
    radial-gradient(circle at top, rgba(125, 255, 215, 0.08), transparent 30rem),
    linear-gradient(180deg, #030707 0%, #06100e 40%, #0a1714 100%);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
}

.theme-toggle-row {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 8;
  display: flex;
  justify-content: flex-end;
}

.theme-toggle {
  position: static;
  min-height: 2.5rem;
  min-width: 2.5rem;
  padding: 0.1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell,
.gateway-screen,
.flow-screen {
  min-height: 100vh;
}

/* Ensure HTML hidden attribute works even when display is set by CSS */
[hidden] {
  display: none !important;
}

.gateway-screen,
.flow-screen {
  display: grid;
  place-items: center;
  padding: 1rem;
}

.screen-stack {
  width: min(100%, 42rem);
  display: grid;
  gap: 0.9rem;
}

.gateway-frame,
.flow-frame {
  width: min(100%, 42rem);
  border: 1px solid var(--line);
  border-radius: 1.35rem;
  background:
    linear-gradient(180deg, rgba(12, 23, 21, 0.98), rgba(6, 14, 13, 0.96)),
    var(--panel);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.gateway-frame::before,
.flow-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0, transparent 1px),
    linear-gradient(90deg, rgba(125, 255, 215, 0.02) 0, transparent 1px);
  background-size: 100% 0.34rem, 0.34rem 100%;
  opacity: 0.22;
  pointer-events: none;
}

.gateway-frame {
  padding: 1.4rem 1.2rem;
  display: grid;
  gap: 1rem;
  align-content: center;
  min-height: min(88vh, 44rem);
}

.gateway-title {
  margin: 0;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  font-size: clamp(2rem, 8vw, 3.35rem);
  line-height: 0.98;
  max-width: 12ch;
}

.gateway-copy {
  margin: 0;
  max-width: 30rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.gateway-copy a {
  color: var(--accent);
}

.gateway-actions {
  display: grid;
  gap: 0.8rem;
}

.site-disclaimer {
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.55;
  text-align: center;
}

.site-disclaimer-flow {
  padding-top: 0;
  border-top: 0;
}

.flow-frame {
  padding: 1rem 0.95rem 1.15rem;
}

.step-complete-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  gap: 1rem;
  align-content: center;
  justify-items: center;
  padding: 1.4rem;
  text-align: center;
  background: rgba(3, 7, 7, 0.88);
  backdrop-filter: blur(0.32rem);
}

.step-complete-message {
  margin: 0;
  max-width: 28rem;
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--ink);
}

.progress-bar {
  height: 0.46rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(125, 255, 215, 0.08);
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7dffd7, #25d3a8);
  box-shadow: 0 0 18px rgba(125, 255, 215, 0.34);
  transition: width 220ms ease;
}

.progress-copy {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.step-panel[hidden] {
  display: none;
}

.question-card {
  display: grid;
  gap: 1rem;
  min-height: min(74vh, 44rem);
  align-content: start;
  padding: 1.1rem 0 0.2rem;
}

.question-card h1 {
  margin: 0;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  font-size: clamp(1.7rem, 6vw, 2.45rem);
  line-height: 1.06;
}

html[data-resolved-theme='light'] {
  color-scheme: light;
}

body[data-resolved-theme='light'] {
  --bg: #eef5f3;
  --panel: rgba(255, 255, 255, 0.96);
  --line: rgba(12, 44, 36, 0.16);
  --ink: #11221e;
  --muted: #42645d;
  --accent: #0c6f57;
  --accent-soft: rgba(12, 111, 87, 0.12);
  --blue-month: rgba(53, 128, 188, 0.32);
  --red-month: rgba(186, 84, 84, 0.28);
  --future: rgba(73, 100, 93, 0.52);
  --shadow: 0 26px 64px rgba(8, 37, 32, 0.16);
  background:
    radial-gradient(circle at top, rgba(12, 111, 87, 0.1), transparent 32rem),
    linear-gradient(180deg, #f7fbfa 0%, #eef5f3 42%, #e4efec 100%);
}

body[data-resolved-theme='light'] .gateway-frame,
body[data-resolved-theme='light'] .flow-frame {
  background:
    linear-gradient(180deg, rgba(252, 255, 254, 0.98), rgba(242, 249, 247, 0.96)),
    var(--panel);
}

body[data-resolved-theme='light'] .gateway-frame::before,
body[data-resolved-theme='light'] .flow-frame::before {
  background:
    linear-gradient(180deg, rgba(10, 40, 33, 0.03) 0, transparent 1px),
    linear-gradient(90deg, rgba(12, 111, 87, 0.03) 0, transparent 1px);
  opacity: 0.32;
}

body[data-resolved-theme='light'] .step-complete-overlay {
  background: rgba(244, 252, 250, 0.88);
}

body[data-resolved-theme='light'] .progress-bar,
body[data-resolved-theme='light'] .transition-bar {
  background: rgba(12, 111, 87, 0.12);
}

body[data-resolved-theme='light'] .calendar-month {
  border-color: rgba(12, 111, 87, 0.12);
  background: rgba(248, 253, 251, 0.9);
}

body[data-resolved-theme='light'] .month-prior {
  box-shadow: inset 0 0 0 1px rgba(186, 84, 84, 0.1);
}

body[data-resolved-theme='light'] .month-current {
  box-shadow: inset 0 0 0 1px rgba(53, 128, 188, 0.12);
}

body[data-resolved-theme='light'] .calendar-day {
  border-color: rgba(12, 111, 87, 0.16);
  background: rgba(255, 255, 255, 0.96);
}

body[data-resolved-theme='light'] .month-prior .calendar-day {
  border-color: rgba(186, 84, 84, 0.18);
}

body[data-resolved-theme='light'] .month-current .calendar-day {
  border-color: rgba(53, 128, 188, 0.18);
}

body[data-resolved-theme='light'] .calendar-day.is-active:hover,
body[data-resolved-theme='light'] .calendar-day.is-active:focus-visible {
  border-color: rgba(12, 111, 87, 0.36);
  background: rgba(236, 248, 244, 0.96);
}

body[data-resolved-theme='light'] .calendar-day.is-future {
  background: rgba(245, 250, 248, 0.78);
}

body[data-resolved-theme='light'] .transition-ring::after {
  background: rgba(248, 253, 252, 0.98);
  border-color: rgba(12, 111, 87, 0.22);
}

body[data-resolved-theme='light'] .field input,
body[data-resolved-theme='light'] .field textarea,
body[data-resolved-theme='light'] .terminal-check,
body[data-resolved-theme='light'] .button-ghost,
body[data-resolved-theme='light'] .button-muted,
body[data-resolved-theme='light'] .choice-button,
body[data-resolved-theme='light'] .summary-box,
body[data-resolved-theme='light'] .fieldset-block,
body[data-resolved-theme='light'] .template-box {
  border-color: rgba(12, 111, 87, 0.2);
  background: rgba(255, 255, 255, 0.95);
}

body[data-resolved-theme='light'] .done-cta-card {
  border-color: rgba(12, 111, 87, 0.14);
  background: rgba(255, 255, 255, 0.92);
}

body[data-resolved-theme='light'] .field input:focus,
body[data-resolved-theme='light'] .field textarea:focus {
  border-color: rgba(12, 111, 87, 0.5);
  box-shadow: 0 0 0 0.18rem rgba(12, 111, 87, 0.1);
}

body[data-resolved-theme='light'] .field input.is-valid {
  border-color: rgba(12, 111, 87, 0.64);
  box-shadow: 0 0 0 0.18rem rgba(12, 111, 87, 0.08);
}

body[data-resolved-theme='light'] .field input.is-invalid {
  border-color: rgba(179, 66, 66, 0.58);
  box-shadow: 0 0 0 0.18rem rgba(179, 66, 66, 0.08);
}

body[data-resolved-theme='light'] .status[data-kind='success'] {
  color: #166f53;
}

body[data-resolved-theme='light'] .status[data-kind='error'] {
  color: #9b2f2f;
}

.microcopy {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
  max-width: 31rem;
}

.calendar-shell {
  position: relative;
  display: grid;
  gap: 1rem;
  padding-top: 0.4rem;
}

.calendar-hover-label {
  position: absolute;
  left: -0.2rem;
  top: 0.35rem;
  transform: translateX(-12%);
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px rgba(89, 188, 255, 0.28);
  opacity: 0.46;
  pointer-events: none;
}

.calendar-hover-label[data-theme='prior'] {
  -webkit-text-stroke-color: rgba(255, 119, 119, 0.26);
}

.calendar-hover-label[data-theme='current'] {
  -webkit-text-stroke-color: rgba(89, 188, 255, 0.28);
}

.calendar-month {
  border: 1px solid rgba(125, 255, 215, 0.08);
  border-radius: 1rem;
  background: rgba(5, 12, 11, 0.74);
  padding: 0.85rem 0.75rem 0.8rem;
  position: relative;
  z-index: 1;
}

.month-prior {
  box-shadow: inset 0 0 0 1px rgba(255, 119, 119, 0.04);
}

.month-current {
  box-shadow: inset 0 0 0 1px rgba(89, 188, 255, 0.05);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.45rem;
}

.calendar-weekdays {
  margin-bottom: 0.55rem;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 0.76rem;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  text-align: center;
}

.calendar-spacer {
  min-height: 2.85rem;
}

.calendar-day {
  min-height: 2.85rem;
  border-radius: 0.92rem;
  border: 1px solid rgba(125, 255, 215, 0.08);
  background: rgba(8, 16, 15, 0.82);
  color: var(--ink);
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  font-size: 1rem;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.month-prior .calendar-day {
  border-color: rgba(255, 119, 119, 0.08);
}

.month-current .calendar-day {
  border-color: rgba(89, 188, 255, 0.08);
}

.calendar-day.is-active {
  cursor: pointer;
}

.calendar-day.is-active:hover,
.calendar-day.is-active:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(125, 255, 215, 0.34);
  background: rgba(12, 28, 24, 0.92);
}

.calendar-day.is-today {
  border-color: rgba(125, 255, 215, 0.72);
  background: linear-gradient(180deg, rgba(125, 255, 215, 0.2), rgba(125, 255, 215, 0.08));
  box-shadow: inset 0 0 0 1px rgba(125, 255, 215, 0.08), 0 0 18px rgba(125, 255, 215, 0.14);
}

.calendar-day.is-future,
.calendar-day.is-outside-window {
  color: var(--future);
  cursor: not-allowed;
}

.calendar-day.is-future {
  background: rgba(8, 16, 15, 0.42);
}

.transition-panel {
  display: grid;
  gap: 1rem;
  align-content: center;
  justify-items: center;
  min-height: min(74vh, 44rem);
  text-align: center;
}

.transition-ring {
  --ring-sweep: 0deg;
  position: relative;
  width: 5rem;
  height: 5rem;
  border-radius: 999px;
  background: conic-gradient(var(--accent) var(--ring-sweep), rgba(125, 255, 215, 0.08) 0);
  display: grid;
  place-items: center;
  animation: ring-fill 1.25s linear forwards;
}

.transition-ring::after {
  content: "";
  width: 3.95rem;
  height: 3.95rem;
  border-radius: 999px;
  background: rgba(6, 14, 13, 0.98);
  border: 1px solid rgba(125, 255, 215, 0.12);
}

.transition-ring span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.3rem;
  height: 0.72rem;
  border-left: 0.18rem solid var(--accent);
  border-bottom: 0.18rem solid var(--accent);
  transform: translate(-50%, -58%) rotate(-45deg);
  z-index: 1;
}

@keyframes ring-fill {
  to {
    --ring-sweep: 360deg;
  }
}

.transition-message {
  margin: 0;
  max-width: 27rem;
  font-size: 1.02rem;
  line-height: 1.55;
}

.transition-bar {
  width: min(100%, 16rem);
  height: 0.32rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(125, 255, 215, 0.08);
}

.transition-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #7dffd7, #25d3a8);
  transition: width 950ms linear;
}

.field {
  display: grid;
  gap: 0.65rem;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 3.65rem;
  border-radius: 1rem;
  border: 1px solid rgba(125, 255, 215, 0.16);
  background: rgba(4, 10, 10, 0.92);
  color: var(--ink);
  padding: 0.95rem 1rem;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  font-size: 1.04rem;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.field textarea {
  min-height: 8.5rem;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(125, 255, 215, 0.52);
  box-shadow: 0 0 0 0.18rem rgba(125, 255, 215, 0.1);
}

.field input.is-valid {
  border-color: rgba(125, 255, 215, 0.64);
  box-shadow: 0 0 0 0.18rem rgba(125, 255, 215, 0.08);
}

.field input.is-invalid {
  border-color: rgba(255, 155, 155, 0.66);
  box-shadow: 0 0 0 0.18rem rgba(255, 155, 155, 0.08);
}

.checkbox-line {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin: 0;
}

.terminal-check {
  padding: 0.95rem 1rem;
  border: 1px solid rgba(125, 255, 215, 0.1);
  border-radius: 1rem;
  background: rgba(8, 16, 15, 0.72);
  color: var(--muted);
}

.terminal-check input {
  margin-top: 0.2rem;
}

.fine-print,
.status,
.summary-box,
.fieldset-block legend {
  color: var(--muted);
}

.status {
  min-height: 1.35rem;
  margin: 0;
}

.status[data-kind='success'] {
  color: #9effc7;
}

.status[data-kind='error'] {
  color: #ff9b9b;
}

.touch-kdf-link {
  color: var(--accent);
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
}

.done-cta-cards {
  display: grid;
  gap: 1.1rem;
}

.done-cta-card {
  display: grid;
  gap: 0.6rem;
  padding: 1rem;
  border: 1px solid rgba(125, 255, 215, 0.1);
  border-radius: 1rem;
  background: rgba(8, 16, 15, 0.5);
}

.done-cta-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.step-actions,
.button-row,
.choice-grid {
  display: grid;
  gap: 0.75rem;
}

.button,
.button-ghost,
.button-muted,
.choice-button {
  width: 100%;
  min-height: 3.6rem;
  border-radius: 1rem;
  padding: 0.95rem 1.15rem;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  font-size: 0.98rem;
  font-weight: 700;
  transition: transform 140ms ease, filter 140ms ease, border-color 140ms ease, background 140ms ease;
}

.button:hover,
.button-ghost:hover,
.button-muted:hover,
.choice-button:hover,
.button:focus-visible,
.button-ghost:focus-visible,
.button-muted:focus-visible,
.choice-button:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.button {
  background: linear-gradient(135deg, #7dffd7, #24d2a8);
  color: #04100d;
}

.button.is-selected,
.button-muted.is-selected {
  box-shadow: 0 0 0 0.18rem rgba(125, 255, 215, 0.18);
  filter: brightness(1.05);
}

.button-ghost.is-selected {
  border-color: rgba(125, 255, 215, 0.52);
  background: rgba(125, 255, 215, 0.08);
  box-shadow: 0 0 0 0.18rem rgba(125, 255, 215, 0.1);
}

.button-ghost,
.button-muted,
.choice-button {
  border: 1px solid rgba(125, 255, 215, 0.14);
  background: rgba(8, 16, 15, 0.84);
  color: var(--ink);
}

.button-muted {
  color: var(--accent);
}

.choice-button.is-selected {
  border-color: rgba(125, 255, 215, 0.64);
  background: linear-gradient(180deg, rgba(125, 255, 215, 0.16), rgba(125, 255, 215, 0.08));
}

.summary-box,
.fieldset-block {
  border: 1px solid rgba(125, 255, 215, 0.1);
  border-radius: 1rem;
  background: rgba(8, 16, 15, 0.7);
  padding: 0.95rem 1rem;
}

.fieldset-block {
  margin: 0;
}

.summary-box strong {
  color: var(--ink);
  margin-left: 0.35rem;
}

.send-address {
  margin: 0;
}

.send-copy-zone {
  display: grid;
  gap: 0.5rem;
}

.step-actions:has([data-continue-after-send]:not([hidden])) .send-proceed-hint {
  display: none;
}

.send-to-email {
  color: var(--accent);
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
}

.send-subhead {
  margin: 0;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  font-size: clamp(1.15rem, 4vw, 1.45rem);
  font-weight: 700;
  line-height: 1.15;
}

.template-box {
  min-height: 15rem;
  border-radius: 1rem;
  border: 1px solid rgba(125, 255, 215, 0.14);
  background: rgba(2, 6, 6, 0.98);
  color: var(--ink);
  padding: 1rem;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  line-height: 1.5;
}

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

@media (min-width: 720px) {
  .gateway-actions,
  .step-actions,
  .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button-row.question-button-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button-row.question-button-row .col-span-2,
  .step-actions .col-span-2 {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .theme-toggle-row {
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
  }

  .gateway-screen,
  .flow-screen {
    padding: 0.75rem;
  }

  .gateway-frame,
  .flow-frame {
    border-radius: 1.15rem;
  }

  .flow-frame {
    padding: 0.92rem 0.82rem 1rem;
  }

  .gateway-frame {
    min-height: min(88vh, 40rem);
    padding: 1.15rem 0.95rem;
  }

  .question-card {
    min-height: min(76vh, 46rem);
  }

  .calendar-hover-label {
    position: static;
    transform: none;
    font-size: 1.45rem;
  }
}
