/* ChiselAssess — Redesign
   Editorial Swiss, warm ink palette, data-dense faculty-first.
   All visual tokens live here; Tweaks rewrite the CSS vars at runtime.
*/

/* ── TOKENS ────────────────────────────────────────────────── */
:root {
  /* Base palette — Editorial warm ink (light default) */
  --ink:          #14120f;
  --ink-2:        #2a2622;
  --ink-3:        #5a534a;
  --ink-4:        #8a8278;
  --ink-5:        #b8b0a4;
  --rule:         #e6e1d8;
  --rule-2:       #d4cdbf;
  --paper:        #faf8f3;
  --paper-2:      #f2ede2;
  --paper-3:      #ebe5d6;
  --card:         #ffffff;
  --card-2:       #fbf9f4;

  /* Single accent — deep ink-red, editorial */
  --accent:       #a93226;
  --accent-2:     #c0392b;
  --accent-wash:  #f9ecea;
  --accent-ink:   #7a1f17;

  /* Semantic (muted so data reads neutral first) */
  --ok:           #2d6a4f;
  --ok-wash:      #e6f0eb;
  --warn:         #8a5a1b;
  --warn-wash:    #f5ecd9;
  --bad:          #a93226;
  --bad-wash:     #f9ecea;
  --info:         #2e4a7a;
  --info-wash:    #e7ecf5;

  /* Data viz hues — 5 saturated but editorial */
  --viz-1: #c2410c;  /* burnt orange */
  --viz-2: #0e7490;  /* deep cyan */
  --viz-3: #b45309;  /* amber */
  --viz-4: #4338ca;  /* indigo */
  --viz-5: #9d174d;  /* magenta */
  --viz-6: #047857;  /* emerald */

  /* Criterion hues (used in report cards) */
  --crit-content:    #c2410c;
  --crit-structure:  #4338ca;
  --crit-delivery:   #0e7490;
  --crit-voice:      #9d174d;
  --crit-engagement: #b45309;
  --crit-visual:     #047857;

  --crit-content-w:    #fef0e6;
  --crit-structure-w:  #ecebff;
  --crit-delivery-w:   #e3f3f8;
  --crit-voice-w:      #fce7f0;
  --crit-engagement-w: #faedd8;
  --crit-visual-w:     #daf1e7;

  /* Type — single-family sans for UI + serif for display + mono for data */
  --f-sans:    'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --f-display: 'Instrument Serif', 'Source Serif Pro', 'Georgia', serif;
  --f-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;

  /* Density scale */
  --d-unit: 4px;
  --d-gap:  12px;
  --d-pad:  16px;
  --d-row:  34px;

  /* Fixed */
  --sidebar-w: 232px;
  --topbar-h:  54px;
  --radius:    3px;
  --radius-lg: 6px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 0 rgba(20,18,15,.04), 0 1px 2px rgba(20,18,15,.04);
  --shadow-2: 0 4px 14px rgba(20,18,15,.06), 0 1px 3px rgba(20,18,15,.04);
  --shadow-3: 0 24px 56px rgba(20,18,15,.14), 0 2px 6px rgba(20,18,15,.06);
}

/* ── THEME: dark ───────────────────────────────────────────── */
[data-theme="dark"] {
  --ink:          #f0ece3;
  --ink-2:        #d8d2c5;
  --ink-3:        #a89f8e;
  --ink-4:        #7a7362;
  --ink-5:        #5a5244;
  --rule:         #2a2620;
  --rule-2:       #3a342b;
  --paper:        #100e0b;
  --paper-2:      #17140f;
  --paper-3:      #1e1a14;
  --card:         #181510;
  --card-2:       #1f1b15;

  --accent-wash:  #3a1a16;
  --ok-wash:      #15271f;
  --warn-wash:    #2c2013;
  --bad-wash:     #3a1a16;
  --info-wash:    #161e30;

  --shadow-1: 0 1px 0 rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.3);
  --shadow-2: 0 4px 14px rgba(0,0,0,.45), 0 1px 3px rgba(0,0,0,.3);
  --shadow-3: 0 24px 56px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.3);
}

