/* Tabe3: paper and ink, one brand color, one signature element (the load meter).
   Soft style: panels on paper instead of hairlines; radius 12 controls, 16 panels, pill for search/chips. */

:root {
  /* primitives */
  --paper-0:   #ffffff;
  --paper-50:  #fbfaf7;
  --paper-100: #f6f5f1;
  --paper-200: #eceae3;
  --paper-300: #dedbd2;
  --paper-400: #c9c5b9;
  --ink-900:   #10202e;
  --ink-700:   #34495a;
  --ink-500:   #5b6d7d;
  --ink-400:   #8a98a4;
  --brand-50:  #eef6f8;
  --brand-100: #d9edf2;
  --brand-300: #8cc6d6;
  --brand-600: #0b7a99;
  --brand-700: #08627b;
  --amber-500: #d4912a;
  --amber-700: #8f5c10;
  --red-50:    #fbeef0;
  --red-600:   #c8364b;

  /* semantic */
  --bg:        var(--paper-100);
  --surface:   var(--paper-0);
  --sunken:    var(--paper-200);
  --line:      var(--paper-200);
  --line-2:    var(--paper-300);
  --text:      var(--ink-900);
  --text-2:    var(--ink-700);
  --muted:     var(--ink-500);
  --faint:     var(--ink-400);
  --accent:    var(--brand-600);
  --accent-ink: var(--brand-700);
  --accent-bg: var(--brand-50);
  --warn:      var(--amber-500);
  --warn-ink:  var(--amber-700);
  --danger:    var(--red-600);
  --danger-bg: var(--red-50);

  /* components */
  --font: 'IBM Plex Sans Arabic', system-ui, 'Segoe UI', Tahoma, sans-serif;
  --r: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  --h-ctl: 44px;
  --h-ctl-sm: 34px;
  --top-h: 60px;
  --meter-h: 6px;
  --ring: 0 0 0 3px var(--brand-100);
  --shadow-pop: 0 4px 12px rgba(16,32,46,.08), 0 24px 56px rgba(16,32,46,.16);
  --ease: cubic-bezier(.2,.7,.2,1);
  --t: .16s;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 16px; line-height: 1.6;
  color: var(--text); background: var(--bg);
  min-height: 100dvh; -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; color: var(--text); line-height: 1.35; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.ltr { direction: ltr; text-align: right; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ───────── controls ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h-ctl); padding: 0 18px; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 15px; white-space: nowrap;
  transition: background var(--t), border-color var(--t), color var(--t);
}
.btn:hover { border-color: var(--ink-400); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-danger-fill, .btn-danger-fill:hover { background: var(--danger); border-color: var(--danger); }
.btn-text { border-color: transparent; background: transparent; color: var(--accent-ink); padding: 0 10px; }
.btn-text:hover { background: var(--accent-bg); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-text.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { height: var(--h-ctl-sm); font-size: 14px; padding: 0 10px; }
.btn-block { width: 100%; }
.btn:disabled, .btn:disabled:hover {
  background: var(--sunken); border-color: var(--sunken); color: var(--faint); cursor: not-allowed;
}
.btn-text:disabled, .btn-text:disabled:hover { background: transparent; border-color: transparent; }
.icon-btn {
  width: var(--h-ctl); height: var(--h-ctl); border-radius: var(--r); border: 0;
  background: transparent; color: var(--text-2); display: inline-grid; place-items: center;
  transition: background var(--t), color var(--t);
}
.icon-btn:hover { background: var(--sunken); color: var(--text); }
.icon-btn:disabled { color: var(--paper-400); background: transparent; cursor: default; }
.icon-btn.sm { width: var(--h-ctl-sm); height: var(--h-ctl-sm); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 14px; font-weight: 500; color: var(--text-2); }
.field .help { font-size: 13px; color: var(--muted); }
.input {
  width: 100%; height: var(--h-ctl); padding: 0 14px; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  outline: none; transition: border-color var(--t), box-shadow var(--t);
}
textarea.input { height: auto; min-height: 96px; padding: 10px 14px; resize: vertical; line-height: 1.7; }
textarea.input.code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; direction: ltr; text-align: left; min-height: 360px; }
select.input { padding-inline-end: 10px; }
.input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.input[type="search"] { border-radius: var(--r-pill); padding: 0 18px; }
.input.short { max-width: 140px; }
.pw { position: relative; }
/* eye stays on the right; the LTR password is aligned right, so the room for it is padding-right */
.pw .input { padding-right: 48px; padding-left: 14px; }
.pw .icon-btn { position: absolute; right: 0; top: 0; }

/* segmented: one choice out of a few */
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r);
  background: var(--sunken); max-width: 100%; overflow-x: auto;
}
.seg button {
  height: 36px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent;
  color: var(--text-2); font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background var(--t), color var(--t);
}
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--accent-ink); font-weight: 600; box-shadow: 0 1px 3px rgba(16,32,46,.14); }
.seg.block { display: flex; }
.seg.block button { flex: 1; }
.seg .n { color: var(--muted); font-size: 13px; margin-inline-start: 4px; font-weight: 400; }

/* chips: wrapping choices (single or multi) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 38px; padding: 0 16px; border-radius: var(--r-pill); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text-2); font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  transition: border-color var(--t), background var(--t), color var(--t);
}
.chip:hover { border-color: var(--ink-400); color: var(--text); }
.chip[aria-checked="true"] { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-ink); font-weight: 600; }
.chip .n { color: var(--muted); font-size: 13px; }

/* rowpick: vertical block of full width options */
.rowpick { display: flex; flex-direction: column; gap: 2px; padding: 4px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); }
.rowopt {
  min-height: 42px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text-2); font-size: 15px; font-weight: 500; text-align: start;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  transition: background var(--t), color var(--t);
}
.rowopt:hover { background: var(--bg); color: var(--text); }
.rowopt[aria-checked="true"] { background: var(--accent-bg); color: var(--accent-ink); font-weight: 600; }
.rowopt .n { color: var(--muted); font-size: 13px; font-weight: 400; }
.rowopt[aria-checked="true"] .n { color: var(--accent-ink); }

