:root {
  --bg: #F5F1E8;
  --ink: #29312C;
  --muted: #6B7068;
  --primary: #5B7B6F;
  --primary-dark: #3F5D51;
  --accent: #B78F46;
  --card: #FFFDF8;
  --border: #E1DCCE;
  --danger: #A8542F;
  --display-font: Georgia, "Times New Roman", serif;
  font-size: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
  line-height: 1.55;
}

#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100svh;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(48px + env(safe-area-inset-bottom));
  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, h2 { font-family: var(--display-font); color: var(--ink); letter-spacing: -0.015em; }
h1 { font-size: 1.9rem; margin: 0 0 12px; line-height: 1.2; }
h2 { font-size: 1.4rem; margin: 0 0 14px; line-height: 1.3; }
p { margin: 0 0 18px; color: var(--ink); font-size: 1rem; }
.subhead { color: var(--muted); font-size: 1rem; }
.app-header { display: flex; justify-content: center; align-items: center; padding: 6px 0 5px; }

.wordmark-hero {
  margin-bottom: 16px;
  text-align: center;
}
.logo-hero {
  height: 104px;
  width: auto;
  display: block;
  margin: 0 auto 8px;
  filter: hue-rotate(-95deg) saturate(0.48);
  mix-blend-mode: multiply;
}
.wordmark-header {
  display: flex;
  align-items: center;
}
.logo-header {
  height: 36px;
  width: auto;
  display: block;
  opacity: 0.9;
  filter: hue-rotate(-95deg) saturate(0.48);
  mix-blend-mode: multiply;
}

.landing-scene { text-align: center; }
.landing-scene h1 { color: var(--primary-dark); font-size: 2.15rem; }
.landing-body { font-size: 1.04rem; color: var(--ink); margin: 0 auto 10px; max-width: 32ch; }
.landing-tagline { font-size: 0.94rem; color: var(--muted); font-style: italic; margin-bottom: 20px; }
.landing-scene .helper { max-width: 31ch; margin-right: auto; margin-left: auto; }

/* ── Category grid ── */
.cat-section-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 10px;
  text-align: right;
}
.cat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 28px;
  direction: rtl;
}
@media (max-width: 540px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 541px) and (max-width: 720px) {
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
}
.cat-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px 10px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--card);
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  min-height: 80px;
}
.cat-tile.enabled {
  cursor: pointer;
  user-select: none;
}
.cat-tile.enabled:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(91,123,111,0.13);
}
.cat-tile.enabled:active {
  background: #f0f4f2;
}
.cat-tile.enabled.cat-active {
  border-color: var(--primary);
  background: #edf3f0;
  box-shadow: 0 0 0 2px var(--primary);
}
.cat-tile.disabled {
  opacity: 0.45;
  cursor: default;
  background: #f5f3ef;
  border-color: transparent;
}
.cat-icon {
  width: 28px;
  height: 28px;
  stroke: var(--primary);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex: 0 0 auto;
}
.cat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}
.cat-soon {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--border);
  border-radius: 20px;
  padding: 1px 6px;
  letter-spacing: 0.03em;
  margin-top: 2px;
}
.cat-reset {
  display: block;
  text-align: center;
  font-size: 0.82rem;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  margin: -14px 0 18px;
  background: none;
  border: none;
  padding: 4px 0;
  width: 100%;
}
.cat-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 20px;
}

.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-secondary.ef-active { background: var(--primary); color: #fff; }
.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;
  text-align: right;
}
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;
}
.question-intro { margin-bottom: 12px; }

.scale-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 10px;
  /* Keep scale-row LTR so labels match slider direction (min=left, max=right) */
  direction: ltr;
  text-align: left;
}

/* ── Custom range slider — always LTR so min is left, max is right ── */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  direction: ltr;
}

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: right; 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; text-align: center; }
.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; direction: ltr; }
.gov-row:last-child { margin-bottom: 0; }
.gov-label { flex: 0 0 auto; width: 52%; color: var(--text); text-align: right; direction: rtl; }
.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-right: 20px; padding-left: 0; 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; }

/* completed topic card — no interaction */
.topic-card.topic-done {
  opacity: 0.52;
  cursor: default;
  pointer-events: none;
  background: #F0EDE6;
}
.topic-done-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 0;
}
.topic-done-badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: #5B7B6F;
  background: #D8EAE2;
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
  margin-top: 2px;
}

/* pilot badge — landing page only, top-left (RTL start corner) */
.pilot-badge {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  font-size: 0.7rem;
  font-weight: 600;
  color: #9A9690;
  background: #ECEAE4;
  border: 1px solid #E0DDD6;
  border-radius: 20px;
  padding: 3px 10px;
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 10;
}

/* supplementary reading list — extra-resources section */
.extra-resources {
  margin: 20px 0 8px;
  padding: 14px 16px 10px;
  background: #F0EDE6;
  border-radius: 12px;
  border: 1px solid #E4E0D6;
}
.extra-resources-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #8A8478;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 12px;
  text-align: right;
}
.extra-resource-item {
  padding: 10px 0;
  border-bottom: 1px solid #E4E0D6;
  text-align: right;
}
.extra-resource-item:last-child { border-bottom: none; padding-bottom: 2px; }
.extra-resource-desc {
  font-size: 0.82rem;
  color: #5A5650;
  margin: 0 0 6px;
  line-height: 1.45;
}
.extra-resource-link {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #5B7B6F;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-left: 10px;
}
.extra-resource-link:hover { color: #3d5c52; }
.extra-resource-source {
  font-size: 0.72rem;
  color: #9A9690;
}

.post-card { border-right: 3px solid var(--primary); border-left: none; padding-right: 14px; padding-left: 0; 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; direction: ltr; }
.movement-bar-track { flex: 1; height: 8px; background: var(--border); border-radius: 4px; position: relative; direction: ltr; }
.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; }

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

@media (max-width: 540px) {
  .question-scene h2 {
    font-size: 1.2rem;
    line-height: 1.38;
  }
}

/* ── perspective-suggestions modal ── */
#persp-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 16px;
}
#persp-modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  width: min(460px, 100%);
  box-sizing: border-box;
  direction: rtl;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