/* ── ACCENT VARIANTS (Tweak) ───────────────────────────────── */
[data-accent="ink-red"]   { --accent:#a93226; --accent-2:#c0392b; --accent-wash:#f9ecea; --accent-ink:#7a1f17; }
[data-accent="forest"]    { --accent:#2d6a4f; --accent-2:#3a8a64; --accent-wash:#e6f0eb; --accent-ink:#1b4a35; }
[data-accent="indigo"]    { --accent:#2e4a7a; --accent-2:#3d5f99; --accent-wash:#e7ecf5; --accent-ink:#1e3356; }
[data-accent="ochre"]     { --accent:#8a5a1b; --accent-2:#a86e24; --accent-wash:#f5ecd9; --accent-ink:#5a3a10; }
[data-accent="plum"]      { --accent:#6c4675; --accent-2:#855891; --accent-wash:#efe7f1; --accent-ink:#4a2e52; }
[data-theme="dark"][data-accent="ink-red"]  { --accent-wash:#3a1a16; }
[data-theme="dark"][data-accent="forest"]   { --accent-wash:#15271f; }
[data-theme="dark"][data-accent="indigo"]   { --accent-wash:#161e30; }
[data-theme="dark"][data-accent="ochre"]    { --accent-wash:#2c2013; }
[data-theme="dark"][data-accent="plum"]     { --accent-wash:#26193a; }

/* ── TYPE VARIANTS (Tweak) ─────────────────────────────────── */
[data-type="editorial"] {
  --f-sans:    'Inter Tight', 'Inter', sans-serif;
  --f-display: 'Instrument Serif', serif;
  --f-mono:    'JetBrains Mono', monospace;
}
[data-type="swiss"] {
  --f-sans:    'Neue Haas Grotesk', 'Inter Tight', 'Helvetica Neue', sans-serif;
  --f-display: 'Neue Haas Grotesk', 'Inter Tight', sans-serif;
  --f-mono:    'JetBrains Mono', monospace;
}
[data-type="academic"] {
  --f-sans:    'Source Sans 3', 'Inter Tight', sans-serif;
  --f-display: 'Source Serif 4', 'Source Serif Pro', serif;
  --f-mono:    'JetBrains Mono', monospace;
}
[data-type="geometric"] {
  --f-sans:    'Geist', 'Inter Tight', sans-serif;
  --f-display: 'Fraunces', 'Instrument Serif', serif;
  --f-mono:    'Geist Mono', 'JetBrains Mono', monospace;
}

/* ── DENSITY VARIANTS (Tweak) ──────────────────────────────── */
[data-density="airy"]     { --d-gap:18px; --d-pad:22px; --d-row:42px; }
[data-density="balanced"] { --d-gap:14px; --d-pad:18px; --d-row:36px; }
[data-density="dense"]    { --d-gap:10px; --d-pad:14px; --d-row:30px; }

/* ── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--f-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
  transition: background .4s ease, color .3s ease;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

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

/* Serif display pattern */
.serif { font-family: var(--f-display); font-weight: 400; letter-spacing: -0.01em; }
.mono  { font-family: var(--f-mono); font-feature-settings: 'tnum'; }
.tnum  { font-variant-numeric: tabular-nums; }
.eyebrow {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-4);
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule-2); border-radius: 10px; border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ── SHELL ─────────────────────────────────────────────────── */
/* Layout wrapper — .app is legacy; JSX renders .app-shell */
.app,
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--paper);
}

/* Right-hand column: topbar stays pinned, content scrolls below */
.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Padded scrollable content area inside main-col */
.main-col > main,
.content {
  flex: 1;
  overflow-x: hidden;
  padding: 28px 36px 56px;
}
@media (max-width: 1200px) { .main-col > main, .content { padding: 24px 28px 48px; } }
@media (max-width: 960px)  { .main-col > main, .content { padding: 18px 18px 40px; } }

/* Sidebar */
.sb {
  background: var(--paper-2);
  border-right: 1px solid var(--rule);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 0;
}
.sb-brand {
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 10px;
}
.sb-name { font-family: var(--f-display); font-size: 18px; line-height: 1.1; }
.sb-sub  { font-size: 10.5px; color: var(--ink-4); margin-top: 1px; letter-spacing: .02em; }

.sb-section {
  padding: 14px 18px 6px;
  font-family: var(--f-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.sb-nav { padding: 0 10px; }
.sb-item svg { flex-shrink: 0; opacity: .55; }
.sb-item.active svg { opacity: 1; color: var(--accent); }

.sb-foot {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--rule);
  display: flex; align-items: center; gap: 10px;
}
.sb-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--f-display); font-size: 13px;
  flex-shrink: 0;
}
.sb-who { flex: 1; min-width: 0; }
.sb-who-name { font-size: 12px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-who-role { font-size: 10px; color: var(--ink-4); text-transform: uppercase; letter-spacing: .06em; font-family: var(--f-mono); }

/* Main — kept for backward compat; padding now lives on .content */
.main { display: flex; flex-direction: column; min-width: 0; flex: 1; overflow-x: hidden; }

.crumb { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-4); }
.crumb-sep { color: var(--ink-5); }
.crumb-active { color: var(--ink); font-weight: 500; }
.topbar-r { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.kbd {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--ink-4);
  padding: 2px 6px;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--card);
}

/* Page */
.page {
  padding: 22px 26px 40px;
  max-width: 1320px;
  width: 100%;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px;
  gap: 20px; flex-wrap: wrap;
}
.page-title {
  font-family: var(--f-display);
  font-size: 32px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.page-title em { font-style: italic; color: var(--accent); }
.page-sub { font-size: 13px; color: var(--ink-3); margin-top: 4px; max-width: 64ch; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.card-pad { padding: var(--d-pad); }
.card-hd {
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 10px;
  background: var(--card-2);
}
.card-title { font-size: 12.5px; font-weight: 600; letter-spacing: -0.005em; color: var(--ink); }
.card-desc  { font-size: 11.5px; color: var(--ink-4); }

/* Buttons — enhanced block below */

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.field.req > label::after { content: ' •'; color: var(--accent); }
textarea { resize: vertical; min-height: 72px; font-family: inherit; }

/* Status pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .04em;
  background: var(--paper-3);
  color: var(--ink-3);
  border: 1px solid var(--rule);
  transition: background .15s, color .15s, border-color .15s;
}
.pill-ok   { background: var(--ok-wash);   color: var(--ok);   border-color: transparent; }
.pill-warn { background: var(--warn-wash); color: var(--warn); border-color: transparent; }
.pill-bad  { background: var(--bad-wash);  color: var(--bad);  border-color: transparent; }
.pill-info { background: var(--info-wash); color: var(--info); border-color: transparent; }
.pill-accent { background: var(--accent-wash); color: var(--accent); border-color: transparent; }
.pill-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill-live .pill-dot { animation: livePulse 2.2s ease-in-out infinite; }

/* Rules & dividers */
.rule { height: 1px; background: var(--rule); border: 0; }
.rule-v { width: 1px; background: var(--rule); align-self: stretch; }

/* Utility */
.row { display: flex; align-items: center; gap: var(--d-gap); }
.col { display: flex; flex-direction: column; gap: var(--d-gap); }
.grow { flex: 1; min-width: 0; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.muted { color: var(--ink-4); }
.dim   { color: var(--ink-3); }

/* ── TWEAKS panel ──────────────────────────────────────────── */
.tweaks-fab {
  position: fixed; bottom: 20px; right: 20px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--ink); color: var(--paper);
  border: none; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: var(--shadow-2);
  z-index: 200;
  transition: transform .2s, background .15s;
}
.tweaks-fab:hover { transform: rotate(45deg); }
.tweaks-panel {
  position: fixed; bottom: 72px; right: 20px;
  width: 300px; max-height: 80vh; overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  z-index: 199;
  font-size: 12px;
  animation: twIn .18s ease;
}
@keyframes twIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.tweaks-hd {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 8px;
}
.tweaks-hd-title { font-family: var(--f-display); font-size: 17px; flex: 1; }
.tweaks-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 14px; }
.tweak-group { display: flex; flex-direction: column; gap: 6px; }
.tweak-group > label {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.tweak-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.tweak-pill {
  padding: 4px 9px;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--ink-3);
  font-size: 11.5px;
  cursor: pointer;
  transition: all .15s;
}
.tweak-pill:hover { border-color: var(--ink-4); color: var(--ink); }
.tweak-pill.active {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.tweak-swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--rule-2);
  cursor: pointer;
  transition: all .15s;
}
.tweak-swatch:hover { transform: scale(1.08); }
.tweak-swatch.active {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--ink);
}

/* ── MOTION primitives ────────────────────────────────────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes slideInR { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
@keyframes drawLine { from { stroke-dashoffset: var(--dash, 1000); } to { stroke-dashoffset: 0; } }
@keyframes rotate { to { transform: rotate(360deg); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.fade-up { animation: fadeUp .4s cubic-bezier(.2,.7,.3,1) both; }
.fade-in { animation: fadeIn .35s ease both; }
.scale-in { animation: scaleIn .3s cubic-bezier(.2,.7,.3,1) both; }

/* stagger helpers */
.stagger > * { animation: fadeUp .4s cubic-bezier(.2,.7,.3,1) both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .10s; }
.stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; }
.stagger > *:nth-child(6) { animation-delay: .22s; }
.stagger > *:nth-child(7) { animation-delay: .26s; }
.stagger > *:nth-child(8) { animation-delay: .30s; }

/* ── REPORT MODAL ───────────────────────────────────────────── */
.modal-scrim {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 18, 15, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: start center;
  overflow: auto;
  padding: 40px 24px;
  animation: fadeIn .2s ease;
}
.modal-sheet {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  width: min(1040px, 100%);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.04);
  position: relative;
  animation: modalIn .35s cubic-bezier(.2,.8,.3,1);
}
.modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--rule);
  display: grid; place-items: center; cursor: pointer;
  color: var(--ink-3); transition: all .15s;
}
.modal-close:hover { color: var(--ink); background: var(--paper-2); border-color: var(--rule-2); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* ── INTERACTIVE CARD LIFT ──────────────────────────────────── */
.card-lift {
  transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .18s cubic-bezier(.2,.7,.3,1);
  cursor: pointer;
}
.card-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(20,18,15,.1), 0 2px 6px rgba(20,18,15,.06);
}
.card-lift:active { transform: translateY(0); }

