/* =============================================================
   MAISON — Hair Colour Education Platform
   Editorial design system
   Typography: Fraunces (display serif) · Inter (sans) · JetBrains Mono (metadata)
   Spacing:    Fibonacci scale (1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144)
   Palette:    Bone ground · Deep ink · Oxblood accent · Champagne tertiary
   ============================================================= */

:root {
  /* ---- Palette ---- */
  --bone:        #F3EEE4;   /* primary ground */
  --paper:       #E8E1D1;   /* secondary surface */
  --cream:       #FAF6EE;   /* elevated surface */
  --ink:         #141110;   /* primary text */
  --ink-2:       #3A332E;   /* secondary text */
  --ink-3:       #776C62;   /* tertiary / caption */
  --line:        #C9BFAD;   /* divider */
  --line-soft:   #DDD4C2;   /* subtle divider */
  --oxblood:     #5A1918;   /* luxe accent */
  --oxblood-2:   #7A2823;   /* hover */
  --champagne:   #B99B6B;   /* tertiary gold */
  --sage:        #7D8A78;   /* success */
  --clay:        #A64B2A;   /* rare accent */
  --alert:       #8B2418;   /* error */

  /* ---- Fibonacci spacing (px) ---- */
  --s-1:   1px;
  --s-2:   2px;
  --s-3:   3px;
  --s-5:   5px;
  --s-8:   8px;
  --s-13:  13px;
  --s-21:  21px;
  --s-34:  34px;
  --s-55:  55px;
  --s-89:  89px;
  --s-144: 144px;
  --s-233: 233px;

  /* ---- Typography ---- */
  --serif:   'Fraunces', 'Didot', 'Times New Roman', serif;
  --sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:    'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;

  /* ---- Motion ---- */
  --ease:    cubic-bezier(.2, .7, .2, 1);
  --fast:    180ms;
  --med:     320ms;
  --slow:    560ms;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bone);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; background: none; border: 0; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--ink); color: var(--bone); }

/* ===== Typography primitives ===== */
.display {
  font-family: var(--serif);
  font-weight: 300;
  font-style: normal;
  letter-spacing: -0.02em;
  line-height: 0.92;
  font-variation-settings: "opsz" 144, "SOFT" 0, "WONK" 0;
}
.display-xxl {
  font-family: var(--serif);
  font-weight: 300;
  letter-spacing: -0.035em;
  line-height: 0.88;
  font-size: clamp(64px, 12vw, 180px);
  font-variation-settings: "opsz" 144;
}
.display-xl {
  font-family: var(--serif);
  font-weight: 300;
  letter-spacing: -0.025em;
  line-height: 0.9;
  font-size: clamp(44px, 7.5vw, 104px);
  font-variation-settings: "opsz" 144;
}
.display-l {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 0.98;
  font-size: clamp(32px, 5vw, 56px);
}
.display-m {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.05;
  font-size: clamp(26px, 3.2vw, 38px);
}
.display-italic { font-style: italic; font-weight: 300; }

.eyebrow, .meta, .code {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.meta-ink { color: var(--ink); }
.dot::before { content: "·"; margin: 0 var(--s-8); color: var(--line); }

.body-lg { font-size: 17px; line-height: 1.6; color: var(--ink-2); }
.body    { font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.body-sm { font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.caption { font-size: 12px; color: var(--ink-3); letter-spacing: 0.01em; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 400; }

/* ===== Layout primitives ===== */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.container { width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 var(--s-34); }
.container-lg { max-width: 1600px; margin: 0 auto; padding: 0 var(--s-34); }
.section { padding: var(--s-89) 0; }

.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.divider-soft { height: 1px; background: var(--line-soft); border: 0; margin: 0; }

/* Fibonacci-guided editorial grid: 5 + 8 + 13 + 21 + 34 = 81 column-units per row */
.grid-fib {
  display: grid;
  grid-template-columns: 5fr 8fr 13fr 21fr 34fr;
  gap: var(--s-34);
}
@media (max-width: 900px) {
  .grid-fib { grid-template-columns: 1fr; gap: var(--s-34); }
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-55); }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-34); }
@media (max-width: 900px) {
  .two-col, .three-col { grid-template-columns: 1fr; gap: var(--s-34); }
}

