/* =====================================================================
   Cervical Mobility Lab - HVLA + Therapeutic Massage Console
   Companion to a clinical study on HVLA manipulation and therapeutic
   massage for neck lateral-flexion mobility (BRAIN, 14(4), 2023).
   Palette + layout strictly per the provided visual framework.
   ===================================================================== */

:root {
  --burgundy: #700b06;
  --burgundy-dark: #5a0805;
  --bg: #f7ecd0;
  --panel: #ffffff;
  --panel-strong: #fff8e6;
  --ink: #160907;
  --muted: #3f2719;
  --line: #9b6a1f;
  --warning-line: #d99b18;

  /* Alert state tokens (derived, kept consistent with palette) */
  --optimal: #1f7a43;
  --optimal-bg: #eaf6ee;
  --optimal-line: #3aa564;
  --warning: #a5730a;
  --warning-bg: #fff4d6;
  --high: #8f1108;
  --high-bg: #fbe4e1;
  --high-line: #c8332a;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 26px rgba(22, 9, 7, 0.12);
  --shadow-soft: 0 4px 14px rgba(22, 9, 7, 0.08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; color: var(--ink); }
p { margin: 0 0 0.75rem; }
em { font-style: italic; color: var(--muted); }

/* ===================== Journal header banner ===================== */
.page-header {
  background: var(--burgundy);
  border-bottom: 4px solid var(--warning-line);
}
.image-banner {
  display: block;
  max-width: 1400px;
  margin: 0 auto;
}
.image-banner img {
  display: block;
  width: 100%;
  height: auto;
}

/* ===================== App shell (two-column grid) ===================== */
.app-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  align-items: start;
}

/* ===================== Sidebar ===================== */
.sidebar {
  position: sticky;
  top: 24px;
  background: linear-gradient(165deg, var(--burgundy) 0%, var(--burgundy-dark) 100%);
  color: #fdeede;
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 30px;
  line-height: 1;
  color: var(--warning-line);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.brand-title { font-size: 15px; font-weight: 700; letter-spacing: 0.2px; }
.brand-sub {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--warning-line);
}

.patient-chip {
  position: relative;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 248, 230, 0.22);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.patient-chip-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.patient-chip-label { color: #f3d7b8; }
.patient-chip-value { font-weight: 700; }

.patient-chip-view { display: flex; flex-direction: column; gap: 6px; }
.chip-edit-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  padding: 0;
  line-height: 1;
  font-size: 13px;
  color: #fff8e6;
  background: rgba(255, 248, 230, 0.12);
  border: 1px solid rgba(255, 248, 230, 0.28);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.chip-edit-btn:hover { background: rgba(255, 248, 230, 0.24); transform: rotate(-8deg); }
.chip-edit-form { display: flex; flex-direction: column; gap: 8px; }
.chip-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #f3d7b8; }
.chip-field input {
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 248, 230, 0.3);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
}
.chip-field input:focus { outline: none; border-color: var(--warning-line); box-shadow: 0 0 0 2px rgba(217, 155, 24, 0.35); }
.chip-edit-actions { display: flex; gap: 6px; margin-top: 2px; }
.chip-save,
.chip-cancel {
  flex: 1;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}
