/* ============================================================
   THE ANALOG INTELLECTUAL — Design System
   Стиль: «Тетрадный лист» / Аналоговый минимализм
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap');

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --primary:           #000000;
  --surface:           #F9F9F7;
  --surface-low:       #F4F4F2;
  --surface-container: #EEEEEC;
  --surface-high:      #E8E8E6;
  --surface-highest:   #E2E3E1;
  --surface-bright:    #FFFFFF;
  --outline:           #777777;
  --outline-variant:   #C6C6C4;
  --secondary:         #5F5E5E;
  --error:             #BA1A1A;

  --grid-size:   20px;
  --grid-color:  rgba(0,0,0,0.07);

  /* Highlight colours (from stitch references) */
  --hl-yellow:  rgba(253,224,71,0.6);
  --hl-green:   rgba(134,239,172,0.55);
  --hl-red:     rgba(248,113,113,0.45);
  --hl-blue:    rgba(147,197,253,0.55);
  --ink-red:    #dc2626;
  --ink-blue:   #2563eb;
  --ink-green:  #059669;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--surface);
  color: var(--primary);
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* ── Notebook Background ─────────────────────────────────── */
.notebook-bg {
  background-color: var(--surface);
  background-image:
    linear-gradient(to right,  var(--grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
}

/* ── Typography ──────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Inter', sans-serif;
  color: var(--primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.display-lg  { font-size: 3.5rem;   font-weight: 900; }
.display-md  { font-size: 2.5rem;   font-weight: 900; }
.headline-md { font-size: 1.75rem;  font-weight: 700; }
.headline-sm { font-size: 1.375rem; font-weight: 700; }
.body-lg     { font-size: 1rem;     font-weight: 400; }
.body-sm     { font-size: 0.875rem; font-weight: 400; }
.label-md    { font-size: 0.75rem;  font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.label-sm    { font-size: 0.6875rem;font-weight: 700; letter-spacing: 0.1em;  text-transform: uppercase; }

/* ── Sketch Border ───────────────────────────────────────── */
.sketch-border {
  border: 1px solid var(--primary);
}
.sketch-border-2 { border-width: 2px; }

/* ── Margin Line ─────────────────────────────────────────── */
.margin-line {
  border-left: 2px solid var(--surface-high);
  padding-left: 1.5rem;
}
.margin-line-red {
  border-left: 2px solid #dc2626;
  padding-left: 1.5rem;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.5rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.1s steps(4);
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: #222; }
.btn-primary:active { transform: translateY(1px); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { border-width: 2px; }
.btn-outline:active { transform: translateY(1px); }

.btn-ghost {
  background: transparent;
  color: var(--secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  padding: 0.5rem 0;
}
.btn-ghost:hover { color: var(--primary); text-decoration-thickness: 2px; }

/* Nav logout button — matches nav link style exactly */
.nav-logout-btn {
  background: transparent;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--secondary);
  cursor: pointer;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.1s steps(4), border-bottom-color 0.1s steps(4);
  display: inline;
  outline: none;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}
.nav-logout-btn:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── Input Fields ────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 0.25rem; }
.field-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--secondary);
}
.field-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--primary);
  padding: 0.5rem 0;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: var(--primary);
  outline: none;
  transition: border-bottom-width 0.1s steps(4);
  width: 100%;
}
.field-input:focus { border-bottom-width: 2px; }
.field-input::placeholder { color: var(--outline); }
.field-input.error { border-color: var(--error); }
.field-error { font-size: 0.6875rem; color: var(--error); font-weight: 600; }