/* ===== Header / Nav ===== */
.nav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(243, 238, 228, 0.88);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 72px; padding: 0 var(--s-34);
}
.brand {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand em { font-style: italic; font-weight: 300; }
.nav-links { display: flex; align-items: center; gap: var(--s-34); }
.nav-link {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  transition: color var(--fast);
  padding: var(--s-8) 0;
  border-bottom: 1px solid transparent;
}
.nav-link:hover, .nav-link.active { color: var(--ink); border-bottom-color: var(--ink); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-8);
  padding: 14px 26px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  line-height: 1;
  border: 1px solid var(--ink);
  color: var(--ink);
  background: transparent;
  transition: all var(--med) var(--ease);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.btn:hover { background: var(--ink); color: var(--bone); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--ink); color: var(--bone);
}
.btn-primary:hover { background: var(--oxblood); border-color: var(--oxblood); }

.btn-oxblood {
  background: var(--oxblood); border-color: var(--oxblood); color: var(--bone);
}
.btn-oxblood:hover { background: var(--oxblood-2); border-color: var(--oxblood-2); }

.btn-ghost {
  border-color: var(--line);
  color: var(--ink-2);
}
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); background: transparent; }

.btn-sm { padding: 10px 18px; font-size: 10px; }
.btn-lg { padding: 18px 34px; font-size: 12px; }
.btn-block { width: 100%; }

/* Underline link */
.u-link {
  position: relative;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 2px;
  transition: color var(--fast);
}
.u-link:hover { color: var(--oxblood); border-color: var(--oxblood); }

/* ===== Cards / Surfaces ===== */
.card {
  background: var(--cream);
  border: 1px solid var(--line-soft);
  padding: var(--s-34);
  transition: border-color var(--med), transform var(--med);
}
.card:hover { border-color: var(--line); }
.card-ink {
  background: var(--ink); color: var(--bone);
  padding: var(--s-34);
}
.card-oxblood {
  background: var(--oxblood); color: var(--bone);
  padding: var(--s-34);
}
.card-paper {
  background: var(--paper);
  padding: var(--s-34);
}

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: var(--s-8); margin-bottom: var(--s-21); }
.field label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.field input, .field textarea, .field select {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 10px 0 12px;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
  outline: none;
  transition: border-color var(--fast);
  border-radius: 0;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-bottom-color: var(--ink);
}
.field textarea { min-height: 96px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.field .error { font-size: 12px; color: var(--alert); margin-top: 4px; }

.checkbox, .radio {
  display: flex; align-items: center; gap: var(--s-13);
  font-size: 14px; color: var(--ink-2);
  cursor: pointer;
}
.checkbox input, .radio input {
  appearance: none;
  width: 16px; height: 16px;
  border: 1px solid var(--line);
  background: var(--cream);
  position: relative;
  cursor: pointer;
}
.radio input { border-radius: 50%; }
.checkbox input:checked, .radio input:checked { background: var(--ink); border-color: var(--ink); }
.checkbox input:checked::after {
  content: ""; position: absolute; inset: 3px;
  background: var(--bone);
}
.radio input:checked::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%;
  background: var(--bone);
}

/* Role toggle (segmented) */
.segment {
  display: grid; grid-template-columns: 1fr 1fr;
  border: 1px solid var(--ink);
}
.segment button {
  padding: 14px 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  transition: all var(--fast);
  border-right: 1px solid var(--ink);
}
.segment button:last-child { border-right: 0; }
.segment button[aria-selected="true"] { background: var(--ink); color: var(--bone); }

/* ===== Pills / Chips / Tags (ID style from the trend report) ===== */
.tag {
  display: inline-flex; align-items: center; gap: var(--s-5);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 10px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  background: transparent;
}
.tag::before {
  content: ""; display: inline-block;
  width: 6px; height: 6px; background: var(--ink);
}
.tag-oxblood::before { background: var(--oxblood); }
.tag-sage::before { background: var(--sage); }
.tag-clay::before { background: var(--clay); }
.tag-filled {
  background: var(--ink); color: var(--bone); border-color: var(--ink);
}
.tag-filled::before { background: var(--bone); }

.pill {
  display: inline-flex; align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-2);
}

