:root {
  --bg: #F3E8DB;
  --card: #FBF6EF;
  --ink: #262220;
  --ink-soft: #6f6560;
  --dark: #262220;
  --dark-pressed: #3a332f;
  --chip: #262220;
  --chip-text: #FBF6EF;
  --track: #e3d6c5;
  --accent: #a9846a;
  --danger: #b3564a;
  --radius-lg: 28px;
  --radius-pill: 999px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  font-family: var(--sans);
  color: var(--ink);
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
}

.app-frame {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  background: var(--card);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

@media (min-width: 560px) {
  .app-frame {
    height: min(860px, 92dvh);
    margin: 24px 0;
    border-radius: 36px;
    box-shadow: 0 30px 60px -20px rgba(38, 34, 32, 0.35);
    border: 1px solid rgba(38,34,32,0.06);
  }
}

.loading-screen,
.intro-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  transition: opacity .4s ease;
}
.loading-screen.hide,
.intro-screen.hide {
  opacity: 0;
  pointer-events: none;
}

.loading-orb {
  font-size: 46px;
  animation: orb-pulse 1.3s ease-in-out infinite;
}
@keyframes orb-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.5; }
  50% { transform: scale(1.08); opacity: 1; }
}

.intro-brand {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 20px;
}
.intro-greeting {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 38px;
  margin: 0 0 12px;
  color: var(--ink);
}
.intro-sub {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink-soft);
  margin: 0 0 36px;
  max-width: 260px;
}
.begin-btn {
  background: var(--dark);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 16px 44px;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s ease, opacity .15s ease;
}
.begin-btn:active { transform: scale(0.96); }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 8px;
  flex: 0 0 auto;
}

.app-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  margin: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(38,34,32,0.06); }
.icon-btn:disabled { opacity: 0; pointer-events: none; }

.progress-track {
  height: 3px;
  margin: 0 20px 10px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
  flex: 0 0 auto;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--dark);
  transition: width .35s ease;
}

.screen {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 24px 12px;
  display: flex;
  flex-direction: column;
}

.q-title {
  font-family: var(--serif);
  font-weight: 500;
  font-style: italic;
  font-size: 30px;
  line-height: 1.25;
  color: var(--ink);
  margin: 6px 0 28px;
}

.q-sub {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-soft);
  margin: -20px 0 24px;
}

/* Chip grid (single / multi select) */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: flex-start;
}

.chip {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid rgba(38,34,32,0.25);
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .1s ease;
}
.chip:active { transform: scale(0.97); }
.chip .tick {
  display: none;
  font-size: 12px;
}
.chip.selected {
  background: var(--chip);
  color: var(--chip-text);
  border-color: var(--chip);
}
.chip.selected .tick { display: inline; }

/* full-width variant for yes/no */
.chip-grid.stack {
  flex-direction: column;
}
.chip-grid.stack .chip {
  width: 100%;
  justify-content: center;
  padding: 16px 18px;
  font-size: 16px;
}

/* Slider */
.slider-wrap {
  margin-top: 8px;
}
.slider-value {
  font-family: var(--serif);
  font-style: italic;
  font-size: 56px;
  color: var(--ink);
  margin-bottom: 8px;
}
.slider-caption {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 28px;
}
input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: var(--track);
  outline: none;
  accent-color: var(--dark);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--dark);
  border: 3px solid var(--card);
  box-shadow: 0 0 0 1.5px var(--dark);
  cursor: pointer;
  margin-top: -10px;
}
input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--dark);
  border: 3px solid var(--card);
  box-shadow: 0 0 0 1.5px var(--dark);
  cursor: pointer;
}
.slider-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-soft);
}

/* Text area */
textarea.free-text {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  border: 1.5px solid rgba(38,34,32,0.2);
  border-radius: 18px;
  padding: 16px;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
  background: transparent;
}
textarea.free-text:focus { outline: none; border-color: var(--dark); }

/* Footer */
.app-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 16px 24px 26px;
  gap: 12px;
}
.spacer { flex: 1; }
.text-link {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px 0;
}
.next-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--dark);
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity .15s ease, transform .1s ease;
}
.next-btn:active { transform: scale(0.94); }
.next-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.next-btn.loading { opacity: 0.6; }

/* Done screen */
.done-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}
.done-emoji { font-size: 40px; }
.done-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 28px;
  margin: 4px 0 0;
}
.done-sub {
  color: var(--ink-soft);
  font-size: 14px;
  max-width: 280px;
}
.error-box {
  margin-top: 18px;
  color: var(--danger);
  font-size: 13px;
  max-width: 280px;
}
.retry-btn {
  margin-top: 14px;
  background: var(--dark);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