/* ── ENHANCED TABLE ROWS ────────────────────────────────────── */
table { border-collapse: collapse; width: 100%; }
thead tr { border-bottom: 1px solid var(--rule); background: var(--card-2); }
th {
  padding: 9px 14px;
  font-family: var(--f-mono);
  font-size: 9.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-4); text-align: left; white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr {
  transition: background .12s, box-shadow .12s;
  position: relative;
}
tbody tr:hover { background: color-mix(in oklab, var(--accent) 4%, var(--paper-2)); }
tbody tr:hover td:first-child {
  box-shadow: inset 2px 0 0 var(--accent);
}
tbody tr:last-child td { border-bottom: none; }

/* ── SIDEBAR ENHANCEMENTS ───────────────────────────────────── */
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 12.5px;
  color: var(--ink-3);
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s, padding-left .15s;
  position: relative;
  margin-bottom: 1px;
}
.sb-item:hover { background: var(--paper-3); color: var(--ink); padding-left: 13px; }
.sb-item.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-1);
  padding-left: 13px;
}
.sb-item.active::before {
  content: '';
  position: absolute; left: 0; top: 5px; bottom: 5px; width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  animation: slideInAccent .2s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes slideInAccent {
  from { transform: scaleY(0); opacity: 0; }
  to   { transform: scaleY(1); opacity: 1; }
}

/* ── ENHANCED BUTTONS ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--rule-2);
  background: var(--card);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background .12s, border-color .12s, color .12s, transform .08s, box-shadow .12s;
  white-space: nowrap;
  position: relative; overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute; inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity .12s;
}
.btn:hover { background: var(--paper-2); border-color: var(--ink-4); box-shadow: 0 1px 3px rgba(20,18,15,.08); }
.btn:hover::after { opacity: .03; }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:active::after { opacity: .06; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--ink); color: var(--paper);
  border-color: var(--ink);
  box-shadow: 0 1px 0 rgba(0,0,0,.15), inset 0 1px 0 rgba(255,255,255,.08);
}
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); box-shadow: 0 3px 8px rgba(20,18,15,.22); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.btn-accent:hover { background: var(--accent-2); border-color: var(--accent-2); box-shadow: 0 4px 12px color-mix(in oklab, var(--accent) 40%, transparent); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--paper-3); box-shadow: none; }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-lg { padding: 10px 18px; font-size: 13.5px; }

/* ── ENHANCED INPUTS ─────────────────────────────────────────── */
.input, select, textarea {
  background: var(--card);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  padding: 8px 11px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .2s, background .15s;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
.input:hover, select:hover { border-color: var(--ink-4); }
.input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash), 0 1px 2px rgba(20,18,15,.04);
  background: var(--card);
}
.input::placeholder, textarea::placeholder { color: var(--ink-5); }