/* ===== Section code (1.1 DIRECT FLASH style) ===== */
.section-code {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: inline-flex; gap: var(--s-13);
  align-items: center;
}
.section-code .num { color: var(--ink); }

/* ===== Table ===== */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  padding: var(--s-21) var(--s-13);
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  vertical-align: middle;
}
.table th {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 400;
}
.table tr:hover td { background: rgba(234, 227, 209, 0.35); }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 17, 16, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-21);
  animation: fade var(--med) var(--ease);
}
.modal {
  background: var(--bone);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
  border: 1px solid var(--line);
  padding: var(--s-55);
  animation: rise var(--med) var(--ease);
}
.modal-wide { max-width: 880px; }
.modal-close {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ===== Animations ===== */
@keyframes fade  { from {opacity: 0;} to {opacity: 1;} }
@keyframes rise  { from {opacity: 0; transform: translateY(12px);} to {opacity: 1; transform: translateY(0);} }
@keyframes slide { from {opacity: 0; transform: translateY(24px);} to {opacity: 1; transform: translateY(0);} }

.fade-in { animation: fade var(--med) var(--ease); }
.slide-in { animation: slide var(--slow) var(--ease); }

/* ===== Dashboard layout ===== */
.app-shell {
  display: grid;
  grid-template-columns: 233px 1fr;
  min-height: 100vh;
}
.sidebar {
  border-right: 1px solid var(--line-soft);
  background: var(--paper);
  padding: var(--s-34) var(--s-21);
  display: flex; flex-direction: column;
  gap: var(--s-34);
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.01em;
}
.side-nav { display: flex; flex-direction: column; gap: var(--s-3); }
.side-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px var(--s-13);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  border-left: 2px solid transparent;
  transition: all var(--fast);
}
.side-link:hover { background: rgba(20,17,16,0.04); color: var(--ink); }
.side-link.active { border-left-color: var(--ink); color: var(--ink); background: rgba(20,17,16,0.05); }
.side-link .count {
  font-size: 10px; color: var(--ink-3);
  padding: 2px 6px; background: var(--cream);
  border: 1px solid var(--line-soft);
}
.main {
  padding: var(--s-55) var(--s-55) var(--s-144);
  background: var(--bone);
  overflow-x: hidden;
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative; height: auto;
    flex-direction: row; align-items: center;
    gap: var(--s-21); padding: var(--s-21);
    overflow-x: auto;
  }
  .side-nav { flex-direction: row; gap: var(--s-13); }
  .side-link { border-left: 0; border-bottom: 2px solid transparent; padding: 8px 12px; }
  .side-link.active { border-left: 0; border-bottom-color: var(--ink); }
  .main { padding: var(--s-34) var(--s-21) var(--s-89); }
}

/* ===== Hero ===== */
.hero {
  padding: var(--s-89) 0 var(--s-144);
  position: relative;
  overflow: hidden;
}
.hero-word {
  font-family: var(--serif);
  font-size: clamp(80px, 16vw, 260px);
  font-weight: 300;
  line-height: 0.85;
  letter-spacing: -0.04em;
  color: var(--ink);
  display: block;
}
.hero-word em { font-style: italic; font-weight: 300; }

/* ===== Utility ===== */
.muted { color: var(--ink-3); }
.ink { color: var(--ink); }
.oxblood { color: var(--oxblood); }
.champagne { color: var(--champagne); }

.border { border: 1px solid var(--line); }
.border-t { border-top: 1px solid var(--line-soft); }
.border-b { border-bottom: 1px solid var(--line-soft); }
.border-soft { border: 1px solid var(--line-soft); }

.flex { display: flex; }
.ai-c { align-items: center; }
.ai-s { align-items: flex-start; }
.ai-e { align-items: flex-end; }
.jc-sb { justify-content: space-between; }
.jc-c  { justify-content: center; }
.jc-e  { justify-content: flex-end; }
.fd-c  { flex-direction: column; }
.fw-w  { flex-wrap: wrap; }

.gap-3  { gap: 3px; }
.gap-5  { gap: 5px; }
.gap-8  { gap: 8px; }
.gap-13 { gap: 13px; }
.gap-21 { gap: 21px; }
.gap-34 { gap: 34px; }
.gap-55 { gap: 55px; }

