/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  --paper: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --ink: #1b1c1f;
  --ink-2: #45464c;
  --muted: #76777d;
  --line: #e3dfd4;
  --line-strong: #cfc9bb;

  --accent: #1f4a3a;
  --accent-hover: #173a2d;
  --accent-soft: #e4ece7;
  --accent-tint: #f0f4f1;
  --gold: #9a6b2a;

  --green: #2d6a47;   --green-soft: #e2eee5;
  --amber: #8f5f17;   --amber-soft: #f5ead6;
  --red: #9f3628;     --red-soft: #f6e2dd;
  --blue: #2d4f7c;    --blue-soft: #e2e9f2;
  --gray-soft: #efece5;

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --radius: 8px;
  --radius-sm: 6px;
  --sidebar: 236px;
}

/* ==========================================================================
   Base
   ========================================================================== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; font-weight: 600; }
h1 { font-family: var(--serif); font-weight: 500; font-size: 2.1rem; letter-spacing: -.015em; }
h2 { font-size: 1.05rem; letter-spacing: -.005em; }
h3 { font-size: .98rem; }
p { margin: 0 0 1em; }
code { font-family: var(--mono); font-size: .86em; background: var(--gray-soft); padding: 1px 6px; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
::selection { background: var(--accent-soft); }

.eyebrow {
  font-size: .72rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 8px;
}
.lede { color: var(--ink-2); font-size: 1.05rem; max-width: 62ch; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .85em; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 44px 20px; }

/* ==========================================================================
   Brand mark
   ========================================================================== */
.mark {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 6px;
  background: var(--accent); color: #f4f2ec;
  font-family: var(--serif); font-weight: 600; font-size: .95rem; letter-spacing: .02em;
}

/* ==========================================================================
   Student top bar
   ========================================================================== */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 28px; height: 64px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); font-family: var(--serif); font-size: 1.15rem; font-weight: 500; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 22px; flex: 1; }
.topbar nav a { color: var(--muted); font-weight: 500; font-size: .92rem; padding: 21px 0; border-bottom: 2px solid transparent; }
.topbar nav a:hover { color: var(--ink); text-decoration: none; }
.topbar nav a.active { color: var(--ink); border-bottom-color: var(--accent); }
.who { display: flex; align-items: center; gap: 12px; font-size: .9rem; color: var(--ink-2); white-space: nowrap; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .78rem;
}
.btn-text { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; font-size: .88rem; }
.btn-text:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ==========================================================================
   Admin sidebar
   ========================================================================== */
body.has-sidebar { padding-left: var(--sidebar); }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 30;
  background: #1b1c1f; color: #b9b8b2; display: flex; flex-direction: column; padding: 20px 14px;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; color: #f4f2ec; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand .mark { background: #f4f2ec; color: #1b1c1f; }