.chip-save { background: #fff8e6; color: var(--burgundy-dark); }
.chip-save:hover { background: #fff; }
.chip-cancel { background: transparent; color: #f3d7b8; border-color: rgba(255, 248, 230, 0.28); }
.chip-cancel:hover { background: rgba(255, 248, 230, 0.12); }

/* Sidebar navigation */
.side-nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #fdeede;
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.05s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.10); }
.nav-item:active { transform: translateY(1px); }
.nav-item.is-active {
  background: var(--panel-strong);
  color: var(--burgundy-dark);
  border-color: var(--warning-line);
  font-weight: 700;
}
.nav-ico { width: 20px; text-align: center; font-size: 15px; }

.mobile-nav-label,
.mobile-nav { display: none; }

.ghost-btn {
  background: transparent;
  color: #fdeede;
  border: 1px solid rgba(255, 248, 230, 0.4);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.ghost-btn:hover { background: rgba(255, 255, 255, 0.12); }

/* Ghost button inside light panels */
.content .ghost-btn {
  color: var(--burgundy-dark);
  border-color: var(--line);
}
.content .ghost-btn:hover { background: #f3e6c6; }

.reset-btn { align-self: flex-start; }

.brand-foot {
  margin-top: auto;
  font-size: 11px;
  line-height: 1.5;
  color: #f0d5b4;
  border-top: 1px solid rgba(255, 248, 230, 0.22);
  padding-top: 12px;
}

/* ===================== Main content ===================== */
.content { min-width: 0; display: flex; flex-direction: column; gap: 22px; }

/* Hero */
.hero {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-left: 6px solid var(--burgundy);
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: var(--shadow-soft);
}
.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--burgundy);
  background: #f3e6c6;
  border: 1px solid var(--warning-line);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 12px;
}
.hero-title { font-size: 27px; color: var(--burgundy-dark); margin-bottom: 10px; }
.hero-copy { max-width: 74ch; color: var(--muted); margin-bottom: 14px; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; }

/* ===================== Modules ===================== */
.module { display: none; flex-direction: column; gap: 22px; }
.module.is-active { display: flex; }
.module:focus { outline: none; }

/* Panels */
.panel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-soft);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.panel-head h2 { font-size: 18px; color: var(--burgundy-dark); }
.muted-copy { color: var(--muted); font-size: 14px; }

/* Layout helpers */
.two-col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
  align-items: start;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

/* Tag pill */
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--burgundy-dark);
  background: #f3e6c6;
  border: 1px solid var(--warning-line);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}
.tag-soft {
  color: var(--muted);
  background: #faf1dc;
  border-color: var(--line);
  font-weight: 600;
}
.chip-tag { background: #fdeede; }

/* Stat cards */
.stat-card { display: flex; flex-direction: column; gap: 6px; }
.stat-value { font-size: 30px; font-weight: 800; color: var(--burgundy); line-height: 1.1; }
.stat-unit { font-size: 15px; font-weight: 700; color: var(--muted); }
.stat-label { font-size: 13px; color: var(--muted); }

/* ===================== Alert boxes ===================== */
.alert-box {
  margin-top: 14px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  border-left: 6px solid var(--line);
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 14px;
}
.alert-box strong { color: var(--ink); }
.alert-optimal {
  background: var(--optimal-bg);
  border-color: var(--optimal-line);
  border-left-color: var(--optimal);
  color: #16532e;
}
.alert-optimal strong { color: var(--optimal); }
.alert-warning {
  background: var(--warning-bg);
  border-color: var(--warning-line);
  border-left-color: var(--warning);
  color: #7a5406;
}
.alert-warning strong { color: var(--warning); }
.alert-high {
  background: var(--high-bg);
  border-color: var(--high-line);
  border-left-color: var(--high);
  color: #7a0f08;
}
.alert-high strong { color: var(--high); }

/* ===================== Overview extras ===================== */
.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 6px 0;
}
.snapshot-item {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.snapshot-item .s-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.snapshot-item .s-value { font-size: 16px; font-weight: 700; color: var(--burgundy-dark); }

/* Bar visualisation (disparity) */
.bar-viz { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.bar-row { display: flex; flex-direction: column; gap: 5px; }
.bar-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.bar-top strong { color: var(--ink); }
.bar-track {
  height: 20px;
  background: #f3e6c6;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--burgundy) 0%, var(--warning-line) 100%);
  transition: width 0.6s ease;
}

/* Model grid */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-top: 6px;
}
.model-tile {
  text-align: left;
  display: flex;
  flex-direction: column;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px;
  cursor: pointer;
  font: inherit;
  transition: transform 0.12s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.model-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--burgundy);
}
.model-tile .m-ico { display: block; font-size: 22px; color: var(--burgundy); }
.model-tile .m-title { display: block; font-weight: 700; color: var(--burgundy-dark); margin: 6px 0 4px; }
.model-tile .m-desc { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* ===================== Forms ===================== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--muted); }