.mt-8  { margin-top: 8px; }
.mt-13 { margin-top: 13px; }
.mt-21 { margin-top: 21px; }
.mt-34 { margin-top: 34px; }
.mt-55 { margin-top: 55px; }
.mt-89 { margin-top: 89px; }

.mb-8  { margin-bottom: 8px; }
.mb-13 { margin-bottom: 13px; }
.mb-21 { margin-bottom: 21px; }
.mb-34 { margin-bottom: 34px; }
.mb-55 { margin-bottom: 55px; }

.w-full { width: 100%; }
.ta-c   { text-align: center; }
.ta-r   { text-align: right; }

.hide-sm { }
@media (max-width: 900px) { .hide-sm { display: none !important; } }
.hide-lg { display: none; }
@media (max-width: 900px) { .hide-lg { display: block; } }

/* Loading */
.spinner {
  width: 24px; height: 24px;
  border: 1.5px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress bar */
.progress {
  height: 2px; background: var(--line-soft); width: 100%; position: relative;
}
.progress > span {
  display: block; height: 100%; background: var(--ink);
  transition: width var(--med) var(--ease);
}

/* Avatar (initial) */
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--paper); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 16px; color: var(--ink);
  flex-shrink: 0;
}
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }

/* Toast */
.toast {
  position: fixed; bottom: var(--s-34); right: var(--s-34); z-index: 200;
  background: var(--ink); color: var(--bone);
  padding: var(--s-13) var(--s-21);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  animation: rise var(--med) var(--ease);
}
.toast.err { background: var(--alert); }
.toast.ok  { background: var(--ink); }

/* Resource media tile */
.tile {
  background: var(--cream);
  border: 1px solid var(--line-soft);
  padding: var(--s-21);
  display: flex; flex-direction: column; gap: var(--s-13);
  transition: all var(--med) var(--ease);
  cursor: pointer;
  min-height: 180px;
  position: relative;
}
.tile:hover { border-color: var(--ink); transform: translateY(-2px); }
.tile-type {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.tile-title {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.15;
  color: var(--ink);
  margin: var(--s-5) 0 auto;
}
.tile-foot {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--ink-3);
}

/* Quiz option */
.quiz-opt {
  display: flex; align-items: center; gap: var(--s-13);
  padding: var(--s-21);
  border: 1px solid var(--line);
  background: var(--cream);
  cursor: pointer;
  transition: all var(--fast);
  margin-bottom: var(--s-13);
}
.quiz-opt:hover { border-color: var(--ink-2); }
.quiz-opt.selected { border-color: var(--ink); background: var(--paper); }
.quiz-opt .letter {
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px;
  background: var(--bone);
  flex-shrink: 0;
}
.quiz-opt.selected .letter { background: var(--ink); color: var(--bone); border-color: var(--ink); }

/* Stat block */
.stat {
  padding: var(--s-34);
  background: var(--cream);
  border: 1px solid var(--line-soft);
}
.stat-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--s-13);
}
.stat-value {
  font-family: var(--serif);
  font-size: clamp(40px, 5vw, 64px);
  font-weight: 300;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.stat-sub { font-size: 12px; color: var(--ink-3); margin-top: var(--s-8); }

/* Code block / credential chip (for educator codes) */
.credential {
  display: inline-flex; align-items: center; gap: var(--s-13);
  padding: var(--s-13) var(--s-21);
  background: var(--ink); color: var(--bone);
  font-family: var(--mono);
  letter-spacing: 0.18em;
  font-size: 14px;
  user-select: all;
}
.credential button {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.14em; color: var(--bone);
  opacity: 0.6; padding: 2px 6px; border: 1px solid rgba(255,255,255,0.25);
}
.credential button:hover { opacity: 1; }

/* Pill — active state for filters */
.pill { cursor: pointer; transition: all var(--fast); }
.pill:hover { border-color: var(--ink); color: var(--ink); }
.pill-active {
  background: var(--ink); color: var(--bone); border-color: var(--ink);
}

/* Compact select (admin register, etc.) */
.select-mini {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: var(--cream);
  color: var(--ink);
  outline: none;
  cursor: pointer;
}
.select-mini:focus { border-color: var(--ink); }

/* Table wrapper for mobile scroll */
.table-wrap { width: 100%; overflow-x: auto; }

/* Tile head (admin library detail) */
.tile-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.tile-body { margin: 0; }

/* Smaller display — between display-m and body-lg */
.display-s {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.1;
  font-size: clamp(22px, 2.4vw, 28px);
}

/* ================================================================
   Additions for v3 — avatars, profile chip, media viewer,
   student detail, clickable cards, larger avatars.
   ================================================================ */

/* Extra avatar size */
.avatar-xl {
  width: 96px; height: 96px; font-size: 34px;
}

/* Clickable card (roster link) */
.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: all var(--med) var(--ease);
}
.card-link:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
}
.card-link .chev {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--ink-3);
  transition: transform var(--fast), color var(--fast);
}
.card-link:hover .chev {
  transform: translateX(4px);
  color: var(--ink);
}

