:root {
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-soft: #64748b;

  --emerald: #059669;
  --emerald-dark: #047857;
  --emerald-soft: #d1fae5;
  --sky: #0284c7;
  --sky-dark: #0369a1;
  --sky-soft: #e0f2fe;
  --amber: #d97706;
  --amber-dark: #b45309;
  --amber-soft: #fef3c7;
  --earth: #b45309;
  --earth-dark: #92400e;
  --earth-soft: #ffedd5;
  --rose: #dc2626;
  --rose-dark: #b91c1c;
  --rose-soft: #fee2e2;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 8% 6%, rgba(5, 150, 105, 0.14), transparent 36%),
    radial-gradient(circle at 92% 8%, rgba(2, 132, 199, 0.14), transparent 36%),
    radial-gradient(circle at 50% 96%, rgba(180, 83, 9, 0.09), transparent 40%),
    var(--bg-page);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.app-shell {
  max-width: 1340px;
  margin: 0 auto;
  padding: 16px 20px 36px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===========================
   HEADER
   =========================== */
.app-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-back-portal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.84rem;
  font-weight: 700;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.btn-back-portal:hover {
  background: var(--emerald-soft);
  border-color: var(--emerald);
  color: var(--emerald-dark);
}

.btn-back-portal svg {
  width: 16px;
  height: 16px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.brand-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand h1 {
  margin: 0;
  font-size: 1.24rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.meb-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--emerald-soft);
  color: var(--emerald-dark);
  border: 1px solid #a7f3d0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 0.83rem;
  color: var(--text-muted);
}

.stat-pill strong {
  color: var(--text-main);
  font-size: 0.93rem;
}

.stat-discover strong {
  color: var(--emerald-dark);
}

.stat-score strong {
  color: var(--sky-dark);
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.22);
}

/* ===========================
   BUTTONS
   =========================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 9px 15px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.14s ease, background 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
}

.btn-primary {
  background: linear-gradient(135deg, #059669, #0284c7);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.26);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #047857, #0369a1);
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.34);
}

.btn-soft {
  background: var(--emerald-soft);
  color: var(--emerald-dark);
  border-color: #a7f3d0;
}

.btn-soft:hover:not(:disabled) {
  background: #a7f3d0;
}

.btn-soft.is-active {
  background: var(--emerald);
  color: #ffffff;
  border-color: var(--emerald-dark);
}

.btn-ghost {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-strong);
}

.btn-ghost:hover:not(:disabled) {
  background: #e2e8f0;
}

/* ===========================
   MODE NAV (TABS)
   =========================== */
.mode-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.mode-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 12px 15px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-family: inherit;
  color: var(--text-main);
  transition: transform 0.14s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.mode-tab:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.mode-tab.is-active {
  border-color: var(--emerald);
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
  box-shadow: 0 6px 18px rgba(5, 150, 105, 0.14);
}

.mode-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.86rem;
  flex-shrink: 0;
}

.mode-badge--emerald {
  background: var(--emerald-soft);
  color: var(--emerald-dark);
}

.mode-badge--sky {
  background: var(--sky-soft);
  color: var(--sky-dark);
}

.mode-badge--amber {
  background: var(--amber-soft);
  color: var(--amber-dark);
}

.mode-badge--earth {
  background: var(--earth-soft);
  color: var(--earth-dark);
}

.mode-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mode-copy strong {
  font-size: 0.92rem;
  font-weight: 800;
}

.mode-copy small {
  font-size: 0.77rem;
  color: var(--text-muted);
}

/* ===========================
   CARDS & PANELS
   =========================== */
.mode-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-head h2,
.section-head h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.card-sub {
  margin: 2px 0 0;
  font-size: 0.83rem;
  color: var(--text-muted);
}

.pill-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill-tag--emerald {
  background: var(--emerald-soft);
  color: var(--emerald-dark);
}

.pill-tag--sky {
  background: var(--sky-soft);
  color: var(--sky-dark);
}

