/* ═══════════════════════════════════════════════
   RELAXITY — BASE STYLES
   Design tokens, reset, layout, shared components
═══════════════════════════════════════════════ */

/* ── STRUCTURAL TOKENS (shared — no colours here) ── */
:root {
  /* Typography */
  --font-display: 'Montserrat', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Spacing scale */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;

  /* Radii */
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-full: 9999px;

  /* Nav */
  --nav-height:    64px;
  --sidebar-width: 220px;

  /* Transitions */
  --transition:      150ms ease;
  --transition-slow: 300ms ease;

  /* Safe area (Capacitor / notch) */
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left,   0px);
  --safe-right:  env(safe-area-inset-right,  0px);
}

/* ── DARK THEME (default) ── */
html, [data-theme="dark"] {
  --bg:        #08080a;
  --surface:   #111113;
  --card:      #18181b;
  --card-hover:#202023;
  --border:    #27272a;
  --border-dim:#1f1f22;

  --text:     #d4d4d8;
  --text-dim: #a1a1aa;
  --muted:    #71717a;
  --dim:      #3f3f46;

  --accent:        #7a9a1a;
  --accent-hover:  #8ab020;
  --accent-dim:    rgba(122,154,26,0.12);
  --accent-border: rgba(122,154,26,0.28);

  --survivor:        #6dd8f5;
  --survivor-dim:    rgba(109,216,245,0.10);
  --survivor-border: rgba(109,216,245,0.25);

  --therapist:        #f7bc6a;
  --therapist-dim:    rgba(247,188,106,0.10);
  --therapist-border: rgba(247,188,106,0.25);

  --admin:        #d966f5;
  --admin-dim:    rgba(217,102,245,0.10);
  --admin-border: rgba(217,102,245,0.25);

  --community:     #34d399;
  --community-dim: rgba(52,211,153,0.10);

  --danger:  #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;

  /* Category colors (dark) — font, bg, border */
  --cat-physio:     #aa2dd0;  --cat-physio-bg:     #281838;  --cat-physio-border:     #3a2248;
  --cat-shoulder:   #2ca8cc;  --cat-shoulder-bg:   #102838;  --cat-shoulder-border:   #183848;
  --cat-wrist:      #cc882a;  --cat-wrist-bg:      #2a2010;  --cat-wrist-border:      #3a3018;
  --cat-hand:       #8e76d8;  --cat-hand-bg:       #201838;  --cat-hand-border:       #2e2248;
  --cat-leg:        #cc882a;  --cat-leg-bg:        #2a2010;  --cat-leg-border:        #3a3018;
  --cat-balance:    #2ca8cc;  --cat-balance-bg:    #102838;  --cat-balance-border:    #183848;
  --cat-gait:       #2ab580;  --cat-gait-bg:       #103028;  --cat-gait-border:       #184038;
  --cat-core:       #76941a;  --cat-core-bg:       #1a2210;  --cat-core-border:       #283218;
  --cat-facial:     #1da84e;  --cat-facial-bg:     #103018;  --cat-facial-border:     #184028;
  --cat-face:       #1da84e;  --cat-face-bg:       #103018;  --cat-face-border:       #184028;
  --cat-cognitive:  #bb55d0;  --cat-cognitive-bg:  #281838;  --cat-cognitive-border:  #3a2248;
  --cat-breathing:  #5ab8cc;  --cat-breathing-bg:  #102838;  --cat-breathing-border:  #183848;
  --cat-favorites:  #d9a800;  --cat-favorites-bg:  #2a2008;  --cat-favorites-border:  #3a3010;
  --cat-private:    #8e76d8;  --cat-private-bg:    #1a1430;  --cat-private-border:    #2a2040;  --cat-private-dot: #8e76d8;

  /* Difficulty colors (dark) — font, bg, border */
  --diff-beg:     #22c55e;  --diff-beg-bg:     #0a2016;  --diff-beg-border:     #14382a;
  --diff-bi:      #84cc16;  --diff-bi-bg:      #141e06;  --diff-bi-border:      #243610;
  --diff-int:     #f59e0b;  --diff-int-bg:     #1e1608;  --diff-int-border:     #362810;
  --diff-ia:      #f97316;  --diff-ia-bg:      #1e1208;  --diff-ia-border:      #36200e;
  --diff-adv:     #ef4444;  --diff-adv-bg:     #1e0a0a;  --diff-adv-border:     #361414;
  --diff-all:     #6dd8f5;  --diff-all-bg:     #0c1a1e;  --diff-all-border:     #142e36;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow:    0 4px 16px rgba(0,0,0,0.6);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.7);
}