/* ───────── signature: the load meter ───────── */
.meter { display: flex; gap: 2px; height: var(--meter-h); width: 100%; min-width: 30px; }
.meter i {
  flex: 1; border-radius: 3px; background: var(--paper-300);
  background-image: linear-gradient(to left, var(--fill) calc(var(--f, 0) * 100%), transparent 0);
}
.meter { --fill: var(--accent); }
.meter.warn { --fill: var(--warn); }
.meter.full { --fill: var(--danger); }
.meter.lg { --meter-h: 8px; gap: 3px; }
.meter-label { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ───────── login ───────── */
.login { position: relative; min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px; }
.login-box {
  position: relative; width: min(380px, 100%); display: flex; flex-direction: column; gap: 20px;
  background: var(--surface); border-radius: var(--r-lg); padding: 32px 30px;
  box-shadow: 0 4px 12px rgba(16,32,46,.06), 0 24px 56px rgba(16,32,46,.12);
}
@media (max-width: 480px) { .login-box { padding: 24px 18px; } }
.login-mark { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-mark img { width: 32px; height: 32px; }
.login-mark b { font-size: 24px; font-weight: 700; }
.login-err { min-height: 24px; font-size: 14px; color: var(--danger); }
.login-err:empty { min-height: 0; }
.login-alt { display: flex; align-items: center; justify-content: center; gap: 4px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; }
.role-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.role-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 12px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); color: var(--text); cursor: pointer;
}
.role-card svg { width: 28px; height: 28px; color: var(--accent); }
.role-card b { font-size: 17px; }
.role-card small { color: var(--muted); font-size: 13px; }
.role-card:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-bg); }
.role-card:disabled { opacity: .5; cursor: not-allowed; }
.fixed-class { padding: 10px 12px; background: var(--accent-bg); border-radius: var(--r); }

/* ───────── shell ───────── */
.top {
  position: sticky; top: 0; z-index: 30; height: var(--top-h);
  background: var(--surface); box-shadow: 0 1px 0 var(--line), 0 6px 20px rgba(16,32,46,.06);
}
.top-in { height: 100%; padding: 0 var(--gutter); display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 8px; flex: none; }
.brand img { width: 24px; height: 24px; }
.brand b { font-size: 20px; font-weight: 700; }
/* tabs scroll sideways when they do not fit, instead of pushing the user menu off screen */
.nav { display: flex; align-items: center; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: none; white-space: nowrap;
  position: relative; display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: var(--r-pill);
  color: var(--muted); font-weight: 500; text-decoration: none; transition: color var(--t), background var(--t);
}
.nav a:hover { color: var(--text); background: var(--sunken); }
.nav a[aria-current="page"] { color: var(--accent-ink); font-weight: 600; background: var(--accent-bg); }
.nav svg.i { display: none; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 600; line-height: 20px; text-align: center;
}
.top .spacer { flex: 1; }
.datebtn {
  flex: none; white-space: nowrap;
  border: 0; background: transparent; padding: 4px 10px; border-radius: var(--r); text-align: start;
  display: flex; flex-direction: column; line-height: 1.3;
}
.datebtn:hover { background: var(--sunken); }
.datebtn b { font-size: 14px; font-weight: 600; }
.datebtn small { font-size: 12px; color: var(--muted); }
.menu { position: relative; }
.menu > button {
  height: 40px; border: 0; background: transparent; border-radius: var(--r-pill); padding: 0 12px;
  display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; max-width: 240px;
}
.menu > button:hover { background: var(--sunken); }
.menu > button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-pop {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 200px; z-index: 40;
  background: var(--surface); border: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 6px;
}
.menu-pop .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-pop .who b { display: block; font-size: 14px; }
.menu-pop .who small { color: var(--muted); font-size: 13px; }
.menu-pop button {
  width: 100%; height: 40px; border: 0; background: transparent; border-radius: 10px; padding: 0 10px;
  display: flex; align-items: center; gap: 8px; color: var(--danger); font-weight: 500;
}
.menu-pop button:hover { background: var(--danger-bg); }

/* fluid: content follows the window width, gutter grows with it */
:root { --gutter: clamp(16px, 3vw, 48px); }
main { width: 100%; padding: 32px var(--gutter) 80px; }
main:has(.chat) { padding-bottom: 24px; }  /* chat fills the window: 32 top + 24 bottom = the 56 in .chat */

/* page and section rhythm: 8 / 16 / 24 / 40 */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.sec { margin-top: 40px; }
.sec:first-child { margin-top: 0; }
.sec-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.sec-head .count { color: var(--muted); font-size: 14px; }
.sec-head .grow { flex: 1; }

