/* ── Google Fonts loaded in HTML ─────────────────────────────────────────── */

/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  --font-sans:    'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-display: 'Cinzel', Georgia, serif;
  --sidebar-w:    224px;
  --sidebar-min:  52px;
  --radius:       5px;
  --radius-sm:    3px;
  --ease:         0.15s ease;
}

/* ── Dark theme ──────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:          #0d0d1c;
  --bg-alt:      #111122;
  --surface:     #171730;
  --surface-alt: #1d1d38;
  --surface-hover:#222240;
  --border:      #2a2a4a;
  --border-strong:#3a3a60;

  --text:        #e6ddd0;   /* warm white — contrast 12:1 on --bg */
  --text-muted:  #a89e92;   /* 5.5:1 on --bg */
  --text-faint:  #68605a;

  --accent:      #d4a020;
  --accent-hi:   #eabb40;
  --accent-lo:   #281e04;
  --accent-bdr:  #6a4e08;

  --green:       #4cb870;
  --green-lo:    #081a10;
  --green-bdr:   #1a4828;

  --red:         #e05a5a;
  --red-lo:      #1c0808;
  --red-bdr:     #4a1818;

  --blue:        #5a8cd4;
  --purple:      #9a70d4;

  --warn-bg:     #1a1508;
  --warn-bdr:    #5a3c0a;
  --warn-text:   #d4ac50;

  --shadow:      0 4px 20px rgba(0,0,0,.5);
}

/* ── Light theme ─────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:          #f3ede2;
  --bg-alt:      #ece5d8;
  --surface:     #ffffff;
  --surface-alt: #f8f3ec;
  --surface-hover:#f0e8d8;
  --border:      #d8cec0;
  --border-strong:#b8ae9e;

  --text:        #1a1410;   /* near-black, contrast 14:1 on --surface */
  --text-muted:  #52483e;   /* 7:1 on --surface */
  --text-faint:  #8a8078;

  --accent:      #966008;
  --accent-hi:   #744806;
  --accent-lo:   #fef5e0;
  --accent-bdr:  #d09820;

  --green:       #1a6e2c;
  --green-lo:    #eaf6ee;
  --green-bdr:   #48a860;

  --red:         #b82020;
  --red-lo:      #fdf0f0;
  --red-bdr:     #d85858;

  --blue:        #1a4e8c;
  --purple:      #6432a0;

  --warn-bg:     #fef8e8;
  --warn-bdr:    #d4a020;
  --warn-text:   #7a4808;

  --shadow:      0 2px 14px rgba(0,0,0,.1);
}

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

html { font-size: 15px; height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  transition: background var(--ease), color var(--ease);
}

