/* Kaluka — one stylesheet. Colours are tokens; dark mode redefines them. */
:root {
  --brand: #24305E; --brand-2: #3A4C93; --accent: #F7B538; --accent-ink: #3B2A00;
  --bg: #F5F6FA; --surface: #FFFFFF; --surface-2: #EEF0F6; --line: #E1E4EE;
  --ink: #161B2E; --ink-2: #4A5170; --ink-3: #7C83A0;
  --ok: #1E8E5A; --ok-bg: #E3F5EC; --warn: #B26A00; --warn-bg: #FFF2DB; --bad: #C23B3B; --bad-bg: #FBE6E6; --info: #2C64C9; --info-bg: #E5EEFC;
  --bubble-me: #DCE6FF; --bubble-them: #FFFFFF; --chat-bg: #ECEFF6;
  --radius: 14px; --radius-sm: 10px; --shadow: 0 1px 2px rgba(22,27,46,.06), 0 4px 16px rgba(22,27,46,.06);
  --nav-h: 64px; --head-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #8EA2F5; --brand-2: #B4C1FF; --accent: #F7B538; --accent-ink: #2B1F00;
    --bg: #0E1325; --surface: #161C33; --surface-2: #1E2542; --line: #2A3254;
    --ink: #EDF0FA; --ink-2: #B5BCD6; --ink-3: #8189A8;
    --ok: #4CC38A; --ok-bg: #12301F; --warn: #F0B54A; --warn-bg: #33270F; --bad: #F07171; --bad-bg: #3A1717; --info: #7FA8F5; --info-bg: #15264A;
    --bubble-me: #2A3A78; --bubble-them: #1E2542; --chat-bg: #0B1020;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #8EA2F5; --brand-2: #B4C1FF; --accent: #F7B538; --accent-ink: #2B1F00;
  --bg: #0E1325; --surface: #161C33; --surface-2: #1E2542; --line: #2A3254;
  --ink: #EDF0FA; --ink-2: #B5BCD6; --ink-3: #8189A8;
  --ok: #4CC38A; --ok-bg: #12301F; --warn: #F0B54A; --warn-bg: #33270F; --bad: #F07171; --bad-bg: #3A1717; --info: #7FA8F5; --info-bg: #15264A;
  --bubble-me: #2A3A78; --bubble-them: #1E2542; --chat-bg: #0B1020;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--ink-3); } .small { font-size: 13px; } .tiny { font-size: 12px; } .strong { font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; } .stack.tight { gap: 6px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.center { text-align: center; }

/* Boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.logo-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 19px; position: relative; }
:root[data-theme="dark"] .logo-mark, .logo-mark { background: #24305E; }
.logo-mark::after { content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); right: 5px; bottom: 5px; }
.logo-mark.big { width: 72px; height: 72px; border-radius: 20px; font-size: 38px; }
.logo-mark.big::after { width: 14px; height: 14px; right: 10px; bottom: 10px; }

/* Shell: header + content + nav */
.shell { min-height: 100vh; display: flex; }
.side { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.head { position: sticky; top: 0; z-index: 20; height: calc(var(--head-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 4px; }
.head .title { flex: 1; min-width: 0; padding: 0 6px; }
.head .title h1 { font-size: 18px; } .head .title .sub { font-size: 12px; color: var(--ink-3); }
.content { flex: 1; padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 980px; width: 100%; margin: 0 auto; }
.content.full { padding: 0; max-width: none; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); display: flex; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--ink-3); font-size: 11px; position: relative; }
.nav a.on { color: var(--brand); font-weight: 600; }
.nav a .badge { position: absolute; top: 6px; left: calc(50% + 6px); }
@media (min-width: 900px) {
  .nav { display: none; }
  .side { display: flex; flex-direction: column; width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; padding: 16px 12px; gap: 4px; }
  .side .brand { padding: 4px 8px 16px; }
  .side a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; position: relative; }
  .side a:hover { background: var(--surface-2); }
  .side a.on { background: var(--surface-2); color: var(--brand); font-weight: 600; }
  .side a .badge { margin-left: auto; }
  .side .spacer { flex: 1; }
  .content { padding-bottom: 32px; }
}

/* Icons and buttons */
.ico { width: 22px; height: 22px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.ico.sm { width: 18px; height: 18px; } .ico.xs { width: 14px; height: 14px; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); flex-shrink: 0; position: relative; }
.iconbtn:hover { background: var(--surface-2); }
.iconbtn .badge { position: absolute; top: 4px; right: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent; background: var(--surface-2); color: var(--ink); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--brand); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #0E1325; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #0E1325; } }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn .ico { width: 18px; height: 18px; }
.linkbtn { background: none; border: 0; color: var(--brand); font-weight: 600; cursor: pointer; padding: 0; }

body.in-chat .nav { display: none; }
body.in-chat #toasts { bottom: 90px; }

/* Cards, lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card h2 { margin-bottom: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--ink); cursor: pointer; background: transparent; border-left: 0; border-right: 0; border-top: 0; text-align: left; width: 100%; }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--surface-2); }
.item .meta { margin-left: auto; text-align: right; flex-shrink: 0; }
.section-title { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin: 20px 4px 8px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; color: var(--ink); cursor: pointer; }
.tile:hover { border-color: var(--brand-2); }
.tile .big { font-size: 26px; font-weight: 700; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; }
@media (max-width: 480px) { .kv { grid-template-columns: 110px 1fr; } }

/* Avatars, chips, badges */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center; font-weight: 700; font-size: 15px; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; } .avatar.lg { width: 72px; height: 72px; font-size: 26px; } .avatar.xl { width: 96px; height: 96px; font-size: 34px; }
.avatar.c0 { background: #E4E9FF; color: #2D3D8F; } .avatar.c1 { background: #FFEBCF; color: #8A5300; } .avatar.c2 { background: #DDF3E8; color: #1B6E47; }
.avatar.c3 { background: #FBE0E6; color: #9A2C48; } .avatar.c4 { background: #E5E1FA; color: #4E3A9E; } .avatar.c5 { background: #DCF0F6; color: #1E6479; }
:root[data-theme="dark"] .avatar[class*=" c"] { filter: saturate(.8) brightness(.85); }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.info { background: var(--info-bg); color: var(--info); }
.chip.brand { background: var(--brand); color: #fff; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.badge.ok { background: var(--ok); }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin: 0 -16px 16px; padding: 0 12px; position: sticky; top: calc(var(--head-h) + env(safe-area-inset-top)); background: var(--bg); z-index: 10; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; padding: 12px 10px; color: var(--ink-3); font-weight: 600; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.input, select.input, textarea.input { width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); outline: none; }
textarea.input { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; }
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 20%, transparent); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .form-row { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.search { position: relative; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 18px; height: 18px; }
.search .input { padding-left: 38px; }

/* Sheet / modal */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10,14,30,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); animation: up .2s; }
.sheet .sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
@media (min-width: 640px) { .overlay { align-items: center; } .sheet { border-radius: 20px; } }
.menu { display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: 14px; padding: 13px 6px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 10px; font-size: 15px; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--bad); }
@keyframes fade { from { opacity: 0; } } @keyframes up { from { transform: translateY(30px); opacity: .6; } }

