:root {
  --bg: #f5f7f2;
  --bg-accent-a: #e9f5e1;
  --bg-accent-b: #eef7f6;
  --surface: #ffffff;
  --text: #16211c;
  --muted: #5f6d64;
  --border: #e1e6de;
  --brand: #1f7a4d;
  --brand-dark: #145c39;
  --brand-light: #dcf2e3;
  --accent: #eab308;
  --danger: #c0362c;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 24, 0.06);
  --shadow-md: 0 10px 30px -12px rgba(20, 40, 30, 0.25);
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1512;
    --bg-accent-a: #122019;
    --bg-accent-b: #101a1c;
    --surface: #17201b;
    --text: #eef3ee;
    --muted: #9aa89f;
    --border: #263029;
    --brand: #4fbf82;
    --brand-dark: #7fd8a4;
    --brand-light: #1c3327;
    --accent: #f2c94c;
    --danger: #ff7a6e;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 15% -10%, var(--bg-accent-a), transparent),
    radial-gradient(1000px 500px at 110% 10%, var(--bg-accent-b), transparent),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: block;
}

.brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.topbar-progress[hidden] { display: none; }
.topbar-progress {
  border-top: 1px solid var(--border);
}
.topbar-progress-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 16px 10px;
}
.topbar-progress .progress-label { margin-bottom: 6px; }
.topbar-progress .progress-wrap { margin-bottom: 0; }

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 16px 80px;
  min-height: calc(100vh - 65px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 28px 28px 30px;
  margin-bottom: 20px;
}

.card.hero {
  box-shadow: var(--shadow-md);
  border-top: 4px solid transparent;
  border-image: linear-gradient(90deg, var(--brand), var(--accent)) 1;
}

h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}
h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 4px;
  padding-left: 12px;
  border-left: 3px solid var(--brand);
}
p { color: var(--muted); margin-top: 0; }