/* ── LIGHT THEME ── */
[data-theme="light"] {
  --bg:        #f0ede8;
  --surface:   #f7f4ef;
  --card:      #fffdf9;
  --card-hover:#f2ede6;
  --border:    #c8c0b4;
  --border-dim:#ddd8d0;

  --text:     #1a1714;
  --text-dim: #3a3530;
  --muted:    #6b6358;
  --dim:      #9a9088;

  --accent:        #7a9a1a;
  --accent-hover:  #8ab020;
  --accent-dim:    rgba(122,154,26,0.12);
  --accent-border: rgba(122,154,26,0.35);

  --survivor:        #1480a0;
  --survivor-dim:    rgba(20,128,160,0.14);
  --survivor-border: rgba(20,128,160,0.35);

  --therapist:        #b06c0a;
  --therapist-dim:    rgba(176,108,10,0.14);
  --therapist-border: rgba(176,108,10,0.35);

  --admin:        #8825bb;
  --admin-dim:    rgba(136,37,187,0.14);
  --admin-border: rgba(136,37,187,0.35);

  --community:     #28b87d;
  --community-dim: rgba(40,184,125,0.14);

  --danger:  #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;

  /* Category colors (light) — font, bg, border */
  --cat-physio:     #b030d8;  --cat-physio-bg:     #e8cce8;  --cat-physio-border:     #c898c8;
  --cat-shoulder:   #1a8fa8;  --cat-shoulder-bg:   #c8e2ea;  --cat-shoulder-border:   #90bcd0;
  --cat-wrist:      #d88a1a;  --cat-wrist-bg:      #f0dcc0;  --cat-wrist-border:      #d0b088;
  --cat-hand:       #8b6de0;  --cat-hand-bg:       #dcd0f0;  --cat-hand-border:       #b8a0d8;
  --cat-leg:        #d88a1a;  --cat-leg-bg:        #f0dcc0;  --cat-leg-border:        #d0b088;
  --cat-balance:    #2ab0d8;  --cat-balance-bg:    #c8e4f0;  --cat-balance-border:    #90c8e0;
  --cat-gait:       #28b880;  --cat-gait-bg:       #c8e8dc;  --cat-gait-border:       #90c8b0;
  --cat-core:       #6a8818;  --cat-core-bg:       #dce0c8;  --cat-core-border:       #b8c090;
  --cat-facial:     #c48a2a;  --cat-facial-bg:     #f0dcc0;  --cat-facial-border:     #d0b088;
  --cat-face:       #1a9a48;  --cat-face-bg:       #c8e8d0;  --cat-face-border:       #90c8a0;
  --cat-cognitive:  #b050d8;  --cat-cognitive-bg:  #e8cce8;  --cat-cognitive-border:  #c898c8;
  --cat-breathing:  #1a8fa8;  --cat-breathing-bg:  #c8e2ea;  --cat-breathing-border:  #90bcd0;
  --cat-favorites:  #ffd42a;  --cat-favorites-bg:  #905888;  --cat-favorites-border:  #d9a800;
  --cat-private:    #ffffff;  --cat-private-bg:    #7a6098;  --cat-private-border:    #9880b8;  --cat-private-dot: #b8a0d8;

  /* Difficulty colors (light) */
  --diff-beg:     #15803d;  --diff-beg-bg:     #d8f0e0;  --diff-beg-border:     #a0d0b0;
  --diff-bi:      #4d7c0f;  --diff-bi-bg:      #e0e8d0;  --diff-bi-border:      #b8c8a0;
  --diff-int:     #b45309;  --diff-int-bg:     #f0e0c8;  --diff-int-border:     #d0b890;
  --diff-ia:      #c2410c;  --diff-ia-bg:      #f0d8c8;  --diff-ia-border:      #d0a888;
  --diff-adv:     #dc2626;  --diff-adv-bg:     #f0d0d0;  --diff-adv-border:     #d09090;
  --diff-all:     #1a8fa8;  --diff-all-bg:     #c8e2ea;  --diff-all-border:     #90bcd0;

  --shadow-sm: 0 1px 4px rgba(80,60,20,0.10), 0 0 0 1px rgba(80,60,20,0.06);
  --shadow:    0 4px 16px rgba(60,40,10,0.12);
  --shadow-lg: 0 8px 32px rgba(60,40,10,0.16);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;           /* prevents pull-to-refresh on mobile */
}