/* Toasts */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100% - 32px); max-width: 420px; }
.toast { background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); animation: up .2s; pointer-events: auto; }
.toast.bad { background: var(--bad); color: #fff; }

/* Empty, loading */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty .ico { width: 44px; height: 44px; margin-bottom: 8px; opacity: .6; }
.empty h3 { color: var(--ink-2); margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; height: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 14px; background: var(--info-bg); color: var(--info); }
.banner.warn { background: var(--warn-bg); color: var(--warn); } .banner.ok { background: var(--ok-bg); color: var(--ok); } .banner.bad { background: var(--bad-bg); color: var(--bad); }

/* Sign-in */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 20px; gap: 22px; }
.auth .card { width: 100%; max-width: 400px; padding: 24px; }
.auth .lang { position: absolute; top: 16px; right: 16px; }
.code-input { letter-spacing: .5em; font-size: 24px; text-align: center; font-weight: 700; }
.dev-code { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 13px; }

/* Student header */
.profile-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.profile-head .info { min-width: 0; }
.profile-head h1 { font-size: 21px; }
.family { display: flex; flex-direction: column; gap: 8px; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; background: var(--surface-2); color: var(--ink); }
.person .who { min-width: 0; flex: 1; }
.vis { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.vis.parents { color: var(--ok); } .vis.staff { color: var(--info); } .vis.restricted { color: var(--bad); }

/* Notes, carnet, timeline */
.entry { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.entry .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); }
.entry .body { white-space: pre-wrap; word-wrap: break-word; }
.entry.corrected { opacity: .55; }
.entry.corrected .body { text-decoration: line-through; }
.carnet-paper { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.sig { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ok); font-weight: 600; }
.timeline { position: relative; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl { position: relative; }
.tl::before { content: ""; position: absolute; left: -20px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand-2); }
.tl.bad::before { border-color: var(--bad); } .tl.ok::before { border-color: var(--ok); } .tl.warn::before { border-color: var(--warn); }

