:root {
  --bg: #f4f3ef; --panel: #ffffff; --ink: #1d1c1a; --muted: #6f6b63; --line: #e3e0d8;
  --accent: #d97a0b; --accent-ink: #ffffff; --accent-soft: #fdf0dd;
  --ok: #2f7d4f; --ok-soft: #e3f3e9; --bad: #b3261e; --bad-soft: #fbe7e5; --warn-soft: #fff4d6;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513; --panel: #201f1c; --ink: #ece9e2; --muted: #9c978c; --line: #34322d;
    --accent: #f0952a; --accent-ink: #1b1306; --accent-soft: #3a2a14;
    --ok: #6cc391; --ok-soft: #1c3326; --bad: #f08a80; --bad-soft: #3b1e1b; --warn-soft: #3a3115;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 4px 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 16px 0 6px; }
code, pre { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

header.top { display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 54px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 24px; justify-content: center; margin-bottom: 8px; }
.flame { width: 14px; height: 18px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(circle at 50% 70%, #ffd166, var(--accent) 70%); box-shadow: 0 0 10px var(--accent); display: inline-block; }
header nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
header nav a { color: var(--muted); padding: 7px 11px; border-radius: 7px; white-space: nowrap; }
header nav a:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
header nav a.on { color: var(--ink); background: var(--accent-soft); }
.who { color: var(--muted); white-space: nowrap; font-size: 13px; }
.role { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; background: var(--bg); padding: 1px 6px; border-radius: 4px; }

main { max-width: 1400px; margin: 0 auto; padding: 20px; }
main.bare { display: grid; place-items: center; min-height: 100vh; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.narrow { max-width: 460px; }
.login { width: 340px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row.gap { gap: 8px; }
.inline { display: inline; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.hint { color: var(--muted); background: var(--accent-soft); padding: 8px 12px; border-radius: 8px; }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.split3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .split, .split3 { grid-template-columns: 1fr; } }

label { display: block; margin-bottom: 10px; font-weight: 500; }
label.row { display: flex; font-weight: 400; margin: 0; }
input, select, textarea { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; }
label > input, label > select, label > textarea, .card > textarea, .card > input { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.flash.warn { background: var(--warn-soft); color: var(--ink); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.pill.live { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 5px; background: var(--bg); color: var(--muted); }
.tag.blocked { background: var(--bad-soft); color: var(--bad); }
.tag.search { background: var(--accent-soft); color: var(--accent); }
.tag.app { background: var(--ok-soft); color: var(--ok); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-right: 6px; }
.dot.on { background: var(--ok); }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .url { word-break: break-all; }
.tbl tr.t-blocked td { background: color-mix(in srgb, var(--bad-soft) 50%, transparent); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.toolbar { margin-bottom: 12px; }

.classgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 20px; }
.classcard { color: var(--ink); margin: 0; }
.classcard:hover { border-color: var(--accent); text-decoration: none; }
.classcard h3 { margin: 0 0 4px; font-size: 16px; }

.catlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; margin-bottom: 14px; }
.catrow { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin: 0; font-weight: 400; cursor: pointer; }
.catrow:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.catrow.locked { opacity: .75; cursor: default; }

/* Live grid */
.screengrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.scr { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink); display: block; box-shadow: var(--shadow); }
.scr:hover { border-color: var(--accent); text-decoration: none; }
.scr .img { aspect-ratio: 16/10; background: #0d0d0c; display: grid; place-items: center; position: relative; }
.scr .img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.scr .img .ph { color: #77736b; font-size: 12px; }
.scr .badge { position: absolute; top: 8px; left: 8px; }
.scr .meta { padding: 8px 10px; }
.scr .name { font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }
.scr .line { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scr.offline .img img { opacity: .35; filter: grayscale(1); }
.scr.blocked { border-color: var(--bad); }

/* Student page */
.studentlayout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); gap: 16px; }
@media (max-width: 1000px) { .studentlayout { grid-template-columns: 1fr; } }
.liveframe { background: #0d0d0c; border-radius: 8px; aspect-ratio: 16/9; display: grid; place-items: center; overflow: hidden; margin: 8px 0; }
.liveframe img { width: 100%; height: 100%; object-fit: contain; }
.liveframe .empty { color: #77736b; }
.tablist { list-style: none; margin: 0; padding: 0; }
.tablist li { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.tablist li:last-child { border: 0; }
.tablist img { width: 16px; height: 16px; }
.tablist .t { flex: 1; min-width: 0; }
.tablist .t div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tablist li.active .t div:first-child { font-weight: 700; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: 62px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed li .tm { color: var(--muted); font-size: 12px; }
.feed li .w { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.feed li .u { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed li.blocked { background: var(--bad-soft); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { font: inherit; font-size: 12px; border: 0; background: transparent; color: var(--muted); padding: 4px 10px; cursor: pointer; }
.seg button.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shots img { width: 100%; border-radius: 6px; cursor: zoom-in; display: block; aspect-ratio: 16/10; object-fit: cover; background: #000; }
.shots .muted { grid-column: 1 / -1; }
.shotgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.shot { margin: 0; padding: 0; overflow: hidden; }
.shot img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; background: #000; }
.shot figcaption { padding: 10px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 20; padding: 20px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 100px); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { margin: 0; }
.stats { display: flex; gap: 16px; }
.stat .n { font-size: 26px; font-weight: 700; }
td.what { max-width: 600px; }
.scr .img img[hidden], .liveframe img[hidden], .liveframe .empty[hidden] { display: none; }
.btn.block { display: flex; justify-content: center; width: 100%; margin-bottom: 8px; }
.localform { margin-top: 14px; }
.divider { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.tag.caution, .tag.act-caution { background: var(--warn-soft); color: #9a6200; }
.tag.act-block { background: var(--bad-soft); color: var(--bad); }
.tag.act-allow { background: var(--ok-soft); color: var(--ok); }
.tbl tr.t-caution td { background: color-mix(in srgb, var(--warn-soft) 60%, transparent); }
.feed li.caution { background: var(--warn-soft); }
select.act { font-weight: 600; min-width: 110px; }
select.act-block { color: var(--bad); border-color: var(--bad); }
select.act-caution { color: #9a6200; border-color: #d9a400; }
select.act-allow { color: var(--ok); }
@media (prefers-color-scheme: dark) { .tag.caution, .tag.act-caution, select.act-caution { color: #f2c14e; } }