/* ── Typography ──────────────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: .06em;
  text-transform: uppercase;
  line-height: 1.3;
  color: var(--text);
}
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; margin-top: 1.4em; margin-bottom: .4em; }
h4 { font-size: .9rem; margin-top: 1.2em; }

p { line-height: 1.75; color: var(--text-muted); }
p + p { margin-top: .8em; }

a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; transition: color var(--ease); }
a:hover { color: var(--accent-hi); }

code, .mono {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

ol, ul { padding-left: 1.4em; color: var(--text-muted); }
li { line-height: 1.8; }
strong { color: var(--text); font-weight: 600; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--ease);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 10;
}
.sidebar.collapsed { width: var(--sidebar-min); }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.sidebar-logo { font-size: 1.25rem; color: var(--accent); flex-shrink: 0; }
.sidebar-brand { overflow: hidden; }
.brand-main { font-family: var(--font-display); font-size: .75rem; letter-spacing: .28em; color: var(--accent); line-height: 1; }
.brand-sub  { font-family: var(--font-mono); font-size: .55rem; letter-spacing: .18em; color: var(--text-faint); margin-top: 3px; text-transform: uppercase; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: all var(--ease);
  font-size: .875rem;
}
.nav-item:hover  { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--surface); border-left-color: var(--accent); color: var(--text); }
.nav-icon  { font-size: 1rem; flex-shrink: 0; width: 20px; text-align: center; }
.nav-label { font-size: .85rem; font-weight: 500; }
.nav-sub   { font-family: var(--font-mono); font-size: .6rem; letter-spacing: .12em; color: var(--text-faint); text-transform: uppercase; }

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 36px 42px;
}
@media (max-width: 900px) { .main-content { padding: 24px 20px; } }

/* ── Section header ──────────────────────────────────────────────────────── */
.section-header { border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 28px; }
.section-pillar { font-family: var(--font-mono); font-size: .62rem; letter-spacing: .28em; color: var(--accent); text-transform: uppercase; margin-bottom: 5px; }
.section-title  { font-size: 1.4rem; margin-bottom: 5px; }
.section-sub    { color: var(--text-muted); font-size: .95rem; font-style: italic; margin: 0; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.tab-btn {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--ease);
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn:hover  { color: var(--text); background: var(--surface-hover); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}
.card-header {
  font-family: var(--font-mono);
  font-size: .62rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.card--accent { border-left: 3px solid var(--accent); }
.card--green  { border-left: 3px solid var(--green); }
.card--red    { border-left: 3px solid var(--red); }
.card--blue   { border-left: 3px solid var(--blue); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  line-height: 1;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent); color: #0d0d1c; border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hi); border-color: var(--accent-hi); }

.btn-outline {
  background: transparent; color: var(--accent); border-color: var(--accent);
}
.btn-outline:hover:not(:disabled) { background: var(--accent-lo); }

.btn-ghost {
  background: transparent; color: var(--text-muted); border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }

.btn-green { background: var(--green); color: var(--bg); border-color: var(--green); }
.btn-green:hover:not(:disabled) { filter: brightness(1.1); }

.btn-red { background: var(--red); color: #fff; border-color: var(--red); }

.btn-sm  { padding: 6px 12px; font-size: .67rem; }
.btn-lg  { padding: 12px 28px; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-family: var(--font-mono);
  font-size: .62rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 13px;
  font-family: var(--font-sans);
  font-size: .95rem;
  outline: none;
  transition: border-color var(--ease);
  line-height: 1.5;
}
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { cursor: pointer; }
.form-hint { font-size: .78rem; color: var(--text-faint); margin-top: 5px; }

input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }
.range-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: .62rem;
  color: var(--text-faint);
  margin-top: 4px;
}

/* ── Guardrail ───────────────────────────────────────────────────────────── */
.guardrail {
  background: var(--warn-bg);
  border: 1px solid var(--warn-bdr);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
}
.guardrail-label {
  font-family: var(--font-mono);
  font-size: .6rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 5px;
}
.guardrail p {
  font-size: .9rem;
  color: var(--warn-text);
  font-style: italic;
  line-height: 1.65;
  margin: 0;
}

/* ── Stat grid ───────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-label { font-family: var(--font-mono); font-size: .58rem; letter-spacing: .18em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px; }
.stat-value { font-family: var(--font-mono); font-size: 1.6rem; color: var(--accent); line-height: 1; margin-bottom: 4px; }
.stat-sub   { font-size: .75rem; color: var(--text-faint); }

/* ── Tags / badges ───────────────────────────────────────────────────────── */
.tag {
  font-family: var(--font-mono);
  font-size: .6rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid currentColor;
  display: inline-block;
  line-height: 1.6;
}
.tag-accent { color: var(--accent); }
.tag-green  { color: var(--green); background: var(--green-lo); }
.tag-red    { color: var(--red);   background: var(--red-lo); }
.tag-blue   { color: var(--blue); }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 16px;
  font-size: .9rem;
  line-height: 1.6;
}
.alert-success { background: var(--green-lo); border-color: var(--green-bdr); color: var(--green); }
.alert-error   { background: var(--red-lo);   border-color: var(--red-bdr);   color: var(--red); }
.alert-info    { background: var(--accent-lo); border-color: var(--accent-bdr); color: var(--accent); }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 5px; }
.progress-fill { height: 100%; border-radius: 3px; transition: width .3s ease; }
.progress-fill--accent { background: var(--accent); }
.progress-fill--green  { background: var(--green); }
.progress-fill--red    { background: var(--red); }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  font-family: var(--font-mono);
  font-size: .6rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: .9rem; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-alt); }