/* ── STAT / KPI CARD GLOW ────────────────────────────────────── */
.kpi-card {
  transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .18s cubic-bezier(.2,.7,.3,1), border-color .18s;
}
.kpi-card:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 6px 20px rgba(20,18,15,.09);
  border-color: var(--rule-2);
}

/* ── TOPBAR REFINEMENT ───────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--rule);
  background: color-mix(in oklab, var(--paper) 88%, transparent);
  display: flex; align-items: center;
  padding: 0 36px;
  gap: 14px;
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
}

/* ── IMPROVED MODAL ──────────────────────────────────────────── */
.modal-scrim {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 18, 15, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid; place-items: start center;
  overflow: auto;
  padding: 40px 24px;
  animation: fadeIn .2s ease;
}
.modal-sheet {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  width: min(1040px, 100%);
  box-shadow: 0 40px 80px -20px rgba(0,0,0,.35), 0 0 0 1px rgba(0,0,0,.04);
  position: relative;
  animation: modalIn .3s cubic-bezier(.18,.85,.32,1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(18px) scale(.982); }
  to   { opacity: 1; transform: none; }
}

/* ── SIDEBAR BRAND MARK PULSE ────────────────────────────────── */
.sb-mark {
  width: 30px; height: 30px; border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--f-display);
  font-size: 18px;
  line-height: 1;
  padding-bottom: 2px;
  flex-shrink: 0;
  transition: background .2s, transform .2s;
}
.sb-brand:hover .sb-mark { background: var(--accent); transform: rotate(-4deg) scale(1.08); }

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .35; transform: scale(0.7); }
}

