/* ===== Tokens ===== */
:root {
  --cream: #F6F1E6;
  --surface: #FFFDF9;
  --forest: #22301F;
  --forest-deep: #16200F;
  --ink: #2B2A22;
  --ink-soft: #5B5A4E;
  --sage: #8A9A78;
  --sage-deep: #5C6B4C;
  --sand: #BE9A55;
  --sand-deep: #A07F3C;
  --sand-soft: #ECE0C6;
  --line: #E1D6BC;
  --line-soft: #EAE1CB;
  --danger: #A24B3A;

  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Karla', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius-s: 9px;
  --radius-m: 13px;
  --radius-full: 999px;

  --maxw: 560px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

button, input, textarea { font-family: inherit; }
:focus-visible { outline: 2.5px solid var(--sage-deep); outline-offset: 2px; }

/* ===== App shell ===== */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--cream);
  padding: 9px 20px 5px;
}
.progress-track {
  max-width: var(--maxw);
  margin: 0 auto;
  height: 2px;
  background: var(--line);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--sand);
  transition: width .4s ease;
}
.progress-label {
  max-width: var(--maxw);
  margin: 5px auto 0;
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--ink-soft);
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 4px 20px 18px;
}

.error-slot {
  max-width: var(--maxw);
  margin: 0 auto;
  width: 100%;
  padding: 0 20px;
}

.bottombar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: linear-gradient(to top, var(--cream) 65%, transparent);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  max-width: calc(var(--maxw) + 40px);
  margin: 0 auto;
  width: 100%;
}
.bottombar .btn-primary { flex: 1; }
.bottombar[hidden] { display: none; }
.topbar[hidden] { display: none; }
.bottombar .btn-ghost { flex: 0 0 auto; }

/* ===== Buttons ===== */
.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-full);
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
  min-height: 44px;
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--forest);
  color: var(--cream);
}
.btn-primary:hover { background: var(--forest-deep); }
.btn-primary[disabled] { opacity: .38; cursor: default; }
.btn-primary[disabled]:active { transform: none; }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { border-color: var(--sage-deep); color: var(--ink); }
.btn-text {
  background: none;
  border: none;
  color: var(--sage-deep);
  font-weight: 600;
  padding: 6px 2px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ===== Step layout ===== */
.step {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  animation: rise .32s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.eyebrow {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 12px;
  color: var(--sand-deep);
  letter-spacing: .13em;
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 10px 0 3px;
}
.eyebrow .num { font-size: 16px; }
.eyebrow .label { font-size: 10.5px; color: var(--ink-soft); letter-spacing: .16em; font-family: var(--sans); font-weight: 700; }

.heading {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(21px, 5.4vw, 26px);
  line-height: 1.15;
  color: var(--forest);
  margin: 2px 0 5px;
}

.step-intro {
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.5;
  margin: 0 0 12px;
}

/* ===== Fields ===== */
.field {
  margin: 15px 0;
}
.field-label {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 7px;
}
.field-helper {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: -4px;
  margin-bottom: 8px;
}

textarea, .text-input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-s);
  padding: 10px 13px;
  font-size: 15.5px;
  color: var(--ink);
  resize: vertical;
  min-height: 44px;
  line-height: 1.45;
}
textarea { min-height: 64px; }
textarea:focus, .text-input:focus { border-color: var(--sage-deep); }
textarea::placeholder, .text-input::placeholder { color: #A6A08C; }

/* ===== Scale (1-5) ===== */
.scale-row {
  display: flex;
  gap: 6px;
}
.scale-btn {
  flex: 1;
  min-height: 38px;
  height: 38px;
  border-radius: var(--radius-s);
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
}
.scale-btn:hover { border-color: var(--sage); }
.scale-btn.selected {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--cream);
}
.scale-endlabels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 4px;
}
.scale-skip {
  margin-top: 5px;
  background: none;
  border: none;
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 3px 0;
}
.scale-skip.active { color: var(--sand-deep); font-weight: 700; text-decoration: none; }

/* ===== Choice list (single select, vertical pills) ===== */
.choice-list { display: flex; flex-direction: column; gap: 6px; }
.choice-pill {
  text-align: left;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-m);
  padding: 11px 16px;
  font-size: 14.5px;
  color: var(--ink);
  cursor: pointer;
  min-height: 44px;
  transition: all .15s ease;
}
.choice-pill:hover { border-color: var(--sage); }
.choice-pill.selected {
  background: var(--sand-soft);
  border-color: var(--sand);
  color: var(--forest-deep);
  font-weight: 600;
}

/* ===== Multi-select chips ===== */
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-full);
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  min-height: 40px;
}
.chip.selected {
  background: var(--sage);
  border-color: var(--sage);
  color: #fff;
  font-weight: 600;
}

/* ===== Compact rating list rows (programme / practical items) ===== */
.item-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
}
.item-row:first-of-type { border-top: none; padding-top: 0; }
.item-row-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.item-row-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}
.item-row-sub {
  font-size: 11px;
  color: var(--sage-deep);
  line-height: 1.3;
}
.item-row-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mini-scale {
  display: flex;
  gap: 4px;
  flex: 1;
}
.mini-scale-btn {
  flex: 1;
  max-width: 34px;
  height: 30px;
  border-radius: 7px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.mini-scale-btn:hover { border-color: var(--sage); }
.mini-scale-btn.selected {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--cream);
}
.mini-skip {
  flex: 0 0 auto;
  background: none;
  border: none;
  font-size: 11px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  white-space: nowrap;
  padding: 4px 0 4px 2px;
}
.mini-skip.active { color: var(--sand-deep); font-weight: 700; text-decoration: none; }

@media (min-width: 640px) {
  .item-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 14px; }
  .item-row-label { flex: 1 1 auto; }
  .item-row-controls { flex: 0 0 auto; }
  .mini-scale-btn { width: 30px; max-width: 30px; }
}

/* ===== Yes/No toggle ===== */
.yesno { display: flex; gap: 8px; }
.yesno .choice-pill { flex: 1; text-align: center; }

/* ===== Intro / outro ===== */
.hero {
  width: 100%;
  max-width: var(--maxw);
  margin: 6vh auto 0;
  text-align: left;
}
.hero-kicker {
  font-size: 11px;
  letter-spacing: .15em;
  font-weight: 700;
  color: var(--sage-deep);
  margin-bottom: 10px;
}
.hero-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 10vw, 50px);
  line-height: 1.03;
  color: var(--forest);
  margin: 0 0 5px;
}
.hero-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  color: var(--sage-deep);
  margin: 0 0 16px;
}
.hero-body {
  font-size: 14.5px;
  line-height: 1.58;
  color: var(--ink);
  margin-bottom: 14px;
}
.hero-body + .hero-body { margin-top: -6px; }
.hero-meta {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 20px;
}
.hero .btn-primary { width: 100%; }

.outro {
  width: 100%;
  max-width: var(--maxw);
  margin: 11vh auto 0;
  text-align: center;
}
.outro-mark { font-size: 30px; margin-bottom: 12px; }
.outro-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
  color: var(--forest);
  margin: 0 0 12px;
}
.outro-body {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 18px;
}
.outro-signature {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--sage-deep);
}

.field-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
}
.submit-error-banner {
  background: #F7E7E1;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-s);
  max-width: 100%;
  height: auto;
  min-height: 0;
  padding: 12px 16px;
  margin: 12px 0;
  font-size: 13.5px;
  line-height: 1.4;
}

@media (min-width: 640px) {
  .stage { padding-top: 12px; }
}