/* Roll call */
.roll { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.roll:last-child { border-bottom: 0; }
.roll .marks { display: flex; gap: 4px; margin-left: auto; }
.roll .marks button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; color: var(--ink-3); }
.roll .marks button.on.present { background: var(--ok); border-color: var(--ok); color: #fff; }
.roll .marks button.on.absent { background: var(--bad); border-color: var(--bad); color: #fff; }
.roll .marks button.on.late { background: var(--warn); border-color: var(--warn); color: #fff; }
.roll .marks button.on.excused { background: var(--info); border-color: var(--info); color: #fff; }
.sticky-bar { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); z-index: 5; }
@media (min-width: 900px) { .sticky-bar { bottom: 12px; } }

/* Gradebook */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-height: 70vh; }
table.grid-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
.grid-table th, .grid-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: center; }
.grid-table th { position: sticky; top: 0; background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--ink-2); z-index: 2; }
.grid-table th:first-child, .grid-table td:first-child { position: sticky; left: 0; background: var(--surface); text-align: left; z-index: 1; min-width: 160px; }
.grid-table th:first-child { z-index: 3; background: var(--surface-2); }
.grid-table input { width: 64px; height: 34px; text-align: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.grid-table input:focus { outline: 2px solid var(--brand-2); }
.grid-table input.bad { border-color: var(--bad); background: var(--bad-bg); }
.grid-table .total { font-weight: 700; }

/* Chat */
.chat-page { display: flex; flex-direction: column; height: calc(100vh - var(--head-h) - env(safe-area-inset-top)); height: calc(100dvh - var(--head-h) - env(safe-area-inset-top)); background: var(--chat-bg); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; }
.day-sep { align-self: center; background: var(--surface); color: var(--ink-3); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 8px; margin: 10px 0; box-shadow: var(--shadow); }
.msg { display: flex; flex-direction: column; max-width: min(78%, 560px); align-self: flex-start; margin-top: 2px; position: relative; }
.msg.me { align-self: flex-end; }
.msg.first { margin-top: 8px; }
.bubble { background: var(--bubble-them); border-radius: 14px; padding: 7px 10px 6px; box-shadow: 0 1px 1px rgba(0,0,0,.06); position: relative; word-wrap: break-word; overflow-wrap: anywhere; cursor: default; user-select: text; }
.msg.me .bubble { background: var(--bubble-me); }
.msg.first:not(.me) .bubble { border-top-left-radius: 4px; } .msg.first.me .bubble { border-top-right-radius: 4px; }
.bubble .sender { font-size: 12.5px; font-weight: 700; margin-bottom: 2px; color: var(--brand-2); }
.bubble .sender .role { font-weight: 500; color: var(--ink-3); }
.bubble .text { white-space: pre-wrap; }
.bubble .foot { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11px; color: var(--ink-3); margin-top: 2px; float: right; margin-left: 10px; position: relative; top: 4px; }
.bubble .foot .ico { width: 15px; height: 15px; }
.bubble .foot .read { color: #3C8DFF; }
.bubble .deleted { font-style: italic; color: var(--ink-3); }
.bubble .fwd { font-size: 12px; color: var(--ink-3); font-style: italic; display: flex; align-items: center; gap: 4px; }
.bubble .quote { border-left: 3px solid var(--brand-2); background: color-mix(in srgb, var(--ink) 5%, transparent); padding: 5px 8px; border-radius: 6px; margin-bottom: 5px; font-size: 13px; cursor: pointer; }
.bubble .quote b { color: var(--brand-2); display: block; font-size: 12px; }
.bubble img.photo { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; margin-bottom: 4px; cursor: zoom-in; min-width: 160px; min-height: 80px; background: var(--surface-2); object-fit: cover; }
.bubble .file { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink); margin-bottom: 4px; min-width: 200px; cursor: pointer; }
.bubble audio { width: 240px; max-width: 100%; height: 36px; margin-bottom: 2px; }
.reacts { display: flex; gap: 4px; margin-top: -6px; padding: 0 8px; z-index: 1; flex-wrap: wrap; }
.msg.me .reacts { justify-content: flex-end; }
.react { background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 1px 7px; font-size: 13px; cursor: pointer; box-shadow: var(--shadow); }
.react.mine { border-color: var(--brand-2); background: var(--info-bg); }
.sys { align-self: center; background: var(--warn-bg); color: var(--warn); font-size: 13px; padding: 6px 12px; border-radius: 10px; margin: 8px 0; max-width: 90%; text-align: center; }
.poll { min-width: 240px; display: flex; flex-direction: column; gap: 8px; }
.poll .q { font-weight: 700; }
.poll .opt { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; overflow: hidden; background: var(--surface); display: flex; gap: 8px; align-items: center; }
.poll .opt .bar { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--brand-2) 18%, transparent); z-index: 0; transition: width .3s; }
.poll .opt > *:not(.bar) { position: relative; z-index: 1; }
.poll .opt.mine { border-color: var(--brand-2); }
.poll .opt .n { margin-left: auto; font-weight: 700; font-size: 13px; }
.ack { margin-top: 6px; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 22px; padding: 10px 16px; max-height: 140px; min-height: 44px; background: var(--bg); outline: none; line-height: 1.35; }
.composer .send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
:root[data-theme="dark"] .composer .send { color: #0E1325; }
.composer .send.rec { background: var(--bad); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.reply-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border-top: 1px solid var(--line); font-size: 13px; }
.reply-bar .q { border-left: 3px solid var(--brand-2); padding-left: 8px; flex: 1; min-width: 0; }
.pin-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.typing { font-size: 12px; color: var(--ok); }
.chat-item .last { font-size: 13.5px; color: var(--ink-3); }
.chat-item.unread .last { color: var(--ink); font-weight: 600; }
.quick-reacts { display: flex; gap: 6px; justify-content: space-around; padding: 4px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.quick-reacts button { font-size: 26px; background: none; border: 0; cursor: pointer; border-radius: 50%; width: 46px; height: 46px; }
.quick-reacts button:hover, .quick-reacts button.on { background: var(--surface-2); }
.photo-view { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 150; display: grid; place-items: center; }
.photo-view img { max-width: 96vw; max-height: 92vh; }
.highlight .bubble { animation: flash 1.2s; }
@keyframes flash { 30% { box-shadow: 0 0 0 3px var(--accent); } }

/* Report card (screen + print) */
.report { background: #fff; color: #111; border-radius: 6px; padding: 28px; max-width: 800px; margin: 0 auto; box-shadow: var(--shadow); font-size: 14px; }
.report .r-head { display: flex; align-items: center; gap: 16px; border-bottom: 3px double #24305E; padding-bottom: 12px; margin-bottom: 14px; }
.report .r-head h1 { font-size: 22px; color: #24305E; }
.report table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.report th, .report td { border: 1px solid #c9cddc; padding: 6px 8px; text-align: center; }
.report th { background: #EEF0F6; font-size: 12px; }
.report td:first-child, .report th:first-child { text-align: left; }
.report .r-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; margin-bottom: 8px; }
.report .r-box { border: 1px solid #c9cddc; border-radius: 6px; padding: 10px; margin-top: 10px; }
.report .r-box b { display: block; font-size: 12px; color: #555; margin-bottom: 4px; }
@media print {
  body { background: #fff; }
  .side, .nav, .head, .no-print, #toasts { display: none !important; }
  .content { padding: 0; max-width: none; }
  .report { box-shadow: none; padding: 0; }
}

/* Online test copy banner */
.test-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 300; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; text-align: center; padding: calc(3px + env(safe-area-inset-top)) 8px 3px; pointer-events: none; }
body.test-copy .head, body.test-copy .auth { margin-top: 22px; }
body.test-copy .head { top: 22px; }
@media (min-width: 900px) { body.test-copy .side { top: 22px; height: calc(100vh - 22px); } }
body.test-copy .auth .lang { top: 34px; }