input[type="number"],
input[type="text"],
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
}
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--burgundy);
  box-shadow: 0 0 0 3px rgba(112, 11, 6, 0.12);
}
textarea { resize: vertical; }

.symptom-set { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 12px; margin: 6px 0 12px; }
.symptom-set legend { padding: 0 6px; }
.check-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 6px; }
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.check-item input { width: 16px; height: 16px; accent-color: var(--burgundy); }

/* Buttons */
.primary-btn {
  display: inline-block;
  background: var(--burgundy);
  color: #fff8e6;
  border: 1px solid var(--burgundy-dark);
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.05s ease;
}
.primary-btn:hover { background: var(--burgundy-dark); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

/* Sliders */
.slider-field { margin-bottom: 14px; }
.slider-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.slider-val {
  color: var(--burgundy-dark);
  background: #f3e6c6;
  border: 1px solid var(--warning-line);
  border-radius: 999px;
  padding: 0 10px;
  min-width: 42px;
  text-align: center;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--burgundy), var(--warning-line));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--panel-strong);
  border: 3px solid var(--burgundy);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--panel-strong);
  border: 3px solid var(--burgundy);
  cursor: pointer;
}

/* Toggles */
.toggle-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 6px; }
.toggle-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.toggle-chip input { width: 16px; height: 16px; accent-color: var(--burgundy); }
.toggle-chip.is-on { border-color: var(--burgundy); background: #fdeede; color: var(--burgundy-dark); font-weight: 700; }

/* ===================== Canvas + charts ===================== */
.canvas-wrap {
  width: 100%;
  margin-top: 6px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
}
canvas { display: block; width: 100%; }

.legend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}
.legend-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-right: 2px; vertical-align: -1px; }
.legend-sys { background: var(--burgundy); }
.legend-dia { background: var(--warning-line); }
.legend-thr { background: var(--high-line); }
.legend-before { background: var(--muted); }
.legend-after { background: var(--optimal); }