textarea.field-input {
  resize: vertical;
  min-height: 7rem;
  border: 1px solid var(--primary);
  padding: 0.5rem;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface-bright);
  border: 1px solid var(--primary);
  padding: 1.5rem;
}
.card-notebook {
  background-color: var(--surface);
  background-image:
    linear-gradient(to right,  var(--grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  border: 1px solid var(--primary);
  padding: 1.5rem;
}

/* ── Tags / Chips ────────────────────────────────────────── */
.chip {
  display: inline-block;
  background: var(--surface-low);
  border: 1px solid var(--primary);
  padding: 0.2rem 0.6rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.1s steps(4);
}
.chip:hover, .chip.active { background: var(--primary); color: #fff; }

/* ── Ink / Highlight Styles ──────────────────────────────── */
.ink-blue  { color: var(--ink-blue); }
.ink-red   { color: var(--ink-red); }
.ink-green { color: var(--ink-green); }

/* Handwritten highlight bars (like a marker) */
.hl-yellow {
  background: var(--hl-yellow);
  padding: 1px 4px;
  display: inline;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.hl-green {
  background: var(--hl-green);
  padding: 1px 4px;
  display: inline;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.hl-red {
  background: var(--hl-red);
  padding: 1px 4px;
  display: inline;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.hl-blue {
  background: var(--hl-blue);
  padding: 1px 4px;
  display: inline;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* Red-ink underline (like a pen stroke) */
.ink-underline-red {
  position: relative;
  display: inline;
}
.ink-underline-red::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: -3px;
  height: 2px;
  background: var(--ink-red);
  border-radius: 0 !important;
  transform: rotate(-0.5deg);
}

.ink-underline-blue {
  background-image: linear-gradient(transparent 90%, var(--ink-blue) 90%);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.ink-underline-green {
  background-image: linear-gradient(transparent 90%, var(--ink-green) 90%);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.ink-highlight {
  background: rgba(0,0,0,0.07);
  padding: 0 4px;
  display: inline-block;
}

/* Red circle outline around word (like pencil) */
.ink-circle {
  position: relative;
  display: inline;
}
.ink-circle::after {
  content: '';
  position: absolute;
  top: -4px; left: -6px; right: -6px; bottom: -4px;
  border: 2px solid var(--ink-red);
  border-radius: 48% 52% 55% 45% / 40% 45% 55% 60% !important;
  opacity: 0.8;
  transform: rotate(-2deg);
  pointer-events: none;
}

/* ── Doodle Layer ────────────────────────────────────────── */
/* SVG background doodles drawn 'in the margin' of pages    */
.doodle-layer {
  position: absolute; /* absolute so they scroll with the page */
  inset: 0;
  pointer-events: none;
  z-index: -1;   /* strictly below all content */
  overflow: hidden;
  opacity: 0;
  animation: doodle-appear 0.5s steps(1) 0.8s forwards;
}

/* Only show doodles when there's enough margin space (≥100px each side outside 1100px container) */
@media (max-width: 1300px) {
  .doodle-layer { display: none !important; }
}

@keyframes doodle-appear { to { opacity: 1; } }

.doodle-layer svg {
  position: absolute;
  opacity: 0.7;
}
.doodle-layer svg.doodle-darker {
  opacity: 0.8;
}

.math-symbol {
  position: absolute;
  pointer-events: none;
  font-weight: 700;
  color: var(--primary);
  z-index: 0;
}

/* ── Margin Scribbles (inline red/blue annotations) ───────*/
.scribble {
  display: inline-block;
  font-style: italic;
  color: var(--ink-red);
  font-size: 0.7em;
  vertical-align: super;
  margin-left: 4px;
  line-height: 1;
}

/* ── Red box outline (from design ref _4) ────────────────── */
.ink-box {
  position: relative;
  display: inline-block;
  padding: 2px 6px;
}
.ink-box::before {
  content: '';
  position: absolute;
  inset: -2px -4px;
  border: 2px solid var(--ink-red);
  border-radius: 2px !important;
  transform: rotate(-0.5deg);
  pointer-events: none;
}

/* ── Material Symbols ────────────────────────────────────── */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
  vertical-align: middle;
}

/* ── Navigation ──────────────────────────────────────────── */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  gap: 1rem;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--primary);
}
.nav-logo {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--primary);
  flex-shrink: 0;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
  flex: 1;
  margin-left: 2.5rem;
}
.nav-links a {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--secondary);
  text-decoration: none;
  transition: color 0.1s steps(4);
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── Nav right slot: profile icon + hamburger ── */
.nav-right-slot {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.nav-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: var(--secondary);
  transition: color 0.1s steps(4);
  padding: 4px 8px;
  border: 1.5px solid transparent;
  transition: all 0.1s steps(4);
}
.nav-profile-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}
.nav-profile-btn.nav-profile-active {
  color: var(--primary);
  border-color: var(--primary);
}
.nav-profile-btn .material-symbols-outlined {
  font-size: 1.5rem;
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}
.nav-profile-name {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-avatar {
  display: none;
}
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
}
.mobile-menu {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--surface);
  flex-direction: column;
  padding: 2rem;
}
.mobile-menu.open { display: flex; }
.mobile-nav-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: 3rem;
  gap: 1.5rem;
  list-style: none;
}
.mobile-nav-links a, .mobile-nav-links button {
  font-family: 'Inter', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--primary);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.mobile-nav-links a:hover { text-decoration: underline; }

@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-hamburger { display: block; }
  .nav-user-label { display: none; }
  .nav-profile-name { display: none; }
  .top-nav { padding: 0 1rem; }
  .container { padding: 0 1rem; }
  .section { padding: 2rem 0; }
}