/* Profile chip in the sidebar */
.profile-chip {
  display: flex;
  align-items: center;
  gap: var(--s-13);
  padding: var(--s-13);
  border: 1px solid var(--line-soft);
  background: var(--cream);
  text-decoration: none;
  color: inherit;
  transition: all var(--fast);
}
.profile-chip:hover {
  border-color: var(--ink);
  background: var(--paper);
}
.profile-name {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-role {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 2px;
}

/* Avatar upload (settings page) */
.avatar-upload {
  position: relative;
  width: 160px; height: 160px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--paper);
  flex-shrink: 0;
  transition: all var(--med) var(--ease);
}
.avatar-upload:hover { border-color: var(--ink); }
.avatar-upload img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-upload-initials {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
  font-size: 64px;
  font-weight: 300;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.avatar-upload-overlay {
  position: absolute; inset: 0;
  background: rgba(20,17,16,0.75);
  color: var(--bone);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity var(--fast);
}
.avatar-upload:hover .avatar-upload-overlay { opacity: 1; }

/* View-as banner (admin impersonation) */
.view-as-banner {
  background: var(--oxblood);
  color: var(--bone);
  padding: var(--s-13) var(--s-21);
  margin: calc(var(--s-55) * -1) calc(var(--s-55) * -1) var(--s-34);
  border-bottom: 1px solid rgba(243,238,228,0.2);
}
@media (max-width: 900px) {
  .view-as-banner { margin: calc(var(--s-34) * -1) calc(var(--s-21) * -1) var(--s-21); }
}
.view-as-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-13); flex-wrap: wrap;
}
.view-as-role {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  padding: 4px 10px;
  border: 1px solid rgba(243,238,228,0.3);
  color: var(--bone);
}
.view-as-exit {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: var(--bone);
  color: var(--ink);
  border: 1px solid var(--bone);
  padding: 10px 18px;
  cursor: pointer;
  transition: all var(--fast);
}
.view-as-exit:hover { background: transparent; color: var(--bone); }

/* Media viewer frames */
.media-body { display: flex; flex-direction: column; }
.media-frame {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  overflow: hidden;
}
.media-frame-video {
  aspect-ratio: 16/9;
}
.media-frame-pdf {
  height: min(72vh, 800px);
  background: var(--bone);
}
.media-frame-image {
  background: var(--bone);
  padding: var(--s-21);
  display: flex; align-items: center; justify-content: center;
}

/* Print suppression */
@media print { .nav, .sidebar, .no-print, .app-shell > aside { display: none !important; } }

/* ============================================================
   MODULES — curriculum card lists
   ============================================================ */
.lesson-list {
  list-style: none;
  margin: 21px 0 0;
  padding: 0;
  border-top: 1px solid var(--line-soft);
}
.lesson-list li {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
  color: var(--ink-1);
}
.lesson-type {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  min-width: 56px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  text-align: center;
}
.lesson-title { flex: 1; font-family: var(--serif); font-size: 17px; }
.lesson-status { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.link-list {
  border-top: 1px solid var(--line-soft);
}
.link-row {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  font-size: 15px;
}
.link-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--ink); }

/* Progress line under modules */
.progress-line {
  width: 100%;
  height: 3px;
  background: var(--line-soft);
  border-radius: 2px;
  overflow: hidden;
}
.progress-line-fill {
  height: 100%;
  background: var(--ink);
  transition: width 360ms ease;
}

