:root {
  --bg: #F7F5F0;
  --ink: #2B2B28;
  --muted: #6F6B5F;
  --primary: #5B7B6F;
  --primary-dark: #45604F;
  --accent: #C9A24B;
  --card: #FFFFFF;
  --border: #E4E0D6;
  --danger: #A8542F;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.55;
}

#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  padding: max(24px, calc(env(safe-area-inset-top) + 16px)) 20px max(48px, calc(env(safe-area-inset-bottom) + 28px));
  display: flex;
  flex-direction: column;
}

/* Vertically center screen content */
.screen-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.progress-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 32px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

h1 { font-size: 1.9rem; margin: 0 0 12px; line-height: 1.2; letter-spacing: -0.025em; }
h2 { font-size: 1.4rem; margin: 0 0 14px; line-height: 1.3; letter-spacing: -0.015em; }
p { margin: 0 0 18px; color: var(--ink); font-size: 1rem; }
.subhead { color: var(--muted); font-size: 1rem; }
.logo-hero { max-width: 190px; width: 100%; height: auto; margin-bottom: 18px; display: block; margin-left: auto; margin-right: auto; filter: hue-rotate(-65deg) saturate(0.58) brightness(0.82); }
.app-header { display: flex; justify-content: center; align-items: center; padding: 10px 0 6px; }
.logo-header { height: 32px; width: auto; max-width: 120px; display: block; opacity: 0.88; filter: hue-rotate(-65deg) saturate(0.58) brightness(0.82); }

.landing-body { font-size: 1.06rem; color: var(--ink); margin-bottom: 10px; max-width: 29rem; }
.landing-tagline { font-size: 0.95rem; color: var(--muted); font-style: italic; margin-bottom: 20px; }
.question-intro { margin-bottom: 18px; }
.question-title { text-wrap: balance; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 18px;
}

.btn {
  display: block;
  width: 100%;
  padding: 17px 18px;
  border-radius: 12px;
  border: none;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  margin-top: 10px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:disabled { background: #B9C4BE; cursor: not-allowed; }
.btn-primary:active:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-link { background: none; border: none; color: var(--muted); text-decoration: underline; font-size: 0.9rem; padding: 10px; cursor: pointer; }

input[type=text], input[type=tel], textarea {
  width: 100%;
  padding: 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 1rem;
  margin-bottom: 14px;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 96px; }

/* ── Slider container ── */
.slider-wrap {
  margin: 20px 0 28px;
}

.slider-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 12px;
  letter-spacing: 0.01em;
}
.slider-status {
  min-height: 1.35em;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  margin: 12px 0 0;
}

.scale-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 10px;
}

/* ── Custom range slider ── */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.22);
  border: 3px solid #fff;
  transition: background 0.15s ease, transform 0.1s ease;
}
input[type=range]:active::-webkit-slider-thumb {
  background: var(--primary-dark);
  transform: scale(1.1);
}

input[type=range]::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.22);
}

.error-box { background: #F5E4DC; color: var(--danger); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 0.9rem; }
.helper { color: var(--muted); font-size: 0.88rem; margin-top: -8px; margin-bottom: 18px; }
.back-link { display: block; margin-bottom: 12px; text-align: left; font-size: 0.88rem; }
.video-progress { font-size: 0.82rem; font-weight: 600; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase; margin: 0 0 6px; }
.radio-row, .checkbox-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 0.97rem; }
.radio-row:last-child, .checkbox-row:last-child { border-bottom: none; padding-bottom: 0; }
.radio-row input[type="radio"], .checkbox-row input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; accent-color: var(--primary); width: 16px; height: 16px; }
.gov-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 0.88rem; }
.gov-row:last-child { margin-bottom: 0; }
.gov-label { flex: 0 0 auto; width: 52%; color: var(--text); }
.gov-bar-wrap { flex: 1; background: rgba(0,0,0,0.07); border-radius: 4px; height: 8px; overflow: hidden; }
.gov-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.4s ease; }
.gov-pct { flex: 0 0 auto; width: 34px; text-align: right; font-weight: 600; color: var(--primary); }
.quick-context { color: var(--muted); font-size: 0.82rem; line-height: 1.45; margin-top: 10px; margin-bottom: 18px; padding: 8px 12px; background: rgba(0,0,0,0.03); border-radius: 6px; }

.checkbox-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 18px; }
.checkbox-row input { margin-top: 4px; }

ul.plain { padding-left: 20px; margin: 0 0 18px; }
ul.plain li { margin-bottom: 10px; font-size: 1rem; }

