/* Base tokens are set from JS by theme JSON */
:root {
  --primary: #B8241C;
  --accent: #D4A24C;
  --bg: #FDF6EC;
  --surface: #FFFFFF;
  --text: #2B1F1A;
  --muted: #6B5B54;
  --border: rgba(43, 31, 26, 0.12);
  --border-strong: rgba(43, 31, 26, 0.24);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow-card: 0 12px 32px -8px rgba(43, 31, 26, 0.18), 0 2px 4px rgba(43, 31, 26, 0.08);
  --radius-lg: 24px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Loading */
.loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Center-view (thank you, error) */
.center-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
}
.error-card {
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  border: 1px solid var(--border);
}
.error-card h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.error-card p { color: var(--muted); }

/* Wizard */
.wizard {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.wizard-header {
  padding: calc(env(safe-area-inset-top, 0px) + 1.5rem) 1.25rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}
.brand-logo { height: 40px; width: auto; }
.brand-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.brand-name {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}
.brand-sub {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-top: 2px;
}

/* Progress */
.progress-wrap { padding: 0 1.25rem; margin-bottom: 1rem; }
.progress-track {
  height: 6px;
  background: rgba(43, 31, 26, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  width: 0%;
  transition: width 0.35s cubic-bezier(0.5, 0.05, 0.15, 1);
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 500;
}

/* Card */
.card-wrap {
  flex: 1;
  padding: 0 1.25rem 1.25rem;
  display: flex;
  align-items: flex-start;
}
.card {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: slideIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
.card.slide-back { animation-name: slideInBack; }
@keyframes slideInBack {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: translateX(0); }
}
.card-header {
  padding: 2rem 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 4%, var(--surface)), var(--surface));
}
.card-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}
@media (min-width: 480px) {
  .card-title { font-size: 1.875rem; }
}
.card-subtitle {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.375rem;
}
.card-subtitle:empty { display: none; }
.card-body {
  padding: 1.5rem;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-body > * { width: 100%; }

/* Stars */
.stars {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.5rem 0;
}
.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  transition: transform 0.15s;
  color: rgba(43, 31, 26, 0.2);
}
.star-btn:hover, .star-btn.active { color: var(--accent); }
.star-btn:active { transform: scale(0.9); }
.star-btn.active { color: var(--accent); }
.star-btn svg { width: 44px; height: 44px; fill: currentColor; }
.stars.sm .star-btn svg { width: 24px; height: 24px; }

/* NPS scale */
.nps-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}
@media (min-width: 480px) {
  .nps-scale { grid-template-columns: repeat(10, 1fr); }
}
.nps-btn {
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.875rem 0;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.nps-btn:hover { border-color: var(--primary); }
.nps-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  transform: scale(0.98);
}
.nps-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 0.5rem;
  padding: 0 0.25rem;
}

/* Multi-select grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
.option-btn {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.option-btn:hover { border-color: var(--border-strong); }
.option-btn.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  color: var(--primary);
}
.checkbox {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid rgba(43, 31, 26, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.option-btn.active .checkbox {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox svg {
  width: 14px;
  height: 14px;
  opacity: 0;
  color: white;
}
.option-btn.active .checkbox svg { opacity: 1; }

/* Yes/no big cards */
.yesno-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.yesno-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-body);
}
.yesno-btn.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}
.yesno-emoji {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}
.yesno-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

/* Item ratings list */
.item-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 0.625rem;
}
@media (min-width: 480px) {
  .item-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
.item-row-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

/* Text inputs */
input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text);
  transition: border-color 0.15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
textarea { resize: none; }
.text-input-inline { margin-top: 0.75rem; }

/* Nav footer */
.nav-footer {
  position: sticky;
  bottom: 0;
  padding: 0.75rem 1.25rem calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
  background: linear-gradient(180deg, transparent 0%, var(--bg) 40%);
  display: flex;
  gap: 0.75rem;
  z-index: 10;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9375rem;
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-md);
  transition: all 0.15s;
  min-height: 48px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: white;
  flex: 1;
}
.btn-primary:not(:disabled):hover {
  background: color-mix(in srgb, var(--primary) 92%, black);
}
.btn-primary:not(:disabled):active {
  transform: scale(0.98);
}
.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border-strong);
  padding: 0.75rem;
  min-width: 48px;
  flex: none;
}
.btn-outline:hover { border-color: var(--text); }

/* Thank you */
.thankyou-emoji {
  font-size: 5rem;
  margin-bottom: 1.5rem;
  animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop {
  0% { transform: scale(0) rotate(-20deg); }
  100% { transform: scale(1) rotate(0); }
}
.thankyou-heading {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.thankyou-body {
  color: var(--muted);
  max-width: 360px;
  margin-bottom: 2rem;
  line-height: 1.5;
}
.powered-by {
  color: color-mix(in srgb, var(--text) 40%, transparent);
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
