:root {
  --bg-night: #0e1324;
  --bg-dawn: #f1dfbf;
  --ink: #11111f;
  --accent: #b76a24;
  --accent-strong: #8a4511;
  --surface: rgba(255, 247, 232, 0.92);
  --surface-strong: rgba(255, 243, 220, 0.98);
  --line: rgba(35, 22, 6, 0.18);
  --user-bubble: #1d2b57;
  --seer-bubble: #fff6ea;
  --glass: rgba(255, 255, 255, 0.32);
  --glass-strong: rgba(255, 255, 255, 0.48);
  --danger: #8b1a1a;
  --success: #1f6f3c;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(70vw 60vh at 10% 15%, rgba(255, 196, 118, 0.32), transparent 64%),
    radial-gradient(70vw 60vh at 88% 75%, rgba(77, 119, 255, 0.2), transparent 62%),
    linear-gradient(155deg, #080a1a 0%, var(--bg-night) 35%, #18204a 62%, #273f6e 100%);
  display: grid;
  place-items: center;
  padding: 28px 14px;
}

.sky-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 20% 35%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1px 1px at 30% 55%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(2px 2px at 70% 20%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1px 1px at 80% 60%, rgba(255, 255, 255, 0.52), transparent);
  opacity: 0.45;
}

/* --- Layout --- */

.layout {
  width: min(1080px, 100%);
  display: grid;
  gap: 18px;
  z-index: 1;
}

.hero {
  background: linear-gradient(125deg, rgba(255, 232, 194, 0.95), rgba(255, 247, 230, 0.82));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: clamp(18px, 3vw, 30px);
  box-shadow: 0 18px 40px rgba(4, 10, 25, 0.35);
  animation: rise-in 0.6s ease-out both;
}

.hero h1 {
  margin: 4px 0;
  font-size: clamp(2rem, 4.4vw, 3.6rem);
  font-family: "Cormorant Garamond", serif;
  line-height: 1;
  letter-spacing: 0.02em;
}

.tag {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.73rem;
  color: #5d3f23;
  font-weight: 700;
}

.subtitle {
  margin: 8px 0 0;
  max-width: 72ch;
  color: #2f2941;
}

.landing .grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

/* --- Cards --- */

.card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.4));
  backdrop-filter: blur(14px);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    0 18px 36px rgba(8, 12, 30, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  padding: 18px 20px;
  animation: rise-in 0.6s ease-out both;
}

.form-card h2,
.report-card h2 {
  margin: 4px 0 10px;
}

/* --- Stepper --- */

.stepper {
  display: flex;
  gap: 8px;
  margin: 6px 0 14px;
  align-items: center;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  transition: all 0.25s ease;
}

.dot.active {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  box-shadow: 0 0 0 6px rgba(183, 106, 36, 0.15);
}

/* --- Steps --- */

.step {
  animation: fade-slide 0.35s ease;
}

/* --- Buttons --- */

button {
  font: inherit;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-next {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #fff4e7;
  padding: 10px 22px;
  box-shadow: 0 4px 14px rgba(138, 69, 17, 0.28);
}

.btn-next:hover {
  box-shadow: 0 6px 20px rgba(138, 69, 17, 0.4);
  transform: translateY(-1px);
}

.btn-next:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(138, 69, 17, 0.2);
}

.btn-next:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.btn-back {
  background: rgba(236, 221, 198, 0.65);
  border: 1px solid rgba(117, 64, 9, 0.18);
  color: var(--ink);
  padding: 10px 18px;
}

.btn-back:hover {
  background: rgba(236, 221, 198, 0.9);
}