.video-wrap { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 12px; background: #000; margin-bottom: 16px; }
.video-wrap iframe { position: absolute; top:0; left:0; width:100%; height:100%; border: 0; }

.pill {
  display: inline-block;
  background: #EFEAE0;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.topic-card {
  cursor: pointer;
  border: 2px solid var(--border);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.topic-card:hover, .topic-card:focus {
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(91, 123, 111, 0.18);
  outline: none;
}
.topic-card:active { background: #F0F5F2; }

.post-card { border-left: 3px solid var(--primary); padding-left: 14px; margin-bottom: 16px; }
.post-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.82rem; color: var(--muted); margin-top: 8px; }
.upvote-btn { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 5px 12px; cursor: pointer; color: var(--primary); font-weight: 600; }

.movement-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.movement-bar-track { flex: 1; height: 8px; background: var(--border); border-radius: 4px; position: relative; }
.movement-marker { position: absolute; top: -4px; width: 16px; height: 16px; border-radius: 50%; transform: translateX(-50%); }
.marker-baseline { background: var(--muted); }
.marker-final { background: var(--primary); }

.footer-note { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 24px; }

/* Exit-feedback toggle buttons */
.toggle-row { display: flex; gap: 10px; flex-wrap: wrap; }
.toggle-btn {
  flex: 1; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--ink); font-size: 1rem; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.toggle-btn:hover { border-color: var(--primary); }
.toggle-btn.toggle-active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.field-label { display: block; font-weight: 600; margin-bottom: 8px; }

/* ── Category grid ── */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.cat-tile {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 5px;
}

.cat-tile--active {
  cursor: pointer;
  border-color: var(--primary);
  transition: box-shadow 0.15s ease, background 0.15s ease;
}
.cat-tile--active:hover,
.cat-tile--active:focus {
  box-shadow: 0 2px 10px rgba(91, 123, 111, 0.22);
  outline: none;
  background: #F0F5F2;
}
.cat-tile--active:active { background: #E6EFEB; }
.cat-tile--selected {
  background: #EEF3F0;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(91, 123, 111, 0.25);
}

.cat-tile--disabled {
  opacity: 0.42;
  pointer-events: none;
  user-select: none;
  border-color: var(--border);
}

.cat-icon {
  color: var(--primary);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cat-icon svg {
  width: 1.55rem;
  height: 1.55rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cat-name {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}
.cat-soon {
  font-size: 0.67rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 1px;
}

.cat-section-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 12px;
}

@media (max-width: 380px) {
  #app { padding: max(18px, calc(env(safe-area-inset-top) + 14px)) 14px max(36px, calc(env(safe-area-inset-bottom) + 22px)); }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.25rem; }
  .cat-name { font-size: 0.72rem; }
}

@media (max-width: 600px) {
  .question-title { font-size: 1.22rem; line-height: 1.34; }
}

/* ── Perspective suggestion link ── */
.ps-link-wrap {
  text-align: center;
  margin-top: 14px;
  margin-bottom: 0;
}
.ps-link-wrap a {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  opacity: 0.72;
  transition: opacity 0.15s;
}
.ps-link-wrap a:hover,
.ps-link-wrap a:focus { opacity: 1; text-decoration: underline; outline: none; }

/* ── Perspective suggestion modal ── */
#ps-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.42);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#ps-modal {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px 24px;
  max-width: 430px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.18);
}
#ps-modal h3 {
  margin: 0 0 18px;
  font-size: 1.1rem;
  color: var(--ink);
}
#ps-modal label {
  display: block;
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
#ps-modal textarea {
  width: 100%;
  min-height: 88px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.94rem;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
  margin-bottom: 16px;
}
#ps-modal input[type="url"] {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.94rem;
  font-family: inherit;
  box-sizing: border-box;
  margin-bottom: 14px;
}
#ps-modal textarea:focus,
#ps-modal input[type="url"]:focus {
  outline: none;
  border-color: var(--primary);
}
#ps-error {
  font-size: 0.83rem;
  color: #c0392b;
  min-height: 18px;
  margin-bottom: 8px;
}
.ps-btns {
  display: flex;
  gap: 10px;
}
.ps-btns .btn { flex: 1; }

/* ── Completed topic card ── */
.topic-card--done {
  opacity: 0.52;
  pointer-events: none;
  cursor: default;
}
.topic-done-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: #3a6358;
  background: #d6ebe4;
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
}

.pilot-badge {
  position: fixed;
  top: max(14px, calc(env(safe-area-inset-top) + 10px));
  right: 18px;
  font-size: 0.7rem;
  font-weight: 500;
  color: #999;
  background: #f0eeea;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 3px 10px;
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 10;
}