/* ── Page Layout ─────────────────────────────────────────── */
.page-main {
  margin-top: 60px;
  min-height: calc(100dvh - 60px);
}
.container {
  max-width: 1320px; /* 1100 content + 220 sidebar space */
  margin: 0 auto;
  padding: 0 2rem;
  padding-left: 252px; /* 220 sideboard space + 32px standard padding */
}
@media (max-width: 1200px) {
  .container { padding-left: 2rem; max-width: 1100px; }
}
.section { padding: 4rem 0; }
.section-sm { padding: 2rem 0; }

/* ── Divider ─────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px dashed var(--outline-variant);
  margin: 2rem 0;
}

/* ── Progress bar ────────────────────────────────────────── */
.progress-track {
  height: 4px;
  background: var(--surface-highest);
  width: 100%;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s steps(8);
}

/* ── Badge ───────────────────────────────────────────────── */
.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--surface-low);
  border: 1px solid var(--primary);
  min-width: 90px;
  text-align: center;
}
.badge.locked { opacity: 0.35; }
.badge .badge-icon { font-size: 1.75rem; }
.badge .badge-label { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; line-height: 1.3; }

/* ── Calendar ────────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-day-name {
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--secondary);
  padding: 0.5rem 0;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  position: relative;
  cursor: default;
  background: var(--surface-bright);
  border: 1px solid var(--surface-high);
}
.cal-day.today { border-color: var(--primary); border-width: 2px; }
.cal-day.has-lesson { background: var(--surface-low); }
.cal-day.other-month { color: var(--outline-variant); }
.lesson-dot {
  width: 5px; height: 5px;
  background: var(--primary);
  margin-top: 3px;
}

/* ── Lesson Card ──────────────────────────────────────────── */
.lesson-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface-bright);
  border: 1px solid var(--outline-variant);
  border-left: 3px solid var(--primary);
  margin-bottom: 0.75rem;
  transition: border-color 0.1s steps(4);
}
.lesson-card.active-soon {
  border-color: var(--primary);
  background: var(--surface-low);
}
.lesson-card.active-soon .lesson-join-btn {
  display: inline-flex !important;
}

/* ── HW Table ─────────────────────────────────────────────── */
.hw-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.hw-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--outline-variant);
  background: var(--surface-bright);
  transition: border-color 0.1s steps(4), transform 0.1s steps(4);
}
.hw-item:hover { border-color: var(--primary); transform: translateX(3px); }
.hw-status {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  border: 1px solid currentColor;
}
.hw-status.pending  { color: var(--secondary); }
.hw-status.done     { color: #059669; }
.hw-status.overdue  { color: var(--error); }
.hw-status.checking { color: #2563eb; }

/* ── Classroom ───────────────────────────────────────────── */
.classroom-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  grid-template-rows: 100%;
  height: calc(100dvh - 60px);
  overflow: hidden;
}
.whiteboard-area {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--primary);
}
.wb-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--outline-variant);
  background: var(--surface-low);
  flex-wrap: wrap;
}
.wb-tool-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: 1px solid var(--outline-variant);
  cursor: pointer;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.1s steps(2);
}
.wb-tool-btn:hover { border-color: var(--primary); }
.wb-tool-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.wb-tool-btn.active .material-symbols-outlined { color: #fff; }

#whiteboard-canvas {
  flex: 1;
  display: block;
  cursor: crosshair;
  background-color: var(--surface);
  background-image:
    linear-gradient(to right,  var(--grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
}
#whiteboard-canvas.view-only { cursor: not-allowed; }

.sidebar-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--primary);
}
.sidebar-tab {
  flex: 1;
  padding: 0.75rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  cursor: pointer;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  transition: all 0.1s steps(2);
}
.sidebar-tab.active {
  border-bottom-color: var(--primary);
  background: var(--surface-low);
}

