/* CSE 101 Section 16 LMS — one stylesheet, no external dependencies. */

:root {
  --ink:       #16202c;
  --ink-soft:  #5b6875;
  --line:      #dde3ea;
  --bg:        #f4f6f9;
  --panel:     #ffffff;
  --brand:     #14497b;
  --brand-dk:  #0e3357;
  --good:      #1c7a4a;
  --good-bg:   #e6f5ed;
  --bad:       #a32020;
  --bad-bg:    #fbeaea;
  --warn:      #8a6100;
  --warn-bg:   #fdf4e0;
  --radius:    6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--brand); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ---------- header / nav ---------- */
.topbar { background: var(--brand); color: #fff; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 62px; gap: 16px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; display: flex; flex-direction: column; line-height: 1.25; }
.brand-code { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.brand-sub { font-size: 12.5px; opacity: .82; }
.who { text-align: right; font-size: 13px; line-height: 1.35; }
.who-name { display: block; font-weight: 600; }
.who-role { display: block; opacity: .8; font-size: 12px; }
.signout { color: #fff; opacity: .9; font-size: 12px; }

.mainnav { background: var(--brand-dk); }
.mainnav .wrap { display: flex; gap: 2px; flex-wrap: wrap; }
.mainnav a {
  color: #d8e5f2; text-decoration: none; padding: 11px 15px;
  font-size: 14px; border-bottom: 3px solid transparent;
}
.mainnav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.mainnav a.on { color: #fff; border-bottom-color: #ffc043; background: rgba(255,255,255,.09); }

main.wrap { padding-top: 22px; padding-bottom: 40px; }

.foot { border-top: 1px solid var(--line); background: #fff; color: var(--ink-soft); font-size: 12.5px; }
.foot .wrap { padding-top: 14px; padding-bottom: 14px; }

/* ---------- panels ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px;
}
.card > h1, .card > h2 { margin-top: 0; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
.sub { color: var(--ink-soft); margin-top: -6px; }
.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-soft); }
.stat .v { font-size: 27px; font-weight: 700; margin-top: 4px; }
.stat .n { font-size: 12.5px; color: var(--ink-soft); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.grid thead th { background: #eef2f7; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: #405266; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.grid tbody tr:hover { background: #f8fafc; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.mid { text-align: center; }
.rownum { color: var(--ink-soft); font-size: 12.5px; width: 34px; }

/* ---------- badges / alerts ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.ok { background: var(--good-bg); color: var(--good); }
.badge.no { background: var(--bad-bg); color: var(--bad); }
.badge.pend { background: #eef2f7; color: var(--ink-soft); }
.badge.prov { background: var(--warn-bg); color: var(--warn); }

.alert { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; font-size: 14px; }
.alert.good, .alert.ok { background: var(--good-bg); border-color: #b9e0cb; color: var(--good); }
.alert.bad  { background: var(--bad-bg);  border-color: #f0c4c4; color: var(--bad); }
.alert.warn { background: var(--warn-bg); border-color: #efdcae; color: var(--warn); }
.alert ul { margin: 6px 0 0 18px; padding: 0; }

/* ---------- forms / buttons ---------- */
label { display: block; margin-bottom: 13px; font-size: 13.5px; font-weight: 600; color: #33414f; }
label.check { font-weight: 400; }
input:not([type]), input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; margin-top: 4px; font: inherit;
  border: 1px solid #c3ccd6; border-radius: 4px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9dc0e4; outline-offset: -1px; border-color: var(--brand); }
textarea { min-height: 130px; resize: vertical; }
.inline { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.inline label { margin-bottom: 0; }
.field-sm { max-width: 150px; }
.score-in { width: 80px; text-align: right; padding: 5px 7px; margin: 0; }

.btn {
  display: inline-block; padding: 8px 16px; border-radius: 4px; font: inherit; font-size: 14px;
  border: 1px solid #c3ccd6; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f1f4f8; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dk); }
.btn.danger { color: var(--bad); border-color: #e2b5b5; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* ---------- policy ---------- */
.policy h2 { border-bottom: 2px solid var(--line); padding-bottom: 6px; }
.policy ol { padding-left: 22px; }
.policy li { margin-bottom: 9px; }
.formula { background: #eef2f7; border-left: 4px solid var(--brand); padding: 12px 16px; border-radius: 0 4px 4px 0; }
.formula table { border-collapse: collapse; }
.formula td { padding: 3px 18px 3px 0; }

/* ---------- setup / login ---------- */
body.plain { background: var(--bg); }
.setup, .loginbox {
  max-width: 560px; margin: 48px auto; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 30px;
}
.loginbox { max-width: 400px; }
.loginbox h1 { margin-top: 0; font-size: 20px; }
.setup h1 { margin-top: 0; }
.next { margin-top: 22px; }
.warn-note { font-size: 12.5px; color: var(--warn); }

/* ---------- print ---------- */
@media print {
  .topbar, .mainnav, .foot, .btn, .toolbar, .noprint { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .card { border: none; padding: 0; margin-bottom: 14px; }
  table.grid { font-size: 10pt; }
  table.grid thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: #000; text-decoration: none; }
}

/* ---------- marking one submission at a time ---------- */
.gradelayout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .gradelayout { grid-template-columns: 1fr; } }
.gradework { min-width: 0; }

.workframe {
  width: 100%; height: 70vh; min-height: 420px;
  border: 1px solid var(--line); border-radius: 4px; background: #fff;
}
.workimage {
  max-width: 100%; height: auto; display: block;
  border: 1px solid var(--line); border-radius: 4px; background: #fff;
}
.workcode {
  margin: 0; padding: 12px 14px; max-height: 60vh; overflow: auto;
  background: #f6f8fb; border: 1px solid var(--line); border-radius: 4px;
  font: 13px/1.5 Consolas, "Courier New", monospace; white-space: pre;
}
.worktext {
  white-space: pre-wrap; padding: 12px 14px;
  background: #f6f8fb; border: 1px solid var(--line); border-radius: 4px;
}

@media print {
  .gradelayout { display: block; }
  .workframe { height: auto; min-height: 300px; }
}
.workvideo { width: 100%; max-height: 60vh; background: #000; border-radius: 4px; display: block; }
.workaudio { width: 100%; display: block; margin: 8px 0; }
/* Class conversation and delegated teaching responsibilities. */
.notification-toast {position:fixed;right:20px;bottom:20px;background:#123654;color:white;padding:16px 22px;border-radius:10px;box-shadow:0 4px 20px #0003;z-index:1000;max-width:calc(100vw - 40px);box-sizing:border-box}
.notification-toast a {color:white}.notification-toast[hidden] {display:none}
.notification-row {display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px;border-bottom:1px solid #dbe3ee}
.notification-unread {background:#edf5fc}#alert-count {display:inline-block;background:#ffce66;color:#122a42;border-radius:20px;padding:0 6px;font-weight:bold}
.permission-form {padding:18px 0;border-top:1px solid #dbe3ee}.permission-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-bottom:18px}

/* ==========================================================================
   Chat — class conversation and private messages
   ========================================================================== */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:root {
  --chat-bg:     #eae6df;   /* paper behind the bubbles */
  --chat-in:     #ffffff;   /* a message from someone else */
  --chat-out:    #d9fdd3;   /* a message from me */
  --chat-panel:  #ffffff;
  --chat-line:   #e3e6ea;
  --chat-time:   #667781;
}

/* ---------- shell ---------- */
.chat-shell {
  display: flex; flex-direction: column;
  height: calc(100vh - 190px); min-height: 460px;
  background: var(--chat-panel);
  border: 1px solid var(--chat-line);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(16,32,44,.06), 0 8px 24px rgba(16,32,44,.05);
  position: relative;
}

/* ---------- header strip ---------- */
.chat-top {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: #f0f2f5;
  border-bottom: 1px solid var(--chat-line);
  flex: none;
}
.chat-top-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700; letter-spacing: .3px; color: #fff;
  background: hsl(var(--hue, 210) 42% 45%);
}
.chat-top-avatar.is-group { background: var(--brand); font-size: 18px; }
.chat-top-id { min-width: 0; flex: 1; line-height: 1.3; }
.chat-top-id strong { display: block; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-top-id span { display: block; font-size: 12.5px; color: var(--chat-time); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-top-actions { display: flex; gap: 4px; flex: none; }

.chat-icon {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  background: transparent; border: 0; cursor: pointer;
  color: #54656f; font-size: 17px; line-height: 1; text-decoration: none;
  transition: background .15s, color .15s;
}
.chat-icon:hover { background: rgba(0,0,0,.06); color: var(--ink); }
.chat-icon.is-on { background: var(--brand); color: #fff; }
.chat-icon:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.chat-back { font-size: 19px; }

/* ---------- moderation / pinned ---------- */
.chat-admin {
  flex: none; padding: 10px 16px; background: #fffbe9;
  border-bottom: 1px solid #f0e2b6; font-size: 13.5px;
}
.chat-admin summary { cursor: pointer; font-weight: 600; }
.chat-admin .inline { margin-top: 8px; gap: 10px; align-items: center; }

.chat-pinned {
  flex: none; padding: 12px 16px; background: #f6f8fb;
  border-bottom: 1px solid var(--chat-line);
  max-height: 30%; overflow-y: auto;
}
.chat-pinned-tag {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .7px;
  color: var(--brand); background: #e7eff7; padding: 2px 8px; border-radius: 999px;
}
.chat-pinned h2 { margin: 8px 0 4px; font-size: 16px; }
.chat-pinned p { margin: 0; font-size: 14px; color: #33414f; }

/* ---------- message area ---------- */
.chat-scroll {
  flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth;
  background-color: var(--chat-bg);
  /* A faint woven texture, drawn rather than loaded, so there is no image request. */
  background-image:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,.035) 1px, transparent 0),
    radial-gradient(circle at 13px 13px, rgba(0,0,0,.025) 1px, transparent 0);
  background-size: 24px 24px, 24px 24px;
}
.chat-messages { display: flex; flex-direction: column; gap: 2px; padding: 16px 16px 20px; }

.chat-older { text-align: center; padding: 12px 0 0; }

/* ---------- day divider ---------- */
.chat-day { display: flex; justify-content: center; margin: 14px 0 10px; }
.chat-day span {
  background: rgba(255,255,255,.85); color: #54656f;
  font-size: 11.5px; font-weight: 600; letter-spacing: .3px;
  padding: 5px 13px; border-radius: 999px;
  box-shadow: 0 1px 1px rgba(16,32,44,.08);
}

/* ---------- one message ---------- */
.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 78%; margin-top: 10px; }
.msg.msg-grouped { margin-top: 2px; }
.msg-own { margin-left: auto; flex-direction: row-reverse; }

.msg-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; color: #fff;
  background: hsl(var(--hue, 210) 42% 48%);
  align-self: flex-end;
}
.msg-grouped .msg-avatar { background: none; }

.msg-col { min-width: 0; display: flex; flex-direction: column; }
.msg-own .msg-col { align-items: flex-end; }

.msg-name {
  font-size: 12.5px; font-weight: 600; color: var(--brand);
  margin: 0 0 3px 12px;
}
.msg-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  background: #e7eff7; color: var(--brand); padding: 1px 6px; border-radius: 999px;
  margin-left: 4px; vertical-align: 1px;
}

/* ---------- the bubble ---------- */
.bubble {
  position: relative;
  background: var(--chat-in);
  padding: 7px 10px 6px 11px;
  border-radius: 10px;
  box-shadow: 0 1px 1px rgba(16,32,44,.11);
  font-size: 14.5px; line-height: 1.45;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.msg-own .bubble { background: var(--chat-out); }

/* The little tail, only on the first bubble of a run. */
.msg:not(.msg-grouped) .bubble::after {
  content: ""; position: absolute; bottom: 0; width: 10px; height: 13px;
}
.msg:not(.msg-grouped):not(.msg-own) .bubble { border-bottom-left-radius: 2px; }
.msg:not(.msg-grouped):not(.msg-own) .bubble::after {
  left: -7px;
  background: radial-gradient(circle at 100% 0, transparent 10px, var(--chat-in) 10px);
}
.msg:not(.msg-grouped).msg-own .bubble { border-bottom-right-radius: 2px; }
.msg:not(.msg-grouped).msg-own .bubble::after {
  right: -7px;
  background: radial-gradient(circle at 0 0, transparent 10px, var(--chat-out) 10px);
}

.bubble-gone { background: #f2f3f5 !important; font-style: italic; }
.msg-removed { color: var(--chat-time); }

.msg-text { margin: 0; white-space: pre-wrap; padding-right: 54px; }
.msg-text a { color: var(--brand); text-decoration: underline; }

.msg-time {
  display: block; text-align: right;
  font-size: 11px; color: var(--chat-time);
  margin: -14px 0 0 0; line-height: 1; height: 12px;
  pointer-events: none;
}
.bubble > .msg-time:first-child { margin-top: 0; }
.msg-photo + .msg-time, .msg-audio + .msg-time, .msg-file + .msg-time { margin-top: 2px; }

/* ---------- quoted reply ---------- */
.msg-quote {
  display: block; text-decoration: none;
  background: rgba(0,0,0,.05); border-left: 3px solid var(--brand);
  border-radius: 5px; padding: 5px 9px; margin-bottom: 5px;
  font-size: 13px; line-height: 1.35; color: inherit;
}
.msg-quote strong { display: block; color: var(--brand); font-size: 12.5px; }
.msg-quote span { display: block; color: #4b5b6b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-quote:hover { background: rgba(0,0,0,.08); }

/* ---------- attachments ---------- */
.msg-photo { display: block; margin: -1px 0 3px; border-radius: 7px; overflow: hidden; }
.msg-photo img { display: block; max-width: 100%; max-height: 320px; object-fit: cover; }
.msg-audio { display: block; width: 240px; max-width: 100%; margin: 3px 0; height: 38px; }

.msg-file {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  background: rgba(0,0,0,.05); border-radius: 7px; padding: 8px 10px; margin: 2px 0 4px;
  color: inherit;
}
.msg-file:hover { background: rgba(0,0,0,.09); }
.msg-file-icon {
  width: 32px; height: 32px; border-radius: 6px; flex: none;
  background: var(--brand); position: relative;
}
.msg-file-icon::after {
  content: ""; position: absolute; inset: 9px 10px;
  border-top: 2px solid #fff; border-bottom: 2px solid #fff;
}
.msg-file-meta { min-width: 0; font-size: 13px; line-height: 1.3; }
.msg-file-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.msg-file-meta span { color: var(--chat-time); font-size: 11.5px; }

/* ---------- hover actions ---------- */
.msg-actions {
  display: flex; gap: 2px; align-items: center;
  opacity: 0; transition: opacity .12s;
  margin: 2px 4px 0;
}
.msg:hover .msg-actions,
.msg:focus-within .msg-actions { opacity: 1; }
.msg-remove { display: inline; margin: 0; }
.msg-act {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-grid; place-items: center;
  border: 0; background: rgba(255,255,255,.85); color: #54656f;
  cursor: pointer; font-size: 13px; line-height: 1;
  box-shadow: 0 1px 2px rgba(16,32,44,.15);
}
.msg-act:hover { background: #fff; color: var(--brand); }
.msg-remove .msg-act:hover { color: var(--bad); }

/* ---------- empty state ---------- */
.chat-empty { margin: auto; text-align: center; padding: 48px 20px; }
.chat-empty-mark svg { width: 28px; height: 28px; }
.chat-empty-mark {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-items: center; font-size: 26px;
  background: rgba(255,255,255,.8); color: var(--brand);
  box-shadow: 0 1px 2px rgba(16,32,44,.1);
}
.chat-empty p { margin: 3px 0; }

/* ---------- jump to latest ---------- */
.chat-jump {
  position: absolute; right: 18px; bottom: 96px; z-index: 3;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: #fff; color: var(--brand); cursor: pointer;
  font-size: 17px; box-shadow: 0 2px 8px rgba(16,32,44,.22);
}
.chat-jump:hover { background: var(--brand); color: #fff; }

/* ---------- locked banner ---------- */
.chat-locked {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; font-size: 13px;
  background: var(--warn-bg); color: var(--warn);
  border-top: 1px solid #efdcae;
}
/* An inline SVG with no width takes its default size and swallows the panel,
   hiding the messages a locked chat is still meant to let students read. */
.chat-locked svg { flex: none; width: 16px; height: 16px; }

/* ---------- composer ---------- */
.chat-compose { flex: none; background: #f0f2f5; border-top: 1px solid var(--chat-line); padding: 8px 12px 6px; }
.chat-compose fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.chat-compose fieldset:disabled { opacity: .55; }

.chat-reply-banner {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 8px; padding: 8px 8px 8px 0;
  margin-bottom: 8px; overflow: hidden;
}
.chat-reply-bar { width: 4px; align-self: stretch; background: var(--brand); flex: none; }
.chat-reply-copy { flex: 1; min-width: 0; font-size: 13px; color: #4b5b6b;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-chip {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 8px; padding: 7px 8px 7px 11px;
  margin-bottom: 8px; font-size: 13px;
}
.chat-chip span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-chip-icon { color: var(--brand); font-size: 10px; flex: none; }
.chat-chip-icon svg { width: 15px; height: 15px; display: block; }
.score-in.is-bad { border-color: #c0392b; background: #fdf0ee; color: #a5281b; }
.score-in.is-bad:focus { outline-color: #c0392b; }

.chat-recording { display: block; width: 100%; margin-bottom: 8px; height: 38px; }

.chat-bar { display: flex; align-items: flex-end; gap: 6px; }
.chat-bar textarea {
  flex: 1; min-width: 0; resize: none; margin: 0;
  border: 1px solid transparent; border-radius: 20px;
  background: #fff; padding: 10px 14px;
  font: inherit; font-size: 14.5px; line-height: 1.4;
  max-height: 140px; overflow-y: auto;
}
.chat-bar textarea:focus { outline: none; border-color: #c9d3de; box-shadow: 0 0 0 2px rgba(20,73,123,.12); }

.chat-attach { position: relative; overflow: hidden; font-size: 22px; font-weight: 300; }
.chat-attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

.chat-send {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  border: 0; background: var(--brand); color: #fff; cursor: pointer;
  font-size: 16px; display: grid; place-items: center;
  transition: background .15s, transform .1s;
}
.chat-send:hover { background: var(--brand-dk); }
.chat-send:active { transform: scale(.94); }
.chat-send:disabled { background: #b6c2ce; cursor: not-allowed; }

.chat-status { margin: 0; }
.chat-status:not(:empty) { margin: 6px 2px 0; }
.chat-hint { margin: 4px 2px 0; font-size: 11.5px; }
.chat-hint kbd {
  background: #fff; border: 1px solid #ccd4dd; border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; font-size: 10.5px; font-family: inherit;
}
.chat-shell [hidden] { display: none !important; }

/* ==========================================================================
   Private chat — conversation list
   ========================================================================== */
.chat-list-shell { height: auto; min-height: 0; }
.chat-listwrap { flex: 1; overflow-y: auto; padding: 6px 0 12px; background: #fff; }

.thread-heading {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--ink-soft); margin: 18px 0 4px; padding: 0 18px;
}
.thread-list { list-style: none; margin: 0; padding: 0; }
.thread {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 18px; text-decoration: none; color: inherit;
  border-bottom: 1px solid #f0f2f5;
}
.thread:hover { background: #f5f7f9; }
.thread-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 16px; font-weight: 700; color: #fff;
  background: hsl(var(--hue, 210) 42% 48%);
}
.thread-copy { flex: 1; min-width: 0; }
.thread-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.thread-row strong { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-row time { font-size: 11.5px; color: var(--chat-time); flex: none; }
.thread-preview {
  display: block; font-size: 13.5px; color: var(--chat-time);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px;
}
.thread-you { color: #8696a0; }
.thread-go { color: #c4ccd4; font-size: 20px; flex: none; }
.thread-list-new .thread-avatar { background: hsl(var(--hue, 210) 22% 62%); }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .chat-shell { height: calc(100vh - 150px); border-radius: 0; border-left: 0; border-right: 0; }
  .msg { max-width: 90%; }
  .chat-messages { padding: 12px 10px 16px; }
  .chat-top-actions .chat-icon { width: 34px; height: 34px; }
  .msg-actions { opacity: 1; }   /* there is no hover on a touch screen */
  .thread { padding: 10px 14px; }
}

@media print {
  .chat-top, .chat-compose, .chat-jump, .msg-actions, .chat-admin { display: none !important; }
  .chat-shell { height: auto; border: 0; box-shadow: none; }
  .chat-scroll { overflow: visible; background: #fff; }
}
.chat-icon.is-recording { background: var(--bad); color: #fff; animation: chat-pulse 1.2s ease-in-out infinite; }
@keyframes chat-pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.chat-search { flex: none; padding: 10px 14px; background: #f0f2f5; border-bottom: 1px solid var(--chat-line); }
.chat-search input {
  width: 100%; margin: 0; border: 1px solid transparent; border-radius: 18px;
  background: #fff; padding: 8px 14px; font: inherit; font-size: 14px;
}
.chat-search input:focus { outline: none; border-color: #c9d3de; box-shadow: 0 0 0 2px rgba(20,73,123,.12); }
.thread-none { padding: 24px 18px; text-align: center; }

/* ---------- corrections ---------- */
/* The app-wide textarea rule sets min-height:130px; the composer is one line. */
.chat-bar textarea { min-height: 0; height: 42px; }

/* Float the hover actions beside the bubble instead of below it, so they take
   no layout space and the avatar stays level with the message. */
.msg-col { position: relative; }
.msg-actions {
  position: absolute; top: 50%; transform: translateY(-50%);
  margin: 0; pointer-events: none;
}
.msg:hover .msg-actions, .msg:focus-within .msg-actions { pointer-events: auto; }
.msg:not(.msg-own) .msg-actions { left: 100%; margin-left: 6px; }
.msg-own .msg-actions { right: 100%; margin-right: 6px; flex-direction: row-reverse; }

/* Icon buttons carry SVG, not text glyphs. */
.chat-icon svg, .chat-send svg, .msg-act svg { width: 20px; height: 20px; display: block; }
.msg-act svg { width: 14px; height: 14px; }
.chat-send svg { width: 19px; height: 19px; margin-left: 2px; }
.chat-top-avatar.is-group svg { width: 22px; height: 22px; }
/* Few messages should rest at the bottom of the window, as in any messenger,
   rather than clinging to the top with dead space beneath. */
.chat-messages { justify-content: flex-end; min-height: 100%; box-sizing: border-box; }
.chat-messages > .chat-empty { margin: auto; }
.push-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.push-prefs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 20px; margin-bottom: 14px; }
.push-ok { color: var(--good); }
.push-bad { color: var(--bad); }

/* ==========================================================================
   Alerts
   ========================================================================== */
.alerts-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.alerts-head h1 { margin: 0; }
.alerts-head .sub { margin: 4px 0 0; }

.alerts-card { padding: 0; overflow: hidden; }

.alert-list { list-style: none; margin: 0; padding: 0; }

.alert-day {
  padding: 12px 18px 6px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase;
  color: var(--ink-soft); background: #f8fafc; border-bottom: 1px solid var(--line);
}
.alert-day:first-child { border-top: 0; }

.alert-row { margin: 0; border-bottom: 1px solid #f0f2f5; }
.alert-row.is-new { background: #f4f9ff; }

/* The whole row is the button, so the target is large on a phone. */
.alert-hit {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 13px 18px; border: 0; background: none; cursor: pointer;
  font: inherit; text-align: left; color: inherit;
}
.alert-hit:hover { background: #eef3f8; }
.alert-hit:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.alert-mark {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: #fff; letter-spacing: .3px;
  position: relative;
}
/* One colour per kind of alert, so the list is scannable at a glance. */
.alert-talk { background: #14497b; }   /* messages and replies */
.alert-news { background: #7a5ea8; }   /* announcements */
.alert-task { background: #b4761c; }   /* assignments */
.alert-grade { background: #1c7a4a; }  /* grades */
.alert-mark:empty { background: var(--ink-soft); }

.alert-copy { flex: 1; min-width: 0; }
.alert-line {
  display: block; font-size: 14.5px; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.alert-line strong { font-weight: 600; }
.alert-when {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--ink-soft); margin-top: 3px;
}
.alert-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--brand);
  display: inline-block; flex: none;
}
.alert-go { color: #c4ccd4; font-size: 20px; flex: none; }

.alerts-more { padding: 14px 18px; text-align: center; }

.alerts-empty { text-align: center; padding: 52px 24px; }
.alerts-empty-mark {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-items: center; background: #eef3f8; color: var(--brand);
}
.alerts-empty-mark svg { width: 30px; height: 30px; }
.alerts-empty p { margin: 3px 0; }

@media (max-width: 600px) {
  .alert-hit { padding: 12px 14px; gap: 11px; }
  .alert-mark { width: 38px; height: 38px; font-size: 13px; }
}

/* Shared phone/tablet layout: constrain content, keep wide data inside its scroller. */
.card, .toolbar > *, .inline > *, .stat, .gradelayout > * { min-width: 0; }
.card, .toolbar, .foot, .brand, .who { overflow-wrap: anywhere; }
input, select, textarea { max-width: 100%; min-width: 0; }
.tablewrap { max-width: 100%; overscroll-behavior-x: contain; }
fieldset { min-inline-size: 0; max-width: 100%; }
legend { max-width: 100%; overflow-wrap: anywhere; }
.quiz-question { margin: 16px 0; padding: 16px; }
.quiz-choice { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; min-height: 44px; overflow-wrap: anywhere; }
.quiz-choice input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; }
.quiz-choice:has(input:checked) { background: #edf5fc; border-color: var(--brand); }
.quiz-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
@media screen and (max-width: 600px) {
  .wrap { padding-inline: 12px; }
  main.wrap { padding-top: 16px; }
  .topbar .wrap { padding-block: 12px; gap: 10px; }
  .brand, .who { max-width: 100%; }
  .who { text-align: left; }
  .mainnav .wrap { flex-wrap: nowrap; overflow-x: auto; }
  .mainnav a { flex: none; white-space: nowrap; min-height: 44px; }
  .card { padding: 16px 14px; margin-bottom: 16px; }
  .inline { align-items: stretch; }
  .inline > label { flex: 1 1 100%; max-width: 100%; }
  .toolbar > div { width: 100%; }
  .cards, .permission-grid, .push-prefs { grid-template-columns: minmax(0, 1fr); }
  input:not([type]), input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=datetime-local], input[type=file], select, textarea { font-size: 16px; min-height: 44px; }
  .btn, .btn.sm { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .quiz-buttons > .btn { flex: 1 1 100%; }
  .quiz-question { padding: 12px; }
  .notification-row { flex-wrap: wrap; }
  .setup, .loginbox { margin: 24px 12px; padding: 22px 18px; }
}
@media (hover: none) {
  .msg-actions { opacity: 1; pointer-events: auto; }
}

@media screen and (max-width: 600px) {
  .formula table, .formula tbody, .formula tr, .formula td { display: block; width: 100%; }
  .formula td { padding: 3px 0; }
}

/* SweetAlert2 follows LMS sizing and colors on phones. */
.swal2-popup { font-family: "Segoe UI", Roboto, Arial, sans-serif; max-width: calc(100vw - 24px); }
.swal2-html-container { overflow-wrap: anywhere; }
.swal2-actions button { min-height: 44px; }
@media (max-width:600px) { .swal2-toast { width: calc(100vw - 24px) !important; } }
.resit-pick {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 2px 18px; max-height: 300px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: #fbfcfd;
}
.resit-pick .check { margin: 0; padding: 3px 0; }
.resit-pick input:disabled + * { opacity: .55; }