/* ── AUTH SCREEN POLISH ──────────────────────────────────────── */
.auth-left-panel {
  background: var(--paper-2);
  border-right: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
}
.auth-left-panel::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(circle, var(--rule-2) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.6;
}
.auth-left-panel::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 40%;
  background: linear-gradient(to top, var(--paper-2), transparent);
  pointer-events: none;
}

/* ── ROW / CARD FOCUS RINGS ──────────────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── COUNTER ANIMATION ───────────────────────────────────────── */
@keyframes countUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.count-up { animation: countUp .5s cubic-bezier(.2,.7,.3,1) both; }

/* ── SLOT CARD HOVER ─────────────────────────────────────────── */
.slot-card {
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.slot-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 18px rgba(20,18,15,.07), inset 0 0 0 1px var(--accent);
  transform: translateY(-1px);
}

/* ── PROGRESS BAR ANIMATION ──────────────────────────────────── */
@keyframes growX {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
.progress-bar-fill {
  transform-origin: left;
  animation: growX .6s cubic-bezier(.2,.7,.3,1) both;
}

/* ── REPORT ROW HOVER ────────────────────────────────────────── */
.report-row {
  transition: background .12s, transform .12s;
  cursor: pointer;
}
.report-row:hover { background: color-mix(in oklab, var(--accent) 5%, var(--paper-2)); transform: translateX(2px); }

/* ── SIDEBAR BADGE ANIMATION ─────────────────────────────────── */
.sb-badge {
  margin-left: auto;
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--ink-4);
  background: var(--paper-3);
  padding: 1px 6px;
  border-radius: 3px;
  transition: background .15s, color .15s, transform .15s;
}
.sb-item:hover .sb-badge { transform: scale(1.08); }
.sb-item.active .sb-badge { background: var(--accent-wash); color: var(--accent); }