.sidebar-brand strong { display: block; font-family: var(--serif); font-weight: 500; font-size: 1.05rem; line-height: 1.2; }
.sidebar-brand small { display: block; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: #85847e; }
.sidebar-label { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: #6f6e69; padding: 14px 10px 6px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 6px;
  color: #c9c8c2; font-size: .92rem; font-weight: 500;
}
.sidebar-nav a svg { width: 17px; height: 17px; opacity: .75; flex: none; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: rgba(255, 255, 255, .09); color: #fff; box-shadow: inset 2px 0 0 #9cc5ad; }
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-foot { margin-top: auto; border-top: 1px solid #2e2f33; padding: 16px 10px 2px; font-size: .84rem; }
.sidebar-foot a { color: #b9b8b2; display: block; margin-bottom: 10px; }
.sidebar-foot a:hover { color: #fff; }
.sidebar-user { color: #85847e; margin-bottom: 10px; }
.sidebar-user strong { color: #e8e6e0; font-weight: 500; }
.sidebar-foot .btn-text { color: #b9b8b2; font-size: .84rem; }
.sidebar-foot .btn-text:hover { color: #fff; }

/* ==========================================================================
   Layout
   ========================================================================== */
.container { max-width: 1240px; margin: 0 auto; padding: 36px 28px 72px; }
.container.narrow { max-width: 860px; }
.has-sidebar .container { max-width: 1180px; padding-top: 34px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 6px 0 0; }
.crumbs { font-size: .84rem; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 22px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card h2 { font-size: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 18px 24px 0; }

.grid { display: grid; gap: 22px; }
.grid.two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.halves { grid-template-columns: 1fr 1fr; }

/* Stats: one strip with dividers instead of floating tiles */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 26px; overflow: hidden;
}
.stat { padding: 18px 22px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.stat .num { font-family: var(--serif); font-size: 1.9rem; font-weight: 500; line-height: 1.1; letter-spacing: -.01em; }
.stat .lbl { color: var(--muted); font-size: .8rem; margin-top: 4px; }

/* ==========================================================================
   Buttons & forms
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: 9px 16px; border-radius: var(--radius-sm); font: inherit; font-size: .9rem; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-2); border-color: var(--ink-2); }
.btn.danger { background: var(--surface); color: var(--red); border-color: #e2bdb5; }
.btn.danger:hover { background: var(--red-soft); }
.btn.success { background: var(--green); border-color: var(--green); }
.btn.success:hover { background: #24573a; }
.btn.small { padding: 5px 11px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn.link { background: none; border: 0; color: var(--muted); padding: 0; }
.btn.link:hover { color: var(--ink); text-decoration: underline; }
form.inline { display: inline; }

.field { margin-bottom: 16px; }
.field label, .label { display: block; font-weight: 500; font-size: .84rem; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: .8rem; margin-top: 5px; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: .92rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 12px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=file] { font: inherit; font-size: .88rem; }
textarea { resize: vertical; }
.input-group { display: flex; gap: 8px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.check input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--accent); }
.course-pick { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; background: var(--surface-2); }
.course-pick .fields { margin-top: 14px; }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--surface-2);
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .name { font-weight: 600; color: var(--ink); }
.table .name:hover { color: var(--accent); }

/* ==========================================================================
   Badges & progress
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 500;
  padding: 2px 9px 2px 8px; border-radius: 4px; background: var(--gray-soft); color: var(--ink-2); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.completed, .badge.active, .badge.published { background: var(--green-soft); color: var(--green); }
.badge.inprogress { background: var(--blue-soft); color: var(--blue); }
.badge.started, .badge.sent { background: var(--amber-soft); color: var(--amber); }
.badge.revoked, .badge.suspended { background: var(--red-soft); color: var(--red); }

.progress { height: 5px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.progress.done > span { background: var(--green); }
.enr { margin-bottom: 12px; }
.enr:last-child { margin-bottom: 0; }
.enr-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: .86rem; margin-bottom: 6px; }

/* ==========================================================================
   Messages
   ========================================================================== */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 22px; font-size: .92rem; border: 1px solid transparent; }
.flash.success { background: var(--green-soft); color: var(--green); border-color: #c8ddcd; }
.flash.error { background: var(--red-soft); color: var(--red); border-color: #e9c3bb; }
.flash.credentials { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 20px 22px; color: var(--ink); }
.flash.credentials h3 { font-family: var(--serif); font-size: 1.2rem; font-weight: 500; margin-bottom: 4px; }
.flash.credentials textarea { font-family: var(--mono); font-size: .84rem; background: var(--surface-2); margin: 14px 0; }
.error-box { background: var(--red-soft); color: var(--red); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .9rem; }

/* ==========================================================================
   Activity feed
   ========================================================================== */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.feed li:last-child { border-bottom: 0; }
.feed .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 7px; flex: none; }
.feed .dot.admin { background: var(--gold); }
.feed .meta { color: var(--muted); font-size: .78rem; margin-top: 2px; }

/* ==========================================================================
   Sign-in pages
   ========================================================================== */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--surface); }
.auth-aside {
  background: #1b1c1f; color: #d9d7d0; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside .brand { color: #f4f2ec; }
.auth-aside .mark { background: #f4f2ec; color: #1b1c1f; }
.auth-aside blockquote { margin: 0; font-family: var(--serif); font-size: 2rem; line-height: 1.25; font-weight: 400; color: #f4f2ec; max-width: 18ch; letter-spacing: -.01em; }
.auth-aside .foot { font-size: .82rem; color: #85847e; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 1.9rem; margin-bottom: 6px; }
.auth-card p.sub { color: var(--muted); margin: 0 0 28px; }
.auth-card .btn { padding: 11px 16px; }
.auth-card .brand { margin-bottom: 36px; display: none; }
.auth.simple { grid-template-columns: 1fr; background: var(--paper); }
.auth.simple .auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 36px; text-align: center; max-width: 440px; }
.auth.simple .auth-card .brand { display: flex; justify-content: center; }

/* ==========================================================================
   Admin course builder
   ========================================================================== */
.module { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; background: var(--surface); }
.module-head { background: var(--surface-2); border-bottom: 1px solid var(--line); padding: 10px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.module-head input { max-width: 360px; padding: 6px 10px; font-weight: 600; }
.lesson-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.module-head + .lesson-row { border-top: 0; }
.lesson-row .title { flex: 1; font-weight: 500; color: var(--ink); }
.lesson-row .title:hover { color: var(--accent); }
.lesson-add { padding: 10px 14px; border-top: 1px solid var(--line); background: var(--surface-2); }
.lesson-add input { padding: 6px 10px; }
.icon-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 5px; width: 28px; height: 28px; cursor: pointer; color: var(--muted); font-size: .72rem; }
.icon-btn:hover:not(:disabled) { border-color: var(--ink-2); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; }

.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.editor textarea { min-height: 460px; font-family: var(--mono); font-size: .86rem; line-height: 1.6; }
.editor .preview-pane { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px 22px; min-height: 460px; max-height: 70vh; overflow: auto; background: var(--surface-2); }

/* ==========================================================================
   Files
   ========================================================================== */
.file { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--surface); }
.file-icon {
  width: 34px; height: 42px; border-radius: 3px 9px 3px 3px; border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--red); display: grid; place-items: end center; padding-bottom: 6px; font-size: .58rem; font-weight: 700; letter-spacing: .04em; flex: none;
}
.file .name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 500; font-size: .9rem; }
.file.is-active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.preview-banner { background: var(--amber-soft); color: var(--amber); padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: .9rem; }

/* ==========================================================================
   Student: home
   ========================================================================== */
.page-intro { margin: 8px 0 34px; }
.page-intro h1 { font-size: 2.5rem; margin-bottom: 10px; }
.resume {
  display: flex; align-items: center; gap: 24px; justify-content: space-between;
  background: var(--accent); color: #eef2ef; border-radius: var(--radius); padding: 22px 28px; margin-bottom: 40px;
}
.resume:hover { text-decoration: none; background: var(--accent-hover); }
.resume .eyebrow { color: #a9cbb7; }
.resume-title { font-family: var(--serif); font-size: 1.45rem; color: #fff; line-height: 1.25; margin-bottom: 4px; }
.resume .meta { font-size: .86rem; color: #b8cfc1; }
.resume-go { font-weight: 500; white-space: nowrap; border: 1px solid rgba(255, 255, 255, .35); padding: 9px 16px; border-radius: var(--radius-sm); color: #fff; }

.section-title { display: flex; align-items: baseline; gap: 10px; font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line-strong); padding-bottom: 10px; margin-bottom: 0; }
.course-list { display: flex; flex-direction: column; }
.course-item {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; align-items: center;
  padding: 28px 0; border-bottom: 1px solid var(--line);
}
.course-item h3 { font-family: var(--serif); font-size: 1.55rem; font-weight: 500; margin: 0 0 8px; letter-spacing: -.01em; line-height: 1.2; }
.course-item h3 a { color: var(--ink); }
.course-item h3 a:hover { color: var(--accent); text-decoration: none; }
.course-item p { color: var(--ink-2); margin: 0; max-width: 64ch; }
.course-item .meta { color: var(--muted); font-size: .84rem; margin-top: 10px; }
.course-side .enr-top { color: var(--muted); }
.course-side .progress { margin-bottom: 14px; }
.course-side .row .btn { flex: 1; }

/* ==========================================================================
   Student: course outline
   ========================================================================== */
.course-hero { padding: 6px 0 30px; border-bottom: 1px solid var(--line-strong); margin-bottom: 32px; }
.course-hero h1 { font-size: 2.6rem; max-width: 22ch; margin-bottom: 14px; }
.course-hero .facts { display: flex; gap: 22px; flex-wrap: wrap; color: var(--muted); font-size: .88rem; margin: 18px 0; }
.course-hero .facts strong { color: var(--ink); font-weight: 600; }
.course-hero .progress { max-width: 420px; margin-bottom: 22px; }

.outline-module { margin-bottom: 30px; }
.outline-module h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--gold); margin: 0 0 6px; }
.outline-lesson {
  display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 4px; border-bottom: 1px solid var(--line); color: var(--ink);
}
.outline-lesson:hover { text-decoration: none; background: var(--surface-2); }
.outline-lesson .num { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.outline-lesson .t { font-weight: 500; }
.outline-lesson .state { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.outline-lesson.done .num { color: var(--green); }
.outline-lesson.done .state { color: var(--green); }
.tick { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: inline-grid; place-items: center; font-size: .6rem; flex: none; color: #fff; background: var(--surface); }
.tick.done { background: var(--green); border-color: var(--green); }
.tick.seen { border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 9px var(--accent-soft); }

/* ==========================================================================
   Student: lesson
   ========================================================================== */
.lesson-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 36px; align-items: start; }
.lesson-side { position: sticky; top: 88px; max-height: calc(100vh - 110px); overflow: auto; padding-right: 6px; }
.lesson-side .side-head { padding: 0 8px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.lesson-side .side-head a { font-family: var(--serif); font-size: 1.05rem; color: var(--ink); line-height: 1.3; display: block; margin-bottom: 10px; }
.lesson-side a.item { display: flex; gap: 10px; align-items: flex-start; padding: 7px 8px; border-radius: 5px; color: var(--ink-2); font-size: .86rem; line-height: 1.4; }
.lesson-side a.item .tick { margin-top: 1px; }
.lesson-side a.item:hover { background: var(--surface); text-decoration: none; color: var(--ink); }
.lesson-side a.item.current { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.lesson-side .mod { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--gold); font-weight: 600; margin: 16px 8px 4px; }

.lesson-head { margin-bottom: 24px; }
.lesson-head h1 { font-size: 2.3rem; margin-bottom: 0; }
.lesson-text { max-width: 72ch; margin-bottom: 28px; }
.lesson-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line-strong); padding-top: 22px; margin-top: 28px;
}
.done-note { display: inline-flex; align-items: center; gap: 8px; color: var(--green); font-weight: 500; font-size: .9rem; }

.materials { margin-top: 18px; }
.materials h2 { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 10px; }

/* PDF viewer */
.viewer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.viewer-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.viewer-title { font-weight: 500; font-size: .88rem; flex: 1; min-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-page-num { font-family: var(--mono); font-size: .78rem; color: var(--muted); white-space: nowrap; }
.viewer-tools { display: flex; align-items: center; gap: 4px; }
.viewer-tools button, .viewer-tools a {
  height: 30px; min-width: 30px; padding: 0 9px; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 5px; font: inherit; font-size: .82rem; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.viewer-tools button:hover, .viewer-tools a:hover { border-color: var(--ink-2); color: var(--ink); text-decoration: none; }
.viewer-zoom { font-family: var(--mono); font-size: .76rem; color: var(--muted); min-width: 44px; text-align: center; }
.viewer-body { height: 78vh; overflow: auto; background: #e9e6de; padding: 20px 16px; }
.viewer-page { margin: 0 auto 16px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); max-width: none; }
.viewer-page canvas { display: block; width: 100%; height: auto; }
.viewer-status { padding: 60px 20px; text-align: center; color: var(--muted); }
.viewer:fullscreen { border-radius: 0; border: 0; display: flex; flex-direction: column; }
.viewer:fullscreen .viewer-body { height: auto; flex: 1; }

/* Prose (lesson text) */
.prose { font-size: 1.04rem; line-height: 1.75; color: var(--ink-2); overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { color: var(--ink); font-family: var(--serif); font-weight: 500; }
.prose h1 { font-size: 1.7rem; margin-top: 1.2em; }
.prose h2 { font-size: 1.4rem; margin-top: 1.4em; }
.prose h3 { font-size: 1.15rem; margin-top: 1.3em; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose hr { margin: 1.4em 0; }
.prose img { max-width: 100%; border-radius: 6px; }
.prose blockquote { margin: 1.2em 0; padding: 4px 0 4px 18px; border-left: 2px solid var(--gold); font-family: var(--serif); font-size: 1.15rem; color: var(--ink); }
.prose pre { background: #1b1c1f; color: #e8e6e0; padding: 14px 16px; border-radius: 6px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; color: inherit; }
.prose table { border-collapse: collapse; width: 100%; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }

/* ==========================================================================
   Messages
   ========================================================================== */
.notice-bar { background: var(--amber-soft); color: var(--amber); text-align: center; padding: 9px 16px; font-size: .88rem; border-bottom: 1px solid var(--line); }
.notice-bar a { color: var(--amber); font-weight: 600; text-decoration: underline; }
.count-pill { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: #b4532a; color: #fff; font-size: .7rem; font-weight: 600; }
.inbox { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 22px; align-items: start; }
.conv { display: block; padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--ink); }
.conv:last-child { border-bottom: 0; }
.conv:hover { background: var(--surface-2); text-decoration: none; }
.conv.current { background: var(--accent-tint); box-shadow: inset 2px 0 0 var(--accent); }
.conv-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat { margin-bottom: 0; }
.thread { display: flex; flex-direction: column; gap: 14px; height: 52vh; min-height: 280px; overflow-y: auto; padding: 4px 2px 16px; }
.msg { display: flex; flex-direction: column; max-width: 78%; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 10px 14px; border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .94rem; }
.msg.mine .bubble { background: var(--accent); color: #fff; }
.msg.theirs .bubble { background: var(--gray-soft); color: var(--ink); }
.msg-meta { color: var(--muted); font-size: .74rem; margin-top: 4px; }
.composer { border-top: 1px solid var(--line); padding-top: 16px; }
.composer .row { margin-top: 10px; }

/* ==========================================================================
   Delivery report
   ========================================================================== */
.report { max-width: 900px; margin: 0 auto; background: #fff; padding: 48px 56px; border: 1px solid var(--line); border-radius: var(--radius); }
.report h1 { font-size: 1.8rem; margin-bottom: 4px; }
.report h2 { font-size: .74rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink); border-bottom: 1px solid var(--ink); padding-bottom: 7px; margin-top: 34px; }
.report-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding-bottom: 20px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 220px 1fr; gap: 7px 16px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.summary { background: var(--surface-2); border-left: 2px solid var(--accent); padding: 16px 20px; font-size: .94rem; line-height: 1.65; }
.report table.table th { background: none; }
.report table.table td, .report table.table th { padding: 7px 10px; font-size: .82rem; }
.fingerprint { font-family: var(--mono); font-size: .74rem; word-break: break-all; color: var(--muted); }
.toolbar { max-width: 900px; margin: 0 auto 18px; }

@media print {
  body { background: #fff; font-size: 12px; padding: 0 !important; }
  .no-print { display: none !important; }
  .report { border: 0; padding: 0; max-width: none; }
  .container { padding: 0; }
  .report h2 { break-after: avoid; }
  tr { break-inside: avoid; }
  a { color: inherit; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1240px) {
  .has-sidebar .grid.two, .inbox { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  .grid.two, .grid.halves, .editor, .lesson-layout { grid-template-columns: 1fr; }
  .lesson-side { position: static; max-height: none; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); padding: 14px 8px; }
  .course-item { grid-template-columns: 1fr; gap: 18px; }
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-card .brand { display: flex; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dd { margin-bottom: 8px; }
  .report { padding: 26px 20px; }
}
@media (max-width: 820px) {
  body.has-sidebar { padding-left: 0; }
  .sidebar { position: static; width: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 12px 16px; }
  .sidebar-brand { padding: 0; margin-right: auto; }
  .sidebar-brand small, .sidebar-label { display: none; }
  .sidebar-nav { display: flex; gap: 2px; order: 3; width: 100%; overflow-x: auto; }
  .sidebar-nav a.active { box-shadow: none; }
  .sidebar-foot { margin: 0; border: 0; padding: 0; display: flex; align-items: center; gap: 14px; }
  .sidebar-foot a, .sidebar-user { display: none; }
}
@media (max-width: 640px) {
  .container { padding: 24px 16px 56px; }
  .topbar-inner { padding: 0 16px; gap: 14px; }
  .topbar nav { display: none; }
  .who .who-name { display: none; }
  h1 { font-size: 1.75rem; }
  .page-intro h1, .course-hero h1 { font-size: 2rem; }
  .lesson-head h1 { font-size: 1.8rem; }
  .resume { flex-direction: column; align-items: flex-start; padding: 20px; }
  .viewer-body { height: 70vh; padding: 10px 8px; }
  .card { padding: 18px; }
  .stat { padding: 14px 16px; }
}
