:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --side: #13294b;
  --side-2: #1e3a5f;
  --side-text: #e2e8f0;
  --accent: #f59e0b;
  --accent-ink: #1f1300;
  --primary: #2563eb;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --ok-bg: #dcfce7;
  --bad-bg: #fee2e2;
  --warn-bg: #fef3c7;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .05);
  --radius: 14px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2e;
  --surface-2: #16213a;
  --text: #e5e9f2;
  --muted: #94a3b8;
  --border: #23314f;
  --side: #0a1426;
  --side-2: #14223d;
  --primary: #60a5fa;
  --ok: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --ok-bg: #12301f;
  --bad-bg: #3a1717;
  --warn-bg: #3a2a0c;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; letter-spacing: .02em; }
h3 { font-size: .95rem; margin: 16px 0 8px; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; width: 100%; }
textarea { min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
label input, label select, label textarea { margin-top: 4px; color: var(--text); }

.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, var(--side), var(--side-2)); }
.login-card { background: var(--surface); padding: 28px; border-radius: var(--radius); width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-card .btn { width: 100%; margin-top: 6px; }
.error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 260px; flex: 0 0 260px; background: var(--side); color: var(--side-text); padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; letter-spacing: .01em; }
.brand.big { font-size: 1.35rem; color: var(--text); }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--side); font-size: 14px; }
.who { display: flex; gap: 10px; align-items: center; padding: 10px; background: var(--side-2); border-radius: 12px; }
.who small { color: #9fb3cf; display: block; font-size: .72rem; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--side); display: grid; place-items: center; font-weight: 800; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { color: var(--side-text); text-decoration: none; padding: 9px 10px; border-radius: 10px; display: flex; gap: 10px; align-items: center; }
nav a span { width: 18px; text-align: center; opacity: .8; }
nav a:hover { background: var(--side-2); }
nav a.active { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.card-dark { background: var(--side-2); border-radius: 12px; padding: 12px; }
.timer-head { font-size: .78rem; color: #9fb3cf; text-transform: uppercase; letter-spacing: .06em; }
.timer-clock { font: 700 1.6rem ui-monospace, Consolas, monospace; margin: 4px 0 8px; }
.timer select { background: var(--side); color: var(--side-text); border-color: #2c4669; margin-bottom: 8px; font-size: .85rem; }
.timer .btn { width: 100%; }
.timer.running .timer-clock { color: var(--accent); }
.theme-toggle { color: #9fb3cf; display: flex; gap: 8px; align-items: center; margin-top: auto; }
.theme-toggle input { width: auto; }
.main-wrap { flex: 1; min-width: 0; }
.topbar { display: flex; gap: 12px; align-items: center; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar select { max-width: 460px; font-weight: 600; }
.topbar .today { margin-left: auto; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.menu-btn { font-size: 1.1rem; padding: 6px 10px; }
/* menu recolhido: só a trilha de ícones */
@media (min-width: 801px) {
  .sidebar { transition: width .2s, flex-basis .2s, padding .2s; }
  .shell.collapsed .sidebar { width: 64px; flex-basis: 64px; padding: 18px 8px; overflow-x: hidden; }
  .shell.collapsed .brand { font-size: 0; justify-content: center; }
  .shell.collapsed .brand .logo { font-size: 14px; }
  .shell.collapsed .who, .shell.collapsed .timer-head, .shell.collapsed .theme-toggle { display: none; }
  .shell.collapsed nav a { font-size: 0; justify-content: center; padding: 10px 0; }
  .shell.collapsed nav a span { font-size: 1rem; width: auto; }
  .topbar .timer { display: flex; align-items: center; gap: 10px; padding: 6px 10px; margin-left: auto; color: var(--side-text); }
  .topbar .timer .timer-clock { font-size: 1.15rem; margin: 0; }
  .topbar .timer select { width: 200px; margin: 0; padding: 5px 8px; }
  .topbar .timer .btn { width: auto; }
  .topbar .timer + .today { margin-left: 0; }
}
main { padding: 24px; max-width: 1400px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

/* cards & grids */
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.accent-top { border-top: 4px solid var(--accent); }
.stat .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.stat .value { font-size: 2rem; font-weight: 800; line-height: 1.2; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: .85rem; }
.stat.hero { background: linear-gradient(135deg, var(--side), var(--side-2)); color: #fff; border: none; }
.stat.hero .label, .stat.hero .sub { color: #c7d5ea; }
.stat.hero .value { color: var(--accent); }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 320px; }
.gauge-label { text-align: center; margin-top: -40px; font-weight: 800; font-size: 1.4rem; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.kv:last-child { border-bottom: 0; }
.kv b { font-variant-numeric: tabular-nums; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { color: var(--muted); font-size: .8rem; }
.list li.done .title { text-decoration: line-through; color: var(--muted); }
.check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; flex: 0 0 22px; display: grid; place-items: center; padding: 0; font-size: 13px; }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.tag.late { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.tag.imp { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.tag.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; flex: 0 0 10px; margin-top: 6px; }
.news li a { text-decoration: none; color: var(--text); font-weight: 600; }
.news li a:hover { color: var(--primary); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs .btn.on { background: var(--side); color: #fff; border-color: var(--side); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .btn { flex: 0 0 auto; }

/* weekly schedule */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.day { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px; min-width: 0; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.day h3 { margin: 0 0 8px; font-size: .85rem; display: flex; justify-content: space-between; }
.block { background: var(--surface); border-left: 4px solid var(--primary); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; font-size: .82rem; position: relative; }
.block .x { position: absolute; top: 2px; right: 4px; border: 0; background: none; cursor: pointer; color: var(--muted); }
.block.done { opacity: .6; }
.block.clickable { cursor: pointer; }
.block.clickable:hover { box-shadow: 0 0 0 2px var(--accent) inset; }
.ed-disc.today { border-color: var(--accent); background: var(--surface); }
.ed-disc { scroll-margin-top: 80px; }

/* questions */
.qcard { max-width: 860px; }
.qmeta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.statement { font-size: 1.05rem; line-height: 1.6; margin: 0 0 16px; white-space: pre-wrap; }
.answers { display: flex; gap: 10px; flex-wrap: wrap; }
.answers .btn { min-width: 110px; }
.opts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.opt { text-align: left; font-weight: 500; white-space: normal; }
.opt.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; }
.opt.right { background: var(--ok-bg); border-color: var(--ok); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); }
.feedback { margin-top: 16px; padding: 14px; border-radius: 12px; }
.feedback.ok { background: var(--ok-bg); }
.feedback.bad { background: var(--bad-bg); }
.feedback.blank { background: var(--warn-bg); }
.sim-q { border-bottom: 1px solid var(--border); padding: 16px 0; }
.sim-q:last-child { border-bottom: 0; }
.ce .btn.sel { background: var(--side); color: #fff; border-color: var(--side); }
.sticky-bar { position: sticky; top: 64px; z-index: 4; display: flex; gap: 12px; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.clock { font: 700 1.3rem ui-monospace, Consolas, monospace; }
.clock.low { color: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.note { border-left: 4px solid var(--accent); }
.note p { margin: 6px 0 10px; white-space: pre-wrap; }
.notes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.files li a { text-decoration: none; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
details summary { cursor: pointer; font-weight: 700; }
pre { background: var(--surface-2); padding: 12px; border-radius: 10px; overflow-x: auto; font-size: 12px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(120px); background: var(--side); color: #fff; padding: 10px 18px; border-radius: 10px; transition: transform .25s; z-index: 50; max-width: calc(100% - 32px); }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--bad); }

/* edital */
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 3px solid var(--border); }
.timeline li { position: relative; padding: 6px 0 6px 12px; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 13px; width: 11px; height: 11px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); }
.timeline li.past { color: var(--muted); }
.timeline li.past::before { border-color: var(--border); background: var(--border); }
.timeline li.next::before { border-color: var(--accent); background: var(--accent); }
tr.hl td { background: var(--warn-bg); font-weight: 700; }
.bul { margin: 6px 0 0; padding-left: 20px; }
.bul li { margin-bottom: 6px; }
.ed-disc { border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; background: var(--surface-2); }
.ed-disc summary { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.bar { height: 6px; background: var(--border); border-radius: 99px; margin: 8px 0; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.topics { list-style: none; margin: 0; padding: 0; }
.topics li { padding: 4px 0; }
.topics li.th { font-weight: 700; margin-top: 8px; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.topics label { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-size: .92rem; margin: 0; cursor: pointer; }
.topics input { width: auto; margin-top: 4px; }
.topics input:checked + span { color: var(--muted); text-decoration: line-through; }
.yt { color: #dc2626; font-size: .9rem; }
.alert { background: var(--warn-bg); border-left: 4px solid var(--warn); padding: 10px 14px; border-radius: 10px; margin-bottom: 10px; }
.gcal { font-size: .78rem; margin-left: 6px; white-space: nowrap; }
.tips { margin: 0; padding-left: 22px; }
.tips li { margin-bottom: 8px; }

/* tutor */
.chat-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; }
.chat-list { padding: 12px; max-height: calc(100vh - 200px); overflow-y: auto; }
.chat-list li { padding: 6px; border-radius: 8px; align-items: center; }
.chat-list li.on { background: var(--surface-2); box-shadow: 0 0 0 1px var(--accent) inset; }
.chat-list li a { text-decoration: none; color: var(--text); font-size: .9rem; }
.chat-main { display: flex; flex-direction: column; height: calc(100vh - 200px); min-height: 420px; padding: 0; overflow: hidden; }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--side); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.ai p { margin: 0 0 10px; }
.msg.ai p:last-child { margin-bottom: 0; }
.msg.ai h3, .msg.ai h4, .msg.ai h5 { margin: 12px 0 6px; }
.msg.ai ul, .msg.ai ol { margin: 4px 0 10px; padding-left: 22px; }
.msg.ai code { background: var(--surface); padding: 1px 5px; border-radius: 5px; font-size: .88em; }
.msg.ai blockquote { margin: 8px 0; padding: 6px 12px; border-left: 4px solid var(--accent); background: var(--surface); }
.msg .status { color: var(--muted); font-style: italic; font-size: .88rem; }
.msg .status:empty { display: none; }
.codeblock pre { margin: 8px 0; max-height: 320px; }
.codeblock pre code { background: none; padding: 0; }
.chat-form { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-form textarea { min-height: 52px; max-height: 160px; font-family: inherit; font-size: .95rem; resize: vertical; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 560px; }
.chat-empty .logo { margin: 0 auto 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chips .btn { white-space: normal; text-align: left; font-weight: 500; }

/* sala de estudo: sumário da disciplina + PDF da apostila */
.study-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.study-chips .chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; font-size: .85rem; }
.study-chips .chip.on { border-color: var(--accent); background: var(--warn-bg); font-weight: 700; }
.study { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.study-toc { position: sticky; top: 12px; max-height: calc(100vh - 120px); overflow: auto; padding: 14px; }
.study-toc ul { list-style: none; margin: 0; padding: 0; }
.study-toc a { display: flex; gap: 8px; align-items: baseline; padding: 6px 8px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .88rem; }
.study-toc a:hover { background: var(--surface-2); }
.study-toc a.on { background: var(--warn-bg); font-weight: 700; }
.study-toc a.extra { color: var(--muted); font-style: italic; }
.study-toc small { color: var(--muted); white-space: nowrap; }
.study-toc small .ok { color: var(--ok); font-weight: 700; }
.study-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.study-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; }
.study-bar .small { font-size: .8rem; }
.study-topics { flex: 1 1 100%; border-top: 1px solid var(--border); padding-top: 8px; }
.study-pdf { width: 100%; height: calc(100vh - 150px); min-height: 520px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.topics li.has-study { display: flex; gap: 8px; align-items: flex-start; font-size: .92rem; }
.topics li.has-study .study-link { flex: 1; color: var(--text); text-decoration: none; }
.topics li.has-study .study-link:hover { color: var(--accent); text-decoration: underline; }
.topics li.has-study input:checked + .study-link { color: var(--muted); text-decoration: line-through; }
.topics .tag.sec { flex: 0 0 auto; }
.tag.link { text-decoration: none; cursor: pointer; }
.tag.link:hover { border-color: var(--accent); color: var(--text); }
.study-toc > summary { list-style: none; cursor: pointer; }
.study-toc > summary::-webkit-details-marker { display: none; }
.study-toc > summary h2 { margin-bottom: 8px; }
.study-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.study-tabs .btn { text-decoration: none; color: var(--text); }
.study-tabs .btn.on { background: var(--side); border-color: var(--side); color: #fff; }
.study-tabs .tag { margin-left: 4px; }

/* leitor de PDF do celular (pdf.js) */
.study-pdf.pdfjs { display: flex; flex-direction: column; overflow: hidden; }
.pdf-tools { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface); }
.pdf-tools .btn { min-width: 40px; font-size: 1.1rem; }
.pdf-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 8px; }
.pdf-pages { margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.pdf-page { background: #fff; box-shadow: var(--shadow); width: 100%; display: grid; place-items: center; }
.pdf-page:empty::before { content: "Carregando página…"; color: #94a3b8; font-size: .85rem; }
.pdf-page canvas { width: 100%; height: 100%; display: block; }

/* acervo de vídeos e podcasts */
.media-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.media-player { position: sticky; top: 76px; padding: 0; overflow: hidden; }
.media-player > .empty { padding: 60px 20px; }
.media-player video, .media-frame { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; background: #000; }
.media-spotify { display: block; width: 100%; height: 232px; border: 0; }
.media-player audio { display: block; width: calc(100% - 32px); margin: 0 16px 12px; }
.audio-art { display: grid; place-items: center; aspect-ratio: 16 / 6; font-size: 3.2rem; background: linear-gradient(135deg, var(--side), var(--side-2)); margin-bottom: 12px; }
.media-info { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); }
.media-side { display: flex; flex-direction: column; gap: 12px; }
.media-side .card { padding: 14px; }
.media-side summary { cursor: pointer; }
.media-ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.media-item { display: flex; align-items: center; gap: 4px; border-radius: 10px; }
.media-item.on { background: var(--warn-bg); }
.media-open { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; text-align: left; background: none; border: 0; padding: 6px; border-radius: 10px; cursor: pointer; }
.media-open:hover { background: var(--surface-2); }
.media-open img, .media-open .thumb-ico { flex: 0 0 96px; width: 96px; aspect-ratio: 16 / 9; border-radius: 6px; object-fit: cover; }
.media-open .thumb-ico { display: grid; place-items: center; background: var(--surface-2); font-size: 1.4rem; }
.media-open b { display: block; font-size: .88rem; line-height: 1.3; }
.media-open small { font-size: .76rem; }
.media-item.done b { color: var(--muted); }
.install-btn { width: 100%; }

@media (max-width: 1000px) {
  .study { grid-template-columns: minmax(0, 1fr); }
  .study-toc { position: static; max-height: none; }
  .study-toc[open] ul { max-height: 300px; overflow: auto; }
  .study-toc > summary h2::after { content: " ▾"; color: var(--muted); }
  .study-pdf { height: calc(100vh - 120px); height: calc(100dvh - 120px); min-height: 420px; }
  .media-layout { grid-template-columns: minmax(0, 1fr); }
  .media-player { position: static; }
}
@media (max-width: 800px) {
  .topbar .timer { padding: 4px 8px; gap: 6px; }
  .topbar .timer select { display: none; }
  .topbar .timer .timer-clock { font-size: .95rem; }
  .topbar .timer .btn { padding: 4px 8px; font-size: .78rem; }
  .topbar select#plan-select { min-width: 0; flex: 1; font-size: .85rem; }
  .study-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .study-chips .chip { flex: 0 0 auto; }
  .study-bar .row { flex-wrap: wrap; }
  .page-head .btn { font-size: .85rem; }
}

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: -280px; z-index: 20; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  main { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .topbar .today { display: none; }
  .week { grid-template-columns: minmax(0, 1fr); }
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-list { max-height: 220px; }
  .msg { max-width: 100%; }
}