.pill-tag--amber {
  background: var(--amber-soft);
  color: var(--amber-dark);
}

.pill-tag--earth {
  background: var(--earth-soft);
  color: var(--earth-dark);
}

.pill-tag--rose {
  background: var(--rose-soft);
  color: var(--rose-dark);
}

/* ===========================
   TAB 1: ABIOTIC CONTROLS & CANVAS
   =========================== */
.eco-controls-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px;
}

.sliders-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.slider-control {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.slider-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.83rem;
  font-weight: 800;
  color: var(--text-main);
}

.dot-ind {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-ind--amber { background: var(--amber); }
.dot-ind--rose { background: var(--rose); }
.dot-ind--sky { background: var(--sky); }
.dot-ind--earth { background: var(--earth); }

.slider-val-badge {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.badge--amber { background: var(--amber-soft); color: var(--amber-dark); }
.badge--emerald { background: var(--emerald-soft); color: var(--emerald-dark); }
.badge--sky { background: var(--sky-soft); color: var(--sky-dark); }
.badge--earth { background: var(--earth-soft); color: var(--earth-dark); }
.badge--rose { background: var(--rose-soft); color: var(--rose-dark); }

.range-input {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  appearance: none;
  background: #dbeafe;
  outline: none;
  cursor: pointer;
}

.range--amber { accent-color: var(--amber); background: #fde68a; }
.range--emerald { accent-color: var(--emerald); background: #a7f3d0; }
.range--sky { accent-color: var(--sky); background: #bae6fd; }
.range--earth { accent-color: var(--earth); background: #fed7aa; }

.slider-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.71rem;
  color: var(--text-soft);
  font-weight: 600;
}

.biotic-test-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
}

.biotic-test-group,
.preset-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 0.73rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

.segmented-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 11px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.81rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.seg-btn:hover {
  color: var(--text-main);
  background: #e2e8f0;
}

.seg-btn.is-active {
  background: var(--emerald);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.25);
}

.seg-btn.is-active[data-biotic="no-producers"],
.seg-btn.is-active[data-biotic="no-consumers"],
.seg-btn.is-active[data-biotic="no-decomposers"] {
  background: var(--rose);
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.25);
}

.preset-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Main Grid */
.eco-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(300px, 1fr);
  gap: 14px;
  align-items: start;
}

.canvas-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.canvas-stage-wrap {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #e0f2fe;
  position: relative;
}

.canvas-stage-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* Telemetry Strip */
.telemetry-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.telemetry-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.telemetry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.telemetry-name {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
}

.telemetry-val {
  font-size: 0.92rem;
  font-weight: 800;
}

.text-emerald { color: var(--emerald-dark); }
.text-sky { color: var(--sky-dark); }
.text-earth { color: var(--earth-dark); }

.meter-track {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.fill-emerald { background: linear-gradient(90deg, #10b981, #059669); }
.fill-sky { background: linear-gradient(90deg, #38bdf8, #0284c7); }
.fill-earth { background: linear-gradient(90deg, #f59e0b, #b45309); }

.health-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.health-pill--good { background: var(--emerald-soft); color: var(--emerald-dark); }
.health-pill--warn { background: var(--amber-soft); color: var(--amber-dark); }
.health-pill--bad { background: var(--rose-soft); color: var(--rose-dark); }

/* Right Explanation Card */
.eco-explain-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.explain-header h2,
.explain-header h3 {
  margin: 6px 0 0;
  font-size: 1.06rem;
  font-weight: 800;
  line-height: 1.3;
}

.explain-body {
  margin: 0;
  font-size: 0.87rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.stress-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stress-chip {
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.chip--good { background: var(--emerald-soft); color: var(--emerald-dark); }
.chip--warn { background: var(--amber-soft); color: var(--amber-dark); }
.chip--bad { background: var(--rose-soft); color: var(--rose-dark); }
.chip--info { background: var(--sky-soft); color: var(--sky-dark); }

.cycle-mini-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 13px;
}

.cycle-mini-box h3 {
  margin: 0 0 6px;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text-main);
}

.cycle-list {
  margin: 0;
  padding-left: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meb-callout {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fcd34d;
  border-radius: var(--radius-md);
  padding: 11px 13px;
}

.meb-callout-title {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--amber-dark);
  margin-bottom: 4px;
}

.meb-callout p {
  margin: 0;
  font-size: 0.82rem;
  color: #78350f;
  line-height: 1.5;
}

/* ===========================
   TAB 2: BIOTIC & CONCEPTS
   =========================== */
.biotic-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.biotic-card {
  text-align: left;
  background: var(--bg-subtle);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.14s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.biotic-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.biotic-card.is-active {
  background: #ffffff;
  border-color: var(--emerald);
  box-shadow: 0 8px 20px rgba(5, 150, 105, 0.13);
}

.biotic-card[data-role="consumers"].is-active {
  border-color: var(--sky);
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.14);
}

.biotic-card[data-role="decomposers"].is-active {
  border-color: var(--earth);
  box-shadow: 0 8px 20px rgba(180, 83, 9, 0.14);
}

.biotic-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.role-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.role-icon--emerald { background: var(--emerald-soft); }
.role-icon--sky { background: var(--sky-soft); }
.role-icon--earth { background: var(--earth-soft); }

.biotic-card h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-main);
}

.biotic-card p {
  margin: 0;
  font-size: 0.81rem;
  color: var(--text-muted);
}

.biotic-detail-panel {
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.biotic-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.biotic-detail-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.biotic-detail-desc {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.biotic-subtypes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.subtype-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.subtype-card h4 {
  margin: 0 0 5px;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main);
}

.subtype-card p {
  margin: 0 0 6px;
  font-size: 0.81rem;
  color: var(--text-muted);
}

.subtype-examples {
  font-size: 0.77rem;
  font-weight: 700;
  color: var(--emerald-dark);
  background: var(--emerald-soft);
  display: inline-block;
  padding: 3px 8px;
  border-radius: 7px;
}

/* Dual Nutrition */
.dual-nutrition-box {
  background: linear-gradient(135deg, #fffbeb 0%, #f0fdf4 100%);
  border: 1.5px solid #fcd34d;
  border-radius: 14px;
  padding: 15px 17px;
}

.dual-header h3 {
  margin: 6px 0 3px;
  font-size: 1rem;
  font-weight: 800;
}

.dual-header p {
  margin: 0 0 11px;
  font-size: 0.83rem;
  color: var(--text-muted);
}

.dual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dual-card {
  text-align: left;
  background: #ffffff;
  border: 1.5px solid #fde68a;
  border-radius: 12px;
  padding: 13px 15px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.dual-card:hover,
.dual-card.is-active {
  border-color: var(--amber);
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.15);
}

.dual-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.dual-card-head strong {
  font-size: 0.93rem;
  color: var(--text-main);
}

.dual-pill {
  background: var(--amber-soft);
  color: var(--amber-dark);
  font-size: 0.73rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.dual-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Organization Ladder */
.ladder-layout {
  display: grid;
  grid-template-columns: minmax(250px, 0.95fr) minmax(0, 1.55fr);
  gap: 16px;
  align-items: stretch;
}

.ladder-steps {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ladder-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.14s ease;
}

.ladder-step:hover {
  border-color: var(--sky);
  transform: translateX(3px);
}

.ladder-step.is-active {
  background: linear-gradient(90deg, #e0f2fe 0%, #f0fdf4 100%);
  border-color: var(--sky);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.14);
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--sky-soft);
  color: var(--sky-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 800;
  flex-shrink: 0;
}

.ladder-step.is-active .step-num {
  background: var(--sky);
  color: #ffffff;
}

.step-name {
  font-size: 0.89rem;
  font-weight: 800;
  color: var(--text-main);
  flex: 1;
}

.step-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-soft);
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}

.ladder-detail-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.nested-rings {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

.ring {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 3px;
  font-size: 0.61rem;
  font-weight: 800;
  color: var(--text-soft);
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.ring-5 { width: 198px; height: 198px; }
.ring-4 { width: 168px; height: 168px; }
.ring-3 { width: 138px; height: 138px; }
.ring-2 { width: 108px; height: 108px; }
.ring-1 { width: 78px; height: 78px; }
.ring-0 { width: 50px; height: 50px; align-items: center; padding-top: 0; font-size: 0.56rem; }

.ring.is-highlighted {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.2);
  color: var(--emerald-dark);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.18);
}

.ladder-copy-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.ladder-copy h3 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 800;
}

.ladder-copy p {
  margin: 0 0 10px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.ladder-example-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--emerald);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.83rem;
  color: var(--text-main);
  margin-bottom: 8px;
}

.ladder-note {
  font-size: 0.8rem !important;
  color: var(--sky-dark) !important;
  font-weight: 600;
  margin-bottom: 0 !important;
}

/* Habitat vs Niche vs Ecotone */
.concept-trio {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.concept-card {
  text-align: left;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 13px 15px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.concept-card:hover {
  border-color: var(--border-strong);
}

.concept-card.is-active {
  background: #ffffff;
  border-color: var(--amber);
  box-shadow: 0 6px 18px rgba(217, 119, 6, 0.14);
}

.concept-eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--amber-dark);
  margin-bottom: 3px;
}

.concept-card h3 {
  margin: 0 0 5px;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-main);
}

.concept-card p {
  margin: 0;
  font-size: 0.81rem;
  color: var(--text-muted);
}

.ecotone-stage-wrap {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f0fdf4;
  margin-bottom: 12px;
}

.ecotone-stage-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
}

.ecotone-traits-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.trait-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-top: 3px solid var(--emerald);
  border-radius: 11px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.trait-box strong {
  font-size: 0.83rem;
  color: var(--text-main);
}

.trait-box span {
  font-size: 0.77rem;
  color: var(--text-muted);
}

/* ===========================
   TAB 3: TOLERANCE LAB
   =========================== */
.tol-controls-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.species-selector {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.species-btn {
  text-align: left;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.species-btn:hover {
  border-color: var(--sky);
}

.species-btn.is-active {
  background: linear-gradient(180deg, #ffffff 0%, #e0f2fe 100%);
  border-color: var(--sky);
  box-shadow: 0 5px 15px rgba(2, 132, 199, 0.15);
}

.species-btn strong {
  font-size: 0.93rem;
  color: var(--text-main);
}

.species-btn small {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.tol-slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: center;
}

.tol-slider-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 15px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tol-live-readout {
  background: var(--bg-subtle);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tol-zone-pill {
  display: inline-flex;
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.pill--optimum { background: var(--emerald-soft); color: var(--emerald-dark); }
.pill--stress { background: var(--amber-soft); color: var(--amber-dark); }
.pill--lethal { background: var(--rose-soft); color: var(--rose-dark); }

.tol-live-readout strong {
  font-size: 0.95rem;
  color: var(--text-main);
}

.tol-live-readout small {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.tol-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr);
  gap: 14px;
  align-items: start;
}

.tol-info-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tol-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tol-metric {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tol-metric--opt {
  background: var(--emerald-soft);
  border-color: #a7f3d0;
}

.tol-metric span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-soft);
}

.tol-metric--opt span {
  color: var(--emerald-dark);
}

.tol-metric strong {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main);
}

/* ===========================
   TAB 4: CASE CARDS & QUIZ
   =========================== */
.case-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.case-feedback-banner {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-left: 4px solid var(--sky);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-main);
  margin-bottom: 12px;
}

.case-feedback-banner.is-correct {
  background: #f0fdf4;
  border-color: #bbf7d0;
  border-left-color: var(--emerald);
  color: var(--emerald-dark);
}

.case-feedback-banner.is-wrong {
  background: #fef2f2;
  border-color: #fecaca;
  border-left-color: var(--rose);
  color: var(--rose-dark);
}

.cases-deck {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.case-card {
  background: #ffffff;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-main);
  cursor: grab;
  user-select: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.case-card:hover {
  border-color: var(--sky);
  transform: translateY(-2px);
}

.case-card.is-selected {
  border-color: var(--emerald);
  background: #f0fdf4;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.22);
}

.case-card.is-dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.case-card-num {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--sky-dark);
  background: var(--sky-soft);
  padding: 1px 7px;
  border-radius: 999px;
  margin-bottom: 5px;
}

.bins-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.drop-bin {
  background: var(--bg-subtle);
  border: 2px dashed var(--border-strong);
  border-radius: 14px;
  padding: 12px;
  min-height: 155px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.14s ease;
}

.drop-bin:hover,
.drop-bin.is-over {
  transform: translateY(-2px);
}

.bin--sky { border-color: #7dd3fc; background: #f0f9ff; }
.bin--emerald { border-color: #6ee7b7; background: #ecfdf5; }
.bin--amber { border-color: #fcd34d; background: #fffbeb; }
.bin--earth { border-color: #fdba74; background: #fff7ed; }

.drop-bin.is-over {
  border-style: solid;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
}

.bin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.bin-head strong {
  font-size: 0.87rem;
  color: var(--text-main);
}

.bin-count {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.77rem;
  font-weight: 800;
}

.bin-hint {
  margin: 0;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.bin-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.placed-chip {
  background: #ffffff;
  border: 1px solid #a7f3d0;
  border-left: 3px solid var(--emerald);
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 0.76rem;
  color: var(--text-main);
  line-height: 1.35;
}

/* Quiz */
.quiz-head-pills {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quiz-progress-track {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #059669, #0284c7);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.quiz-topic-row {
  margin-bottom: 8px;
}

.quiz-question-text {
  margin: 0 0 14px;
  font-size: 1.03rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.45;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.quiz-opt-btn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.87rem;
  color: var(--text-main);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.quiz-opt-btn:hover:not(:disabled) {
  border-color: var(--sky);
  background: #f0f9ff;
}

.quiz-opt-btn:disabled {
  cursor: default;
}

.opt-letter {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.quiz-opt-btn.is-correct {
  background: #ecfdf5;
  border-color: var(--emerald);
  color: var(--emerald-dark);
}

.quiz-opt-btn.is-correct .opt-letter {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #ffffff;
}

.quiz-opt-btn.is-wrong {
  background: #fef2f2;
  border-color: var(--rose);
  color: var(--rose-dark);
}

.quiz-opt-btn.is-wrong .opt-letter {
  background: var(--rose);
  border-color: var(--rose);
  color: #ffffff;
}

.quiz-explanation {
  background: #f0fdf4;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 12px 15px;
  margin-bottom: 14px;
}

.quiz-explanation.is-wrong-exp {
  background: #fffbeb;
  border-color: #fcd34d;
}

.quiz-explanation strong {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: var(--text-main);
}

.quiz-explanation p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.quiz-footer {
  display: flex;
  justify-content: flex-end;
}

.quiz-summary {
  text-align: center;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.summary-badge {
  font-size: 2.8rem;
  line-height: 1;
}

.quiz-summary h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.summary-score-line {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--emerald-dark);
}

.summary-msg {
  margin: 0 0 10px;
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 560px;
}

.app-footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-soft);
  padding-top: 6px;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 1080px) {
  .mode-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sliders-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .eco-main-grid,
  .tol-main-grid,
  .ladder-layout {
    grid-template-columns: 1fr;
  }
  .cases-deck,
  .bins-grid,
  .ecotone-traits-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px 12px 28px;
  }
  .mode-nav,
  .sliders-grid,
  .telemetry-strip,
  .biotic-cards-grid,
  .dual-grid,
  .concept-trio,
  .species-selector,
  .tol-slider-row,
  .quiz-options,
  .cases-deck,
  .bins-grid,
  .ecotone-traits-grid {
    grid-template-columns: 1fr;
  }
  .ladder-detail-box {
    grid-template-columns: 1fr;
  }
}