img, svg { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; color: inherit; background: none; border: none; outline: none; }
ul, ol { list-style: none; }

/* ── SHELL LAYOUT ── */
#shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;   /* dynamic viewport height — respects mobile browser chrome */
  overflow: hidden;
}

/* Main content area */
#app {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ── RECOVERER LAYOUT (bottom nav) ── */
body.role-survivor #shell {
  flex-direction: column;
}

body.role-survivor #nav-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  pointer-events: none;
}

body.role-survivor #nav-container > * {
  pointer-events: auto;
}

body.role-survivor #app {
  order: 1;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

/* ── THERAPIST / ADMIN LAYOUT (left sidebar — desktop) ── */
body.role-therapist #shell,
body.role-admin #shell {
  flex-direction: row;
}

body.role-therapist #nav-container,
body.role-admin #nav-container {
  flex-shrink: 0;
  width: var(--sidebar-width);
  padding-top: var(--safe-top);
}

body.role-therapist #app,
body.role-admin #app {
  padding-top: var(--safe-top);
}

/* ── THERAPIST / ADMIN — MOBILE (floating bottom tab bar) ── */
@media (max-width: 767px) {
  body.role-therapist #shell,
  body.role-admin #shell {
    flex-direction: column;
  }
  body.role-therapist #nav-container,
  body.role-admin #nav-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto !important;
    padding-top: 0;
    padding-bottom: 0;
    z-index: 100;
    pointer-events: none;
  }
  body.role-therapist #nav-container > *,
  body.role-admin #nav-container > * {
    pointer-events: auto;
  }
  body.role-therapist #app,
  body.role-admin #app {
    order: 1;
    padding-top: var(--safe-top);
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
  }
  body.role-therapist #toast-container,
  body.role-admin #toast-container {
    left: 50%;
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 28px);
  }
}

/* ── PAGE WRAPPER ── */
.page {
  min-height: 100%;
  padding: 15px 15px 15px 10px;
  animation: page-in var(--transition-slow) both;
}
@media (min-width: 768px) {
  .page { padding: var(--space-6); }
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── SPLASH SCREEN ── */
.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: var(--space-6);
}

.splash-logo {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -2px;
  color: var(--accent);
}

.splash-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── TYPOGRAPHY ── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

h1 { font-size: 28px; letter-spacing: -1px; color: var(--accent); }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
h4 { font-size: 14px; font-weight: 600; }

.text-muted  { color: var(--muted); }
.text-dim    { color: var(--dim); }
.text-accent { color: var(--accent); }
.text-mono   { font-family: var(--font-mono); }

/* ── CARDS ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card-sm { padding: var(--space-4); border-radius: var(--radius); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover { background: var(--accent-hover); }
[data-theme="light"] .btn-primary { color: #fff; }

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--card); border-color: var(--dim); }

.btn-danger {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
}

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; }

/* ── FORM INPUTS ── */
.input-wrap { display: flex; flex-direction: column; gap: 3px; }
.input-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted);
}

.input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 15px;
  color: var(--text);
  transition: border-color var(--transition);
  width: 100%;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--dim); }

/* Override browser autofill yellow */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0px 1000px var(--surface) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  border-color: var(--border);
  transition: background-color 9999s ease;
}