/* ============================================================
   COMMENTS — media viewer discussion thread
   ============================================================ */
.media-thread { margin-top: 13px; }
.comment-list { display: flex; flex-direction: column; gap: 21px; margin-bottom: 21px; }
.comment {
  display: flex; gap: 13px; align-items: flex-start;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
}
.comment-body { flex: 1; min-width: 0; }
.comment-head {
  display: flex; gap: 13px; align-items: center;
  margin-bottom: 4px;
  font-size: 13px;
}
.comment-author {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}
.comment-del {
  background: none; border: none;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  cursor: pointer;
  padding: 0;
  margin-left: auto;
}
.comment-del:hover { color: var(--oxblood); }
.comment-form {
  display: flex; gap: 13px;
  padding: 21px 0;
  border-top: 1px solid var(--line-soft);
}
.comment-form textarea {
  width: 100%;
  resize: vertical;
}

/* ============================================================
   REPORT CARD + CERTIFICATE
   ============================================================ */
.report-page {
  min-height: 100vh;
  background: var(--paper);
  padding: var(--s-55);
  display: flex; flex-direction: column; align-items: center; gap: var(--s-34);
}
.report-actions {
  width: 100%;
  max-width: 880px;
  display: flex; justify-content: space-between;
}
.report-paper {
  width: 100%;
  max-width: 880px;
  background: var(--bone);
  padding: var(--s-89);
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.report-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 34px;
  flex-wrap: wrap; gap: 21px;
}
.report-brand {
  font-family: var(--serif);
  font-size: 34px;
  font-style: italic;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.divider {
  border: none;
  border-top: 1px solid var(--ink);
  margin: 34px 0;
  opacity: 0.6;
}
.report-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-21);
}
.report-stat {
  padding: var(--s-21);
  border: 1px solid var(--line-soft);
  background: var(--paper);
}
.report-stat-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.report-stat-value {
  font-family: var(--serif);
  font-size: 34px;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.05;
  margin-bottom: 4px;
}
.report-stat-sub {
  font-size: 12px;
  color: var(--ink-3);
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.report-table th,
.report-table td {
  padding: 13px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
}
.report-table th {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.report-modules {
  list-style: none;
  padding: 0;
  margin: 0;
}
.report-modules li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
}
.report-module-title {
  font-family: var(--serif);
  font-size: 19px;
  color: var(--ink);
}
.report-module-status {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  color: var(--ink-3);
}
.report-footer {
  margin-top: 55px;
  padding-top: 21px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
}

/* Certificate */
.certificate {
  width: 100%;
  max-width: 880px;
  aspect-ratio: 11/8.5;
  background: var(--bone);
  padding: var(--s-89) var(--s-55);
  border: 1px solid var(--line);
  text-align: center;
  display: flex; flex-direction: column; justify-content: center;
  gap: var(--s-13);
  position: relative;
}
.cert-hairline {
  position: absolute; left: var(--s-34); right: var(--s-34); top: var(--s-21);
  height: 1px; background: var(--ink); opacity: 0.6;
}
.cert-hairline-bottom { top: auto; bottom: var(--s-21); }
.cert-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.cert-ornament {
  font-size: 21px;
  color: var(--ink);
  margin: var(--s-13) 0;
}
.cert-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 55px;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 0;
}
.cert-copy {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink-2);
  margin: 0;
}
.cert-name,
.cert-educator {
  font-family: var(--serif);
  font-size: 44px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.cert-module {
  font-family: var(--serif);
  font-size: 27px;
  font-style: italic;
  color: var(--oxblood);
}
.cert-signature {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: var(--s-34);
}

/* Report print rules */
@media print {
  body { background: white; }
  .report-page { padding: 0; background: white; }
  .report-paper, .certificate {
    border: none;
    box-shadow: none;
    max-width: 100%;
    margin: 0;
    page-break-after: always;
  }
  .report-actions, .no-print { display: none !important; }
}

/* ============================================================
   Mobile polish — tighten padding, stack sidebar, bigger touch
   ============================================================ */
@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr !important;
  }
  .app-shell > aside.sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    width: 100%;
    height: auto;
    padding: var(--s-13) var(--s-21);
    flex-direction: row;
    flex-wrap: wrap;            /* let the nav drop to a second row */
    align-items: center;
    overflow-x: visible;
    gap: var(--s-8);
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--bone);
  }
  .app-shell > aside .sidebar-brand {
    flex-shrink: 0;
    margin-right: 0;
    font-size: 19px;
  }
  /* Nav takes its own row, full-width, horizontally scrollable */
  .app-shell > aside .side-nav {
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    flex: 1 0 100%;             /* full row */
    order: 99;                  /* push below brand + profile */
    border: 0;
    padding: 0 0 4px 0;
    margin-top: 4px;
    /* hide ugly scrollbar on iOS */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .app-shell > aside .side-nav::-webkit-scrollbar { display: none; }
  .app-shell > aside .side-link {
    padding: 8px 14px;
    font-size: 13px;
    white-space: nowrap;
    border-radius: 100px;
    border: 1px solid var(--line-soft);
  }
  .app-shell > aside .side-link.active {
    background: var(--ink);
    color: var(--bone);
    border-color: var(--ink);
  }
  /* Profile chip wrapper — pushed to the far right of row 1 */
  .app-shell > aside > div:last-child {
    flex-shrink: 0;
    margin-top: 0 !important;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--s-8);
  }
  .app-shell > aside > div:last-child > hr { display: none; }
  /* Compact the profile chip on phones — avatar + first name only */
  .app-shell > aside .profile-chip {
    padding: 4px 10px 4px 4px;
    gap: 8px;
    border-radius: 100px;
  }
  .app-shell > aside .profile-chip .profile-name { font-size: 13px; line-height: 1.1; }
  .app-shell > aside .profile-chip .profile-role { display: none; }
  .app-shell > aside > div:last-child .btn { display: none; }

  .main { padding: var(--s-13) !important; }
  .three-col { grid-template-columns: 1fr !important; }
  .two-col { grid-template-columns: 1fr !important; }

  /* v14: kill horizontal overflow everywhere */
  html, body { overflow-x: hidden; max-width: 100vw; }
  .app-shell { max-width: 100vw; overflow-x: hidden; }
  .main { max-width: 100%; overflow-x: hidden; }
  .card, .card-paper, .card-ink, .tile, article { max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
  table { max-width: 100%; display: block; overflow-x: auto; }
  pre, code { max-width: 100%; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
  img, canvas, video, iframe { max-width: 100%; height: auto; }

  /* Auth pages: collapse the editorial column, full-width form */
  main[style*="grid-template-columns: 1fr 1fr"],
  main[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  main[style*="grid-template-columns: 1fr 1fr"] > section,
  main[style*="grid-template-columns:1fr 1fr"] > section {
    padding: var(--s-34) var(--s-21) !important;
  }

  /* Modal goes nearly full screen and never overflows */
  .modal-backdrop .modal { width: 100% !important; max-width: 100% !important; }

  /* Inputs/textareas/selects don't burst the viewport */
  input, textarea, select { max-width: 100%; }

  /* Header on mobile: stack title and actions */
  .app-shell .main > header { margin-bottom: var(--s-34) !important; }

  /* Quiz options need bigger tap area */
  .quiz-opt { padding: 14px 16px !important; }

  /* Settings + form rows */
  .field { margin-bottom: var(--s-13); }
  .display-xl { font-size: 44px !important; }
  .display-l  { font-size: 34px !important; }
  .display-m  { font-size: 27px !important; }
  .report-paper, .certificate { padding: var(--s-34) var(--s-21); }
  .report-stats { grid-template-columns: repeat(2, 1fr); }
  .cert-title { font-size: 40px; }
  .cert-name, .cert-educator { font-size: 28px; }
  .cert-module { font-size: 21px; }

  /* bigger tap targets */
  .btn { min-height: 44px; }
  .lesson-list li { padding: 13px 0; }

  /* modal full-bleed */
  .modal-backdrop .modal { margin: 0; max-height: 100vh; border-radius: 0; }
}

@media (max-width: 480px) {
  .report-stats { grid-template-columns: 1fr; }
  .display-xl { font-size: 34px !important; }
}

/* PWA install prompt */
.pwa-install {
  position: fixed;
  bottom: 21px; right: 21px;
  z-index: 200;
  padding: 13px 21px;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.pwa-install:hover { background: var(--oxblood); }