/* dropPick: dropdown list with a single/multi switch */
.dp { position: relative; }
.dp-btn {
  width: 100%; height: 44px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 500; text-align: start; transition: border-color var(--t);
}
.dp-btn:hover { border-color: var(--ink-400); }
.dp-btn[aria-expanded="true"] { border-color: var(--accent); }
.dp-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-arrow { flex: none; color: var(--muted); transition: transform var(--t); }
.dp-btn[aria-expanded="true"] .dp-arrow { transform: rotate(180deg); }
.dp-pop {
  position: absolute; top: calc(100% + 6px); inset-inline: 0; z-index: 20; overflow: hidden;
  background: var(--surface); border: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 4px;
}
.dp-head { padding: 6px 10px; margin-bottom: 2px; border-radius: 10px; background: var(--bg); }
.dp-mode { display: inline-flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 4px 0; font-size: 14px; color: var(--text-2); cursor: pointer; }
.dp-mode .sw { position: relative; width: 34px; height: 20px; border-radius: 10px; background: var(--line-2); transition: background var(--t); }
.dp-mode .sw::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: inset-inline-start var(--t); }
.dp-mode[aria-checked="true"] { color: var(--accent-ink); font-weight: 600; }
.dp-mode[aria-checked="true"] .sw { background: var(--accent); }
.dp-mode[aria-checked="true"] .sw::after { inset-inline-start: 16px; }
.dp-list { display: flex; flex-direction: column; max-height: 300px; overflow: auto; }
.dp-opt {
  min-height: 44px; padding: 0 14px; display: flex; align-items: center; gap: 12px; flex: none;
  border: 0; border-radius: 10px; background: transparent; color: var(--text-2); font-size: 15px; text-align: start;
}
.dp-opt:hover { background: var(--bg); color: var(--text); }
.dp-opt[aria-selected="true"] { background: var(--accent-bg); color: var(--accent-ink); font-weight: 600; }
.dp-box { width: 18px; height: 18px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--line-2); border-radius: 50%; }
.dp-list.multi .dp-box { border-radius: 4px; }
.dp-opt[aria-selected="true"] .dp-box { background: var(--accent); border-color: var(--accent); color: #fff; }
.dp-box svg.i { width: 12px; height: 12px; }
.dp-opt .grow { flex: 1; }
.dp-opt .n { color: var(--muted); font-size: 13px; font-weight: 400; }

/* fold: collapsible section with an arrow */
.fold-btn { display: inline-flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 4px 0; color: var(--text); cursor: pointer; }
.fold-btn h2 { margin: 0; }
.fold-btn:hover h2 { color: var(--accent-ink); }
.fold-arrow { transition: transform var(--t); transform: rotate(90deg); color: var(--muted); }
.fold.open .fold-arrow { transform: none; }
.fold:not(.open) .fold-body, .fold:not(.open) .fold-tools { display: none; }
.fold:not(.open) .sec-head { margin-bottom: 0; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.tight { gap: 8px; }
.split { display: grid; gap: clamp(24px, 3vw, 48px); grid-template-columns: clamp(300px, 28vw, 440px) minmax(0, 1fr); align-items: start; }
.split.rule { align-items: stretch; }
.cols-2 { display: grid; gap: 40px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.empty { padding: 24px 0; color: var(--muted); }
.loading { display: flex; align-items: center; gap: 10px; padding: 24px 0; color: var(--muted); }
/* loader: the logo ring, light segments fill blue one after another then empty (see T.ring) */
.ring { flex: none; fill: none; stroke-width: 11; stroke-linecap: round; }
.ring path { stroke: var(--sunken); animation: ring-fill 1.8s var(--ease) infinite; }
.ring path:nth-child(2) { animation-delay: .15s; }
.ring path:nth-child(3) { animation-delay: .3s; }
.ring path:nth-child(4) { animation-delay: .45s; }
.ring path:nth-child(5) { animation-delay: .6s; }
.ring path:nth-child(6) { animation-delay: .75s; }
@keyframes ring-fill { 0% { stroke: var(--sunken); } 15%, 75% { stroke: var(--accent); } 92%, 100% { stroke: var(--sunken); } }
@media (prefers-reduced-motion: reduce) { .ring path { stroke: var(--accent); } }

/* numbers line (admin overview) */
/* figures: one framed box per number */
.figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.figures > div { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface); }
.figures > .danger { background: var(--danger-bg); }
.figures b { font-size: 26px; font-weight: 600; line-height: 1.2; }
.figures small { color: var(--muted); font-size: 13px; }
.figures .danger b { color: var(--danger); }

/* text states */
.t-danger { color: var(--danger); }
.t-warn { color: var(--warn-ink); }
.t-ok { color: var(--accent-ink); }
.lvl-low { color: var(--accent-ink); } .lvl-medium { color: var(--warn-ink); } .lvl-high { color: var(--danger); }
.dot { display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--faint); vertical-align: middle; margin: 0 8px; }

/* ───────── week strip (days with meters) ───────── */
.strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; overflow-x: auto; }
.strip > * {
  padding: 12px 12px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0;
  border: 0; border-radius: var(--r); background: var(--surface); text-align: start;
}
.strip .wkend { background: transparent; opacity: .5; }
.strip .wkend .dh small, .strip .wkend .dh b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip button:hover { background: var(--paper-50); box-shadow: inset 0 0 0 1px var(--line-2); }
.strip .dh { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.strip .dh b { font-size: 14px; font-weight: 600; }
.strip .dh small { font-size: 12px; color: var(--muted); white-space: nowrap; }
.strip .today .dh b { color: var(--accent-ink); }
.strip .past { opacity: .45; }
.strip button[aria-pressed="true"] { background: var(--accent-bg); }
.strip button[aria-pressed="true"] .dh b { color: var(--accent-ink); }

/* ───────── list filters ───────── */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; margin-bottom: 24px; }
.filters .field { margin: 0; }
.frow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.frow .lbl { color: var(--muted); font-size: 14px; min-width: 52px; }