/* ── CHECKBOX CARD (standard selectable row) ── */
.chk-list { display:flex; flex-direction:column; gap:6px; }
.chk-item {
  display:flex; align-items:center; gap:10px;
  padding:10px 12px; border-radius:var(--radius);
  background:var(--card); border:1px solid var(--border);
  cursor:pointer; transition:all 0.15s;
  -webkit-tap-highlight-color:transparent; user-select:none;
}
.chk-item.checked {
  border-color:var(--accent);
  background:color-mix(in srgb, var(--accent) 8%, var(--card));
}
.chk-box {
  width:20px; height:20px; border-radius:5px; flex-shrink:0;
  border:2px solid var(--border); background:var(--surface);
  display:flex; align-items:center; justify-content:center;
  transition:background 0.15s, border-color 0.15s;
  position:relative;
}
.chk-item.checked .chk-box {
  background:var(--accent); border-color:var(--accent);
}
.chk-item.checked .chk-box::after {
  content:''; position:absolute;
  left:5px; top:2px; width:5px; height:9px;
  border:2px solid #fff; border-top:none; border-left:none;
  transform:rotate(45deg);
}
.chk-dot { width:8px; height:8px; border-radius:50%; flex-shrink:0; background:var(--cc-dot, var(--cc)); }
.chk-name { flex:1; font-size:13px; font-weight:600; color:var(--text); }
.chk-actions { display:flex; align-items:center; gap:2px; flex-shrink:0; }

/* ── PILLS & CHIPS ─────────────────────────────────────
   Use --cc for color. bg/border/font set directly per state.
   No opacity, no color-mix, no overlay.
   ─────────────────────────────────────────────────────── */

/* Pill — filter toggle */
.pill {
  display:inline-flex; align-items:center; gap:5px; cursor:pointer;
  border-radius:999px; transition:all 0.15s;
  padding:5px 13px;
  font-family:var(--font-body); font-size:12px; font-weight:600;
  color:var(--muted); background:var(--card); border:1px solid var(--border);
  -webkit-tap-highlight-color:transparent; outline:none;
}
.pill.checked { color:var(--cc); background:var(--cc-bg); border-color:var(--cc-border); }
.pill-dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }

/* Category chip — selectable category button */
.cat-chip {
  display:inline-flex; align-items:center; gap:6px; cursor:pointer;
  border-radius:999px; transition:all 0.15s;
  padding:5px 11px;
  font-size:11px; font-weight:700; letter-spacing:0.8px; text-transform:uppercase;
  color:var(--muted); background:var(--card); border:1px solid var(--border);
  -webkit-tap-highlight-color:transparent; outline:none;
}
.cat-chip.selected { color:var(--cc); background:var(--cc-bg); border-color:var(--cc-border); }
.cat-dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; background:var(--cc-dot, var(--cc)); }
.pill-dot { background:var(--cc-dot, var(--cc)); }

/* Category color classes — set --cc, --cc-bg, --cc-border from theme */
.cc-physio    { --cc:var(--cat-physio);    --cc-bg:var(--cat-physio-bg);    --cc-border:var(--cat-physio-border); }
.cc-shoulder  { --cc:var(--cat-shoulder);  --cc-bg:var(--cat-shoulder-bg);  --cc-border:var(--cat-shoulder-border); }
.cc-wrist     { --cc:var(--cat-wrist);     --cc-bg:var(--cat-wrist-bg);     --cc-border:var(--cat-wrist-border); }
.cc-hand      { --cc:var(--cat-hand);      --cc-bg:var(--cat-hand-bg);      --cc-border:var(--cat-hand-border); }
.cc-leg       { --cc:var(--cat-leg);       --cc-bg:var(--cat-leg-bg);       --cc-border:var(--cat-leg-border); }
.cc-balance   { --cc:var(--cat-balance);   --cc-bg:var(--cat-balance-bg);   --cc-border:var(--cat-balance-border); }
.cc-gait      { --cc:var(--cat-gait);      --cc-bg:var(--cat-gait-bg);      --cc-border:var(--cat-gait-border); }
.cc-core      { --cc:var(--cat-core);      --cc-bg:var(--cat-core-bg);      --cc-border:var(--cat-core-border); }
.cc-facial    { --cc:var(--cat-facial);    --cc-bg:var(--cat-facial-bg);    --cc-border:var(--cat-facial-border); }
.cc-face      { --cc:var(--cat-face);      --cc-bg:var(--cat-face-bg);      --cc-border:var(--cat-face-border); }
.cc-cognitive { --cc:var(--cat-cognitive);  --cc-bg:var(--cat-cognitive-bg);  --cc-border:var(--cat-cognitive-border); }
.cc-breathing  { --cc:var(--cat-breathing);  --cc-bg:var(--cat-breathing-bg);  --cc-border:var(--cat-breathing-border); }
.cc-favorites  { --cc:var(--cat-favorites);  --cc-bg:var(--cat-favorites-bg);  --cc-border:var(--cat-favorites-border); }
.cc-private    { --cc:var(--cat-private);    --cc-bg:var(--cat-private-bg);    --cc-border:var(--cat-private-border); --cc-dot:var(--cat-private-dot); }