/* Chat */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.chat-msg {
  max-width: 90%;
}
.chat-msg.own { align-self: flex-end; text-align: right; }
.chat-msg-name { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--secondary); margin-bottom: 2px; }
.chat-msg-text {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  background: var(--surface-low);
  border: 1px solid var(--outline-variant);
  font-size: 0.875rem;
  line-height: 1.5;
}
.chat-msg.own .chat-msg-text { background: var(--primary); color: #fff; }
.chat-input-row {
  display: flex;
  border-top: 1px solid var(--outline-variant);
  padding: 0.75rem;
  gap: 0.5rem;
}
.chat-input {
  flex: 1;
  border: none;
  border-bottom: 1px solid var(--primary);
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  outline: none;
  padding: 0.25rem 0;
}

/* Participants */
.participants-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.participant-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border: 1px solid var(--outline-variant);
}
.participant-avatar {
  width: 36px; height: 36px;
  background: var(--surface-highest);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem; font-weight: 700;
  flex-shrink: 0;
  border: 1px solid var(--primary);
}
.participant-info { flex: 1; min-width: 0; }
.participant-name { font-size: 0.875rem; font-weight: 700; }
.participant-role { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--secondary); }

/* ── Admin Table ─────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--secondary);
  text-align: left;
  padding: 0.5rem 1rem;
  border-bottom: 2px solid var(--primary);
}
.data-table td {
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--surface-high);
}
.data-table tr:hover td { background: var(--surface-low); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--surface);
  border: 2px solid var(--primary);
  padding: 2rem;
  max-width: 480px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-box h3 { font-size: 1.25rem; font-weight: 800; margin-bottom: 1.5rem; }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--primary);
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--surface);
}
.site-footer p { font-size: 0.75rem; color: var(--secondary); }

/* ── Notification toast ──────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: 2px solid var(--primary);
  z-index: 500;
  transition: transform 0.2s steps(4);
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Utilities ───────────────────────────────────────────── */
.rotate-1  { transform: rotate(1deg); }
.rotate-m1 { transform: rotate(-1deg); }
.flex      { display: flex; }
.flex-col  { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }
.grid    { display: grid; }
.grid-2  { grid-template-columns: repeat(2, 1fr); }
.grid-3  { grid-template-columns: repeat(3, 1fr); }
.grid-4  { grid-template-columns: repeat(4, 1fr); }
.w-full  { width: 100%; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-secondary { color: var(--secondary); }
.text-error  { color: var(--error); }
.mt-1  { margin-top: 0.25rem; }
.mt-2  { margin-top: 0.5rem; }
.mt-4  { margin-top: 1rem; }
.mt-6  { margin-top: 1.5rem; }
.mt-8  { margin-top: 2rem; }
.mb-1  { margin-bottom: 0.25rem; }
.mb-2  { margin-bottom: 0.5rem; }
.mb-4  { margin-bottom: 1rem; }
.mb-6  { margin-bottom: 1.5rem; }
.mb-8  { margin-bottom: 2rem; }
.p-4   { padding: 1rem; }
.p-6   { padding: 1.5rem; }
.p-8   { padding: 2rem; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

@media (max-width: 768px) {
  .display-lg  { font-size: 2.25rem; }
  .display-md  { font-size: 1.75rem; }
  .grid-3 { grid-template-columns: repeat(2,1fr); }
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .classroom-layout { grid-template-columns: 1fr; grid-template-rows: 60vh 1fr; }
  .whiteboard-area { border-right: none; border-bottom: 1px solid var(--primary); }

  /* Mobile buttons: bigger tap targets */
  .btn { min-height: 44px; padding: 0.75rem 1.25rem; }
  .btn-ghost { min-height: 36px; }
  .field-input { font-size: 16px; } /* prevent iOS zoom */
  .modal-box { padding: 1.5rem; margin: 0.5rem; }

  /* Mobile card padding */
  .card, .card-notebook { padding: 1rem; }

  /* HW items touch-friendly */
  .hw-item { padding: 0.875rem 1rem; }
  .lesson-card { padding: 0.875rem 1rem; }

  /* Subject grid single column on very small */
  .subjects-grid { grid-template-columns: 1fr; gap: 1rem; }
}

@media (max-width: 480px) {
  .display-md { font-size: 1.5rem; }
  .headline-md { font-size: 1.375rem; }
  .nav-logo { font-size: 0.875rem; }
}