.btn-primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #fff4e7;
  box-shadow: 0 4px 14px rgba(138, 69, 17, 0.28);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(138, 69, 17, 0.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.actions.spaced {
  justify-content: space-between;
}

/* --- Form Fields --- */

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field.two-col {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.field.three-col {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.time-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

input,
select,
.field textarea {
  width: 100%;
  border: 1px solid rgba(39, 29, 13, 0.24);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  background: rgba(255, 255, 255, 0.9);
  transition: border-color 0.2s ease, outline-color 0.2s ease;
}

input:focus,
select:focus,
.field textarea:focus {
  outline: 2px solid rgba(165, 88, 16, 0.28);
  border-color: rgba(117, 56, 10, 0.42);
}

input.field-error,
select.field-error {
  border-color: rgba(139, 26, 26, 0.5);
  outline: 2px solid rgba(139, 26, 26, 0.15);
}

/* --- Quiz --- */

.quiz-head h3 {
  margin: 0 0 4px;
}

.quiz-list {
  display: grid;
  gap: 10px;
  margin: 10px 0;
}

.quiz-item {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(39, 29, 13, 0.14);
  background: rgba(255, 255, 255, 0.9);
  display: grid;
  gap: 8px;
}

.quiz-actions {
  display: inline-flex;
  gap: 8px;
}

.pill {
  border-radius: 999px;
  padding: 6px 12px;
  border: 1px solid rgba(183, 106, 36, 0.28);
  background: rgba(183, 106, 36, 0.08);
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s ease;
}

.pill:hover {
  background: rgba(183, 106, 36, 0.16);
}

.pill.active.yes {
  background: rgba(44, 158, 90, 0.12);
  border-color: rgba(44, 158, 90, 0.4);
  color: #1f6f3c;
}

.pill.active.no {
  background: rgba(201, 64, 64, 0.12);
  border-color: rgba(201, 64, 64, 0.4);
  color: #7f1c1c;
}

.skeleton {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.04));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
  border-radius: 14px;
}

/* --- Step Errors --- */

.form-hint {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: #5d3f23;
  min-height: 1.4em;
}

.step-error {
  color: var(--danger);
  font-weight: 500;
}

.step-error:empty {
  display: none;
}

/* --- Report --- */

.report-card {
  min-height: 420px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.report-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(25, 41, 82, 0.1);
  font-size: 0.85rem;
}

.badge:empty {
  display: none;
}

.report-output {
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(35, 22, 6, 0.12);
  border-radius: 16px;
  padding: 14px;
  min-height: 240px;
  line-height: 1.6;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  overflow-y: auto;
}

.report-output h3 {
  margin: 8px 0 4px;
}

.report-output ul {
  padding-left: 18px;
  margin: 6px 0 10px;
  display: grid;
  gap: 8px;
}

.report-output li {
  background: rgba(255, 255, 255, 0.4);
  border-radius: 10px;
  padding: 8px 12px;
}

/* --- Chat --- */

.chat-anchor {
  display: grid;
  gap: 10px;
}

.chat-toggle {
  justify-self: start;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #fff4e7;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  font-weight: 700;
}

.chat-shell {
  background: linear-gradient(140deg, var(--surface), var(--surface-strong));
  border-radius: 22px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 46px rgba(8, 12, 30, 0.28);
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 420px;
  overflow: hidden;
  animation: rise-in 0.75s ease-out both;
  animation-delay: 0.08s;
}

.hidden {
  display: none !important;
}

.messages {
  padding: 18px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
}

.msg {
  max-width: min(82%, 720px);
  border-radius: 16px;
  padding: 12px 14px;
  border: 1px solid transparent;
  animation: pop-in 0.3s ease-out both;
}

.msg .role {
  margin: 0 0 6px;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  opacity: 0.85;
}

.msg .content {
  margin: 0;
  line-height: 1.58;
  white-space: pre-wrap;
}

.msg.user {
  justify-self: end;
  background: var(--user-bubble);
  color: #ebf0ff;
  border-color: rgba(87, 129, 255, 0.4);
}

.msg.seer {
  justify-self: start;
  background: var(--seer-bubble);
  border-color: rgba(126, 80, 17, 0.22);
}

.msg.loading {
  opacity: 0.78;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 14px;
  display: grid;
  gap: 10px;
  background: rgba(255, 255, 255, 0.48);
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 88px;
  max-height: 220px;
  font: inherit;
  line-height: 1.45;
  border: 1px solid rgba(39, 29, 13, 0.24);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.8);
  color: #1a1628;
}

textarea:focus {
  outline: 2px solid rgba(165, 88, 16, 0.28);
  border-color: rgba(117, 56, 10, 0.42);
}

.ghost {
  background: rgba(236, 221, 198, 0.65);
  border: 1px solid rgba(117, 64, 9, 0.18);
}

.ghost:hover {
  background: rgba(236, 221, 198, 0.9);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* --- Spinner --- */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 244, 231, 0.4);
  border-top-color: #fff4e7;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* --- Animations --- */

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fade-slide {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

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

@media (max-width: 760px) {
  body {
    padding: 10px;
  }

  .layout {
    gap: 10px;
  }

  .landing .grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 16px;
  }

  /* Force single column on small screens */
  .field.two-col {
    grid-template-columns: 1fr;
  }

  /* Larger touch targets for mobile */
  .btn-next,
  .btn-back,
  .btn-primary,
  .pill {
    min-height: 48px;
    padding: 12px 24px;
    font-size: 1rem;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* Stack action buttons vertically on very small screens */
  .actions.spaced {
    flex-direction: column-reverse;
    gap: 10px;
  }

  .actions.spaced .btn-next,
  .actions.spaced .btn-back {
    width: 100%;
    text-align: center;
  }

  .chat-shell {
    min-height: 76vh;
  }

  .msg {
    max-width: 94%;
  }

  .time-wrap {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }

  select,
  input {
    min-height: 44px;
    font-size: 16px;
    /* Prevents iOS zoom on input focus */
  }
}

@media (max-width: 380px) {
  .hero h1 {
    font-size: 1.8rem;
  }

  .card {
    padding: 12px;
    border-radius: 16px;
  }

  .btn-next,
  .btn-back {
    padding: 14px 20px;
  }
}