/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary:       #1a56a0;
  --primary-dark:  #134080;
  --primary-light: #e8f0fb;
  --danger:        #c0392b;
  --success:       #27ae60;
  --warning:       #f39c12;
  --text:          #1a1a2e;
  --text-light:    #6c757d;
  --border:        #dee2e6;
  --bg:            #f4f6fa;
  --surface:       #ffffff;
  --radius:        6px;
  --shadow:        0 2px 8px rgba(0,0,0,.1);
  --font:          'Segoe UI', system-ui, -apple-system, sans-serif;
}
html { font-size: 16px; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout helpers ───────────────────────────────────── */
.container   { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
.page-wrapper { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Site header ──────────────────────────────────────── */
.site-header {
  background: var(--primary); color: #fff;
  padding: .75rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.site-header__brand { font-size: 1.1rem; font-weight: 600; flex: 1; display: flex; align-items: center; gap: .4rem; min-width: 0; }
.site-header__logo { height: 34px; width: auto; border-radius: 4px; flex-shrink: 0; }
.site-header__actions { display: flex; align-items: center; gap: .75rem; }
.grade-badge {
  background: rgba(255,255,255,.2); color: #fff;
  padding: .2rem .6rem; border-radius: 20px; font-size: .8rem;
}

/* ── Login page ───────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg); padding: 2rem 1rem;
}
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo__img { width: 110px; height: 110px; object-fit: contain; border-radius: 8px; }
.login-logo__mark {
  width: 110px; height: 110px; background: var(--primary); color: #fff;
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 700; margin: 0 auto;
}
.login-logo__name { margin-top: .5rem; font-size: 1.1rem; font-weight: 600; color: var(--text); }
.login-card {
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
  padding: 2rem; width: 100%; max-width: 400px;
}
.login-card__title { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.5rem; text-align: center; }
.login-footer { color: var(--text-light); font-size: .8rem; margin-top: 2rem; }
.pin-input { letter-spacing: .3em; font-size: 1.25rem; text-align: center; }

/* ── Forms ────────────────────────────────────────────── */
.form-group  { margin-bottom: 1rem; }
.form-label  { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; }
.form-control {
  width: 100%; padding: .5rem .75rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .9375rem; font-family: var(--font);
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,160,.15);
}
select.form-control { appearance: auto; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1.1rem; border: 1px solid transparent;
  border-radius: var(--radius); font-size: .9375rem; font-family: var(--font);
  font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary   { background: var(--primary);   color: #fff; border-color: var(--primary); }
.btn--primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn--secondary { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.btn--secondary:hover:not(:disabled) { background: var(--primary-light); }
.btn--danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--danger:hover:not(:disabled) { background: #a93226; border-color: #a93226; }
.btn--ghost     { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btn--ghost:hover:not(:disabled) { background: rgba(255,255,255,.15); }
.btn--sm        { padding: .3rem .7rem; font-size: .8125rem; }

/* ── Notifications ────────────────────────────────────── */
.notification {
  position: fixed; top: 1rem; right: 1rem; z-index: 9000;
  background: var(--success); color: #fff;
  padding: .75rem 1.25rem; border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: .9rem; max-width: 360px;
}
.notification--error { background: var(--danger); }
.error-banner {
  background: #fdecea; color: var(--danger); border: 1px solid #f5c6cb;
  border-radius: var(--radius); padding: .6rem .9rem; font-size: .875rem; margin-bottom: 1rem;
}
.error-banner--success { background: #d4edda; color: #155724; border-color: #c3e6cb; }

/* ── Badges ───────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 20px;
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.badge--published { background: #d4edda; color: #155724; }
.badge--draft     { background: #fff3cd; color: #856404; }
.badge--quiz      { background: var(--primary-light); color: var(--primary); }

/* ── Tables ───────────────────────────────────────────── */
.table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  font-size: .9rem;
}
.table th, .table td {
  padding: .65rem 1rem; text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th   { background: var(--bg); font-weight: 600; font-size: .8125rem; color: var(--text-light); text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:hover { background: var(--primary-light); }
.table--sm th, .table--sm td { padding: .4rem .75rem; font-size: .8125rem; }
.table-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.link-action { color: var(--primary); font-weight: 500; }

/* ── Tabs ─────────────────────────────────────────────── */
.tab-nav {
  display: flex; gap: 0; border-bottom: 2px solid var(--border);
  background: var(--surface); padding: 0 1rem;
  overflow-x: auto;
}
.tab-btn {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  padding: .75rem 1.1rem; font-size: .9rem; font-family: var(--font);
  color: var(--text-light); cursor: pointer; margin-bottom: -2px;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab-btn--active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-btn:hover:not(.tab-btn--active) { color: var(--text); }
.tab-content { padding: 1.5rem 1rem; }

/* ── Page toolbar ─────────────────────────────────────── */
.page-toolbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 1rem 1rem 0;
}
.page-title { font-size: 1.3rem; font-weight: 700; flex: 1; }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 8000; padding: 1rem;
}
.modal-overlay--fullscreen { padding: 0; align-items: stretch; }
.modal {
  background: var(--surface); border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  width: 100%; max-width: 520px; max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal--wide { max-width: 780px; }
.modal--fullscreen { max-width: 100% !important; max-height: 100vh !important; border-radius: 0; height: 100vh; }
.modal__header, .modal__head {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal__header h2, .modal__head h2 { font-size: 1.1rem; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal__body { padding: 1.25rem; overflow-y: auto; }
.modal__close {
  background: none; border: none; cursor: pointer; color: var(--text-light);
  font-size: 1.375rem; line-height: 1; padding: .25rem .4rem;
  border-radius: var(--radius); flex-shrink: 0; min-width: 36px; min-height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.modal__close:hover { background: var(--bg); color: var(--text); }

/* Buttons on light backgrounds (modal headers, editor toolbar) */
.modal__header .btn--ghost,
.page-toolbar .btn--ghost {
  color: var(--text); border-color: var(--border);
}
.modal__header .btn--ghost:hover:not(:disabled),
.page-toolbar .btn--ghost:hover:not(:disabled) {
  background: var(--bg); color: var(--text);
}

/* ── Stats cards ──────────────────────────────────────── */
.stats-summary { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.5rem; min-width: 130px; text-align: center;
  border-top: 3px solid var(--primary);
}
.stat-card__value { display: block; font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card__label { display: block; font-size: .75rem; color: var(--text-light); margin-top: .2rem; }

/* ── Posts grid (student) ─────────────────────────────── */
.posts-grid { padding: 1rem; }
.subject-section { margin-bottom: 2rem; }
.subject-heading { font-size: 1.1rem; font-weight: 700; color: var(--primary); margin-bottom: .75rem; border-bottom: 2px solid var(--primary-light); padding-bottom: .35rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.post-card {
  background: var(--surface); border-radius: 8px; box-shadow: var(--shadow);
  padding: 1rem 1.1rem; cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  border-left: 4px solid var(--primary);
}
.post-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.post-card__header { display: flex; align-items: flex-start; gap: .5rem; }
.post-card__title  { font-size: .95rem; font-weight: 600; flex: 1; }
.post-card__meta   { font-size: .78rem; color: var(--text-light); margin-top: .4rem; }

/* ── Post view ────────────────────────────────────────── */
.post-view { max-width: 820px; margin: 0 auto; padding: 1rem; }
.post-view__title { font-size: 1.6rem; font-weight: 700; margin-bottom: .3rem; }
.post-view__meta  { color: var(--text-light); font-size: .875rem; margin-bottom: 1.25rem; }
.post-content     { line-height: 1.7; background: #fff; border-radius: var(--radius); padding: 1.5rem 1.75rem; box-shadow: 0 1px 4px rgba(0,0,0,.07); margin-bottom: 1.25rem; }
.post-content h1, .post-content h2, .post-content h3 { margin: 1.2em 0 .5em; }
.post-content p   { margin-bottom: .75em; }
.post-content ul, .post-content ol { margin: .5em 0 .75em 1.5rem; }
.post-content img { max-width: 100%; border-radius: 4px; }
.attachments { margin-top: 1.5rem; }
.attachments h4 { margin-bottom: .5rem; }
.attachments a  { display: block; margin-bottom: .25rem; word-break: break-all; }

/* ── Quiz styles ──────────────────────────────────────── */
.quiz-card    { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; margin-top: 2rem; }
.quiz-title   { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; color: var(--primary); }
.quiz-question { margin-bottom: 1.25rem; }
.quiz-question--correct { background: #d4edda; border-radius: 6px; padding: .5rem; }
.quiz-question--wrong   { background: #fdecea; border-radius: 6px; padding: .5rem; }
.quiz-question__text { font-weight: 500; margin-bottom: .6rem; }
.quiz-options  { display: flex; flex-direction: column; gap: .4rem; }
.quiz-option   { display: flex; align-items: center; gap: .5rem; cursor: pointer; padding: .35rem .5rem; border-radius: 4px; }
.quiz-option:hover { background: var(--primary-light); }
.quiz-hint        { font-size: .8rem; color: var(--danger); margin-top: .4rem; font-style: italic; }
.quiz-q-extra     { display: flex; flex-direction: column; gap: .35rem; margin-top: .5rem; }
.quiz-tip         { font-size: .85rem; color: #6b6b6b; background: #fffbea; border-left: 3px solid #f0c040; border-radius: 4px; padding: .4rem .6rem; margin: .4rem 0 .5rem; }
.quiz-explanation { font-size: .8rem; color: #2a6b3a; background: #f0faf3; border-left: 3px solid #4caf70; border-radius: 4px; padding: .4rem .6rem; margin-top: .4rem; }
.quiz-result   { padding: .75rem 1rem; border-radius: 6px; font-size: .95rem; margin-top: .75rem; }
.quiz-result--pass { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.quiz-result--fail { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* ── Teacher editor layout ────────────────────────────── */
.teacher-main { flex: 1; }
.editor-layout { display: flex; gap: 1.5rem; padding: 1rem; align-items: flex-start; }
.editor-left  { flex: 1; min-width: 0; }
.editor-right { width: 320px; flex-shrink: 0; position: sticky; top: 1rem; }
.editor-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 840px) {
  .editor-layout { flex-direction: column; }
  .editor-right  { width: 100%; position: static; }
  .editor-row-3  { grid-template-columns: 1fr; }
}

/* ── Quiz builder (teacher) ───────────────────────────── */
.quiz-builder { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.quiz-builder__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.quiz-builder__title  { font-weight: 700; font-size: .95rem; }
.quiz-q-card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: .75rem; margin-bottom: .75rem; }
.quiz-q-card__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.quiz-q-card__num { font-weight: 700; font-size: .8rem; color: var(--primary); }
.quiz-q-text { margin-bottom: .5rem; }
.quiz-q-options { display: flex; flex-direction: column; gap: .35rem; }
.quiz-opt-row { display: flex; align-items: center; gap: .5rem; }
.quiz-opt-row input[type="text"] { flex: 1; padding: .3rem .5rem; font-size: .85rem; }

/* ── Admin main ───────────────────────────────────────── */
.admin-main { flex: 1; }

/* ── Tag list ─────────────────────────────────────────── */
.tag-list { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; }
.tag {
  background: var(--primary-light); color: var(--primary);
  border-radius: 20px; padding: .3rem .8rem; font-size: .875rem;
  display: flex; align-items: center; gap: .35rem;
}
.tag__del { background: none; border: none; cursor: pointer; color: var(--primary); font-size: 1rem; line-height: 1; padding: 0; }

/* ── Attachment row (editor upload list) ──────────────── */
.attachment-row { display: flex; gap: .5rem; margin-bottom: .4rem; }

/* ── Inline attachment viewer ─────────────────────────── */
.attachment-item { display: flex; align-items: center; gap: .5rem; margin: .5rem 0; }
.attachment-expander { flex: 1; min-width: 0; }
.attachment-expander > summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: .6rem;
  background: var(--primary-light); color: var(--primary);
  border: 1.5px solid var(--primary); border-radius: var(--radius);
  padding: .65rem 1rem; font-weight: 600; font-size: .95rem;
  word-break: break-word; transition: background .15s;
  user-select: none;
}
.attachment-expander > summary::-webkit-details-marker { display: none; }
.attachment-expander > summary:hover { background: #d0e4f7; }
.attachment-expander[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.attachment-expander > summary::after { content: '▾'; margin-left: auto; font-size: .85rem; flex-shrink: 0; }
.attachment-expander[open] > summary::after { content: '▴'; }
.attachment-frame {
  width: 100%; height: 78vh; min-height: 500px;
  border: 1.5px solid var(--primary); border-top: none;
  border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius);
  display: block;
}
.attachment-dl {
  color: var(--text-light); text-decoration: none; padding: .5rem .6rem;
  font-size: 1.1rem; line-height: 1; white-space: nowrap; flex-shrink: 0;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface);
}
.attachment-dl:hover { color: var(--primary); border-color: var(--primary); }

/* ── Quill overrides ──────────────────────────────────── */
.ql-container.ql-snow { border-radius: 0 0 var(--radius) var(--radius); }
.ql-toolbar.ql-snow   { border-radius: var(--radius) var(--radius) 0 0; background: var(--bg); }

/* ── Loading text ─────────────────────────────────────── */
.loading-text { text-align: center; color: var(--text-light); padding: 3rem; font-size: .95rem; }

/* ── Mobile / touch-friendly overrides ───────────────── */
@media (max-width: 600px) {
  /* Larger touch targets */
  .btn { min-height: 44px; padding: .55rem 1rem; }
  .btn--sm { min-height: 36px; padding: .4rem .7rem; }

  /* Site header */
  .site-header { padding: .6rem 1rem; }
  .site-header__brand { font-size: 1rem; }

  /* Page toolbar stacks on mobile */
  .page-toolbar { flex-wrap: wrap; gap: .5rem; }
  .page-toolbar > div { width: 100%; display: flex; gap: .4rem; flex-wrap: wrap; }

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

  /* Cards go single column */
  .cards { grid-template-columns: 1fr; }

  /* Modal full-width on small screens */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: 12px 12px 0 0; max-height: 92vh; }
  .modal--fullscreen { border-radius: 0; max-height: 100vh; }

  /* Attachment iframe — 78vh works fine on mobile too */
  .attachment-frame { min-height: 320px; }

  /* Editor layout already stacks via 840px breakpoint */
  .editor-row-3 { grid-template-columns: 1fr; }

  /* Post cards */
  .post-card { padding: .85rem; }
  .post-view { padding: .75rem; }
  .post-view__title { font-size: 1.3rem; }

  /* Quiz options spacing */
  .quiz-option { padding: .5rem; }
  .quiz-option input[type="radio"] { width: 1.2rem; height: 1.2rem; }
}

/* ── Teacher dashboard (mobile-first) ─────────────────── */
.toolbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.dash-wrap { padding: 1rem; }
.dash-filter { margin-bottom: 1rem; max-width: 260px; }
.dash-totals {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; padding: 0 0 1rem;
}
.page-toolbar + .dash-totals { padding: 1rem 1rem 0; }
.dash-totals .stat-card { min-width: 0; padding: .9rem .5rem; }
.dash-grid { display: grid; grid-template-columns: 1fr; gap: .9rem; }
.dash-card {
  display: flex; flex-direction: column; gap: .75rem; text-align: left; cursor: pointer;
  background: var(--surface); border: 0; border-left: 4px solid var(--primary);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem; min-height: 44px; font: inherit; color: var(--text);
}
.dash-card:active, .dash-card:focus-visible { outline: 2px solid var(--primary); }
.dash-card__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.dash-card__title { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.dash-card__stats { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .75rem; font-size: .9375rem; color: var(--text-light); }
.dash-card__stats strong, .dash-card__foot strong { color: var(--text); }
.dash-card__foot { display: flex; justify-content: space-between; font-size: .9375rem; border-top: 1px solid var(--border); padding-top: .6rem; }
.dash-card__go { color: var(--primary); font-weight: 600; }
.dash-empty { color: #888; text-align: center; padding: 2rem 1rem; }
@media (min-width: 601px) {
  .dash-totals { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .dash-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

/* ── Subject picker (admin user/PIN modals) ───────────── */
.subject-picker { display: grid; grid-template-columns: 1fr; gap: .25rem; max-height: 220px; overflow-y: auto; }
.subject-picker__item { display: flex; align-items: center; gap: .6rem; min-height: 44px; font-size: 1rem; cursor: pointer; }
.subject-picker__item input { width: 20px; height: 20px; flex-shrink: 0; }
@media (min-width: 601px) { .subject-picker { grid-template-columns: 1fr 1fr; } }

/* ── Languages: student switch + teacher translation UI ── */
.lang-switch { display: inline-flex; border: 2px solid var(--primary); border-radius: 999px; overflow: hidden; margin-bottom: 1rem; }
.lang-switch__btn {
  min-height: 44px; min-width: 96px; padding: 0 1rem; border: 0; background: var(--surface);
  color: var(--primary); font: inherit; font-weight: 600; cursor: pointer;
}
.lang-switch__btn--on { background: var(--primary); color: #fff; }

.lang-chip { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; background: #e8edf3; color: #46566a; margin-right: .3rem; white-space: nowrap; }
.lang-chip--verified { background: #d4edda; color: #155724; }
.lang-chip--draft    { background: #fff3cd; color: #7a5b00; }
.lang-chip--stale    { background: #f8d7da; color: #8a1c27; }

.tr-panel { border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: 1rem; background: var(--surface); }
.tr-panel--draft    { border-left-color: #e0a800; }
.tr-panel--verified { border-left-color: #28a745; }
.tr-panel--stale    { border-left-color: #dc3545; }
.tr-panel__title { font-weight: 700; margin-bottom: .25rem; }
.tr-panel__msg   { font-size: .9375rem; color: var(--text-light); margin: 0 0 .75rem; }
.tr-panel__actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.tr-panel__actions .btn { min-height: 44px; }
.tr-hint { font-size: .9375rem; color: var(--text-light); margin: 0 0 1rem; }

.tr-note { background: #fff8e1; border-radius: var(--radius); padding: .75rem 1rem; font-size: .9375rem; margin: 0 0 1rem; }
.tr-orig { background: #f1f3f6; color: #46566a; border-radius: 6px; padding: .5rem .75rem; font-size: .9375rem; margin-bottom: .4rem; overflow-wrap: anywhere; }
.tr-orig img { max-width: 100%; height: auto; }
.tr-orig-details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--primary); font-weight: 600; }
.tr-q { border-top: 1px solid var(--border); padding: .9rem 0; }
.tr-q__n { font-weight: 700; margin-bottom: .35rem; }
.tr-opt { display: grid; grid-template-columns: 1fr; gap: .25rem; margin-top: .6rem; }
.tr-opt--correct .tr-opt__orig { background: #d4edda; color: #155724; }
.tr-opt__orig { margin-bottom: 0; }
.tr-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; position: sticky; bottom: 0; background: var(--surface); padding: .75rem 0; }
.tr-actions .btn { min-height: 44px; flex: 1 1 140px; }
@media (min-width: 601px) { .tr-opt { grid-template-columns: 1fr 1fr; align-items: center; } }

/* ── Language tabs (teacher editor/review) + dual titles ── */
.lang-tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.lang-tab {
  flex: 1; min-height: 44px; padding: 0 .75rem; border: 2px solid var(--primary); border-radius: var(--radius);
  background: var(--surface); color: var(--primary); font: inherit; font-weight: 600; cursor: pointer;
}
.lang-tab--on { background: var(--primary); color: #fff; }
.lang-tab__mark { font-size: .8125rem; font-weight: 700; margin-left: .25rem; }
.lang-tab:not(.lang-tab--on) .lang-tab__mark--verified { color: #1e7e34; }
.lang-tab:not(.lang-tab--on) .lang-tab__mark--stale    { color: #b02a37; }
.lang-tab:not(.lang-tab--on) .lang-tab__mark--draft    { color: #946c00; }
.tr-panel--flash { box-shadow: 0 0 0 3px var(--primary); }

.title-alt { font-size: .875rem; color: var(--text-light); margin-top: .15rem; }
.post-card__alt { font-size: .9375rem; color: var(--text-light); margin: .15rem 0 .25rem; }

/* ── Admin: students ──────────────────────────────────── */
.student-filters { display: grid; grid-template-columns: 1fr; gap: .5rem; }
.pin-big { font-size: 1.35rem; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
@media (min-width: 601px) { .student-filters { grid-template-columns: 200px 1fr; } }
.pin-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.pin-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem .9rem; min-height: 56px; border-bottom: 1px solid var(--border); }
.pin-row:last-child { border-bottom: 0; }
.pin-row__name { font-weight: 600; overflow-wrap: anywhere; }
.pin-row__grade { font-size: .875rem; color: var(--text-light); }
.student-list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.student-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.student-row:last-child { border-bottom: 0; }
.student-row--off { opacity: .6; }
.student-row__info { flex: 1 1 180px; min-width: 0; }
.student-row__name { font-weight: 600; overflow-wrap: anywhere; }
.student-row__meta { font-size: .875rem; color: var(--text-light); }
.student-row__actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.student-row__actions .btn { min-height: 44px; }

/* ── Student header: name centred ─────────────────────── */
.site-header--student { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; column-gap: .75rem; }
.site-header--student .site-header__brand { flex: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-header--student .site-header__actions { justify-self: end; }
.site-header__user {
  grid-column: 2; justify-self: center; max-width: 100%; min-width: 0;
  font-weight: 600; font-size: 1.05rem; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.site-header__user[hidden] { display: none; }
@media (max-width: 600px) {
  /* phone: brand + actions on the first row, the student's name on its own centred row */
  .site-header--student { grid-template-columns: 1fr auto; row-gap: .35rem; }
  .site-header--student .site-header__brand { grid-column: 1; grid-row: 1; }
  .site-header--student .site-header__actions { grid-column: 2; grid-row: 1; }
  .site-header__user {
    grid-column: 1 / -1; grid-row: 2; width: 100%;
    padding-top: .35rem; border-top: 1px solid rgba(255,255,255,.25); font-size: 1.1rem;
  }
}

/* ── Mobile rules (≤600px): last in the file so they win ─ */
@media (max-width: 600px) {
  /* Tap targets ≥ 44px everywhere */
  .btn, .btn--sm { min-height: 44px; font-size: .9375rem; }
  .btn--sm { padding: .5rem .8rem; }
  .tab-btn { min-height: 44px; font-size: .9375rem; }
  .form-control, select.form-control, input.form-control { min-height: 44px; font-size: 1rem; }
  .link-action { display: inline-block; padding: .6rem 0; }
  .tag { padding: 0 0 0 .9rem; min-height: 44px; }
  .tag__del { min-width: 44px; min-height: 44px; font-size: 1.25rem; }
  .lang-tab, .lang-switch__btn { min-height: 44px; }

  /* Legible text */
  .form-label { font-size: .9375rem; }
  .badge, .grade-badge, .lang-chip { font-size: .8125rem; }
  .stat-card__label { font-size: .875rem; }
  .post-card__meta, .title-alt, .student-row__meta, .pin-row__grade { font-size: .9375rem; }
  .table th, .table--sm th, .table--sm td { font-size: .875rem; }
  .tr-note, .tr-panel__msg, .tr-hint { font-size: .9375rem; }

  /* Tables become stacked cards (cells labelled by mobile.js) */
  .table--stack { min-width: 0; display: block; }
  .table--stack thead { display: none; }
  .table--stack tbody, .table--stack tr, .table--stack td { display: block; }
  .table--stack tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: .6rem 0; padding: .35rem .85rem; }
  .table--stack tbody tr:hover { background: var(--surface); }
  .table--stack td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .45rem 0; border: 0; text-align: right; overflow-wrap: anywhere; font-size: .9375rem; }
  .table--stack td::before { content: attr(data-label); flex: 0 0 34%; text-align: left; font-weight: 600; font-size: .875rem; color: var(--text-light); }
  .table--stack td[data-label=""]::before, .table--stack td:not([data-label])::before { content: none; }
  .table--stack td[colspan] { display: block; text-align: center; }
  .table--stack td.table-actions { display: flex; flex-wrap: wrap; justify-content: flex-start; text-align: left; padding-top: .6rem; }
}

/* ── Login links: real tap targets, readable ──────────── */
.login-link { display: inline-block; padding: .75rem .5rem; min-height: 44px; font-size: 1rem; }
.login-footer { font-size: .875rem; }
.link-action { padding: .7rem 0; }

/* ── English | Afrikaans switch ───────────────────────── */
.lang-toggle { display: inline-flex; border: 2px solid currentColor; border-radius: 999px; overflow: hidden; }
.lang-toggle__btn {
  min-width: 48px; min-height: 40px; padding: 0 .6rem; border: 0; background: transparent;
  color: inherit; font: inherit; font-weight: 700; font-size: .9375rem; cursor: pointer;
}
.lang-toggle__btn--on { background: #fff; color: var(--primary); }
.site-header .lang-toggle { border-color: rgba(255,255,255,.7); }
.lang-toggle-wrap { display: flex; justify-content: flex-end; margin-bottom: .75rem; color: var(--primary); }
.lang-toggle-wrap .lang-toggle__btn--on { background: var(--primary); color: #fff; }
.lang-toggle-wrap .lang-toggle__btn { min-height: 44px; }
.site-header__grade { font-weight: 500; opacity: .9; }
@media (min-width: 601px) { .site-header__user--grade-only { display: none; } .site-header__grade { display: none; } .site-header__user .site-header__grade { display: none; } }
@media (max-width: 600px) {
  .site-header--student .grade-badge { display: none; }   /* grade moves to the name row on phones */
  .site-header--student .lang-toggle__btn { min-height: 44px; min-width: 44px; }
}
@media (max-width: 600px) {
  .site-header--student .site-header__brand { white-space: normal; overflow: visible; text-overflow: clip; font-size: .95rem; line-height: 1.2; }
}

/* ── Student dashboard: progress, To do / Done filter, subject groups ── */
.dash-summary { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; margin-bottom: .9rem; }
.dash-summary__line { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .5rem; font-size: 1rem; }
.dash-summary__line span { color: var(--text-light); font-weight: 600; }
.progress-bar { height: 12px; background: var(--primary-light); border-radius: 999px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: #28a745; border-radius: 999px; transition: width .3s; }

.dash-tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.dash-tab {
  flex: 1; min-height: 48px; padding: 0 .5rem; border: 2px solid var(--primary); border-radius: var(--radius);
  background: var(--surface); color: var(--primary); font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer;
}
.dash-tab--on { background: var(--primary); color: #fff; }
.dash-tab__n { display: inline-block; min-width: 1.5rem; margin-left: .25rem; padding: 0 .4rem; border-radius: 999px; background: rgba(0,0,0,.12); font-size: .875rem; }
.dash-tab:not(.dash-tab--on) .dash-tab__n { background: var(--primary-light); }

/* ── Subject–grade–term navigation ───────────────────── */
.dash-subjects { display: flex; flex-direction: column; gap: 1.5rem; }
.subj-group__title { font-size: 1.1rem; font-weight: 700; color: var(--primary); margin: 0 0 .6rem; padding-bottom: .35rem; border-bottom: 2px solid var(--primary-light); }
.grade-btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.grade-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: .15rem;
  min-height: 56px; padding: .5rem .85rem;
  background: var(--surface); border: 2px solid var(--primary); border-radius: var(--radius);
  color: var(--text); font: inherit; cursor: pointer; text-align: left;
}
.grade-btn:hover, .grade-btn:focus-visible { background: var(--primary-light); outline: none; }
.grade-btn__label { font-weight: 700; color: var(--primary); font-size: 1rem; }
.grade-btn__info  { font-size: .8125rem; color: var(--text-light); }

.filter-pills { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.filter-pill {
  min-height: 36px; padding: .25rem .85rem;
  background: var(--surface); border: 1.5px solid var(--primary); border-radius: 999px;
  color: var(--primary); font: inherit; font-size: .9375rem; font-weight: 600; cursor: pointer;
}
.filter-pill:hover:not(.filter-pill--on) { background: var(--primary-light); }
.filter-pill--on { background: var(--primary); color: #fff; }

.dash-empty-state { text-align: center; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem 1rem; margin-bottom: 1rem; }
.dash-empty-state h2 { font-size: 1.25rem; margin-bottom: .4rem; }
.dash-empty-state p { color: var(--text-light); margin-bottom: 1rem; }

details.subject-section { margin-bottom: 1.25rem; }
summary.subject-heading {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  min-height: 48px; cursor: pointer; list-style: none; margin-bottom: .75rem;
}
summary.subject-heading::-webkit-details-marker { display: none; }
summary.subject-heading::after { content: '▾'; margin-left: .25rem; transition: transform .2s; }
details.subject-section:not([open]) > summary.subject-heading::after { transform: rotate(-90deg); }
summary.subject-heading > span:first-child { flex: 1; }
.subject-count { background: var(--primary-light); color: var(--primary); border-radius: 999px; padding: .1rem .65rem; font-size: .9375rem; font-weight: 700; }

.post-card--done { border-left: 4px solid #28a745; }
.post-card--retry { border-left: 4px solid #e0a800; }
.post-card__status { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .6rem; }
.status-chip { font-size: .875rem; font-weight: 700; padding: .2rem .65rem; border-radius: 999px; background: #e8edf3; color: #46566a; }
.status-chip--done  { background: #d4edda; color: #155724; }
.status-chip--retry { background: #fff3cd; color: #7a5b00; }
.score-chip { font-size: .9375rem; font-weight: 700; padding: .2rem .65rem; border-radius: 6px; }
.score-chip--pass { background: #d4edda; color: #155724; }
.score-chip--fail { background: #fde2e2; color: #8a1c27; }
.post-card__tries { font-size: .875rem; color: var(--text-light); }
.dash-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; line-height: 1.15; padding: .35rem .4rem; }
.dash-tab__n { margin-left: 0; }

/* ── Admin: add subject form ──────────────────────────── */
.subject-form { display: grid; grid-template-columns: 1fr; gap: .25rem .75rem; margin-bottom: 1.25rem; max-width: 560px; }
.subject-form .btn { justify-self: start; }
@media (min-width: 601px) { .subject-form { grid-template-columns: 1fr 1fr; } .subject-form .btn { grid-column: 1 / -1; } }

/* ── Students: Excel import summary ───────────────────── */
.import-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; text-align: center; }
.import-counts > div { background: var(--bg); border-radius: var(--radius); padding: .6rem .25rem; }
.import-counts strong { display: block; font-size: 1.5rem; color: var(--primary); }
.import-counts span { font-size: .875rem; color: var(--text-light); }
.import-counts--bad strong { color: #a33; }

/* ── Notifications: errors stay readable and copyable ─── */
.notification--error { cursor: pointer; user-select: text; -webkit-user-select: text; padding-right: 2.5rem; position: fixed; }
.notification--error::after { content: '✕'; position: absolute; right: .9rem; top: .7rem; opacity: .8; }
@media (max-width: 600px) {
  .notification { left: 1rem; right: 1rem; max-width: none; font-size: 1rem; }
}

/* ── Super admin: Google Drive card ───────────────────── */
.drive-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1.25rem; }
.drive-card__head { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; margin-bottom: .35rem; }
.drive-card__dot { width: 12px; height: 12px; border-radius: 50%; background: #aaa; }
.drive-card__dot--ok { background: #28a745; } .drive-card__dot--warn { background: #e0a800; } .drive-card__dot--bad { background: #dc3545; }
.drive-card__line { margin: 0 0 .75rem; font-size: .9375rem; color: var(--text-light); overflow-wrap: anywhere; }
.drive-card__line--bad { color: #a33; } .drive-card__line--ok { color: #1e7e34; }
.drive-card__actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.drive-card__help { margin-top: .75rem; font-size: .9375rem; }
.drive-card__help summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--primary); font-weight: 600; }
.drive-card__help code { word-break: break-all; background: var(--bg); padding: .15rem .4rem; border-radius: 4px; }

/* ── Embedded YouTube video: full width, 16:9, works on phones ── */
iframe.ql-video, .post-content iframe, .ql-editor iframe, .tr-orig iframe {
  display: block; width: 100%; max-width: 720px; aspect-ratio: 16 / 9; height: auto;
  border: 0; border-radius: 8px; margin: .75rem 0; background: #000;
}

/* ── Rich-text editor toolbar: finger-sized buttons on phones ──
   Quill's own stylesheet loads later, so these selectors are deliberately more specific. */
@media (max-width: 600px) {
  html body .ql-toolbar.ql-snow { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; }
  html body .ql-toolbar.ql-snow .ql-formats { display: flex; flex-wrap: wrap; margin-right: 6px; }
  html body .ql-toolbar.ql-snow button { width: 44px; height: 44px; padding: 10px; }
  html body .ql-toolbar.ql-snow .ql-picker { height: 44px; display: inline-flex; align-items: center; }
  html body .ql-toolbar.ql-snow .ql-picker-label { padding: 0 8px; line-height: 44px; height: 44px; display: inline-flex; align-items: center; }
}

/* ── Rich-text editor built-in labels in Afrikaans (they are drawn by CSS, so the page translator cannot reach them) ── */
html[lang="af"] .ql-snow .ql-tooltip[data-mode="link"]::before { content: "Voer skakel in:"; }
html[lang="af"] .ql-snow .ql-tooltip[data-mode="video"]::before { content: "Voer video in:"; }
html[lang="af"] .ql-snow .ql-tooltip::before { content: "Besoek URL:"; }
html[lang="af"] .ql-snow .ql-tooltip a.ql-action::after { content: "Wysig"; }
html[lang="af"] .ql-snow .ql-tooltip a.ql-remove::before { content: "Verwyder"; }
html[lang="af"] .ql-snow .ql-tooltip.ql-editing a.ql-action::after { content: "Stoor"; }
html[lang="af"] .ql-snow .ql-picker.ql-header .ql-picker-label::before,
html[lang="af"] .ql-snow .ql-picker.ql-header .ql-picker-item::before { content: "Normaal"; }
html[lang="af"] .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
html[lang="af"] .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before { content: "Opskrif 1"; }
html[lang="af"] .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
html[lang="af"] .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before { content: "Opskrif 2"; }
html[lang="af"] .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
html[lang="af"] .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before { content: "Opskrif 3"; }
@media (max-width: 600px) {
  .attachment-dl { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
}

/* Wide tables scroll inside their own box on every screen size (Afrikaans headings are longer than English) */
.table-scroll-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* ── Communication Channels ──────────────────────────────────── */
.channel-layout { display: flex; gap: 1rem; align-items: flex-start; min-height: 60vh; }
.channel-tree { flex: 0 0 240px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.channel-tree__head { display: flex; align-items: center; justify-content: space-between; padding: .6rem .75rem; border-bottom: 1px solid var(--border); gap: .5rem; }
.channel-tree__title { font-weight: 700; font-size: .9375rem; margin: 0; }
.channel-posts-pane { flex: 1; min-width: 0; }

.channel-item { display: flex; align-items: center; justify-content: space-between; padding: .5rem .75rem; cursor: pointer; border-radius: 0; border-left: 3px solid transparent; min-height: 44px; gap: .25rem; }
.channel-item:hover { background: var(--bg); }
.channel-item--active { border-left-color: var(--primary); background: var(--bg); font-weight: 600; }
.channel-item--sub  { padding-left: 1.75rem; }
.channel-item--sub2 { padding-left: 3rem; }
.channel-item--sub3 { padding-left: 4.25rem; }
.channel-item__name { font-size: .9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.channel-item__actions { display: flex; gap: .2rem; flex-shrink: 0; }
.channel-tree .btn--ghost { color: var(--text-light); border-color: var(--border); background: transparent; }
.channel-tree .btn--ghost:hover:not(:disabled) { color: var(--text); background: var(--bg); border-color: var(--border); }
.btn--xs { font-size: .75rem; padding: .2rem .45rem; min-height: 30px; }

.channel-posts-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; }
.channel-posts-title { font-size: 1.1rem; font-weight: 600; margin: 0; }
.ch-post-list { display: flex; flex-direction: column; gap: .75rem; }
.ch-post-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: .875rem 1rem; }
.ch-post-card__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .3rem; }
.ch-post-card__title { font-weight: 600; font-size: .9375rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-post-card__meta { font-size: .875rem; color: var(--text-light); margin: 0 0 .5rem; }

/* Student channel tree */
/* Student channel tree */
.channel-tree--student { max-width: 100%; display: flex; flex-direction: column; gap: .75rem; }
.channel-section { border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.channel-section__head { font-size: 1.0625rem; font-weight: 700; padding: .85rem 1rem; cursor: pointer; min-height: 52px; display: flex; align-items: center; list-style: none; background: var(--primary); color: #fff; border-bottom: none; }
.channel-section__head::marker, .channel-section__head::-webkit-details-marker { display: none; }
.channel-section__head::after { content: '›'; margin-left: auto; font-size: 1.5rem; line-height: 1; display: block; transition: transform .2s; }
details[open] > .channel-section__head::after { transform: rotate(90deg); }
.channel-section__body { background: var(--surface); padding: .5rem; display: flex; flex-direction: column; gap: .35rem; }
.channel-sub-btn { text-align: left; background: var(--bg); border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px); padding: .75rem 1rem; font-size: .9375rem; cursor: pointer; color: var(--text); min-height: 50px; display: flex; align-items: center; width: 100%; transition: background .15s, color .15s, border-color .15s; }
.channel-sub-btn::after { content: '→'; margin-left: auto; color: var(--primary); flex-shrink: 0; font-size: 1rem; }
.channel-sub-btn:hover, .channel-sub-btn:active { background: var(--primary); color: #fff; border-color: var(--primary); }
.channel-sub-btn:hover::after, .channel-sub-btn:active::after { color: #fff; }
.channel-section--nested { box-shadow: none; border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px); overflow: hidden; margin: 0; }
.channel-sub-btn--parent { font-weight: 600; font-size: .9375rem; color: var(--text); padding: .7rem 1rem; min-height: 50px; list-style: none; cursor: pointer; display: flex; align-items: center; width: 100%; background: var(--bg); border: none; border-bottom: 1px solid var(--border); transition: background .15s; }
.channel-sub-btn--parent::marker, .channel-sub-btn--parent::-webkit-details-marker { display: none; }
.channel-sub-btn--parent::after { content: '›'; margin-left: auto; font-size: 1.2rem; line-height: 1; transition: transform .2s; }
details[open] > .channel-sub-btn--parent::after { transform: rotate(90deg); }
.channel-sub-btn--nested { padding-left: 1.5rem; border-radius: 0; border: none; border-bottom: 1px solid var(--border); background: var(--surface); }
.channel-sub-btn--nested:last-child { border-bottom: none; }
.channel-section--nested2 { box-shadow: none; border: none; border-radius: 0; overflow: hidden; margin: 0; border-bottom: 1px solid var(--border); }
.channel-section--nested2:last-child { border-bottom: none; }
.channel-section--nested2 > .channel-sub-btn--nested { border-bottom: 1px solid var(--border); font-weight: 600; }
.channel-sub-btn--nested2 { padding-left: 2.75rem; border-radius: 0; border: none; border-bottom: 1px solid var(--border); background: var(--bg); font-size: .9rem; }
.channel-sub-btn--nested2:last-child { border-bottom: none; }
.channel-sub-btn--nested2::after { content: none; }

.ch-post-card--student { cursor: pointer; border-left: 4px solid var(--primary); }
.ch-post-card--student:hover, .ch-post-card--student:active { box-shadow: 0 3px 12px rgba(0,0,0,.12); }
.ch-post-card--student .ch-post-card__title { white-space: normal; overflow: visible; text-overflow: unset; font-size: 1rem; line-height: 1.4; }
.ch-post-list--student { gap: .6rem; }
.ch-post-list--archived .ch-post-card--student { border-left-color: var(--border); opacity: .75; }
.ch-archived-section { margin-top: 1.75rem; }
.ch-archived-section__title { font-size: .9375rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 .6rem; }
.ch-post-view { max-width: 720px; margin: 0 auto; padding: 0 1rem 2rem; }

/* Linked event card inside a channel post */
.ch-event-card { background: var(--bg); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: .75rem 1rem; margin: 1rem 0; }
.ch-event-card__head { font-weight: 600; font-size: 1rem; margin-bottom: .3rem; }
.ch-event-card__dates { font-size: .875rem; color: var(--text-light); margin-bottom: .2rem; }
.ch-event-card__loc { font-size: .875rem; color: var(--text-light); margin-bottom: .2rem; }
.ch-event-card__desc { font-size: .9375rem; margin-top: .4rem; }

/* Mobile: stack channel layout vertically */
@media (max-width: 600px) {
  .channel-layout { flex-direction: column; }
  .channel-tree { flex: none; width: 100%; }
}

/* ── School Calendar ─────────────────────────────────────────── */
.cal-container { display: flex; flex-direction: column; gap: 1.5rem; }
.cal-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.cal-nav__label { font-weight: 600; font-size: 1rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: .75rem; font-weight: 600; color: var(--text-light); padding: .3rem 0; }
.cal-day { min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: .3rem .2rem; border-radius: 6px; font-size: .875rem; position: relative; }
.cal-day--empty { background: none; }
.cal-day--today .cal-day__num { background: var(--primary); color: #fff; border-radius: 50%; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.cal-day--has-event { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.cal-event-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); margin-top: 2px; }

.cal-event-list { display: flex; flex-direction: column; gap: .75rem; }
.cal-event-item { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: .875rem 1rem; border-left: 4px solid var(--primary); }
.cal-event-item__dates { font-size: .875rem; color: var(--text-light); font-weight: 500; margin-bottom: .2rem; }
.cal-event-item__title { font-weight: 600; font-size: .9375rem; }
.cal-event-item__alt { font-size: .875rem; color: var(--text-light); font-style: italic; }
.cal-event-item__loc { font-size: .875rem; color: var(--text-light); margin-top: .2rem; }
.cal-event-item__desc { font-size: .9375rem; margin-top: .4rem; white-space: pre-wrap; }
.cal-upcoming-head { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 .5rem; }

/* ── Student tab navigation ──────────────────────────────────── */
.student-tabs { display: flex; border-bottom: 2px solid var(--border); background: var(--surface); }
.student-tab { flex: 1; padding: .75rem .5rem; min-height: 44px; border: none; background: none; font-size: .9375rem; font-weight: 500; color: var(--text-light); cursor: pointer; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.student-tab--on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.student-tab:hover:not(.student-tab--on) { color: var(--text); background: var(--bg); }

/* ── Form row (two columns) ──────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* ── Full-screen modal ───────────────────────────────────────── */
.modal--fullscreen { width: 100%; max-width: 760px; max-height: 90vh; display: flex; flex-direction: column; }
.modal--fullscreen .modal__body { flex: 1; overflow-y: auto; padding: 1rem; }
