:root {
  --bg: #ffffff;
  --rail: #f9f9f9;
  --card: #ffffff;
  --text: #0d0d0d;
  --text2: #5d5d5d;
  --muted: #8a8a8a;
  --border: #0000001a;
  --grid: #0000000f;
  --hover: #ececec;
  --active: #e3e3e3;
  --bubble: #f4f4f4;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --heat: 42, 120, 214;
  --mark: #fde68a;
  --star: #d99a00;
  --error-bg: #fef2f2;
  --error-border: #fca5a5;
  --error-text: #b91c1c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #212121;
    --rail: #181818;
    --card: #262626;
    --text: #ececec;
    --text2: #b4b4b4;
    --muted: #8f8f8f;
    --border: #ffffff1a;
    --grid: #ffffff12;
    --hover: #ffffff12;
    --active: #ffffff1c;
    --bubble: #303030;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --heat: 57, 135, 229;
    --mark: #7a5b00;
    --star: #f5c542;
    --error-bg: #ef44441a;
    --error-border: #ef444466;
    --error-text: #fca5a5;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; }

.app { display: flex; min-height: 100dvh; }
.rail {
  position: sticky; top: 0; height: 100dvh;
  width: 232px; flex: 0 0 232px;
  background: var(--rail);
  display: flex; flex-direction: column;
  padding: 8px;
  z-index: 30;
}
.rail-top { display: flex; align-items: center; justify-content: space-between; height: 44px; padding: 0 4px 0 10px; }
.brand { font-weight: 600; text-decoration: none; }
.brand-tag { font-weight: 500; color: var(--text2); font-size: 13px; margin-left: 4px; }
.tabs { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; flex: 1; }
.tabs a { padding: 8px 10px; border-radius: 10px; text-decoration: none; font-size: 14px; }
.tabs a:hover { background: var(--hover); }
.tabs a[aria-current="page"] { background: var(--active); font-weight: 600; }
.rail-foot { padding: 10px; font-size: 13px; color: var(--text2); display: flex; flex-direction: column; gap: 10px; }
.rail-foot p { margin: 0; line-height: 1.4; }
.rail-foot a { text-decoration: none; }
.rail-foot a:hover { text-decoration: underline; }

.icon-btn { width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--text2); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.only-mobile { display: none; }
.backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 28px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.title { font-size: 18px; font-weight: 600; margin: 0; flex: 1; min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.seg button { padding: 5px 12px; border-radius: 8px; font-size: 13px; color: var(--text2); }
.seg button[aria-checked="true"] { background: var(--active); color: var(--text); font-weight: 600; }
.seg[hidden] { display: none; }
.seg.small button { padding: 3px 10px; font-size: 12px; }
canvas { transition: opacity .15s ease; }
.view.refreshing canvas { opacity: .5; }
.headline-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.headline { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.caption { font-size: 13px; color: var(--text2); }

.view { padding: 24px 28px 64px; max-width: 1240px; width: 100%; }
.lede { color: var(--text2); margin: 0 0 20px; max-width: 760px; line-height: 1.5; }
.section-title { font-size: 15px; font-weight: 600; margin: 28px 0 12px; }
.note { font-size: 13px; color: var(--text2); line-height: 1.5; }
.callout { border: 1px solid var(--border); border-left: 3px solid var(--s1); border-radius: 8px; padding: 10px 14px; font-size: 13px; color: var(--text2); line-height: 1.5; margin: 0 0 20px; }
.empty { color: var(--text2); padding: 32px 0; }
.error { color: var(--critical); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--card); }
.tile .k { font-size: 12px; color: var(--text2); }
.tile .v { font-size: 26px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 4px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: var(--card); min-width: 0; }
.card h3 { font-size: 14px; font-weight: 600; margin: 0; }
.card .sub { font-size: 12px; color: var(--text2); margin: 4px 0 12px; line-height: 1.4; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 340px; }
.chart-box.short { height: 180px; }
details.as-table { margin-top: 10px; font-size: 13px; }
details.as-table summary { cursor: pointer; color: var(--text2); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-weight: 600; color: var(--text2); background: var(--rail); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 260px; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--hover); }
details.as-table table { margin-top: 8px; }

.chip { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text2); white-space: nowrap; }
.chip .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.chip.warn { border-color: var(--serious); }
.chip.bad { border-color: var(--critical); }
.chip.ok { border-color: var(--good); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type="search"], .toolbar select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}
.toolbar input[type="search"] { width: 280px; max-width: 100%; }
.back { font-size: 13px; color: var(--text2); text-decoration: none; display: inline-block; margin-bottom: 12px; }
.back:hover { color: var(--text); }