/* ── SKELETON LOADING ────────────────────────────────────────── */
@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--paper-2) 25%, var(--paper-3) 50%, var(--paper-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: 4px;
}

/* ── GRADE BADGE ─────────────────────────────────────────────── */
.grade-badge {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 6px;
  font-weight: 700; font-size: 14px;
  transition: transform .15s;
}
.grade-badge:hover { transform: scale(1.1); }

/* ── SCROLL FADE EDGES ───────────────────────────────────────── */
.scroll-fade-y {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 48px, black calc(100% - 48px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, black 48px, black calc(100% - 48px), transparent 100%);
}

/* ── ICON BUTTON ─────────────────────────────────────────────── */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 6px;
  background: transparent; border: 1px solid transparent;
  color: var(--ink-4); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s, transform .1s;
}
.icon-btn:hover { background: var(--paper-3); color: var(--ink); border-color: var(--rule); }
.icon-btn:active { transform: scale(.92); }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 960px) {
  .app, .app-shell { grid-template-columns: 1fr; }
  .sb { position: fixed; left: 0; top: 0; width: var(--sidebar-w); z-index: 50; transform: translateX(-100%); transition: transform .25s; }
  .sb.open { transform: none; }
  .page { padding: 16px; }
  .tweaks-panel { width: calc(100vw - 40px); }
}

/* ── PRINT — PDF EXPORT for student report ─────────────────── */
@media print {
  @page { size: A4; margin: 14mm 14mm 16mm; }
  html, body { background: #fff !important; }
  /* hide everything that isn't the print target */
  body.printing .sb,
  body.printing .topbar,
  body.printing .tweaks-fab,
  body.printing .tweaks-panel,
  body.printing .design-canvas-link,
  body.printing .modal-close,
  body.printing .print-hide {
    display: none !important;
  }
  body.printing .modal-scrim {
    position: static !important;
    inset: auto !important;
    background: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    overflow: visible !important;
    display: block !important;
  }
  body.printing .modal-sheet {
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    max-width: none !important;
    background: #fff !important;
    border-radius: 0 !important;
    page-break-inside: auto;
  }
  body.printing .main-col,
  body.printing .main { display: none !important; }
  body.printing .app { display: block !important; }
  /* Ensure colors print */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .card, [class*='card'] { break-inside: avoid; }
  .fade-up, .fade-in, .stagger > * { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* ── COLORFUL analytics panel accents ───────────────────────── */
.analytics-card {
  position: relative; overflow: hidden;
}
.analytics-card::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(135deg, var(--chip-from, transparent) 0%, transparent 45%);
  opacity: 0.08;
}
.chip-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--chip-c, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--chip-c, var(--accent)) 18%, transparent);
  margin-right: 8px; vertical-align: middle;
}


/* ── ChiselAssess Branding Additions ──────────────────────────────────── */

/* Sidebar logo wrapper */
.sb-logo-wrap {
  width: 44px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: #3755a0; /* chisel brand blue fallback */
}

/* Sidebar copyright footer */
.sb-copyright {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--rule);
  margin-top: auto;
}

/* Report watermark (non-printing version handled by opacity) */
@media print {
  .report-watermark {
    opacity: 0.06 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .report-footer {
    page-break-inside: avoid;
  }
  .report-brand-bar {
    page-break-after: avoid;
  }
}

/* Analysing badge animation (reuse livePulse from faculty) */
.analysing-pulse {
  animation: livePulse 2s ease-out infinite;
}

/* Report footer */
.report-footer {
  position: relative;
  z-index: 1;
}

/* Ensure report content is above watermark */
.report-print-root > *:not(.report-watermark) {
  position: relative;
  z-index: 1;
}

/* ── Login page auth panel ─────────────────────────────────────── */
.auth-left-panel {
  background: linear-gradient(160deg, var(--paper) 0%, var(--paper-2) 100%);
  border-right: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
}

.auth-left-panel::before {
  content: '';
  position: absolute;
  top: -80px; left: -80px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, color-mix(in oklab, var(--accent) 6%, transparent) 0%, transparent 70%);
  pointer-events: none;
}

