@font-face{font-family:Montserrat;src:url(../fonts/montserrat-cyrillic.woff2) format('woff2');font-weight:100 900;font-display:swap;unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}
@font-face{font-family:Montserrat;src:url(../fonts/montserrat-latin.woff2) format('woff2');font-weight:100 900;font-display:swap}
:root {
  color-scheme: light;
  font-family: Montserrat, "Segoe UI", sans-serif;
  color: #20283a;
  background: #ffffff;
  font-synthesis: none;
  --blue: #3d57e8;
  --muted: #6e7585;
  --border: #e8e8ed;
  --paper: #ffffff;
}
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button, textarea, input { font: inherit; }
button { color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; opacity: .34; }
button:focus-visible, canvas:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button svg, [data-icon] svg { display: block; width: 19px; height: 19px; }
[hidden] { display: none !important; }
.topbar {
  height: 72px; flex-shrink: 0; display: flex; align-items: center;
  justify-content: space-between; gap: 16px; padding: 0 28px; z-index: 2;
  border-bottom: 1px solid #e8e7e4; background: #fff;
}
.identity, .top-actions { display: flex; align-items: center; gap: 12px; }
.identity { flex: 1; white-space: nowrap; }
.board-brand { --brand-logo-width: 95px; display: inline-flex; align-items: center; gap: 10px; }
.board-brand .nbv-mark { width: var(--brand-logo-width); }
.board-brand-name { display: block; font-size: 26px; line-height: 1.07; letter-spacing: -.65px; font-weight: 720; }
#board-home { text-align: left; border-radius: 10px; padding: 3px 6px; }
#board-home:hover { background: #eef1ff; }
#board-home:has(#pen-brand[data-color]:not([data-color="#000000"])) .board-brand-name {
  -webkit-text-stroke: 1px var(--pen-ink);
  paint-order: stroke fill;
}
.identity small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.logo { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 12px; background: var(--blue); color: white; }
.logo { background: #3153c5; }
.document { position: relative; min-width: 0; }
.document-name { display: flex; align-items: center; max-width: 100%; gap: 8px; font-size: 18px; font-weight: 650; border-radius: 9px; padding: 9px 10px; }
.document-name:hover, .menu button:hover { background: #f5f5fa; }
.title-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 290px; }
.document-name svg { width: 14px; height: 14px; color: var(--muted); }
.menu { position: absolute; top: calc(100% + 9px); left: 50%; transform: translateX(-50%); width: max-content; padding: 5px; }
.menu button { display: flex; align-items: center; gap: 9px; font-size: 13px; width: 100%; padding: 10px; border-radius: 8px; }
.menu button:last-child { color: #ad384e; }
.top-actions { flex: 1; justify-content: flex-end; gap: 19px; }
.save-state { display: inline-flex; align-items: center; gap: 7px; color: #606977; font-size: 12px; white-space: nowrap; }
.save-state span { width: 7px; height: 7px; background: #359b79; border-radius: 50%; }
.save-state[data-state="waiting"] span { background: #d59c47; }
.save-state[data-state="offline"] span { background: #d94f67; }
.share {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 10px;
  border: 1px solid var(--border); border-radius: 9px; font-size: 12px; font-weight: 700;
  color: #465067; font-variant-numeric: tabular-nums;
}
.share:hover { background: #f5f5fa; }
.share svg { width: 17px; height: 17px; }
#copy-status { align-self: center; color: var(--muted); font-size: 12px; }
.export, .primary, .text-form button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 13px;
  background: var(--blue); color: white; border-radius: 9px; font-size: 13px; font-weight: 650; white-space: nowrap;
}
.export:hover, .primary:hover, .text-form button:hover { background: #3048d0; }
.export svg { width: 16px; height: 16px; }
#workspace { position: relative; min-height: 0; flex: 1; overflow: hidden; background-color: var(--paper); }
canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
#input { touch-action: none; cursor: crosshair; }
#input[data-cursor="hand"] { cursor: grab; }
#input[data-cursor="panning"] { cursor: grabbing; }
#input[data-cursor="text"] { cursor: text; }
#input[data-cursor="eraser"] { cursor: cell; }
#input[data-cursor="select"] { cursor: default; }
#input[data-cursor="moving"] { cursor: move; }
#input[data-cursor="nw"], #input[data-cursor="se"] { cursor: nwse-resize; }
#input[data-cursor="ne"], #input[data-cursor="sw"] { cursor: nesw-resize; }
#input:focus-visible { outline-offset: -3px; }
.surface { background: #fff; border: 1px solid var(--border); border-radius: 13px; box-shadow: 0 4px 14px #20283a0c, 0 1px 2px #20283a08; }
.tools, .stylebar, .bottom-left, .bottom-right { position: absolute; }
.tools { top: 20px; left: 20px; display: grid; gap: 3px; padding: 6px; }
.tools button, .zoom button, .help { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 8px; color: #525b70; }
.tools > button, .tools .shape-picker > button { height: clamp(18px, calc((100dvh - 240px) / 13), 39px); }
.tools button:hover:enabled, .zoom button:hover:enabled, .help:hover { background: #f1f2f8; color: #273251; }
.tools button[aria-pressed="true"] { background: #e9edff; color: #334bdb; }
.tools #shapes[data-active] { background: #e9edff; color: #334bdb; }
.shape-picker { position: relative; }
.shape-options { position: absolute; top: 0; left: calc(100% + 12px); z-index: 1; width: max-content; padding: 5px; }
.shape-options button { display: flex; justify-content: flex-start; gap: 9px; width: 100%; height: 35px; padding: 0 10px; font-size: 13px; }
.selection-bar { padding: 5px 7px 5px 12px; font-size: 12px; color: #465067; }
.selection-bar button { width: 31px; height: 31px; border-radius: 7px; display: grid; place-items: center; color: #b33b54; }
.selection-bar button:hover { background: #fff0f3; }
.selection-bar #edit-selected-graph { color: var(--blue); }
.selection-bar #edit-selected-graph:hover { background: #e9edff; }
.divider { display: block; background: #ededf1; }
.tools .divider { height: 1px; margin: 3px 5px; }
.stylebar { left: 50%; top: 20px; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; padding: 6px 8px; }
.stylebar .divider, .zoom .divider { width: 1px; height: 23px; margin: 0 2px; }
.colors { display: flex; align-items: center; gap: 3px; }
.swatch { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 50%; border: 1px solid transparent; }
.swatch::before { content: ""; width: 17px; height: 17px; border-radius: 50%; background: var(--ink); }
.swatch[data-color="#ffffff"]::before { box-shadow: inset 0 0 0 1px #d7dbe5; }
.rainbow-color { width: 28px; height: 28px; flex-shrink: 0; margin: 0 3px; border-radius: 50%; background: conic-gradient(red, #ff0, #0f0, #0ff, #00f, #f0f, red); border: 2px solid white; box-shadow: 0 0 0 1px #ccd3e3; }
.rainbow-color[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--blue); }
.color-panel { position: absolute; z-index: 8; top: 76px; right: 18px; width: min(292px, calc(100% - 32px)); padding: 12px; }
.color-heading { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding-bottom: 9px; }
.color-heading button { font-size: 24px; width: 28px; }
.color-sv { height: 170px; position: relative; touch-action: none; background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), var(--hue); border-radius: 5px; cursor: crosshair; }
#color-marker { position: absolute; width: 10px; height: 10px; transform: translate(-50%, -50%); border: 2px solid white; border-radius: 50%; box-shadow: 0 0 0 1px #0008; pointer-events: none; }
.color-hue-row { display: flex; gap: 12px; align-items: center; margin: 14px 0; }
#color-preview { width: 32px; height: 32px; border-radius: 50%; border: 1px solid #dfe2eb; }
#color-hue { flex: 1; min-width: 0; appearance: none; height: 12px; border-radius: 9px; background: linear-gradient(to right, red, #ff0, #0f0, #0ff, #00f, #f0f, red); }
#color-hue::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #8992a4; background: transparent; cursor: pointer; }
.color-rgb { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.color-rgb label, .color-hex-label { font-size: 11px; color: var(--muted); display: grid; gap: 5px; }
.color-rgb input, #color-hex, .instrument-options input { min-width: 0; width: 100%; padding: 7px; border: 1px solid var(--border); border-radius: 5px; color: #243047; background: white; }
.color-hex-label { grid-template-columns: 38px 1fr; align-items: center; margin-top: 10px; }
.instrument-options { position: absolute; right: 18px; top: 76px; width: 218px; padding: 14px; font-size: 12px; }
.instrument-options p { color: var(--muted); line-height: 1.5; }
.instrument-options label { display: grid; grid-template-columns: 1fr 80px; align-items: center; margin: 8px 0; }
.instrument-options small { color: var(--muted); }
.card-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; }
.card-action { text-align: left; }
.delete-board { color: #b33b54; font-size: 12px; padding: 5px; border-radius: 5px; }
.delete-board:hover { background: #fff0f3; }
.portal-controls { flex-wrap: wrap; }
.swatch:hover { background: #f2f3f9; }
.swatch[aria-pressed="true"] { border-color: var(--ink); }
.bottom-left, .bottom-right { bottom: 20px; display: flex; align-items: center; gap: 13px; }
.bottom-left { left: 20px; }
.bottom-right { right: 20px; }
.zoom { padding: 4px; display: flex; align-items: center; gap: 1px; }
.zoom button, .help { width: 35px; height: 35px; }
.zoom svg, .help svg { width: 17px; height: 17px; }
.zoom #zoom-reset { width: 52px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.snap-grid { display: flex; align-items: center; gap: 5px; padding: 0 7px; font-size: 11px; white-space: nowrap; cursor: pointer; }
.snap-grid input { accent-color: var(--blue); margin: 0; }
.pressure-control { border-left: 1px solid var(--border); }
.help { width: 45px; height: 45px; border-radius: 13px; }
.coordinates, .hint { color: #626c7e; font-size: 11px; }
.coordinates { font-family: Montserrat, "Segoe UI", sans-serif; }
.hint { display: flex; align-items: center; gap: 6px; }
kbd { display: inline-block; border: 1px solid #e1e2ea; border-radius: 5px; background: #fff; padding: 2px 5px; font: inherit; font-weight: 600; color: #465067; }
.text-form { position: absolute; padding: 8px; width: min(290px, 100%); }
.text-form textarea, dialog input { width: 100%; border: 1px solid #dfe2eb; border-radius: 7px; padding: 8px; color: inherit; }
.text-form textarea { resize: vertical; max-height: 35dvh; }
.text-form > div { display: flex; gap: 5px; align-items: center; justify-content: space-between; padding-top: 5px; }
.text-form small { color: var(--muted); font-size: 10px; }
.toast { position: fixed; top: 84px; bottom: auto; left: 50%; transform: translateX(-50%); z-index: 50; padding: 12px 16px; font-size: 13px; line-height: 1.6; width: max-content; max-width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 180px); overflow: auto; box-shadow: 0 8px 32px #20283a20; }
.toast-heading { display:flex; align-items:start; gap:16px; }
#toast-close { flex:none; font-size:24px; line-height:1; padding:2px; }
.toast details { margin-top:10px; }
.toast pre { white-space:pre-wrap; overflow-wrap:anywhere; font-size:11px; user-select:text; }
#toast-copy, #geometry-retry { color:var(--blue); padding:8px 0; text-align:left; }
dialog { position: fixed; padding: 24px; width: min(450px, calc(100% - 28px)); max-height: calc(100dvh - 28px); border: 1px solid var(--border); border-radius: 16px; color: inherit; box-shadow: 0 18px 55px #20283a24; }
dialog::backdrop { background: #1d284a42; }
dialog h2 { margin: 0 0 16px; font-size: 21px; }
dialog p, dialog dl { font-size: 13px; color: #4e586a; }
dialog dl { display: grid; grid-template-columns: 1fr 1.55fr; gap: 12px; margin: 0; }
dialog dt { font-weight: 650; }
dialog dd { margin: 0; line-height: 1.5; }
.close { position: absolute; top: 14px; right: 14px; padding: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 14px; margin-top: 20px; }
.graph-formula, .graph-range label { display: grid; gap: 6px; font-size: 13px; font-weight: 650; }
.graph-hint { line-height: 1.55; }
.graph-range { margin: 12px 0 0; padding: 9px 10px 11px; border: 1px solid var(--border); border-radius: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.graph-range legend { padding: 0 5px; font-size: 12px; color: var(--muted); }
#graph-error { color: #b33b54; }
body[data-role="loading"] > :not(.access-panel), body[data-role="blocked"] > :not(.access-panel) { display: none !important; }
.access-panel { height: 100dvh; display: grid; place-items: center; padding: 20px; }
.access-panel > div { width: min(420px, 100%); padding: 28px; }
.access-panel h1 { margin: 0 0 16px; font-size: 25px; }
.access-panel p { font-size: 14px; line-height: 1.6; color: var(--muted); }
body[data-role="student"] #board-actions, body[data-role="student"] #share,
body[data-role="student"] #boards-dialog, body[data-role="student"] #board-menu svg { display: none !important; }
body[data-role="student"] #board-menu { pointer-events: none; opacity: 1; color: inherit; }
.identity #role-label { display: block; font-size: 10px; }
.access-links { display: flex; gap: 18px; margin-top: 22px; font-size: 13px; }
.access-links a, .access-links button { color: var(--blue); }
body[data-role="auth"] > :not(#auth-panel), body[data-role="portal"] > :not(#portal-panel):not(#portal-create-dialog):not(#portal-delete-dialog):not(#portal-group-dialog):not(#import-dialog) { display: none !important; }
.auth-panel { min-height: 100dvh; overflow-y: auto; display: grid; grid-template-columns: 1fr 440px; align-items: center; gap: 80px; padding: 60px max(6vw, 28px); max-width: 1280px; margin: auto; width: 100%; }
.portal-brand { font-size: 27px; font-weight: 750; letter-spacing: -.8px; }
.auth-intro h1 { font-size: clamp(32px, 4vw, 56px); line-height: 1.15; letter-spacing: -1.5px; margin: 34px 0 22px; }
.auth-intro p { max-width: 420px; color: var(--muted); line-height: 1.8; font-size: 16px; }
.auth-card { padding: 30px; }
.auth-card h2 { margin: 28px 0 8px; font-size: 24px; }
.auth-card > p { margin: 0 0 24px; font-size: 13px; line-height: 1.6; color: var(--muted); }
#portal-create-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 600; }
.portal-controls input { width: 100%; padding: 11px 12px; border: 1px solid #dfe2eb; border-radius: 8px; background: white; color: inherit; }
#auth-submit { padding: 13px; margin-top: 5px; }
.form-error { color: #b33b54 !important; font-size: 13px; line-height: 1.5; margin: 0; }
.portal-panel { height: 100dvh; overflow-y: auto; }
.portal-header { min-height: 80px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px max(4vw, 20px); background: white; border-bottom: 1px solid var(--border); }
.portal-header > div { display: flex; gap: 20px; align-items: center; font-size: 13px; }
#portal-logout, .account-home, .account-logout { color: #465067; font-size: 12px; padding: 8px; border-radius: 8px; }
#portal-logout:hover, .account-home:hover, .account-logout:hover { background: #eef1ff; }
.portal-main { max-width: 1100px; margin: auto; padding: 42px 24px; }
.portal-heading { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 30px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--blue); }
.portal-heading h1 { margin: 10px 0; font-size: 34px; letter-spacing: -.7px; }
.portal-heading p { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0; }
.portal-controls { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.portal-controls input { max-width: 320px; font-size: 13px; }
.portal-tabs { display: flex; gap: 4px; border-radius: 9px; padding: 4px; background: #eceef5; }
.portal-tabs button { padding: 9px 17px; border-radius: 7px; font-size: 13px; }
.portal-tabs button[aria-pressed="true"] { background: white; color: var(--blue); box-shadow: 0 1px 4px #20283a12; }
#portal-status { font-size: 12px; color: var(--muted); margin: 18px 0; min-height: 16px; }
.portal-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.portal-card { background: white; border: 1px solid var(--border); border-radius: 14px; padding: 22px; text-align: left; display: grid; gap: 12px; align-content: start; }
.portal-card.is-openable { position: relative; }
.board-card-link::after { content: ""; position: absolute; inset: 0; border-radius: 14px; }
.portal-card.is-openable .delete-board { position: relative; z-index: 1; }
.portal-card.is-openable:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
.portal-card.is-openable:hover { border-color: #b9c3fa; box-shadow: 0 5px 18px #20283a0a; }
.portal-card strong { font-size: 17px; overflow-wrap: anywhere; }
.portal-card small { font-size: 12px; color: var(--muted); line-height: 1.5; }
.portal-card .card-action { color: var(--blue); font-size: 12px; margin-top: 6px; }
.student-board { text-align: left; padding: 9px 10px; background: #f3f5ff; border-radius: 7px; font-size: 12px; color: var(--blue); overflow-wrap: anywhere; }
.portal-empty { grid-column: 1 / -1; border: 1px dashed #d3d8e9; border-radius: 14px; padding: 48px 24px; text-align: center; color: var(--muted); line-height: 1.7; font-size: 14px; }
.legacy-banner { display: flex; gap: 20px; align-items: center; justify-content: space-between; padding: 20px; border-radius: 12px; background: #eef1ff; margin: 0 0 26px; }
.legacy-banner strong { font-size: 14px; }
.legacy-banner p { font-size: 12px; line-height: 1.5; color: #5f687c; margin: 7px 0 0; }
@media (max-width: 900px) {
  .auth-panel { grid-template-columns: 1fr; gap: 28px; padding: 30px 20px; max-width: 500px; }
  .auth-intro h1 { font-size: 29px; margin: 18px 0 10px; }
  .auth-intro p { font-size: 13px; }
  .auth-card { padding: 22px; }
}
@media (max-width: 680px) {
  .top-actions { gap: 3px; }
  .account-home { font-size: 10px; padding: 4px; max-width: 40px; }
  .account-logout { font-size: 10px; padding: 4px; }
  .portal-main { padding: 25px 16px; }
  .portal-heading, .legacy-banner { align-items: stretch; flex-direction: column; }
  .portal-heading h1 { font-size: 28px; }
  .portal-controls { align-items: stretch; flex-direction: column; gap: 12px; }
  .portal-controls input { max-width: none; }
}
#boards-dialog { width: min(590px, calc(100% - 28px)); }
#boards-heading { padding-right: 24px; }
.boards-hint { line-height: 1.6; margin: -4px 0 18px; }
#boards-status { min-height: 18px; margin: 10px 0; }
#boards-status[data-error="true"] { color: #b33b54; }
#boards-retry { color: var(--blue); padding: 0 0 12px; }
.boards-list { display: grid; gap: 8px; max-height: 36dvh; overflow-y: auto; overscroll-behavior: contain; }
.board-entry { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 11px; }
.board-entry:hover { background: #f5f6fc; border-color: #c4ccfa; }
.board-entry[aria-current="true"] { background: #f1f3ff; border-color: #c4ccfa; }
.board-entry-copy { min-width: 0; flex: 1; }
.board-entry strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
.board-entry small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
.board-entry-tag { color: var(--blue); font-size: 11px; white-space: nowrap; }
.boards-create { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.boards-create label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 8px; }
.boards-create > div { display: flex; gap: 8px; }
.boards-create input { min-width: 0; }
@media (max-width: 480px) {
  .boards-create > div { flex-direction: column; }
  #boards-dialog { padding: 20px; }
}
@media (max-width: 680px) {
  .topbar { height: 60px; padding: 0 12px; gap: 6px; }
  .identity { gap: 6px; }
  .board-brand { --brand-logo-width: 64px; gap: 6px; }
  .board-brand-name { font-size: 20px; }
  #board-home { padding: 2px; }
  .document-name { font-size: 16px; }
  .identity small, .save-state, .export-label, .hint, .coordinates { display: none; }
  .logo { width: 30px; height: 30px; border-radius: 8px; }
  .title-label { max-width: 32vw; }
  .export { padding: 9px; }
  .top-actions { gap: 5px; }
  .share { padding: 7px; gap: 3px; }
  .title-label { max-width: 25vw; }
  .tools { top: 65px; left: 8px; padding: 4px; gap: 2px; }
  .tools button { width: 34px; height: 34px; }
  .stylebar { top: 10px; }
  #stylebar { gap: 4px; padding: 6px; max-width: calc(100vw - 16px); width: max-content; flex-wrap: wrap; justify-content: center; }
  #stylebar .colors { max-width: 100%; }
  .color-panel, .instrument-options { top: 100px; right: 8px; }
  #stylebar .pressure-control { padding: 0 4px; }
  .bottom-left { left: 8px; bottom: 9px; }
  .bottom-right { right: 8px; bottom: 9px; }
  .bottom-left .zoom { flex-wrap: wrap; max-width: calc(100vw - 76px); }
}
@media (max-height: 490px) {
  .tools { top: 10px; }
  .tools button { height: 28px; }
  .tools .divider { margin: 1px 5px; }
  .shape-options { top: auto; bottom: 0; }
}

/* Shared product navigation; board tools retain their own isolated layout. */
.bank-link{color:#4266ec;text-decoration:none;font:600 12px/1.4 Montserrat,'Segoe UI',sans-serif;white-space:nowrap;padding:8px}
.shared-login{display:inline-block;text-decoration:none;text-align:center;padding:12px 18px}
@media (max-width: 700px) {
  .portal-header { flex-wrap: wrap; row-gap: 8px; }
  .portal-header > div { flex-wrap: wrap; gap: 8px; min-width: 0; }
  #portal-account { overflow-wrap: anywhere; }
  .top-actions .bank-link { font-size: 10px; padding: 4px; }
}
@media(max-width:680px){
 .topbar{display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto auto;height:auto;min-height:88px;padding:8px 12px;gap:4px 8px}
 .identity{grid-column:1;grid-row:1;min-width:0;flex:none}
 .document{grid-column:1/-1;grid-row:2;min-width:0;max-width:100%}
 .document-name{width:100%;min-width:0;padding:4px 0;font-size:12px}
 .title-label{max-width:none;flex:1;text-align:left}
 .top-actions{grid-column:2;grid-row:1;min-width:0;gap:3px;flex:none}
 .top-actions .bank-link{font-size:10px;padding:3px}
 .account-home,.account-logout{font-size:10px;padding:4px}
 .menu{left:0;transform:none}
}

/* Navigation preferences and participant viewports are local to each user. */
[data-shortcut] { position: relative; }
[data-shortcut]::after { content: attr(data-shortcut); position: absolute; left: calc(100% + 7px); top: 9px; min-width: 21px; height: 21px; display: grid; place-items: center; border: 1px solid #c6cede; border-radius: 5px; background: white; color: #243047; font: 12px monospace; opacity: 0; pointer-events: none; box-shadow: 0 2px 8px #24304712; }
[data-shortcut]:hover::after, [data-shortcut]:focus-visible::after { opacity: 1; }
#coordinates { padding: 8px 12px; border: 1px solid #dfe3ed; border-radius: 8px; cursor: pointer; color: #475879; font: inherit; font-size: 12px; }
.view-toggle { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.page-jump { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.page-jump label { display: grid; gap: 6px; flex: 1; min-width: 100px; }
.page-jump input { width: 100%; min-width: 0; }
.participants-list { display: grid; gap: 12px; max-height: 55vh; overflow: auto; }
.participant-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 0; border-top: 1px solid #dfe3ed; }
.participant-row strong { flex: 1 1 180px; overflow-wrap: anywhere; }
.participant-row button { border: 1px solid #c6cede; border-radius: 7px; padding: 8px; background: white; color: #243047; cursor: pointer; }
.participant-row button:disabled { opacity: .45; cursor: default; }
.follow-status { position: fixed; top: 86px; left: 50%; transform: translateX(-50%); z-index: 8; padding: 9px 14px; border-radius: 12px; display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px); font-size: 13px; }
.follow-status[hidden] { display: none; }
.follow-status button { border: 0; color: #4266ec; background: transparent; cursor: pointer; }
@media(max-width:680px) { .tools { top: 104px; } .tools > button, .tools .shape-picker > button { height: clamp(18px, calc((100dvh - 340px) / 14), 32px); } [data-shortcut]::after { left: auto; right: 1px; top: 0; min-width: 13px; height: 13px; font-size: 9px; } .follow-status { top: 105px; } }
@media(max-width:680px) {
  .bottom-left { flex-direction: column-reverse; align-items: flex-start; gap: 6px; }
  #coordinates { display: block; max-width: calc(100vw - 76px); padding: 6px 10px; font-size: 11px; }
}
#view-dialog { max-height: calc(100dvh - 40px); overflow-y: auto; }
#view-dialog h3 { font-size: 14px; margin-top: 22px; }
#view-dialog select { max-width: 100%; padding: 9px; border: 1px solid #dce2ef; border-radius: 7px; background: white; color: #243047; }
#view-dialog p, #shared-settings small { font-size: 12px; line-height: 1.6; color: #65718a; }
.background-label { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; }
#board-background { width: 65px; height: 38px; padding: 3px; cursor: pointer; }
#student-access-list label { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; margin: 12px 0; }
#save-board-settings { margin-top: 15px; }
#access-mode-hint { position: absolute; bottom: 76px; right: 20px; color: #65718a; font-size: 12px; pointer-events: none; }
.portal-board-actions { display: flex; flex-wrap: wrap; gap: 10px; }
#portal-import { padding: 10px 15px; border: 1px solid #dce2ef; border-radius: 9px; background: white; color: #4266ec; }
#import-file { max-width: 100%; }
@media(max-width:680px) { #access-mode-hint { bottom: 105px; right: 10px; max-width: calc(100vw - 70px); font-size: 10px; } .bottom-right { gap: 5px; } .help { width: 35px; height: 35px; } .portal-board-actions { justify-content: flex-start; } }
@media(min-width:681px) and (max-width:1000px) {
  .topbar { padding: 0 16px; gap: 8px; }
  .top-actions { gap: 7px; flex: 0; }
  .save-state, .export-label { display: none; }
  .identity { flex: 0; }
  .document { flex: 1; }
  .title-label { max-width: 18vw; }
}
#view-dialog input[type="checkbox"] { width: 16px; min-width: 16px; height: 16px; flex: 0 0 16px; margin: 0; }
#view-dialog .view-toggle { font-size: 14px; }
#import-form label { display: grid; gap: 7px; margin: 12px 0; font-size: 13px; }
/* The drawing dock is centered below the canvas; popovers open above it. */
.board-dock { position:absolute; left:50%; bottom:18px; transform:translateX(-50%); display:flex; flex-direction:column-reverse; align-items:center; gap:8px; width:max-content; max-width:calc(100% - 430px); z-index:5; pointer-events:none; }
.board-dock>.tools,.board-dock>.stylebar { position:static; transform:none; pointer-events:auto; max-width:100%; }
.board-dock>.tools { display:flex; flex-wrap:wrap; justify-content:center; gap:3px; padding:6px; }
.board-dock .tools>button,.board-dock .tools .shape-picker>button { width:36px; height:36px; }
.board-dock .tools>.divider { width:1px; height:24px; margin:6px 3px; }
.board-dock #stylebar { display:flex; flex-wrap:wrap; justify-content:center; gap:6px; width:max-content; }
.board-dock .shape-options { top:auto; bottom:calc(100% + 10px); left:50%; transform:translateX(-50%); z-index:10; }
.board-dock .color-panel,.board-dock .instrument-options { top:auto; bottom:calc(100% + 10px); left:50%; right:auto; transform:translateX(-50%); max-height:calc(100dvh - 260px); overflow:auto; pointer-events:auto; }
.board-dock [data-shortcut]::after { left:50%; right:auto; top:auto; bottom:calc(100% + 5px); transform:translateX(-50%); }
@media(max-width:1150px) { .board-dock { bottom:80px; max-width:calc(100% - 28px); } }
@media(max-width:680px) { .board-dock { bottom:100px; max-width:calc(100% - 16px); } .board-dock .tools>button,.board-dock .tools .shape-picker>button { width:31px; height:31px; } .board-dock #stylebar { padding:6px; } .board-dock .color-panel,.board-dock .instrument-options { max-width:calc(100vw - 24px); } }
@media(min-width:681px) { .bottom-left { flex-direction:column-reverse; align-items:flex-start; gap:6px; } #coordinates { max-width:176px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } }

.eraser-options label { display:flex; align-items:center; gap:8px; font-size:12px; white-space:nowrap; }
.eraser-options select { font:inherit; border:1px solid var(--border); border-radius:7px; background:#fff; padding:6px; }
.eraser-options input { width:130px; accent-color:var(--blue); }
.eraser-options output { min-width:24px; font-variant-numeric:tabular-nums; }
.eraser-options { gap:14px; flex-wrap:wrap; justify-content:center; }
@media(max-width:480px){.eraser-options label{font-size:11px}.eraser-options input{width:95px}.eraser-options{gap:8px}}

/* Geometry library: document previews stay on white paper in either theme. */
#geometry-dialog { width: min(880px, calc(100% - 28px)); padding: 24px; overflow-y: auto; }
.geometry-tabs { display: flex; gap: 6px; padding: 4px; border-radius: 12px; background: var(--panel, #f1f3f9); margin-bottom: 18px; }
.geometry-tabs button { flex: 1; padding: 11px 8px; font-weight: 650; border-radius: 9px; }
.geometry-tabs button[aria-pressed="true"] { background: #3153c5; color: #fff; }
.geometry-filters { display: flex; gap: 10px; }
.geometry-filters input { min-width: 0; flex: 1; }
.geometry-filters select { max-width: 45%; border: 1px solid var(--border); border-radius: 8px; background: var(--panel, #fff); color: inherit; padding: 8px; }
#geometry-status { min-height: 20px; margin: 12px 0; color: var(--muted, #65718a); }
.geometry-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.geometry-card { min-width: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.geometry-insert { display: flex; width: 100%; height: 100%; min-width: 0; flex-direction: column; padding: 0; text-align: left; }
.geometry-insert:hover { background: #3153c512; }
.geometry-insert strong { padding: 12px; line-height: 1.45; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.geometry-preview { display: grid; place-items: center; width: 100%; height: 152px; background: #fff; color: #65718a; padding: 12px; }
.geometry-preview svg { width: 100%; height: 100%; max-height: 128px; }
.geometry-empty { grid-column: 1 / -1; padding: 24px; text-align: center; }
.geometry-card:has(.geometry-remove) .geometry-insert { height: auto; }
.geometry-remove { padding: 6px 12px 12px; font-size: 12px; color: #b63d57; }
#geometry-more { display: block; margin: 18px auto 0; padding: 10px 18px; border: 1px solid var(--border); border-radius: 8px; }
#geometry-save-form { padding: 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; }
#geometry-save-form label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 9px; }
#geometry-save-form small { display: inline-block; margin-left: 8px; font-weight: 400; }
#geometry-save-form > div { display: flex; gap: 8px; }
#geometry-save-button { padding: 8px 14px; background: #3153c5; color: #fff; border-radius: 8px; }
@media (max-width: 600px) {
  #geometry-dialog { padding: 18px 14px; }
  #geometry-heading { font-size: 19px; padding-right: 24px; }
  .geometry-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .geometry-preview { height: 120px; padding: 8px; }
  .geometry-tabs button { font-size: 11px; padding: 10px 3px; }
  .geometry-filters { flex-wrap: wrap; }
  .geometry-filters select { max-width: 100%; width: 100%; }
  #geometry-save-form > div { flex-direction: column; }
}

.graph-curve { display: flex; gap: 8px; margin-bottom: 8px; }
.graph-curve input[name="formula"] { flex: 1; min-width: 0; }
.graph-curve input[type="color"] { flex: 0 0 44px; width: 44px; height: 38px; padding: 3px; }
.graph-curve button, #graph-add { color: var(--blue); padding: 6px; }
#text-form label { display: flex; gap: 6px; align-items: center; font-size: 12px; }
#text-size { width: 60px; border: 1px solid var(--border); padding: 4px; border-radius: 6px; }
#task-panel {
  position: absolute; z-index: 12; right: 12px; top: 12px;
  width: min(420px, calc(100% - 24px)); max-height: calc(100% - 24px);
  display: flex; flex-direction: column; gap: 9px; padding: 15px;
  background: #fff; font-size: 13px;
}
.task-picker-header, .task-picker-pages { display: flex; align-items: center; justify-content: space-between; }
#task-close { font-size: 23px; padding: 0 5px; }
#task-panel label { display: grid; gap: 5px; color: #53617e; font-size: 12px; font-weight: 700; min-width: 0; }
.board-field {
  width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid #dce3f3;
  border-radius: 9px; background: #f7f9ff; color: #243047; font: inherit;
}
select.board-field {
  appearance: none; padding-right: 29px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%2353617e' stroke-width='1.5'/%3E%3C/svg%3E");
  background-position: right 10px center; background-repeat: no-repeat;
}
.board-field:hover { border-color: #aabbee; }
.board-field:focus-visible, .task-picker-entry button:focus-visible { outline: 2px solid #3153c5; outline-offset: 1px; }
.pen-width { display: flex; align-items: center; gap: 5px; color: #52607a; }
.pen-width-mark { display: block; width: 15px; height: var(--pen-width, 4px); border-radius: 8px; background: currentColor; }
.pen-width .board-field { width: 53px; height: 31px; padding: 5px 21px 5px 6px; background-position: right 6px center; background-size: 9px; font-size: 12px; }
.pen-brand { display: grid; place-items: center; height: auto; border-radius: 9px; flex: none; }
#task-status { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
#task-list { overflow-y: auto; display: grid; gap: 8px; }
.task-picker-entry { display: grid; gap: 7px; padding: 11px; border: 1px solid #e5eaf6; border-radius: 10px; background: #fff; }
.task-picker-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; color: #53617e; font-size: 12px; }
#participants-dialog #share { margin-top: 12px; }
.task-picker-meta strong { color: #3153c5; }
.task-condition-preview { overflow-wrap: anywhere; margin-top: 7px; }
.task-condition-preview img, .task-condition-preview svg:not(.katex svg) { display: block; max-width: 100%; height: auto; }
.task-condition-preview pre, .task-condition-preview table { display: block; overflow: auto; max-width: 100%; }
.task-condition-preview td, .task-condition-preview th { border: 1px solid #dce3f3; padding: 3px; }
.task-picker-add, .task-picker-random { justify-self: start; align-self: start; padding: 6px 10px; border-radius: 7px; font-size: 12px; font-weight: 650; color: #3153c5; background: #eef2ff; }
.task-picker-add:hover, .task-picker-random:hover { background: #e0e8ff; }
.task-picker-pages button { color: var(--blue); padding: 6px; }
.board-task-capture { position: fixed; left: 0; top: 0; z-index: -1; width: 720px; padding: 24px; color: #20283a; background: white; font: 17px/1.45 Montserrat, Arial, sans-serif; }
.board-task-capture > strong { display: block; margin-bottom: 12px; }
.board-task-capture table { border-collapse: collapse; max-width: 100%; font-size: 15px; }
.board-task-capture td, .board-task-capture th { border: 1px solid #788397; padding: 5px 8px; }
.board-task-capture img, .board-task-capture svg:not(.katex svg) { display: block; max-width: 100%; max-height: 900px; object-fit: contain; margin: 8px 0; }
.board-task-capture pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.board-auth-links { display:flex; flex-wrap:wrap; gap:12px 20px; align-items:center; }
.board-auth-links a:not(.primary) { color:var(--blue); }

.portal-archive { margin-left: auto; }
.portal-tabs { flex: 1; }
.portal-board-group { grid-column: 1 / -1; padding: 12px; border: 1px dashed var(--border); border-radius: 14px; }
.portal-board-group h2 { font-size: 1rem; margin: 0 0 10px; }
.portal-board-group.drop-target { background: #edf1ff; border-color: #3153c5; }
.portal-group-cards { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(240px,100%),1fr)); gap: 12px; min-height: 26px; }
.portal-card[draggable="true"] { cursor: grab; user-select: none; }
.portal-card[draggable="true"]:active { cursor: grabbing; }
.portal-card[draggable="true"] .board-card-link::after { pointer-events: none; }
.portal-archive svg { width: 17px; height: 17px; vertical-align: middle; }
.board-view-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 12px; }
.task-reveal { margin-left: auto; }
.task-solution { border-top: 1px solid var(--border); padding-top: 12px; }
.task-picker-entry .task-condition-preview { margin-top: 0; }
.task-condition-preview svg:not(.katex svg) { width: 100%; max-height: 380px; }
.board-task-capture table { overflow-wrap: anywhere; }
.board-task-capture pre { overflow-wrap: anywhere; }
#pen-brand { background: transparent; width: 99px; }
#pen-brand.light-ink { background: #e0e9fa; }
.top-actions #save-state { display: inline-grid; place-items: center; width: 20px; height: 28px; }
#task-open { padding-inline: 17px; }
@media(max-width:680px){
  .topbar { grid-template-columns: minmax(0,1fr) auto auto auto; column-gap: 5px; }
  .top-actions { display: contents; }
  #task-open { grid-column: 2; grid-row: 1; padding-inline: 7px; }
  #participants { grid-column: 3; grid-row: 1; padding: 6px; }
  #save-state { grid-column: 4; grid-row: 1; }
  .document { grid-column: 1/-1; }
  #pen-brand { width: 66px; }
}
@media (max-width: 460px) {
  .topbar { grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto auto; }
  .identity { grid-column: 1 / 3; }
  .document { grid-column: 1 / 2; grid-row: 2; }
  #task-open { grid-column: 2 / -1; grid-row: 2; justify-self: end; font-size: 11px; padding-inline: 8px; }
  .top-actions #save-state { width: 12px; }
}
@media (prefers-reduced-motion: no-preference) {
  button, a, .portal-card { transition: background-color .16s ease, border-color .16s ease, opacity .16s ease, box-shadow .16s ease; }
  #task-panel:not([hidden]), dialog[open], .portal-board-group { animation: board-enter .16s ease-out; }
  @keyframes board-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
}

/* Shared board controls */
#chat-open { position: relative; display: inline-grid; place-items: center; }
#chat-open > [data-icon] { display: grid; }
#chat-unread { position: absolute; top: -4px; right: -4px; min-width: 16px; padding: 1px 3px; border-radius: 10px; background: var(--blue, #3153c5); color: white; font-size: 10px; line-height: 14px; text-align: center; }
#dock-toggle[aria-expanded="false"] { color: #3153c5; background: #eaf0ff; }
#chat-dialog { width: min(470px, calc(100vw - 24px)); }
#chat-messages { display: grid; gap: 10px; min-height: min(16vh, 100px); max-height: min(45dvh, 370px); overflow: auto; padding: 0 5px 0 0; margin: 12px 0; list-style: none; }
#chat-messages li { min-width: 0; padding: 9px 12px; border-radius: 10px; background: #f2f5fb; }
#chat-messages strong { font-size: 12px; color: #405476; overflow-wrap: anywhere; }
#chat-messages p { margin: 4px 0 0; font-size: 14px; color: #243047; white-space: pre-wrap; overflow-wrap: anywhere; }
#chat-messages a { color: #2849ad; text-decoration: underline; }
#chat-status { font-size: 12px; color: #526481; }
#chat-status:empty { display: none; }
#chat-form { display: flex; gap: 8px; align-items: flex-end; }
#chat-form textarea { flex: 1; min-width: 0; resize: vertical; font: inherit; }
@media (max-width: 420px) {
  .bottom-right .help { width: 30px; height: 34px; }
  .bottom-left .zoom button { width: 31px; }
  .bottom-left .zoom #zoom-reset { width: 44px; }
}