.doc { border: 1px solid var(--border); border-radius: 12px; padding: 4px 20px; background: var(--card); line-height: 1.55; font-size: 14px; }
.doc h1 { font-size: 17px; } .doc h2 { font-size: 15px; margin-top: 18px; }

.transcript { display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 820px; line-height: 1.55; font-size: 14px; }
.msg .who { font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.msg.user .body { background: var(--bubble); border-radius: 14px; padding: 10px 14px; }
.msg .body > :first-child { margin-top: 0; } .msg .body > :last-child { margin-bottom: 0; }
.msg pre { overflow-x: auto; background: var(--rail); padding: 10px; border-radius: 8px; }
.msg table th, .msg table td { white-space: normal; }
.msg .katex-display { overflow-x: auto; overflow-y: hidden; }
.msg pre code { background: none; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.match { font-size: 12px; color: var(--text2); margin-top: 3px; line-height: 1.45; }
.match-who { font-weight: 600; }
.match-more { color: var(--muted); }
.refreshing { opacity: .55; transition: opacity .15s ease; }
.chips { display: inline-flex; gap: 4px; }
.star { font-size: 17px; line-height: 1; width: 28px; height: 28px; border-radius: 6px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.star:hover { background: var(--hover); color: var(--star); }
.star.on { color: var(--star); }
.star.error { color: var(--critical); }
.star:focus-visible { outline: 2px solid var(--s1); outline-offset: 1px; }
.btn { font: inherit; font-size: 13px; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; text-decoration: none; white-space: nowrap; cursor: pointer; display: inline-block; }
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.danger { color: var(--critical); }
.share-box { margin-bottom: 16px; }
.share-box .note { margin: 8px 0 0; }
.share-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share-row input { flex: 1 1 260px; min-width: 0; font: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.decision { font-size: 12px; color: var(--text2); border: 1px dashed var(--border); border-radius: 8px; padding: 6px 10px; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 14px; }

.heat td.cell { text-align: center; font-variant-numeric: tabular-nums; min-width: 72px; }
.heat td.diag { outline: 2px solid var(--text2); outline-offset: -2px; }

@media (max-width: 1000px) {
  .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .only-mobile { display: inline-flex; }
  .rail { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s ease; }
  .app.rail-open .rail { transform: none; }
  .app.rail-open .backdrop { display: block; position: fixed; inset: 0; background: #0006; z-index: 20; }
  .topbar { padding: 10px 16px; }
  .view { padding: 16px 16px 48px; }
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .seg { width: 100%; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile .v { font-size: 22px; }
  .seg button { flex: 1; }
}

/* Students' feedback: the Feedback tab and the notes under a reply in a chat. */
.fb-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback { font-size: 13px; line-height: 1.5; border: 1px solid var(--border); border-left: 3px solid var(--s4); border-radius: 8px; padding: 8px 12px; margin-top: 8px; background: var(--card); }
.feedback.up { border-left-color: var(--good); }
.feedback.down { border-left-color: var(--critical); }
.feedback .fb-head { font-size: 12px; color: var(--text2); margin-bottom: 2px; }
.feedback-chat { margin-bottom: 16px; max-width: 820px; }
.msg.flash, .feedback-chat.flash { outline: 2px solid var(--s1); outline-offset: 6px; border-radius: 6px; }
.btn[hidden] { display: none; }