/* New logo — transparent bg, auto height */
.sb-logo-wrap {
  width: 52px;
  height: auto;
  flex-shrink: 0;
  background: transparent;
  border-radius: 0;
  overflow: visible;
}

/* ═══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — works because viewport is now device-width
   ═══════════════════════════════════════════════════════════ */

/* Hamburger button */
.sb-hamburger {
  display: none;
  position: fixed;
  top: 10px; left: 12px; z-index: 200;
  width: 40px; height: 40px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-2);
  color: var(--ink-3);
}
.sb-hamburger:active { background: var(--paper-3); }

/* Scrim overlay for sidebar */
.sb-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 98;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.sb-overlay.visible { display: block; }

/* Prominent logout button */
.sb-logout-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  padding: 6px 12px !important;
  background: color-mix(in oklab, var(--bad) 9%, transparent) !important;
  border: 1px solid color-mix(in oklab, var(--bad) 25%, var(--rule)) !important;
  border-radius: 6px !important;
  color: var(--bad) !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, box-shadow .15s;
}
.sb-logout-btn:hover {
  background: color-mix(in oklab, var(--bad) 18%, transparent) !important;
  box-shadow: 0 2px 8px color-mix(in oklab, var(--bad) 18%, transparent) !important;
}

/* ── 960px breakpoint ─────────────────────────── */
@media (max-width: 960px) {
  /* Sidebar becomes a fixed off-screen drawer */
  .sb {
    position: fixed !important;
    left: 0; top: 0; bottom: 0;
    width: min(240px, 80vw) !important;
    z-index: 99;
    transform: translateX(-110%) !important;
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0,0,0,0.18);
  }
  .sb.open { transform: translateX(0) !important; }

  /* Main grid collapses to full-width */
  .app, .app-shell {
    grid-template-columns: 1fr !important;
  }

  /* Show hamburger */
  .sb-hamburger { display: flex; }

  /* Topbar: shift right to clear hamburger */
  .topbar {
    padding-left: 58px !important;
    padding-right: 12px !important;
  }
  .topbar-r { gap: 6px; }

  /* Shrink search on tablet */
  .topbar input { width: 180px !important; }

  /* Content padding */
  .main-col > main, .content {
    padding: 14px 14px 60px !important;
  }

  /* Grids collapse */
  [style*="repeat(4, 1fr)"],
  [style*="repeat(4,1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }
  [style*="repeat(6, 1fr)"],
  [style*="repeat(6,1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  [style*="1.5fr 1fr"],
  [style*="1.2fr 0.8fr"],
  [style*="1fr 1fr"]:not(.keep-2col) {
    grid-template-columns: 1fr !important;
  }

  /* Page head stacks */
  .page-head {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  /* Tables scroll */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Modals full-width */
  .modal-sheet { width: 96vw !important; }

  /* Tabs scroll */
  .tab-bar { overflow-x: auto; white-space: nowrap; flex-wrap: nowrap !important; }
}

/* ── 600px breakpoint (phones) ────────────────── */
@media (max-width: 600px) {
  /* Hide search bar on phones to save space */
  .topbar input { display: none !important; }
  .topbar .rule-v { display: none !important; }

  /* Single or 2-col on phone */
  [style*="repeat(4, 1fr)"],
  [style*="repeat(4,1fr)"],
  [style*="repeat(3, 1fr)"],
  [style*="repeat(3,1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }
  [style*="repeat(6, 1fr)"],
  [style*="repeat(6,1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Very small analytics grids go 1-col */
  [style*="repeat(5, 1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Report score grid: 3 cols on phone */
  [style*="1fr 1fr 1fr 1fr 1fr 1fr"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Cards less padding */
  .card, .card-pad { padding: 10px !important; }

  .modal-sheet { width: 100vw !important; border-radius: 16px 16px 0 0 !important; position: fixed; bottom: 0; top: auto; }

  .topbar { padding-left: 54px !important; }
}