/* Gauge */
.gauge-wrap { position: relative; display: flex; justify-content: center; padding: 6px 0 2px; }
.gauge-readout {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
.gauge-readout span { font-size: 34px; font-weight: 800; color: var(--burgundy); }
.gauge-unit { font-size: 16px; font-weight: 700; color: var(--muted); }

/* Contribution bars */
.contrib-viz { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.contrib-row { display: flex; flex-direction: column; gap: 4px; }
.contrib-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.contrib-track { height: 14px; background: #f3e6c6; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.contrib-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.contrib-fill.low { background: var(--optimal); }
.contrib-fill.med { background: var(--warning-line); }
.contrib-fill.hi { background: var(--high-line); }

/* Recommendation list */
.reco-list { list-style: none; margin: 6px 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.reco-list li {
  position: relative;
  padding: 9px 12px 9px 34px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--muted);
}
.reco-list li::before {
  content: "✚";
  position: absolute;
  left: 12px;
  top: 9px;
  color: var(--burgundy);
  font-weight: 700;
}

/* ===================== Tables ===================== */
.table-wrap { overflow-x: auto; margin-top: 6px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td {
  text-align: left;
  padding: 9px 11px;
  border-bottom: 1px solid #ecdcb6;
}
.data-table th {
  background: var(--panel-strong);
  color: var(--burgundy-dark);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.data-table tbody tr:hover { background: #fdf7e6; }
.triage-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-radius: 999px;
  padding: 2px 10px;
}
.triage-optimal { background: var(--optimal-bg); color: var(--optimal); border: 1px solid var(--optimal-line); }
.triage-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-line); }
.triage-high { background: var(--high-bg); color: var(--high); border: 1px solid var(--high-line); }
.empty-row td { color: var(--muted); font-style: italic; text-align: center; padding: 18px; }

/* ===================== VR module ===================== */
.breath-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
}
.breath-circle {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff8e6;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  background: radial-gradient(circle at 35% 30%, var(--warning-line), var(--burgundy) 70%);
  box-shadow: var(--shadow);
  transition: transform 3.8s ease-in-out, box-shadow 3.8s ease-in-out;
}
.breath-circle.inhale { transform: scale(1.35); box-shadow: 0 0 40px rgba(217, 155, 24, 0.55); }
.breath-circle.exhale { transform: scale(0.85); }
.breath-timer { font-size: 22px; font-weight: 800; color: var(--burgundy-dark); font-variant-numeric: tabular-nums; }

.mini-stat-row { display: flex; gap: 22px; margin-top: 12px; text-align: center; }
.mini-stat { font-size: 24px; font-weight: 800; color: var(--burgundy); }
.mini-label { font-size: 12px; color: var(--muted); }

/* ===================== Mental health module ===================== */
.screen-questions { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 14px; }
.screen-q { display: flex; flex-direction: column; gap: 6px; }
.screen-q .q-text { font-size: 13.5px; color: var(--ink); font-weight: 600; }
.q-options { display: flex; flex-wrap: wrap; gap: 6px; }
.q-opt {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.q-opt.is-sel { background: var(--burgundy); color: #fff8e6; border-color: var(--burgundy-dark); font-weight: 700; }

.mood-picker { display: flex; gap: 8px; margin: 6px 0 12px; }
.mood-btn {
  flex: 1;
  font-size: 24px;
  padding: 8px 0;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.18s ease;
}
.mood-btn:hover { transform: translateY(-2px); }
.mood-btn.is-sel { border-color: var(--burgundy); background: #fdeede; box-shadow: var(--shadow-soft); }

.journal-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.journal-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-left: 5px solid var(--warning-line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.journal-emoji { font-size: 22px; }
.journal-body { font-size: 13px; color: var(--muted); }
.journal-body .j-time { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--line); }
.journal-empty { color: var(--muted); font-style: italic; }

/* ===================== Blockchain module ===================== */
.chain-wrap { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.block {
  position: relative;
  flex: 1 1 240px;
  min-width: 240px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 5px solid var(--optimal);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--shadow-soft);
}
.block.is-invalid { border-color: var(--high-line); border-top-color: var(--high); background: var(--high-bg); }
.block.is-genesis { border-top-color: var(--burgundy); }
.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.block-index { font-weight: 800; color: var(--burgundy-dark); font-size: 15px; }
.block-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; padding: 2px 8px; border-radius: 999px; }
.block-badge.ok { background: var(--optimal-bg); color: var(--optimal); border: 1px solid var(--optimal-line); }
.block-badge.bad { background: var(--high-bg); color: var(--high); border: 1px solid var(--high-line); }
.block-field { font-size: 12px; color: var(--muted); margin-bottom: 6px; word-break: break-all; }
.block-field .bf-label { font-weight: 700; color: var(--ink); text-transform: uppercase; letter-spacing: 0.5px; font-size: 10px; display: block; }
.hash-mono { font-family: "Consolas", "Courier New", monospace; font-size: 11px; }
.hash-prev { color: var(--line); }
.hash-self { color: var(--burgundy); }
.block .tamper-btn {
  margin-top: 6px;
  width: 100%;
  font-size: 12px;
  padding: 6px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--burgundy-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.block .tamper-btn:hover { background: #f3e6c6; }
.block::after {
  content: "→";
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--line);
  font-size: 20px;
  font-weight: 700;
}
.block:last-child::after { content: none; }
.chain-empty { color: var(--muted); font-style: italic; padding: 8px; }

/* ===================== Responsive: 1120px ===================== */
@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 240px 1fr; gap: 18px; padding: 18px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-title { font-size: 24px; }
}

/* ===================== Responsive: 820px (collapse to single column) ===================== */
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; top: auto; }
  .side-nav { display: none; }
  .brand-foot { display: none; }

  .mobile-nav-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #f3d7b8;
  }
  .mobile-nav {
    display: block;
    background: var(--panel-strong);
    color: var(--burgundy-dark);
    font-weight: 700;
    border-color: var(--warning-line);
  }

  .two-col { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .check-grid { grid-template-columns: 1fr; }
  .hero { padding: 20px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .toggle-grid { grid-template-columns: 1fr; }
  .mini-stat-row { justify-content: space-around; }
}

/* ===================== 5139: AI Self-Efficacy Predictor extras ===================== */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 6px; }
.metric-card { background: var(--panel-strong); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.metric-card .m-val { font-size: 22px; font-weight: 800; color: var(--burgundy); }
.metric-card .m-lab { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }

/* Decision tree */
.tree { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.tree-node {
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-sm);
  padding: 11px 13px; transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.tree-node.is-path { border-color: var(--burgundy); border-left: 5px solid var(--burgundy); box-shadow: var(--shadow-soft); background: #fdeede; }
.tree-node.is-leaf.is-path { background: var(--panel-strong); }
.tree-node .tn-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tree-node .tn-var { font-weight: 700; color: var(--burgundy-dark); font-size: 14px; }
.tree-node .tn-meta { font-size: 11px; color: var(--muted); }
.tree-node .tn-rule { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.tree-node .tn-decision { font-size: 12px; font-weight: 700; margin-top: 6px; color: var(--burgundy); }
.tree-depth-1 { margin-left: 22px; }
.tree-depth-2 { margin-left: 44px; }
.tree-depth-3 { margin-left: 66px; }
.tn-leaf-val { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border-radius: 999px; padding: 2px 10px; background: #f3e6c6; color: var(--burgundy-dark); border: 1px solid var(--warning-line); }

.pred-readout { text-align: center; padding: 8px 0 2px; }
.pred-readout .pr-val { font-size: 46px; font-weight: 800; color: var(--burgundy); line-height: 1; }
.pred-readout .pr-scale { font-size: 16px; font-weight: 700; color: var(--muted); }
.pred-readout .pr-lab { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-top: 4px; }

.dim-desc { background: var(--panel-strong); border: 1px solid var(--line); border-left: 5px solid var(--warning-line); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.dim-desc h3 { font-size: 14px; color: var(--burgundy-dark); margin-bottom: 4px; }

/* ===================== 1487 — Gaming Balance Console ===================== */
.chip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 12px; }
.chip-grid.one-col { grid-template-columns: 1fr; }

/* Screening count readout */
.count-readout { display: flex; align-items: baseline; gap: 8px; margin: 8px 0 4px; }
.count-readout .count-num { font-size: 34px; font-weight: 800; color: var(--burgundy); line-height: 1; }
.count-readout .count-of { font-size: 15px; color: var(--muted); font-weight: 700; }

/* Weekly day-budget stacked bar */
.day-bar {
  display: flex;
  width: 100%;
  height: 30px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  margin: 10px 0 6px;
}
.day-seg { height: 100%; min-width: 0; transition: width 0.2s ease; }
.day-seg.seg-game { background: #700b06; }
.day-seg.seg-sleep { background: #3f2719; }
.day-seg.seg-school { background: #9b6a1f; }
.day-seg.seg-active { background: #1f7a43; }
.day-seg.seg-social { background: #d99b18; }
.day-seg.seg-free { background: #e6d3a6; }
.day-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 8px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.15); flex: none; }

/* Benefits vs harms tally */
.balance-tally { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 10px; }
.tally-side { text-align: center; }
.tally-side .tally-num { font-size: 30px; font-weight: 800; line-height: 1; }
.tally-side .tally-lab { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.tally-side.benefit .tally-num { color: #1f7a43; }
.tally-side.harm .tally-num { color: #c8332a; }
.tally-vs { font-size: 13px; color: var(--muted); font-weight: 700; }

.col-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; margin: 2px 0 8px; }
.col-title.benefit { color: #1f7a43; }
.col-title.harm { color: #c8332a; }

/* =====================================================================
   Custom components — Neuropedagogy of Albinism Console
   ===================================================================== */

/* ---- Conceptual chain model ---- */
.chain {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}
.chain-node {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 6px solid var(--burgundy);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.chain-node:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.chain-node.is-open { border-left-color: var(--warning-line); background: var(--panel-strong); }
.chain-num {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: var(--burgundy);
  color: #fff8e6;
  font-weight: 700;
  font-size: 15px;
}
.chain-body { flex: 1 1 auto; }
.chain-name { display: block; font-weight: 700; font-size: 15px; }
.chain-cue { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.chain-more {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.5;
  display: none;
}
.chain-node.is-open .chain-more { display: block; }
.chain-caret { flex: 0 0 auto; color: var(--line); font-size: 13px; margin-top: 4px; }
.chain-arrow {
  align-self: center;
  color: var(--warning-line);
  font-size: 16px;
  line-height: 1;
  margin: -4px 0;
}

/* ---- Impact meter (functions affected / gauges) ---- */
.impact-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.impact-row { }
.impact-top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13.5px; margin-bottom: 4px;
}
.impact-name { font-weight: 600; color: var(--ink); }
.impact-val { font-size: 12px; color: var(--muted); font-weight: 700; }
.impact-track {
  height: 12px;
  background: #efe1bd;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.impact-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width 0.35s ease, background 0.25s ease;
  background: var(--optimal-line);
}
.impact-fill.med { background: var(--warning-line); }
.impact-fill.hi { background: var(--high-line); }

/* ---- Load readout ---- */
.load-readout {
  display: flex; align-items: baseline; gap: 10px;
  margin: 4px 0 12px;
}
.load-num { font-size: 42px; font-weight: 800; color: var(--burgundy); line-height: 1; }
.load-of { font-size: 13px; color: var(--muted); }

/* ---- Caution gauge (differential) ---- */
.gauge-wrap { text-align: center; margin: 6px 0 4px; }
.gauge-num { font-size: 40px; font-weight: 800; line-height: 1; color: var(--burgundy); }
.gauge-lab { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

/* ---- Two-tone factor columns (wellbeing) ---- */
.factor-scale {
  display: flex; align-items: stretch; gap: 0;
  height: 26px; border-radius: 999px; overflow: hidden;
  border: 1px solid var(--line);
  margin: 6px 0 4px;
  background: #efe1bd;
}
.factor-seg { transition: width 0.35s ease; }
.factor-seg.protect { background: var(--optimal-line); }
.factor-seg.risk { background: var(--high-line); }
.factor-legend {
  display: flex; gap: 18px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--muted); margin-top: 6px;
}
.factor-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.factor-legend .sw.protect { background: var(--optimal-line); }
.factor-legend .sw.risk { background: var(--high-line); }
.col-title.protect { color: var(--optimal); font-weight: 700; margin-bottom: 8px; }
.col-title.risk { color: var(--high); font-weight: 700; margin-bottom: 8px; }

/* ---- Plan domain builder (Table 2) ---- */
.plan-domain {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}
.plan-domain h3 {
  font-size: 15px;
  color: var(--burgundy);
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.plan-domain h3 .num {
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--burgundy); color: #fff8e6;
  font-size: 12px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.plan-map { display: grid; grid-template-columns: 1fr; gap: 8px; }
.plan-line { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; }
.plan-tag {
  flex: 0 0 auto;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--panel-strong); border: 1px solid var(--line); color: var(--muted);
  min-width: 118px; text-align: center;
}
.plan-line.interv .plan-tag { background: #eaf6ee; border-color: var(--optimal-line); color: var(--optimal); }
.plan-line .plan-text { color: var(--ink); }
.plan-empty { color: var(--muted); font-style: italic; }

/* small helper */
.subtle { color: var(--muted); font-size: 13px; }

/* =====================================================================
   1458-specific components: goniometer, segmented control, metrics
   ===================================================================== */

/* --- Goniometer (SVG protractor) --- */
.gonio-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px 4px;
}
.gonio-svg { width: 100%; max-width: 340px; height: auto; display: block; }
.gonio-arc { fill: none; stroke: var(--line); stroke-width: 2; opacity: 0.5; }
.gonio-tick { stroke: var(--line); stroke-width: 1.5; opacity: 0.55; }
.gonio-tick-lab { fill: var(--muted); font-size: 10px; font-family: Arial, Helvetica, sans-serif; }
.gonio-pivot { fill: var(--burgundy-dark); }
.gonio-needle-before { stroke: var(--muted); stroke-width: 4; stroke-linecap: round; opacity: 0.75; }
.gonio-needle-after { stroke: var(--burgundy); stroke-width: 5; stroke-linecap: round; }
.gonio-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 12.5px;
  color: var(--muted);
}
.gonio-legend .gl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}
.gonio-legend .swatch {
  width: 22px; height: 5px; border-radius: 3px; display: inline-block;
}
.gonio-legend .swatch.before { background: var(--muted); opacity: 0.75; }
.gonio-legend .swatch.after { background: var(--burgundy); }

/* --- Predicted-gain readout --- */
.gain-readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 2px;
}
.gain-num { font-size: 46px; font-weight: 800; color: var(--burgundy); line-height: 1; }
.gain-unit { font-size: 18px; font-weight: 700; color: var(--muted); }
.gain-sub { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

/* --- Radio-style choice rows (age / gender) --- */
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.choice-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
}
.choice-btn:hover { border-color: var(--burgundy); }
.choice-btn:active { transform: translateY(1px); }
.choice-btn.is-on {
  background: var(--burgundy);
  border-color: var(--burgundy);
  color: #fff;
}

/* --- Segmented control (cohort explorer views) --- */
.seg-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.is-on { background: var(--burgundy); color: #fff; }

/* --- Bar rows for cohort explorer (reuse impact styling, add label col) --- */
.bar-heading { font-size: 15px; color: var(--burgundy-dark); margin: 4px 0 12px; }
.bar-row { margin-bottom: 12px; }
.bar-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.bar-name { font-weight: 700; color: var(--ink); font-size: 13.5px; }
.bar-name small { font-weight: 600; color: var(--muted); font-size: 11.5px; }
.bar-val { font-size: 13px; color: var(--burgundy-dark); font-weight: 800; }
.bar-track { height: 16px; background: #f0e2c4; border-radius: 999px; overflow: hidden; }
.bar-fill {
  height: 100%;
  background: var(--burgundy);
  border-radius: 999px;
  transition: width 0.4s ease;
  min-width: 3px;
}
.bar-fill.alt { background: var(--warning-line); }
.bar-pair { display: flex; gap: 6px; }
.bar-pair .bar-track { flex: 1; }

/* --- Metric cards (evidence correlations) --- */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 6px 0 8px;
}
.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  padding: 12px 14px;
}
.metric-r { font-size: 26px; font-weight: 800; color: var(--burgundy); line-height: 1.1; }
.metric-r small { font-size: 13px; color: var(--muted); font-weight: 700; }
.metric-cap { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.metric-strength {
  display: inline-block;
  margin-top: 8px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 9px;
}
.metric-strength.strong { background: #eaf6ee; color: var(--optimal); border: 1px solid var(--optimal-line); }
.metric-strength.moderate { background: #fff4d6; color: var(--warning); border: 1px solid var(--warning-line); }
.metric-strength.weak { background: #f2eadb; color: var(--muted); border: 1px solid var(--line); }

/* --- Brief output (evidence) --- */
.brief-box {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  padding: 14px 16px;
  color: var(--ink);
  line-height: 1.55;
  min-height: 40px;
}
.brief-empty { color: var(--muted); font-style: italic; }

/* --- Timeline (protocol) --- */
.time-split { display: flex; height: 34px; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); margin: 8px 0 6px; }
.time-seg { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; }
.time-seg.hvla { background: var(--burgundy); }
.time-seg.massage { background: var(--warning-line); color: var(--ink); }

@media (max-width: 820px) {
  .metric-grid { grid-template-columns: 1fr; }
}