/* ── Habit list ──────────────────────────────────────────────────────────── */
.habit-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: opacity var(--ease);
  user-select: none;
}
.habit-row:last-child { border-bottom: none; }
.habit-box {
  width: 20px; height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--ease);
  font-size: .8rem;
}
.habit-row.done .habit-box { background: var(--green); border-color: var(--green); color: var(--bg); }
.habit-row.done .habit-label { color: var(--text-faint); }
.habit-label { font-size: .95rem; }

/* ── Memory word grid ────────────────────────────────────────────────────── */
.word-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.word-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 14px 8px;
  text-align: center;
  border-radius: var(--radius);
}
.word-index { font-family: var(--font-mono); font-size: .6rem; color: var(--text-faint); display: block; margin-bottom: 4px; }
.word-text  { font-size: 1rem; }

/* ── N-Back grid ─────────────────────────────────────────────────────────── */
.nback-grid { display: grid; gap: 6px; }
.nback-cell {
  aspect-ratio: 1;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: background .08s, border-color .08s;
}
.nback-cell.lit  { background: var(--accent); border-color: var(--accent); }
.nback-cell.hit  { background: var(--green);  border-color: var(--green); }
.nback-cell.miss { background: var(--red);    border-color: var(--red); }

/* ── Chart container ─────────────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 220px; margin: 16px 0; }

/* ── Score colours ───────────────────────────────────────────────────────── */
.c-excellent { color: var(--green); }
.c-good      { color: var(--accent); }
.c-poor      { color: var(--red); }

/* ── Ollama output ───────────────────────────────────────────────────────── */
.ollama-out {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  font-size: .95rem;
  line-height: 1.75;
  margin-top: 16px;
  color: var(--text);
}
.ollama-out p                { color: var(--text-muted); margin-bottom: .75em; }
.ollama-out p:last-child     { margin-bottom: 0; }
.ollama-out h1, .ollama-out h2, .ollama-out h3, .ollama-out h4 {
  font-family: var(--font-display);
  font-size: .9rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text);
  margin: 1.1em 0 .4em;
}
.ollama-out h1:first-child,
.ollama-out h2:first-child,
.ollama-out h3:first-child { margin-top: 0; }
.ollama-out ul, .ollama-out ol {
  padding-left: 1.5em;
  margin-bottom: .75em;
  color: var(--text-muted);
}
.ollama-out li { margin-bottom: .3em; line-height: 1.7; }
.ollama-out strong { color: var(--text); font-weight: 600; }
.ollama-out em    { font-style: italic; }
.ollama-out code  { font-family: var(--font-mono); font-size: .85em;
  background: var(--surface); padding: 2px 6px; border-radius: var(--radius-sm); }
.ollama-out pre   { background: var(--surface); padding: 12px 14px; border-radius: var(--radius);
  overflow-x: auto; margin-bottom: .75em; }
.ollama-out pre code { background: none; padding: 0; font-size: .88em; }
.ollama-out blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  color: var(--text-muted);
  font-style: italic;
  margin: .75em 0;
}
.ollama-out a { color: var(--accent); }
.ollama-out hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.ollama-loading {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: .75rem;
  margin-top: 12px;
}