.loading { text-align: center; color: var(--muted); padding: 48px 0; }
.loading::before {
  content: "";
  display: block;
  width: 22px;
  height: 22px;
  margin: 0 auto 12px;
  border-radius: 999px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

label { display: block; font-weight: 600; margin-bottom: 8px; }
.question { margin-bottom: 26px; }
.question .hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

input[type="text"], input[type="email"], input[type="password"], textarea, select {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  margin-bottom: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

textarea { min-height: 90px; resize: vertical; }

/* Progress bar */
.progress-wrap {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 18px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  border-radius: 999px;
  transition: width 0.3s ease;
}
.progress-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 8px;
}

.likert-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.likert-option {
  flex: 1 1 18%;
  min-width: 64px;
  text-align: center;
}

.likert-option input { display: none; }

.likert-option span {
  display: block;
  padding: 12px 4px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s ease;
}

.likert-option span:hover { border-color: var(--brand); color: var(--text); }

.likert-option input:checked + span {
  border-color: var(--brand);
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.likert-option input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.likert-group[aria-invalid="true"] .likert-option span { border-color: var(--danger); }

.question-pair {
  background: var(--brand-light);
  border-radius: var(--radius-md);
  padding: 18px 20px 4px;
  margin-bottom: 26px;
}
.question-pair .question { margin-bottom: 16px; }
.question-pair .question:first-child label { font-weight: 700; }
.question-pair .question:last-child label {
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--muted);
}

.inline-comment {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  animation: fade-in 0.2s ease;
}
.inline-comment[hidden] { display: none; }
.inline-comment .comment-label {
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.inline-comment textarea { min-height: 60px; }
@keyframes fade-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.likert-notsure { margin-top: 8px; }
.likert-notsure .likert-option { flex: none; min-width: 0; }
.likert-notsure .likert-option span {
  display: inline-block;
  padding: 6px 14px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--muted);
  border-style: dashed;
}
.likert-notsure .likert-option input:checked + span {
  background: var(--muted);
  border-color: var(--muted);
  border-style: solid;
}

.choice-row { display: flex; flex-direction: column; gap: 8px; }
.choice-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.choice-row label:has(input:checked) { border-color: var(--brand); background: var(--brand-light); }
.choice-row input { width: auto; margin: 0; }

button {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  border: none;
  padding: 13px 24px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

button:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
button:active { transform: translateY(0); }
button.secondary {
  background: transparent;
  color: var(--brand);
  border: 1.5px solid var(--brand);
  box-shadow: none;
}
button.secondary:hover { background: var(--brand-light); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

.error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0 0 16px;
  font-size: 0.9rem;
}

.notice {
  color: var(--text);
  background: var(--brand-light);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 16px;
  font-size: 0.9rem;
}
.notice-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.notice-actions button { padding: 8px 16px; font-size: 0.85rem; }

[aria-invalid="true"] { border-color: var(--danger) !important; }

.char-count {
  display: block;
  text-align: right;
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: -12px;
  margin-bottom: 16px;
}
.char-count.near-limit { color: var(--danger); }

.text-list-entry { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.text-list-entry textarea { margin-bottom: 0; flex: 1; }
.text-list-entry .remove-entry-btn {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  box-shadow: none;
  padding: 8px 12px;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.text-list-entry .remove-entry-btn:hover { color: var(--danger); border-color: var(--danger); }
.add-entry-btn { padding: 9px 16px; font-size: 0.85rem; margin-bottom: 16px; }

.restore-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--brand-light);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 0.88rem;
  flex-wrap: wrap;
}
.restore-banner button { padding: 6px 14px; font-size: 0.8rem; }

.review-section { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.review-section:last-of-type { border-bottom: none; }
.review-section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.review-section-head h3 { font-size: 0.95rem; margin: 0; }
.review-edit-btn { background: transparent; color: var(--brand); border: none; box-shadow: none; padding: 4px 8px; font-size: 0.82rem; font-weight: 700; text-decoration: underline; }
.review-answer { margin-bottom: 10px; font-size: 0.92rem; }
.review-answer .q { color: var(--muted); font-size: 0.82rem; margin-bottom: 2px; }
.review-answer .a { font-weight: 500; }
.review-answer .a.unanswered { color: var(--muted); font-style: italic; font-weight: 400; }

.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}

.section-title { margin-top: 36px; margin-bottom: 4px; }
.section-title p { margin-top: 4px; font-size: 0.9rem; }

table { width: 100%; border-collapse: collapse; margin: 12px 0; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.04em; }

.bar-track { background: var(--border); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { background: linear-gradient(90deg, var(--brand), var(--accent)); height: 100%; }

.pill {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pill.draft { background: var(--border); color: var(--muted); }
.pill.open { background: var(--brand-light); color: var(--brand-dark); }
.pill.closed { background: color-mix(in srgb, var(--accent) 25%, transparent); color: #7a5b00; }

nav.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
nav.tabs button { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); box-shadow: none; padding: 9px 18px; font-size: 0.9rem; }
nav.tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.suppressed { color: var(--muted); font-style: italic; font-size: 0.88rem; }

::selection { background: var(--brand-light); }

/* Wizard step header (one section per screen) */
.step-header { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.step-badge {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.step-header h2 {
  border-left: none;
  padding-left: 0;
  font-size: 1.3rem;
  margin: 0;
}
.step-description { margin: 0 0 24px 54px; font-size: 0.92rem; }

.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 30px;
}
.wizard-nav .spacer { flex: 1; }

/* Responsive */
@media (max-width: 600px) {
  .app { padding: 20px 12px 72px; }
  .card { padding: 20px 18px 24px; border-radius: var(--radius-md); }
  h1 { font-size: 1.3rem; }
  .step-badge { width: 34px; height: 34px; font-size: 0.9rem; }
  .step-header h2 { font-size: 1.12rem; }
  .step-description { margin-left: 0; }

  /* Full-width vertical list instead of a 3+2 grid: preserves the
     ordinal top-to-bottom reading and gives each option a full-width,
     comfortably-sized (~48px) tap target. */
  .likert-row { flex-direction: column; }
  .likert-option { flex: none; width: 100%; text-align: left; }
  .likert-option span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.88rem;
    padding: 13px 16px;
    min-height: 48px;
  }
  .likert-notsure .likert-option span { justify-content: flex-start; }

  .wizard-nav { flex-wrap: wrap; }
  .wizard-nav .spacer { display: none; }
  .wizard-nav button.next-btn { flex: 1 1 100%; }
  .wizard-nav button.secondary { flex: 1 1 100%; }
  nav.tabs { gap: 6px; }
  nav.tabs button { flex: 1 1 auto; padding: 9px 10px; font-size: 0.82rem; }
  table { font-size: 0.82rem; }
  th, td { padding: 6px; }
}