/* Difficulty color classes */
.cc-diff-beg { --cc:var(--diff-beg); --cc-bg:var(--diff-beg-bg); --cc-border:var(--diff-beg-border); }
.cc-diff-bi  { --cc:var(--diff-bi);  --cc-bg:var(--diff-bi-bg);  --cc-border:var(--diff-bi-border); }
.cc-diff-int { --cc:var(--diff-int); --cc-bg:var(--diff-int-bg); --cc-border:var(--diff-int-border); }
.cc-diff-ia  { --cc:var(--diff-ia);  --cc-bg:var(--diff-ia-bg);  --cc-border:var(--diff-ia-border); }
.cc-diff-adv { --cc:var(--diff-adv); --cc-bg:var(--diff-adv-bg); --cc-border:var(--diff-adv-border); }
.cc-diff-all { --cc:var(--diff-all); --cc-bg:var(--diff-all-bg); --cc-border:var(--diff-all-border); }

/* ── CATEGORY CARD (expandable section header) ── */
.cat-card {
  border:1px solid var(--cc-border); border-radius:var(--radius);
  overflow:hidden; margin-bottom:8px; cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.cat-card-head {
  display:flex; align-items:center; gap:8px;
  padding:11px 14px; background:var(--cc-bg);
}
.cat-card-title {
  font-size:12px; font-weight:800; text-transform:uppercase;
  letter-spacing:2px; color:var(--cc);
}
.cat-card-chevron {
  font-size:8px; color:var(--muted); transition:transform 0.2s;
}
.cat-card-open .cat-card-chevron { transform:rotate(180deg); }
.cat-card-count {
  font-size:11px; font-weight:700; border:1px solid var(--cc-border);
  border-radius:999px; padding:1px 7px; color:var(--cc);
}
.cat-card-desc {
  font-size:12px; color:var(--dim); margin-left:auto;
}

/* ── EVIDENCE PILLS — solid colors only ── */
.ev-pill {
  font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:1px;
  padding:2px 8px; border-radius:999px; white-space:nowrap;
}
.ev-vs { color:#22c55e; background:#0a2016; border:1px solid #14382a; }
.ev-s  { color:#8aad1e; background:#141e06; border:1px solid #243610; }
.ev-m  { color:#f59e0b; background:#1e1608; border:1px solid #362810; }
[data-theme="light"] .ev-vs { color:#15803d; background:#d8f0e0; border-color:#a0d0b0; }
[data-theme="light"] .ev-s  { color:#4d7c0f; background:#e0e8d0; border-color:#b8c8a0; }
[data-theme="light"] .ev-m  { color:#b45309; background:#f0e0c8; border-color:#d0b890; }

/* ── DIFFICULTY PILLS — solid colors only ── */
.diff-pill {
  display:inline-flex; align-items:center; font-size:10px; font-weight:700;
  text-transform:uppercase; letter-spacing:1px; padding:2px 8px; border-radius:999px;
}
.diff-beg { color:#22c55e; background:#0a2016; border:1px solid #14382a; }
.diff-bi  { color:#84cc16; background:#141e06; border:1px solid #243610; }
.diff-int { color:#f59e0b; background:#1e1608; border:1px solid #362810; }
.diff-ia  { color:#f97316; background:#1e1208; border:1px solid #36200e; }
.diff-adv { color:#ef4444; background:#1e0a0a; border:1px solid #361414; }
.diff-all { color:#6dd8f5; background:#0c1a1e; border:1px solid #142e36; }
[data-theme="light"] .diff-beg { color:#15803d; background:#d8f0e0; border:1px solid #a0d0b0; }
[data-theme="light"] .diff-bi  { color:#4d7c0f; background:#e0e8d0; border:1px solid #b8c8a0; }
[data-theme="light"] .diff-int { color:#b45309; background:#f0e0c8; border:1px solid #d0b890; }
[data-theme="light"] .diff-ia  { color:#c2410c; background:#f0d8c8; border:1px solid #d0a888; }
[data-theme="light"] .diff-adv { color:#dc2626; background:#f0d0d0; border:1px solid #d09090; }
[data-theme="light"] .diff-all { color:#1a8fa8; background:#c8e2ea; border:1px solid #90bcd0; }

/* ── STEPPER ── */
.stepper {
  display:flex; align-items:center;
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); overflow:hidden; min-height:40px;
}
.stepper-btn {
  width:40px; min-height:40px;
  display:flex; align-items:center; justify-content:center;
  font-size:18px; color:var(--muted); flex-shrink:0;
  background:transparent; border:none; cursor:pointer;
  transition:color 0.15s, background 0.15s;
}
.stepper-btn:hover { color:var(--text); background:var(--card); }
.stepper-val {
  flex:1; text-align:center; background:transparent;
  border:none; color:var(--text);
  font-size:16px; font-weight:800; font-family:var(--font-display);
  padding:4px 0; min-width:0; height:40px;
  -moz-appearance:textfield;
}
.stepper-val::-webkit-outer-spin-button,
.stepper-val::-webkit-inner-spin-button { -webkit-appearance:none; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  border: 1px solid;
}
.badge-accent   { background: var(--accent-dim);    border-color: var(--accent-border);    color: var(--accent); }
.badge-survivor{ background: var(--survivor-dim); border-color: var(--survivor-border); color: var(--survivor); }
.badge-therapist{ background: var(--therapist-dim); border-color: var(--therapist-border); color: var(--therapist); }
.badge-admin    { background: var(--admin-dim);     border-color: var(--admin-border);     color: var(--admin); }
.badge-danger   { background: rgba(239,68,68,0.1);  border-color: rgba(239,68,68,0.3);     color: var(--danger); }
.badge-success  { background: rgba(34,197,94,0.1);  border-color: rgba(34,197,94,0.3);     color: var(--success); }

/* ── DIVIDER ── */
.divider { height: 1px; background: var(--border); margin: var(--space-5) 0; }

/* ── TOAST ── */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 1000;
  pointer-events: none;
  width: min(360px, 90vw);
}

body.role-therapist #toast-container,
body.role-admin #toast-container {
  bottom: 20px;
  left: calc(var(--sidebar-width) + 50%);
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: toast-in 0.25s ease both;
}
.toast.toast-success { border-color: rgba(34,197,94,0.3); color: var(--success); }
.toast.toast-error   { border-color: rgba(239,68,68,0.3); color: var(--danger); }
.toast.toast-out     { animation: toast-out 0.25s ease both; }

@keyframes toast-in  { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; transform:translateY(-4px); } }

/* ── MODAL ── */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(4px);
  z-index: 900;
}
/* Container: full-screen flex, centers the .modal box */
#modal-container {
  position: fixed; inset: 0;
  z-index: 901;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  pointer-events: none;
  overflow: hidden;
  transform: none;
  width: auto; height: auto;
  background: transparent;
  border: none; border-radius: 0;
  animation: none; max-height: none;
}
#modal-container:not(.hidden) { pointer-events: auto; }

/* The modal box itself — use class="modal" inside #modal-container */
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 480px; max-height: 92dvh;
  display: flex; flex-direction: column;
  overflow: hidden; cursor: default;
}
/* Header */
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--accent);
}
.modal-close {
  color: var(--muted); font-size: 15px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }
/* Scrollable body */
.modal-body {
  padding: 10px 14px;
  overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 7px;
}
.modal-body .input-label { margin-bottom: 0; }
.modal-body .input { padding: 6px 10px; font-size: 13px; color: var(--text); }
.modal-body textarea.input { resize: none; }
/* Autofill fix inside modals */
.modal-body .input:-webkit-autofill,
.modal-body .input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0px 1000px var(--surface) inset;
  -webkit-text-fill-color: var(--text);
}
/* Footer: side-by-side buttons, no top border */
.modal-foot {
  padding: 8px 14px 14px;
  display: flex; flex-direction: row; gap: 8px;
  flex-shrink: 0;
}
.modal-foot .btn {
  flex: 1; padding: 8px 14px;
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.2px; justify-content: center;
  border-radius: var(--radius);
}
.modal-foot .btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--muted);
}

.hidden { display: none !important; }

/* ── UTILITY ── */
.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.mt-4   { margin-top: var(--space-4); }
.mt-6   { margin-top: var(--space-6); }
.mb-4   { margin-bottom: var(--space-4); }
.mb-6   { margin-bottom: var(--space-6); }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── TOP BAR ── */
#topbar-container { flex-shrink: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--bg);
  z-index: 100;
  border-bottom: 1px solid var(--border);
}
.topbar-burger {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: none; border: 1px solid var(--border); color: var(--text);
  cursor: pointer; flex-shrink: 0; transition: border-color 0.15s;
}
.topbar-burger:hover { border-color: var(--accent); }
.topbar-logo {
  font-family: var(--font-display); font-weight: 800; font-size: 18px;
  color: var(--accent); text-decoration: none; letter-spacing: -0.5px;
}
.topbar-spacer { flex: 1; }
.topbar-signup {
  font-family: var(--font-body); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; text-decoration: none;
  border: none; cursor: pointer; white-space: nowrap;
  transition: filter 0.15s;
}
.topbar-signup:hover { filter: brightness(1.1); }

/* ── HAMBURGER MENU ── */
.menu-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,0.5); opacity: 0;
  pointer-events: none; transition: opacity 0.25s;
}
.menu-overlay.menu-open { opacity: 1; pointer-events: auto; }

.menu-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 1000;
  width: 280px; max-width: 80vw;
  background: var(--surface);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.menu-drawer.menu-open { transform: translateX(0); }

.menu-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.menu-logo {
  font-family: var(--font-display); font-weight: 800; font-size: 20px;
  color: var(--accent); letter-spacing: -0.5px;
}
.menu-close-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: none; border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; transition: color 0.15s;
}
.menu-close-btn:hover { color: var(--text); }

.menu-nav {
  flex: 1; padding: 12px 0;
}
.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px;
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  color: var(--text); text-decoration: none;
  transition: background 0.15s;
}
.menu-item:hover { background: var(--card); }
.menu-item.menu-sub { padding-left: 36px; font-size: 13px; font-weight: 500; }
.menu-item.menu-locked {
  color: var(--dim); cursor: default;
}
.menu-item.menu-locked:hover { background: transparent; }
.menu-lock {
  display: flex; align-items: center; color: var(--dim);
}
.menu-logout { color: var(--danger); }

.menu-divider {
  height: 1px; background: var(--border); margin: 6px 20px;
}
.menu-group-label {
  display: flex; align-items: center; gap: 6px;
  padding: 13px 20px;
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  color: var(--text); cursor: pointer; user-select: none;
  transition: background 0.15s;
}
.menu-group-label:hover { background: var(--card); }
.menu-group-label svg { color: var(--muted); transition: transform 0.2s; }
.menu-group-collapsed + .menu-group-label svg,
.menu-group-label.collapsed svg { transform: rotate(-90deg); }

.menu-group { }
.menu-group.menu-group-collapsed { display: none; }

.menu-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center;
}
.menu-theme-btn {
  font-size: 18px; background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); width: 36px; height: 36px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