/* ── Loading ─────────────────────────────────────────────────────────────── */
.loading-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 50vh; gap: 16px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .1em;
}
.loading-spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-body { align-items: stretch; justify-content: stretch; }
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; width: 100%; background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo     { font-size: 2rem; color: var(--accent); text-align: center; margin-bottom: 8px; }
.login-title    { font-family: var(--font-display); font-size: 1.4rem; color: var(--accent); letter-spacing: .22em; text-align: center; margin-bottom: 4px; }
.login-subtitle { font-family: var(--font-mono); font-size: .65rem; letter-spacing: .15em; color: var(--text-faint); text-align: center; text-transform: uppercase; margin-bottom: 32px; }
.login-hint     { font-size: .8rem; color: var(--text-faint); text-align: center; margin-top: 16px; }

/* ── Utility classes ─────────────────────────────────────────────────────── */
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.flex-wrap     { flex-wrap: wrap; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-muted   { color: var(--text-muted) !important; }
.text-faint   { color: var(--text-faint) !important; }
.text-accent  { color: var(--accent) !important; }
.text-green   { color: var(--green) !important; }
.text-red     { color: var(--red) !important; }
.text-sm      { font-size: .85rem; }
.text-xs      { font-size: .75rem; }
.mono         { font-family: var(--font-mono); }
.italic       { font-style: italic; }
.bold         { font-weight: 600; color: var(--text); }
.w-full       { width: 100%; }
.max-w-sm     { max-width: 280px; }
.hidden       { display: none !important; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── Page wrapper (needed for mobile bar + content column) ───────────────── */
.page-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  overflow: hidden;
}

/* ── Mobile top bar (hidden on desktop) ──────────────────────────────────── */
.mobile-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 52px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.mobile-bar-title {
  font-family: var(--font-display);
  font-size: .7rem;
  letter-spacing: .22em;
  color: var(--accent);
  text-transform: uppercase;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-bar .btn { flex-shrink: 0; }

/* ── Mobile overlay (behind open sidebar drawer) ─────────────────────────── */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 99;
  -webkit-tap-highlight-color: transparent;
}
.mobile-overlay.active { display: block; }

/* ── Desktop: sidebar is sticky column, page-body fills rest ─────────────── */
@media (min-width: 769px) {
  .mobile-bar    { display: none !important; }
  .mobile-overlay{ display: none !important; }
}

/* ── Mobile: sidebar becomes a slide-in drawer ───────────────────────────── */
@media (max-width: 768px) {
  body { flex-direction: row; } /* keep row so sidebar overlays */

  .mobile-bar { display: flex; }

  .sidebar {
    position: fixed !important;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w) !important; /* always full width when open */
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform .22s ease;
    z-index: 100;
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  /* Collapsed class has no meaning on mobile — ignore it */
  .sidebar.collapsed { width: var(--sidebar-w) !important; }
  .sidebar-brand, .nav-item-text, .nav-label, .nav-sub { display: block !important; opacity: 1 !important; }

  .page-body { flex: 1; min-width: 0; }

  .main-content {
    padding: 20px 16px 32px;
    overflow-y: auto;
    flex: 1;
  }

  /* Compact stat grid */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-value { font-size: 1.3rem; }

  /* Word grid 3 columns */
  .word-grid { grid-template-columns: repeat(3, 1fr); gap: 7px; }

  /* Tabs scroll horizontally without wrapping */
  .tabs-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs-bar::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 10px 13px; font-size: .68rem; }

  /* Cards slightly tighter */
  .card { padding: 16px; }

  /* N-back grid cells smaller */
  .nback-cell { min-width: 0; }

  /* Section header smaller */
  .section-title { font-size: 1.15rem; }

  /* Forms full width */
  .max-w-sm { max-width: 100%; }

  /* Chart containers shorter on mobile */
  .chart-wrap { height: 180px; }

  /* Tables scroll horizontally */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 480px; }

  /* Buttons wrap on small screens */
  .flex.gap-2, .flex.gap-3 { flex-wrap: wrap; }

  /* Hide desktop sidebar toggle icon — not needed */
  #sidebarLogoToggle { pointer-events: none; }
}