/* ───────── calendar (5 school days per row) ───────── */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cal-head b { font-size: 16px; font-weight: 600; }
.cal-head .grow { flex: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) repeat(2, minmax(0, .45fr)); gap: 6px; }
.cal-dow { font-size: 13px; color: var(--muted); padding: 0 4px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-dow.wkend { color: var(--faint); }
.cell.wkend { opacity: .4; background: transparent; border-color: var(--line-2); border-style: dashed; cursor: default; }
.cell.wkend:hover { border-color: var(--line-2); }
.cell {
  position: relative; min-height: 68px; padding: 8px 10px 10px; border-radius: var(--r);
  border: 1px solid transparent; background: var(--surface); text-align: start;
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
  transition: border-color var(--t), background var(--t);
}
.cell .dn { display: flex; align-items: baseline; gap: 6px; }
.cell .dn b { font-size: 17px; font-weight: 600; line-height: 1; }
.cell .dn small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell.today .dn b { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.cell .ex { position: absolute; top: 9px; inset-inline-end: 9px; width: 7px; height: 7px; border-radius: 1px; background: var(--ink-900); transform: rotate(45deg); }
.cell:hover:not(:disabled) { border-color: var(--line-2); }
.cell:disabled { cursor: default; background: transparent; border-color: transparent; }
.cell:disabled .dn b, .cell:disabled .dn small { color: var(--faint); }
.cell:disabled .meter { opacity: .4; }
.cell.past { opacity: .45; }
.cell.av-ok { border-color: var(--accent); background: var(--accent-bg); }
.cell.av-part { border-color: var(--brand-300); border-style: dashed; }
.cell.av-no { background: var(--paper-50); }
.cell.av-no .dn b { color: var(--muted); }
.cell.sel, .cell.sel:hover { border-color: var(--accent); background: var(--accent); }
.cell.sel .dn b, .cell.sel .dn small { color: #fff; }
.cell.sel .meter { --fill: #fff; }
.cell.sel .meter i { background-color: rgba(255,255,255,.3); }
.cell.sel .ex { background: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--surface); }
.legend i.ok { border-color: var(--accent); background: var(--accent-bg); }
.legend i.ex { width: 7px; height: 7px; border: 0; border-radius: 1px; background: var(--ink-900); transform: rotate(45deg); margin: 0 2px; }

/* decision bar under the calendar */
.decide { margin-top: 16px; padding: 18px 20px; border-radius: var(--r-lg); background: var(--surface); display: flex; flex-direction: column; gap: 12px; }
.decide .when { font-size: 17px; font-weight: 600; }
.decide .when.none { color: var(--muted); font-weight: 400; font-size: 15px; }
.verdict { display: flex; align-items: flex-start; gap: 10px; font-size: 15px; line-height: 1.6; }
.verdict svg.i { margin-top: 2px; width: 18px; height: 18px; stroke-width: 2.2; }
.verdict.ok { color: var(--accent-ink); }
.verdict.no { color: var(--danger); }
.verdict .cls { font-weight: 600; min-width: 34px; }
.verdict small { display: block; color: var(--muted); font-size: 13px; }

/* ───────── lists and tables ───────── */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 15px; }
table.t th { text-align: start; font-size: 13px; font-weight: 500; color: var(--muted); padding: 0 12px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.t td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th:first-child, table.t td:first-child { padding-inline-start: 0; }
table.t th:last-child, table.t td:last-child { padding-inline-end: 0; }
table.t td.acts { text-align: end; white-space: nowrap; vertical-align: middle; }
table.t .sub { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
table.t tr.dim td { color: var(--muted); }
table.t td.nw { white-space: nowrap; }

.list { display: flex; flex-direction: column; gap: 8px; }
.li { display: flex; gap: 16px; align-items: flex-start; padding: 16px 0; border-bottom: 1px solid var(--line); }
.list > .li { padding: 14px 18px; border: 0; border-radius: var(--r-lg); background: var(--surface); }
.li .body { flex: 1; min-width: 0; }
.li .meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; }
.li .title { font-weight: 600; }
.li p { margin-top: 4px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.li.dim .title, .li.dim p { color: var(--muted); }
.li .end { flex: none; display: flex; align-items: center; gap: 4px; }

/* student items grouped by day */
/* student list: one framed block per day, one card per item */
.weeks { display: flex; flex-direction: column; gap: 32px; }
.week-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin: 0 0 10px; }
.week-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) repeat(2, minmax(0, .4fr)); gap: 10px; align-items: stretch; }
.week-grid .day-group { min-width: 0; }
.week-grid .li { flex-direction: column; gap: 10px; }
.week-grid .li .end { width: 100%; }
.week-grid .prog { display: flex; width: 100%; }
.week-grid .prog button { flex: 1; padding: 0 6px; }
.week-grid .cards { padding: 8px; gap: 8px; }
.week-grid .cards > .li { padding: 12px; }
.day-group { border: 0; border-radius: var(--r-lg); background: var(--surface); overflow: hidden; scroll-margin-top: calc(var(--top-h) + 16px); }
.day-group > h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 16px; margin: 0; padding: 12px 16px; background: transparent; }
.day-group > h2 { flex-wrap: wrap; }
.day-group > h2 small { font-size: 13px; font-weight: 400; color: var(--muted); }
.day-group .dname { display: flex; flex-direction: column; gap: 2px; }
.day-group .none { padding: 14px 16px; color: var(--faint); font-size: 13px; margin: 0; }
.day-group.today > h2 { background: var(--accent-bg); color: var(--accent-ink); }
.day-group.past { opacity: .6; }
.day-group.wkend { opacity: .45; background: transparent; border: 1px dashed var(--line-2); }
.day-group.wkend > h2 { background: transparent; color: var(--muted); }
.cards { display: flex; flex-direction: column; gap: 8px; padding: 0 8px 8px; }
.cards > .li { padding: 14px 16px; border: 0; border-radius: var(--r); background: var(--bg); }
.item .subj { font-size: 13px; color: var(--muted); }
.item .subj b { font-size: 16px; font-weight: 700; color: var(--text); }
.item.done .title { text-decoration: line-through; text-decoration-color: var(--faint); color: var(--muted); }
.prog { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r); background: var(--sunken); }
.prog button { height: 32px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.prog button:hover:not(:disabled) { color: var(--text); }
.prog button[aria-checked="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(16,32,46,.08); }
.prog button:last-child[aria-checked="true"] { background: var(--accent); color: #fff; box-shadow: none; }
.prog button:disabled { cursor: default; }

/* risk line (student head) */
.risk { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; font-size: 15px; }
.risk > * { white-space: nowrap; }
.risk > .small { white-space: normal; }
.risk .meter { width: 120px; }

/* heatmap (admin) */
.heat { border-collapse: separate; border-spacing: 3px; font-size: 13px; }
.heat th { font-weight: 500; color: var(--muted); padding: 0 2px 4px; text-align: center; white-space: nowrap; line-height: 1.3; }
.heat th.cl { text-align: start; padding-inline-end: 12px; }
.heat th.cl button { border: 0; background: transparent; font-weight: 600; color: var(--text); padding: 4px 6px; border-radius: 6px; }
.heat th.cl button:hover, .heat th.cl button[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent-ink); }
.heat td { width: 40px; min-width: 40px; height: 36px; border-radius: 8px; text-align: center; background: var(--surface); box-shadow: none; color: var(--text); position: relative; }
.heat td.full { background: var(--danger); color: #fff; box-shadow: none; }
.heat td.ex::after { content: ""; position: absolute; top: 4px; inset-inline-end: 4px; width: 5px; height: 5px; border-radius: 1px; transform: rotate(45deg); background: currentColor; }
.heat th.wkend { color: var(--faint); font-size: 11px; }
.heat td.wkend { width: 22px; min-width: 22px; background: var(--paper-200); box-shadow: none; opacity: .5; }
.heat .riskcell { width: 160px; background: none; box-shadow: none; text-align: start; padding-inline-start: 16px; }
.heat .riskcell small { color: var(--muted); white-space: nowrap; }

/* timetable */
/* timetable: closed grid, outer frame on every side */
.tt { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; border: 0; border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.tt th { font-size: 13px; font-weight: 500; color: var(--muted); padding: 10px; text-align: start; background: var(--paper-50); border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line); }
.tt th:first-child { border-inline-start: 0; }
.tt th.cur { color: var(--accent-ink); font-weight: 600; }
.tt td { padding: 12px 10px; border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line); vertical-align: top; }
.tt tr:last-child td { border-bottom: 0; }
.tt td.per { border-inline-start: 0; width: 84px; background: var(--paper-50); }
.tt td.per b { display: block; font-size: 18px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.tt td.per small { display: block; font-size: 12px; color: var(--muted); direction: ltr; text-align: right; }
.tt td.todaycol { background: var(--paper-50); }
.tt th.wkend { width: 7%; color: var(--faint); }
.tt td.wkend { background: var(--paper-100); opacity: .6; }
.tt td.on { background: var(--accent-bg); }
.tt td b.s { display: block; font-size: 15px; font-weight: 600; }
.tt td small.t { display: block; font-size: 13px; color: var(--muted); line-height: 1.5; }
.tt td.act b.s { color: var(--muted); font-weight: 500; }

/* ───────── modal & toast ───────── */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(16,32,46,.45); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: min(540px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-pop); padding: 24px; }
.modal.wide { width: min(720px, 100%); }
.modal > h2 { font-size: 20px; margin-bottom: 16px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink-900); color: #fff; padding: 12px 18px; border-radius: var(--r); box-shadow: var(--shadow-pop); font-size: 15px; max-width: min(520px, 90vw); animation: fade .15s; }
.toast.err { background: var(--danger); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv b { direction: ltr; }
details.raw summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; padding: 8px 0; }

/* ───────── responsive ───────── */
@media (max-width: 1200px) {
  .week-grid { grid-template-columns: 1fr; gap: 8px; }
  .week-grid .li { flex-direction: row; flex-wrap: wrap; }
  .week-grid .day-group.wkend > h2 { padding: 8px 16px; }
}
@media (max-width: 1280px) {
  .top-in { gap: 16px; }
  .nav a { padding: 0 10px; }
}
@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; gap: 32px; }
  .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --top-h: 56px; }
  h1 { font-size: 22px; }
  .top-in { gap: 12px; }
  .datebtn { flex: 0 1 auto; min-width: 0; white-space: normal; }
  .menu > button span { display: none; }
  main { padding: 24px var(--gutter) calc(96px + env(safe-area-inset-bottom)); }
  main:has(.chat) { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }  /* room for the bottom bar */
  /* tabs become a bottom bar */
  .nav {
    position: fixed; bottom: 0; inset-inline: 0; z-index: 30; gap: 0;
    background: var(--surface); box-shadow: 0 -1px 0 var(--line), 0 -8px 24px rgba(16,32,46,.06);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0;
  }
  .nav a { flex: 1 0 64px; flex-direction: column; justify-content: center; gap: 2px; padding: 4px 2px; height: auto; min-height: 52px; font-size: 12px; border-radius: var(--r); }
  .nav svg.i { display: block; width: 22px; height: 22px; }
  .nav .badge { position: absolute; top: 2px; inset-inline-start: calc(50% + 6px); }
  .cell { min-height: 58px; padding: 6px 7px 8px; }
  .cell .dn small { display: none; }
  .strip > * { padding: 10px 6px; }
  .strip .dh { flex-direction: column; gap: 0; }
  .li { flex-wrap: wrap; }
  .li .end { width: 100%; }
  .risk > .small { flex-basis: 100%; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  table.t.stackable thead { display: none; }
  table.t.stackable tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.t.stackable td { display: block; padding: 2px 0; border: 0; }
  table.t.stackable td.acts { text-align: start; padding-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* day contents and points (add homework) */
.help-line { font-size: 13px; color: var(--muted); line-height: 1.8; margin-top: -8px; }
.help-line b { color: var(--text-2); font-weight: 600; }
.dayitems .li { padding: 10px 0; }
.dayitems + .dayitems { margin-top: 16px; }
.li .end.pts { gap: 10px; font-size: 14px; }
.li .end.pts b { min-width: 28px; text-align: end; }

/* notifications bell */
.bell .icon-btn { position: relative; }
.bell-badge { position: absolute; top: 4px; inset-inline-end: 2px; min-width: 18px; height: 18px; line-height: 18px; font-size: 11px; padding: 0 5px; }
.notif-pop { width: min(360px, calc(100vw - 32px)); max-height: 70vh; overflow-y: auto; }
.notif-pop .who { padding-bottom: 8px; }
.notif-pop button.notif {
  height: auto; color: var(--text); font-weight: 400; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  text-align: start; padding: 10px; line-height: 1.6; font-size: 14px; border-radius: 8px;
}
.notif-pop button.notif:hover { background: var(--sunken); }
.notif-pop button.notif.new { background: var(--accent-bg); }
.notif-pop button.notif small { color: var(--muted); font-size: 12px; }
.notif-pop .empty { padding: 12px 10px; }

/* admin: students who did not submit */
.missed { border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.missed-row { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 16px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.missed-row:last-child { border-bottom: 0; }
.missed-row .who { display: flex; align-items: center; gap: 10px; }
.missed-row .who b { font-weight: 600; }
.badge-n { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--danger-bg); color: var(--danger); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.missed-row .what { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border: 0; border-radius: var(--r-pill); background: var(--bg); font-size: 13px; color: var(--text-2); }
.tag b { font-weight: 600; color: var(--text); }

/* teacher: student rows that open to show undone items */
.slist { border-radius: var(--r-lg); background: var(--surface); overflow: hidden; margin-top: 16px; }
.sgroup + .sgroup { margin-top: 28px; }
.sgroup-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sgroup-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.sgroup-head .count { color: var(--muted); font-size: 13px; }
.sgroup-head .count.lvl-medium, .sgroup-head .count.lvl-high { font-weight: 600; }
.sgroup-head .count.lvl-medium { color: var(--warn-ink); }
.sgroup-head .count.lvl-high { color: var(--danger); }
.sgroup .slist { margin-top: 10px; }
.srow { border-bottom: 1px solid var(--line); }
.srow:last-child { border-bottom: 0; }
.srow-head { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 16px; border: 0; background: transparent; color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.srow-head:hover { background: var(--paper-50); }
.srow-head .name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.srow-head .name b { font-weight: 600; }
.srow-head .name small { color: var(--muted); font-size: 13px; }
.srow-head .risk { display: flex; align-items: center; gap: 10px; width: 220px; font-weight: 600; }
.srow-head .left { display: flex; align-items: center; gap: 8px; min-width: 110px; justify-content: flex-end; }
.srow-head .left .count { color: var(--muted); font-size: 13px; }
.srow.open .fold-arrow { transform: none; }
.srow-body { display: none; padding: 0 16px 16px; }
.srow.open .srow-body { display: flex; flex-wrap: wrap; gap: 8px; }
.hw-block { display: flex; flex-direction: column; gap: 2px; min-width: 150px; padding: 8px 12px; border: 1px solid transparent; border-radius: var(--r); background: var(--bg); }
.hw-block b { color: var(--accent-ink); font-weight: 700; }
.hw-block .k { font-size: 13px; color: var(--text-2); }
.hw-block .d { font-size: 13px; color: var(--muted); }
.hw-block.late { border-color: var(--danger); background: var(--danger-bg); }
.hw-block.late .d { color: var(--danger); font-weight: 600; }
.input.search { max-width: 240px; }
/* teacher general: my numbers */
.my-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-radius: var(--r-lg); background: var(--surface); }
.my-col { display: flex; flex-direction: column; gap: 2px; padding: 16px; border-inline-start: 1px solid var(--line); }
.my-col:first-child { border-inline-start: 0; }
.my-col > small { color: var(--muted); font-size: 13px; }
.my-col > b { font-size: 24px; font-weight: 700; }
.my-col ul { list-style: none; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.my-col li { display: flex; justify-content: space-between; gap: 8px; color: var(--text-2); }
.my-left { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; }
.my-bar { display: grid; grid-template-columns: 110px 1fr 48px; align-items: center; gap: 12px; font-size: 14px; }
.my-bar .track { height: 10px; border-radius: 5px; background: var(--paper-300); overflow: hidden; }
.my-bar .track i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.my-bar:first-child .track i { background: var(--accent-ink); }
@media (max-width: 760px) {
  .my-grid { grid-template-columns: 1fr; }
  .my-col { border-inline-start: 0; border-top: 1px solid var(--line); }
  .my-col:first-child { border-top: 0; }
}
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--paper-50); }
table.t tr.sel td { background: var(--accent-bg); }
@media (max-width: 760px) {
  .srow-head { flex-wrap: wrap; gap: 8px 12px; }
  .srow-head .risk { order: 3; width: 100%; }
  .input.search { max-width: none; }
}
@media (max-width: 760px) { .missed-row { grid-template-columns: 1fr; gap: 8px; } }

/* admin: class risk average */
.risk-avg { display: flex; align-items: center; gap: 20px; padding: 16px 20px; border-radius: var(--r-lg); background: var(--surface); }
.risk-avg > b { font-size: 36px; font-weight: 700; line-height: 1; min-width: 56px; }
.risk-avg small { display: block; margin-top: 8px; color: var(--muted); font-size: 13px; }
.risk-avg .grow { flex: 1; min-width: 0; }

/* statistics */
.stats-views { margin-bottom: 28px; }
.stats-views .seg { max-width: 100%; overflow-x: auto; }
.sbar { display: flex; align-items: center; gap: 10px; }
.sbar .track { flex: 1; min-width: 60px; height: 10px; background: var(--paper-200); border-radius: 5px; overflow: hidden; }
.sbar .track i { display: block; height: 100%; background: var(--accent); border-start-end-radius: 4px; border-end-end-radius: 4px; }
.sbar b { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; min-width: 28px; }
.linkbtn { border: 0; background: transparent; padding: 0; color: var(--accent-ink); font-weight: 600; font-size: inherit; text-align: start; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; text-underline-offset: 3px; }
table.t td.num { font-variant-numeric: tabular-nums; color: var(--text-2); }
.stats-t td { vertical-align: middle; }
.heat td.avg { width: auto; min-width: 60px; background: none; box-shadow: none; font-weight: 600; }

/* ───────── chat ───────── */
.chat {
  display: grid; grid-template-columns: clamp(280px, 26vw, 380px) minmax(0, 1fr); gap: 16px;
  height: calc(100dvh - var(--top-h) - 56px); min-height: 420px;
}
.chat-list { display: flex; flex-direction: column; gap: 12px; min-height: 0; padding: 16px; border-radius: var(--r-lg); background: var(--surface); }
.chat-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-list-head h1 { margin: 0; }
.chat-items { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
/* chat directory: folding sections (recent, teachers, one per class) */
.dir-sec {
  width: 100%; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; margin-top: 4px; border: 0; border-radius: 10px;
  background: transparent; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; text-align: start;
}
.dir-sec:hover { background: var(--sunken); }
.dir-sec .lbl { flex: 1; }
.dir-sec .n { font-weight: 400; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dir-sec svg.i { width: 16px; height: 16px; color: var(--muted); transition: transform var(--t) var(--ease); }
.dir-sec.on { color: var(--accent-ink); }
.dir-sec.on svg.i { transform: rotate(180deg); color: var(--accent-ink); }
.dir-rows { display: flex; flex-direction: column; gap: 2px; }
.dir-rows .empty { padding: 14px 10px; }
.dir-sec.sub { padding-inline-start: 22px; font-weight: 500; color: var(--text-2); margin-top: 2px; }
.dir-rows.sub .conv { padding-inline-start: 34px; }
.dir-err { padding: 12px 10px; font-size: 13px; color: var(--danger); }
.conv {
  width: 100%; display: flex; gap: 10px; align-items: flex-start; text-align: start;
  padding: 10px; border: 0; border-radius: var(--r); background: transparent; cursor: pointer; color: var(--text);
}
.conv:hover { background: var(--sunken); }
.conv[aria-current="true"] { background: var(--accent-bg); }
.cv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv .nm { font-weight: 600; }
.conv .sub, .thread-head .sub { color: var(--muted); font-size: 13px; }
.conv .pv { color: var(--text-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-end { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12px; color: var(--muted); }
.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; padding: 12px; border-radius: var(--r-lg); background: var(--surface); }
.thread > .empty.center, .msgs .empty.center { margin: auto; text-align: center; }
.thread-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px 12px; }
.thread-head .grow { display: flex; flex-direction: column; min-width: 0; }
.thread-head .back { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; border-radius: var(--r); background: var(--bg); }
.msg { max-width: min(78%, 560px); padding: 8px 12px 6px; border-radius: 16px; line-height: 1.6; }
.msg p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.msg time { display: block; font-size: 11px; opacity: .7; text-align: end; margin-top: 2px; font-variant-numeric: tabular-nums; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-end-end-radius: 6px; }
.msg.them { align-self: flex-start; background: var(--surface); border-end-start-radius: 6px; }
.msg-from { display: block; font-size: 12px; opacity: .8; }
/* delete button on own messages: shows on hover/focus, always on touch screens */
.msg { position: relative; }
.msg-del {
  position: absolute; top: 50%; inset-inline-end: calc(100% + 4px); transform: translateY(-50%);
  width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--surface); color: var(--muted);
  display: inline-grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity var(--t), color var(--t);
}
.msg-del svg.i { width: 16px; height: 16px; }
.msg:hover .msg-del, .msg-del:focus-visible { opacity: 1; }
.msg-del:hover { color: var(--danger); background: var(--danger-bg); }
@media (hover: none) { .msg-del { opacity: .7; } }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); padding: 2px 12px; margin: 8px 0 4px; border-radius: var(--r-pill); background: var(--surface); }
.more-btn { align-self: center; margin-bottom: 8px; }
/* composer: one row of 44px controls (dots, field, send); counter sits under the field */
.composer { display: flex; gap: 8px; align-items: flex-start; }
.composer .field-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.composer textarea {
  display: block; width: 100%; height: var(--h-ctl); min-height: var(--h-ctl); max-height: 140px; box-sizing: border-box;
  border: 1px solid var(--line-2); border-radius: 22px; background: var(--bg); outline: 0; resize: none;
  padding: 10px 16px; line-height: 22px; font-size: 15px; overflow-y: hidden; scrollbar-width: thin;
  transition: border-color var(--t), box-shadow var(--t);
}
.composer textarea.multi { border-radius: 16px; }
.composer textarea:focus { border-color: var(--accent); box-shadow: var(--ring); background: var(--surface); }
.composer textarea::placeholder { color: var(--faint); }
.composer .icon-btn, .composer .send { flex: none; width: var(--h-ctl); height: var(--h-ctl); border-radius: 50%; }
.composer .send {
  align-self: flex-end; margin-bottom: 20px;
  border: 0; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.composer .send:hover { background: var(--accent-ink); }
.composer .send:disabled { opacity: .5; cursor: default; }
.composer .send svg.i { width: 20px; height: 20px; }
.composer .count { align-self: flex-end; height: 20px; line-height: 20px; padding-inline: 16px; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.composer .count.hi { color: var(--warn-ink); }
.att-wrap { position: relative; flex: none; align-self: flex-end; margin-bottom: 20px; }
.att-menu { top: auto; bottom: calc(100% + 8px); inset-inline-end: auto; inset-inline-start: 0; min-width: 190px; }
.att-menu button { color: var(--text); font-weight: 400; }
.att-menu button:hover { background: var(--sunken); }
.att-menu svg.i { width: 18px; height: 18px; color: var(--muted); }
.chat-closed { padding: 12px 8px 0; color: var(--muted); }
@media (max-width: 760px) {
  .chat { grid-template-columns: 1fr; height: calc(100dvh - var(--top-h) - 120px - env(safe-area-inset-bottom)); }
  .chat-list, .thread { padding: 12px; }
  .chat .thread, .chat.open .chat-list { display: none; }
  .chat.open .thread { display: flex; }
  .thread-head { padding: 0 0 10px; }
  .msgs { border-radius: var(--r); }
  .thread-head .back { display: inline-flex; }
  .msgs { padding: 12px 10px; }
  .composer-wrap, .chat-closed { padding-inline: 0; }
}

/* chat files */
.msg.has-file { padding: 6px 6px 4px; }
.msg.has-file p, .msg.has-file time { padding-inline: 6px; }
.msg-img { display: block; border: 0; padding: 0; background: var(--sunken); border-radius: 12px; overflow: hidden; cursor: zoom-in; }
.msg-img img { display: block; max-width: min(260px, 60vw); max-height: 320px; object-fit: contain; }
.msg-img.loading { width: 200px; height: 140px; }
.msg-file {
  display: flex; align-items: center; gap: 10px; min-width: 200px; max-width: 100%; padding: 8px 10px;
  border: 0; border-radius: 12px; background: rgba(16,32,46,.06); color: inherit; text-align: start; cursor: pointer;
}
.msg.me .msg-file { background: rgba(255,255,255,.16); }
.msg-file svg.i { flex: none; width: 28px; height: 28px; }
.msg-file .fbody { display: flex; flex-direction: column; min-width: 0; }
.msg-file b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.msg-file small { font-size: 12px; opacity: .75; }
.msg-file-err { display: block; padding: 8px; font-size: 13px; }
.composer-wrap { padding: 12px 0 0; }
.composer-wrap .tray { padding: 0 0 8px; }
.tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 20px 0; }
.chip-file {
  position: relative; display: inline-flex; align-items: center; gap: 6px; max-width: 260px; padding: 6px 6px 6px 10px;
  border: 0; border-radius: var(--r-pill); background: var(--bg); font-size: 13px; overflow: hidden;
}
.chip-file svg.i { flex: none; width: 18px; height: 18px; }
.chip-file .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chip-file small { flex: none; color: var(--muted); }
.chip-file .x { flex: none; border: 0; background: transparent; padding: 2px; border-radius: 6px; color: var(--muted); cursor: pointer; display: inline-flex; }
.chip-file .x:hover { background: var(--sunken); color: var(--danger); }
.chip-file .x svg.i { width: 16px; height: 16px; }
.chip-file .bar { position: absolute; inset-inline: 0; bottom: 0; height: 3px; }
.chip-file .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.chip-file.up .x { visibility: hidden; }
.thread.drop { outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: var(--r); }
@media (max-width: 760px) { .tray { padding-inline: 0; } }

/* ───────── attachments ───────── */
.att-tools { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.att-tools .input { max-width: 360px; }
.att-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.att-files .msg-file { min-width: 0; max-width: min(320px, 100%); }
.att-tray { padding: 0; }
.att-tray:empty { display: none; }

/* ───────── announcements ───────── */
.ann-compose { display: flex; flex-direction: column; gap: 12px; padding: 16px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.ann-compose .btn svg { width: 18px; height: 18px; }
.btn.rec { border-color: var(--danger); color: var(--danger); }
.ann-up { display: flex; flex-direction: column; gap: 8px; }
.ann-up:empty { display: none; }
.ann-up-row { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r); }
.ann-up-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.ann-up-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ann-up-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ann-up-row small { color: var(--muted); font-size: 13px; }
.ann-up-row audio { width: 100%; height: 36px; }
.ann-up-row.failed { border-color: var(--danger); }
.ann-up-row.failed small { color: var(--danger); }
.ann-up-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-bg); color: var(--accent); flex: none; }
.ann-up-ic svg { width: 20px; height: 20px; }
.ann-bar { display: block; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.ann-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.ann-up-row.done .ann-bar, .ann-up-row.failed .ann-bar { display: none; }
.ann-feed { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.ann { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg); }
.ann-head { display: flex; align-items: center; gap: 12px; }
.ann-head .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ann-head small { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; }
.ann-av { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-bg); color: var(--accent); flex: none; }
.ann-av svg { width: 20px; height: 20px; }
.ann-imgs { display: grid; gap: 8px; }
.ann-imgs.multi { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.ann-imgs img { display: block; width: 100%; max-height: 520px; object-fit: contain; background: var(--sunken); border-radius: var(--r); }
.ann-imgs.multi img { height: 220px; object-fit: cover; }
.ann-toggle { align-self: flex-start; }
.ann-toggle svg { width: 16px; height: 16px; }
.ann-text { line-height: 1.8; white-space: pre-wrap; word-break: break-word; }
.ann-audio { width: 100%; }
.ann-file { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r); }
.ann-file .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ann-file b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ann-file small { color: var(--muted); font-size: 13px; display: flex; align-items: center; }
