* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "Segoe UI", sans-serif; color: #414447; background: #f2f2f2; }
main:not(.studio) { max-width: 64rem; margin: 3rem auto; padding: 1rem; }
input, select, button { font: inherit; }
button { cursor: pointer; }
.studio { --top: clamp(52px, 5vw, 84px); --side: clamp(44px, 4.7vw, 78px); position: relative; height: 100dvh; overflow: hidden; }
.studio { --pages-width: clamp(162px, 24vw, 300px); }
.toolbar { position: absolute; inset: 0 0 auto var(--pages-width); display: flex; height: var(--top); overflow-x: auto; scrollbar-width: thin; }
.group { display: flex; align-items: stretch; padding: 0 4px; border-right: 1px solid #ddd; }
.studio button { border: 0; background: transparent; color: inherit; display: inline-grid; place-items: center; padding: 0; }
.toolbar button { width: clamp(44px, 5.1vw, 88px); flex: none; }
.studio button:hover { background: #e7e7e7; }
.studio button[aria-pressed=true] { background: #d9d9d9; }
.studio button:disabled { opacity: .35; cursor: default; }
.studio button:focus-visible { outline: 2px solid #538626; outline-offset: -3px; }
.studio button svg { width: clamp(21px, 2vw, 33px); height: auto; aspect-ratio: 1; fill: none; stroke: currentColor; stroke-width: 1.45; stroke-linecap: round; stroke-linejoin: round; }
.rail { position: absolute; right: 0; top: var(--top); width: var(--side); display: grid; }
.rail button { height: var(--side); }
.viewport { position: absolute; inset: var(--top) var(--side) 12px 5px; container-type: size; overflow: auto; scrollbar-width: thin; border: 1px solid #8dcc52; border-radius: clamp(15px, 1.8vw, 32px); background: white; }
.paper { position: relative; width: 100%; height: 100%; background: white; }
.paper > svg { display: block; width: 100%; height: 100%; }
.input { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }
.input { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.input > * { pointer-events: none; }
.paste-control { position: relative; display: inline-flex; }
#paste-field { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; resize: none; font-size: 16px; }
.paste-control:focus-within { outline: 2px solid #538626; outline-offset: -3px; }
.cursor-layer { position: absolute; inset: 0; pointer-events: none; }
polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pages { position: absolute; top: 0; left: 0; width: var(--pages-width); height: var(--top); display: grid; grid-template-columns: 36px minmax(0,1fr) 36px; align-items: center; border-right: 1px solid #ddd; }
.pages button { height: 100%; }
.pages .page-picker { display: flex; justify-content: center; align-items: center; gap: 3px; min-width: 0; }
.page-picker span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.page-picker svg { flex: none; }
.pages button svg { width: 16px; }
.panel, .caption, .messages span:not(:empty) { padding: 12px; border: 1px solid #ddd; border-radius: 10px; background: white; box-shadow: 0 4px 18px #0001; }
.panel { position: fixed; inset: calc(var(--top) + 6px) auto auto 8px; margin: 0; max-width: calc(100vw - 16px); }
#settings { inset: calc(var(--top) + var(--side)) calc(var(--side) + 6px) auto auto; }
.panel label { display: flex; align-items: center; gap: 8px; }
.panel label + label { margin-top: 8px; }
#page-panel { width: min(310px, calc(100vw - 16px)); }
#page-panel header, .page-row, #page-panel form { display: flex; align-items: center; gap: 4px; }
#page-panel header { justify-content: space-between; border-bottom: 1px solid #ddd; }
#page-panel input { min-width: 0; flex: 1; padding: 6px; font-size: 16px; }
#page-panel button { min-width: 44px; min-height: 44px; padding: 6px 10px; border-radius: 5px; }
.page-list { list-style: none; padding: 0; margin: 0; max-height: min(60dvh, 32rem); overflow-y: auto; }
#page-panel .page-link, #page-panel .row-actions button { display: flex; align-items: center; gap: 8px; text-align: left; }
.page-link { flex: 1; justify-content: space-between; overflow-wrap: anywhere; }
.page-link[aria-current=page] { background: #eef4e9; }
.page-link svg { flex: none; }
.row-more { font-size: 22px; }
.row-actions { display: grid; padding-left: 10px; border-left: 2px solid #ddd; }
#page-panel button svg { width: 20px; }
#create-page label { align-items: flex-start; flex-direction: column; }
#create-page input { width: min(260px, 72vw); padding: 8px; font-size: 16px; }
#create-page button { width: 44px; height: 44px; margin-top: 4px; }
#create-page output { display: block; }
#pen-smoothing { display: block; width: 100%; min-height: 40px; margin: 0; }
#smoothing-value { margin-left: auto; font-variant-numeric: tabular-nums; }
#grid-calibration { margin-top: 12px; max-width: 260px; }
#grid-calibration summary { cursor: pointer; }
#ruler-reference { width: 160px; max-width: 100%; height: 12px; border-inline: 1px solid; background: linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat; margin: 16px 0; }
#ruler-length { width: 6em; }
#grid-calibration button { margin: 8px 0; padding: 6px 12px; border: 1px solid #ccc; border-radius: 5px; }
#ruler-result { display: block; }
#share input { width: min(48vw, 360px); }
.caption, .messages { position: absolute; z-index: 2; left: 15px; }
.caption { top: calc(var(--top) + 8px); }
.messages { bottom: 60px; pointer-events: none; }
.paper::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image: linear-gradient(to right, #85a0b599 1px, transparent 1px),
                      linear-gradient(to bottom, #85a0b599 1px, transparent 1px);
    background-size: var(--sheet-size); background-position: var(--sheet-origin);
}
#print-sheets { display: none; }
.paper.with-grid::after {
    background-image: linear-gradient(to right, #6989a6aa 1px, transparent 1px),
                      linear-gradient(to bottom, #6989a6aa 1px, transparent 1px),
                      linear-gradient(to right, #8aa5bb55 1px, transparent 1px),
                      linear-gradient(to bottom, #8aa5bb55 1px, transparent 1px);
    background-size: var(--sheet-size), var(--sheet-size),
                     var(--cell-size) var(--cell-size), var(--cell-size) var(--cell-size);
}
#zoom-in, #zoom-out { font-size: 24px; }
#zoom-reset { font-size: 12px; font-variant-numeric: tabular-nums; height: 28px; }
.rail { max-height: calc(100dvh - var(--top)); overflow-y: auto; }
@media print {
    @page { size: A4 landscape; margin: 0; }
    body { margin: 0; background: white; }
    .studio { position: fixed; visibility: hidden; }
    #print-sheets { display: block; }
    #print-sheets > svg { display: block; width: 297mm; height: 210mm; overflow: hidden; break-after: page; }
    #print-sheets > svg:last-child { break-after: auto; }
}
.shape-menu { width: max-content; max-height: calc(100dvh - var(--top) - 12px); overflow-y: auto; padding: 5px; }
.shape-menu button { display: block; width: 100%; padding: 9px 12px; text-align: left; border-radius: 5px; }
#polygon-actions button { display: inline-block; padding: 5px 8px; border: 1px solid #ccc; border-radius: 5px; }
#polygon-actions { max-width: calc(100vw - var(--side) - 20px); }
#sides, #free-count { width: 4rem; }
.selection-overlay { pointer-events: none; }
.selection-overlay rect { fill: #3273c810; stroke: #3273c8; stroke-width: 1.5; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
.selection-overlay .resize-handle { fill: white; stroke-dasharray: none; }
.selection-overlay line, .selection-overlay .rotate-handle { fill: #3273c8; stroke: #3273c8; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
#selection-actions button { display: inline-block; padding: 5px 9px; border: 1px solid #ccc; border-radius: 5px; }

.vertex-handles circle { fill: white; stroke: #3273c8; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.vertex-handles .chosen { fill: #3273c8; }
.page-link small { display: block; font-size: 12px; color: #667; }
#page-panel .board-limits form { display: grid; }
#page-panel .board-limits label { display: flex; justify-content: space-between; }
#page-panel .board-limits input { max-width: 90px; }
#page-panel .apply-limits { background: #286b28; color: white; font-weight: 600; }
#page-panel .apply-limits:hover { background: #205620; }
.account, .catalogue { background: white; border-radius: 18px; }
main.account { max-width: 32rem; }
.account form, .account label, .catalogue label { display: grid; gap: .6rem; }
.account form { gap: 1.2rem; }
.account input, .catalogue input { padding: .7rem; border: 1px solid #b9c1c8; border-radius: 8px; min-width: 0; width: 100%; }
.account button, .catalogue button { padding: .7rem 1rem; border: 0; border-radius: 8px; background: #2868ab; color: white; }
.account [role=alert] { color: #ad2430; }
.account-bar, .board-create, .board-search { display: flex; align-items: end; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.account-bar { justify-content: space-between; align-items: center; }
.board-create label, .board-search label { flex: 1; min-width: 180px; }
.board-list { padding: 0; list-style: none; display: grid; gap: .7rem; }
.board-list a { display: block; padding: 1rem; background: #f0f5fa; border-radius: 8px; color: #20598f; overflow-wrap: anywhere; }
.catalogue-link { display: grid; place-items: center; width: 44px; color: inherit; text-decoration: none; font-size: 28px; }
.catalogue-link:hover { background: #e7e7e7; }
.totp-qr { width: min(100%, 320px); margin: 0 auto; background: white; }
.totp-qr svg { display: block; width: 100%; height: auto; }
.board-row { display: flex; flex-wrap: wrap; align-items: start; gap: .5rem; padding: .5rem; background: #f0f5fa; border-radius: 10px; }
.board-list .board-row > a { flex: 1; min-width: 140px; }
.board-action { flex: 0 0 44px; }
.board-action[open] { flex-basis: 100%; }
.board-action summary { display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer; border-radius: 8px; list-style: none; }
.board-action summary::-webkit-details-marker { display: none; }
.board-action summary:hover { background: #dce6ef; }
.board-action summary svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.board-action form { display: grid; gap: .8rem; padding: .7rem; }
.board-delete summary { color: #b12632; }
.board-delete button { background: #b12632; }
/* Teacher catalogue */
main.catalogue { max-width: 1180px; margin: 32px auto; padding: 32px; background: #f8fafc; color: #26354a; border: 1px solid #e1e7ef; border-radius: 24px; box-shadow: 0 12px 45px #213c5a08; }
.catalogue-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 28px; }
.brand-label { color: #587b99; font-size: 10px; font-weight: 700; letter-spacing: .15em; }
.catalogue h1 { font-size: clamp(28px, 4vw, 38px); letter-spacing: -.035em; margin: 10px 0; line-height: 1.15; }
.catalogue-header p, .create-panel p { margin: 0; color: #6b7c8f; font-size: 14px; line-height: 1.6; }
.catalogue .account-bar { margin: 0; flex-wrap: nowrap; gap: 12px; font-size: 13px; }
.user-badge { background: #e6eff5; color: #37677e; padding: 9px 13px; border-radius: 24px; overflow-wrap: anywhere; }
.catalogue button { font-weight: 600; font-size: 13px; min-height: 42px; background: #347d80; transition: background .15s; }
.catalogue button:hover { background: #28696b; }
.catalogue .quiet-button { color: #52667b; background: white; border: 1px solid #dce4ec; }
.catalogue .quiet-button:hover { background: #edf2f6; }
.catalogue input { background: white; font-size: 14px; border-color: #dce4ec; min-height: 44px; }
.catalogue :is(input,button,a,summary):focus-visible { outline: 3px solid #70b8c5; outline-offset: 3px; }
.catalogue label { font-size: 12px; font-weight: 600; color: #586d82; }
.catalogue-tabs { display: flex; gap: 24px; border-bottom: 1px solid #e0e7ef; }
.catalogue-tabs a { color: #748397; text-decoration: none; padding: 12px 0; font-size: 14px; border-bottom: 3px solid transparent; }
.catalogue-tabs a[aria-current=page] { color: #286f73; border-color: #347d80; font-weight: 700; }
.catalogue-overview { display: flex; flex-wrap: wrap; gap: 12px 24px; color: #7a8898; font-size: 12px; padding: 22px 0; }
.catalogue-overview strong { color: #334a60; font-size: 15px; margin-right: 4px; }
.overview-note { margin-left: auto; }
.create-panel { display: grid; grid-template-columns: 1fr 1.7fr; align-items: center; gap: 28px; padding: 24px; border: 1px solid #dceae7; background: #edf5f2; border-radius: 16px; }
.create-panel h2 { margin: 0 0 5px; font-size: 18px; letter-spacing: -.02em; }
.create-symbol { float: left; display: grid; place-items: center; width: 42px; height: 42px; margin-right: 14px; background: white; color: #347d80; border-radius: 12px; font-size: 25px; }
.catalogue .board-create { margin: 0; gap: 10px; flex-wrap: nowrap; }
.catalogue .board-create button { white-space: nowrap; min-height: 44px; }
.catalogue .board-search { margin: 24px 0 18px; gap: 10px; align-items: end; }
.catalogue .board-search label { flex: 0 1 360px; }
.search-count { margin-left: auto; padding-bottom: 12px; color: #8794a4; font-size: 12px; }
.reset-search { font-size: 12px; color: #56758c; padding: 12px 4px; }
.catalogue .board-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0; }
.catalogue .board-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; padding: 20px; gap: 20px 8px; background: white; border: 1px solid #e1e8ef; border-radius: 16px; transition: border-color .15s, box-shadow .15s; }
.catalogue .board-row:hover { border-color: #bdcfd7; box-shadow: 0 5px 20px #23496308; }
.catalogue .board-row > .board-title { display: flex; align-items: center; gap: 12px; padding: 0; min-width: 0; background: none; color: #2d4258; text-decoration: none; font-weight: 650; font-size: 15px; line-height: 1.4; }
.board-title small { display: block; color: #94a0ad; font-size: 11px; font-weight: 400; margin-top: 5px; }
.board-emblem { flex: 0 0 40px; width: 40px; height: 46px; padding: 10px; color: #52898d; background: #edf5f4; border-radius: 10px; }
.board-emblem svg, .board-actions svg { width: 22px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.board-actions { display: flex; gap: 1px; }
.catalogue .board-action, .catalogue .board-action[open] { flex: initial; }
.catalogue .board-action summary, .catalogue .archive-action button { width: 32px; height: 36px; min-height: 36px; padding: 4px; color: #8392a3; background: transparent; border-radius: 7px; }
.catalogue .board-action summary:hover, .catalogue .archive-action button:hover { color: #286f73; background: #edf5f4; }
.catalogue .board-delete summary:hover { color: #b12632; background: #fff0f0; }
.catalogue .board-action form { position: absolute; top: 68px; right: 16px; width: calc(100% - 32px); z-index: 2; padding: 18px; border: 1px solid #cedbe5; border-radius: 12px; background: white; box-shadow: 0 10px 30px #26354a25; }
.catalogue .board-action form p { font-size: 13px; line-height: 1.6; margin: 0; }
.catalogue .board-delete button { background: #b13e48; }
.board-metadata { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr .7fr 1fr; gap: 8px; margin: 0; padding-top: 16px; border-top: 1px solid #edf1f5; }
.board-metadata dt { font-size: 10px; color: #8b99a8; margin-bottom: 6px; }
.board-metadata dd { font-size: 11px; font-variant-numeric: tabular-nums; margin: 0; color: #53677c; line-height: 1.5; }
.catalogue-footnote { font-size: 11px; color: #8a98a8; margin-top: 22px; }
.catalogue-empty { padding: 45px 20px; text-align: center; border: 1px dashed #cedbe5; border-radius: 16px; color: #75869a; }
.catalogue-empty h2 { font-size: 19px; color: #425c74; }
.catalogue-empty p { font-size: 14px; line-height: 1.7; }
.login-link { color: #286f73; }
@media (max-width: 850px) { main.catalogue { margin: 16px; padding: 24px; } .catalogue .board-list { grid-template-columns: 1fr; } .create-panel { grid-template-columns: 1fr; gap: 18px; } }
@media (max-width: 520px) { main.catalogue { margin: 8px; padding: 18px; border-radius: 18px; } .catalogue-header { flex-direction: column; align-items: start; gap: 16px; } .catalogue .account-bar { width: 100%; } .brand-label { font-size: 8px; } .catalogue .board-create { flex-wrap: wrap; } .catalogue .board-create button { width: 100%; } .create-panel { padding: 18px; } .overview-note { margin-left: 0; width: 100%; } .catalogue .board-row { padding: 14px; } .board-emblem { display: none; } .board-metadata { grid-template-columns: 1fr; gap: 8px; } .board-metadata > div { display: flex; justify-content: space-between; gap: 12px; } .board-metadata dt { margin: 0; } .catalogue .board-search label { flex: 1; min-width: 140px; } .search-count { display: none; } }
.admin-nav { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.admin-nav a { text-decoration: none; color: #286f73; padding: 12px 16px; background: #e7f2ef; border-radius: 10px; font-size: 14px; }
.admin-user { background: white; border: 1px solid #e1e8ef; border-radius: 16px; padding: 22px; margin-bottom: 16px; }
.admin-user header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.admin-user h2 { margin: 0; font-size: 20px; overflow-wrap: anywhere; }
.admin-user header span { color: #789; font-size: 12px; }
.admin-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; }
.admin-metrics dt { color: #789; font-size: 12px; margin-bottom: 5px; }
.admin-metrics dd { margin: 0; font-size: 14px; }
.admin-user summary { cursor: pointer; font-size: 13px; padding: 10px 0; }
.admin-table { overflow-x: auto; }
.admin-table table { border-collapse: collapse; width: 100%; font-size: 12px; text-align: left; }
.admin-table th, .admin-table td { padding: 10px; border-bottom: 1px solid #e1e8ef; }
.admin-reset { margin-top: 8px; color: #a23c48; }
.admin-reset form { display: grid; gap: 12px; max-width: 600px; font-size: 13px; }
.admin-reset label { display: flex; align-items: center; }
.admin-reset input[type=checkbox] { width: 20px; min-height: 20px; }
.admin-reset button { background: #a23c48; }
@media(max-width:600px) { .admin-metrics { grid-template-columns: 1fr 1fr; } }
