/* Базовые стили, страницы входа и кабинета, холст и панели. */
:root {
    font: 14px/1.45 system-ui,-apple-system,'Segoe UI',sans-serif;
    color: #202838;
    background: #f4f6fa;
    --accent: #3159d7;
    --line: #e4e8f0;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
}
button,input,textarea,select {
    font: inherit;
}
button {
    cursor: pointer;
    border: 1px solid var(--line);
    background: white;
    border-radius: 9px;
    color: inherit;
    padding: 8px 12px;
    white-space: nowrap;
}
button:hover {
    background: #edf1fc;
}
button:disabled {
    opacity: .42;
    cursor: not-allowed;
}
button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
button.danger {
    color: #b42336;
}
input,textarea,select {
    border: 1px solid #d9deea;
    border-radius: 8px;
    padding: 9px 10px;
    background: white;
    color: inherit;
    min-width: 0;
}
input:focus,textarea:focus {
    outline: 2px solid #aebeff;
    outline-offset: 1px;
}
h1,h2,p {
    margin: 0;
}
h1 {
    font-size: 30px;
    letter-spacing: -.8px;
}
h2 {
    font-size: 19px;
}
small,.muted {
    color: #68758a;
}
.brand {
    font-weight: 780;
    letter-spacing: -.5px;
    font-size: 21px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo {
    background: #3159d7;
    color: white;
    border-radius: 10px;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    font-size: 20px;
}
.dash {
    max-width: 1120px;
    margin: auto;
    padding: 28px 24px;
}
.dashhead,.sectionhead,.line {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
}
.hero {
    padding: 48px 0 25px;
}
.hero p {
    margin-top: 7px;
}
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill,minmax(265px,1fr));
    gap: 16px;
    margin-top: 18px;
}
.boardcard {
    background: white;
    border: 1px solid var(--line);
    border-radius: 15px;
    overflow: hidden;
}
.boardthumb {
    height: 112px;
    background-color: #f8faff;
    background-image: linear-gradient(#e9edf7 1px,transparent 1px),linear-gradient(90deg,#e9edf7 1px,transparent 1px);
    background-size: 20px 20px;
    display: grid;
    place-items: center;
    color: #8da0cd;
    font-size: 32px;
}
.cardbody {
    padding: 16px;
    display: grid;
    gap: 12px;
}
.cardbody h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pill {
    border-radius: 20px;
    background: #edf0f5;
    padding: 3px 9px;
    font-size: 12px;
    white-space: nowrap;
}
.pill.live {
    background: #e2f5e9;
    color: #176a3e;
}
.actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.login {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 20px;
}
.loginbox {
    width: min(420px,100%);
    background: white;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 32px;
    display: grid;
    gap: 18px;
    box-shadow: 0 12px 50px #2233550b;
}
.loginbox form {
    display: grid;
    gap: 12px;
}
.error {
    color: #b42336;
    white-space: pre-wrap;
}
.boardapp {
    height: 100dvh;
    overflow: hidden;
    background: #fff;
}
.topbar {
    position: absolute;
    z-index: 5;
    top: 10px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    pointer-events: none;
}
.topgroup,.toolbar,.stylebar,.bottomgroup,.participants {
    pointer-events: auto;
    background: #fff;
    border: 1px solid #e1e6ef;
    border-radius: 12px;
    box-shadow: 0 3px 18px #24364e12;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px;
}
.topgroup {
    max-width: 100%;
    flex-wrap: wrap;
}
.topgroup .boardtitle {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 650;
    padding: 0 5px;
}
.topgroup button,.bottomgroup button,.toolbar button {
    border: 0;
    padding: 7px;
    min-width: 32px;
}
.toolbar {
    position: absolute;
    z-index: 5;
    left: 12px;
    top: 75px;
    flex-direction: column;
    gap: 3px;
    max-height: calc(100dvh - 145px);
    overflow: auto;
    scrollbar-width: thin;
}
.toolbar button {
    height: 34px;
    width: 36px;
    display: grid;
    place-items: center;
    position: relative;
    font-size: 19px;
    line-height: 1;
}
.toolbar button.active,.bottomgroup button.active {
    background: #e5ebff;
    color: #244ac7;
}
.toolbar button svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.stylebar {
    position: absolute;
    z-index: 5;
    top: 75px;
    left: 69px;
    display: flex;
    flex-wrap: wrap;
    max-width: calc(100vw - 83px);
    gap: 7px;
    padding: 7px 9px;
}
.stylebar label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #68758a;
}
.stylebar input[type=color] {
    height: 28px;
    width: 30px;
    padding: 2px;
    cursor: pointer;
}
.stylebar select {
    padding: 4px;
    max-width: 95px;
}
.stylebar button {
    font-size: 12px;
    padding: 5px;
}
.swatch {
    width: 23px;
    height: 23px;
    border: 2px solid white;
    box-shadow: 0 0 0 1px #dce1ea;
    border-radius: 50%;
    padding: 0;
}
.swatch.chosen {
    box-shadow: 0 0 0 2px #3159d7;
}
.bottom {
    position: absolute;
    z-index: 5;
    left: 12px;
    right: 12px;
    bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
}
.bottomgroup {
    flex-wrap: wrap;
}
.participants {
    padding: 7px 10px;
    max-width: 50vw;
    flex-wrap: wrap;
}
.avatar {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: white;
    font-size: 11px;
    font-weight: 700;
}
.status {
    font-size: 12px;
    color: #68758a;
    white-space: nowrap;
    padding: 0 4px;
}
.status.online {
    color: #16734c;
}
.status.offline {
    color: #b42336;
}
#surface {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    outline: none;
    cursor: crosshair;
}
.hint {
    position: absolute;
    bottom: 66px;
    left: 50%;
    transform: translateX(-50%);
    background: #fffD;
    border: 1px solid var(--line);
    padding: 5px 12px;
    border-radius: 8px;
    color: #68758a;
    font-size: 12px;
    pointer-events: none;
    text-align: center;
    max-width: 80vw;
}
#toast {
    position: fixed;
    z-index: 30;
    bottom: 65px;
    left: 50%;
    transform: translateX(-50%);
    padding: 11px 16px;
    background: #202838;
    color: white;
    border-radius: 10px;
    display: none;
    max-width: 90vw;
    box-shadow: 0 4px 20px #0002;
}
dialog {
    border: 1px solid var(--line);
    border-radius: 15px;
    max-width: min(500px,92vw);
    width: 100%;
    padding: 22px;
    color: inherit;
    box-shadow: 0 12px 60px #0002;
}
dialog::backdrop {
    background: #17223655;
}
dialog form {
    display: grid;
    gap: 12px;
}
dialog textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
}
dialog .actions {
    justify-content: flex-end;
}
.hidden {
    display: none!important;
}
.keyhelp {
    font-size: 12px;
    color: #68758a;
}
.viewbadge {
    font-size: 12px;
    padding: 5px;
    color: #a15d00;
}
.cursor-name {
    font-size: 12px;
}
@media(max-width:700px) {
    .topbar {
        left: 6px;
        right: 6px;
        top: 6px;
    }
    .topgroup {
        gap: 2px;
        padding: 3px;
    }
    .topgroup .boardtitle {
        max-width: 105px;
    }
    .topgroup button {
        font-size: 11px;
        padding: 6px 4px;
    }
    .toolbar {
        left: 6px;
        top: 105px;
        max-height: calc(100dvh - 180px);
    }
    .stylebar {
        top: 105px;
        left: 54px;
        max-width: calc(100vw - 60px);
        padding: 5px;
        gap: 5px;
    }
    .stylebar .swatch {
        width: 18px;
        height: 18px;
    }
    .bottom {
        left: 6px;
        right: 6px;
        bottom: 6px;
    }
    .hint {
        display: none;
    }
    .participants {
        max-width: 35vw;
    }
    .dash {
        padding: 20px 14px;
    }
    .hero {
        padding-top: 30px;
    }
    .status {
        font-size: 10px;
    }
    .brand {
        font-size: 18px;
    }
}
/* Верхняя панель, всплывающие меню инструментов и редактор формул. */
.toolbar {
    top: 67px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100vw - 16px);
    width: max-content;
    max-height: none;
    overflow: visible;
    gap: 4px;
    padding: 5px 7px;
}
.toolbar button {
    height: 39px;
    width: 40px;
}
.toolbar .grouptrigger {
    width: 53px;
    display: flex;
    justify-content: center;
    gap: 2px;
    align-items: center;
}
.chevron {
    font-size: 13px;
    color: #68758a;
}
.toolgroup {
    position: relative;
}
.toolmenu {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(4,40px);
    gap: 4px;
    padding: 7px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 11px;
    box-shadow: 0 6px 25px #24364e25;
    z-index: 12;
}
.toolmenu#penMenu {
    grid-template-columns: repeat(2,40px);
}
.stylebar {
    top: 124px;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100vw - 16px);
    justify-content: center;
    z-index: 4;
}
.linkdialog {
    display: grid;
    gap: 14px;
}
.linkdialog input {
    width: 100%;
    font-size: 13px;
}
.linkdialog #rotateConfirm {
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 10px;
    display: grid;
    gap: 10px;
}
.linkdialog .actions {
    justify-content: flex-end;
}
#editor {
    max-width: min(660px,94vw);
    max-height: 90dvh;
    overflow: auto;
}
#formulaBuilder {
    display: grid;
    gap: 8px;
}
.mathheader {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.mathheader button,.mathbuttons button {
    padding: 5px 9px;
}
.visualMath {
    display: grid;
    gap: 8px;
}
.mathbuttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.mathbuttons button {
    min-width: 36px;
    font-family: Cambria Math,Georgia,serif;
    font-size: 19px;
}
.mathbuttons.symbols button {
    min-width: 29px;
    font-size: 17px;
    padding: 3px 6px;
}
.matrixdims {
    display: flex;
    align-items: center;
    gap: 5px;
}
.matrixdims select {
    padding: 3px 6px;
}
.mathroot {
    display: flex!important;
    align-items: center;
    flex-wrap: wrap;
    gap: 3px;
    min-height: 74px!important;
    padding: 12px!important;
    font-size: 22px!important;
    width: 100%;
    border: 1px solid #d9deea!important;
    border-radius: 8px;
}
.mathfield {
    display: inline-block;
    min-width: 24px;
    min-height: 23px;
    padding: 2px 4px;
    border: 1px dashed #a9b7d0;
    border-radius: 3px;
    outline: none;
    vertical-align: middle;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: Cambria Math,Georgia,serif;
    font-size: 18px;
    line-height: 1.2;
}
.mathfield:focus {
    border-color: #3159d7;
    box-shadow: 0 0 0 1px #3159d7;
}
.mathnode {
    display: inline-flex;
    position: relative;
    align-items: center;
    vertical-align: middle;
    margin: 3px 8px 3px 2px;
    padding: 4px;
    user-select: none;
}
.mathbody {
    display: inline-grid;
    gap: 3px;
    align-items: center;
}
.math-frac .mathbody {
    grid-template-columns: 1fr;
}
.math-frac .mathbody>.mathfield:first-child {
    border-bottom: 2px solid #202838;
}
.math-sqrt:before {
    content: '√';
    font: 30px Cambria Math,serif;
}
.math-sqrt .mathbody {
    border-top: 1.5px solid #202838;
}
.math-power .mathbody,.math-index .mathbody {
    grid-template-columns: auto auto;
    align-items: end;
}
.math-power .mathbody>.mathfield:last-child {
    font-size: 13px;
    align-self: start;
    margin-bottom: 12px;
}
.math-index .mathbody>.mathfield:last-child {
    font-size: 13px;
    margin-top: 12px;
}
.math-sum:before {
    content: '∑';
    font: 26px Cambria Math,serif;
}
.math-integral:before {
    content: '∫';
    font: 29px Cambria Math,serif;
}
.math-sum .mathbody,.math-integral .mathbody {
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
}
.math-sum .mathbody>.mathfield:nth-child(3),.math-integral .mathbody>.mathfield:nth-child(3) {
    grid-column: 2;
    grid-row: 1/3;
}
.math-sum .mathbody>.mathfield:nth-child(1),.math-integral .mathbody>.mathfield:nth-child(1) {
    grid-row: 2;
}
.math-sum .mathbody>.mathfield:nth-child(2),.math-integral .mathbody>.mathfield:nth-child(2) {
    grid-row: 1;
}
.math-matrix .mathbody {
    border-left: 2px solid;
    border-right: 2px solid;
    border-radius: 7px;
    padding: 3px;
}
.math-det .mathbody {
    border-left: 2px solid;
    border-right: 2px solid;
    padding: 3px;
}
.math-cases:before {
    content: '{';
    font: 42px Cambria Math,serif;
}
.mathdelete {
    position: absolute;
    top: -8px;
    right: -10px;
    padding: 0!important;
    line-height: 15px;
    width: 16px;
    height: 16px;
    font-size: 12px;
    background: white;
    color: #68758a;
}
.mathpreview {
    width: 100%;
    height: auto;
    max-height: 100px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}
.mathroot:empty:before {
    content: 'Введите формулу или выберите шаблон';
    color: #8b96a8;
    font: 14px system-ui;
    pointer-events: none;
}
@media(max-width:700px) {
    .toolbar {
        top: 87px;
        gap: 2px;
        padding: 4px;
    }
    .toolbar button {
        width: 31px;
        height: 33px;
    }
    .toolbar button svg {
        width: 18px;
        height: 18px;
    }
    .toolbar .grouptrigger {
        width: 39px;
    }
    .toolmenu {
        grid-template-columns: repeat(4,32px);
        gap: 3px;
    }
    .toolmenu#penMenu {
        grid-template-columns: repeat(2,32px);
    }
    .stylebar {
        top: 171px;
        gap: 4px;
        padding: 5px;
    }
    .stylebar label {
        font-size: 11px;
    }
    .stylebar select {
        max-width: 78px;
    }
    .toolbar .toolmenu button {
        width: 32px;
    }
    .topgroup .boardtitle {
        max-width: 115px;
    }
}
@media(min-width:430px) and (max-width:700px) {
    .stylebar {
        top: 133px;
    }
}
.mathroot {
    display: block!important;
    line-height: 2.1;
    overflow-wrap: anywhere;
}
.mathnode .mathfield {
    user-select: text;
    line-height: 1.2;
}
.mathbody {
    pointer-events: auto;
}
.mathroot:empty:before {
    display: inline;
}
/* Расположение названия, инструментов и действий в одной верхней области. */
.topbar {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
    grid-template-areas: 'identity tools actions' '. style .';
    align-items: start;
    gap: 7px;
    top: 10px;
    left: 12px;
    right: 12px;
}
.topbar>.topgroup:first-child {
    grid-area: identity;
    justify-self: start;
    min-width: 0;
    max-width: 100%;
    flex-wrap: nowrap;
    overflow: hidden;
    height: 51px;
}
.topbar>.topgroup:first-child .boardtitle {
    min-width: 0;
    max-width: 180px;
    flex-shrink: 1;
}
.topbar>.topgroup:first-child button,.topbar>.topgroup:first-child .status {
    flex-shrink: 0;
}
.topbar>.topactions {
    grid-area: actions;
    justify-self: end;
    height: 51px;
}
.topactions:empty {
    display: none;
}
.topbar>.toolbar {
    grid-area: tools;
    position: relative;
    inset: auto;
    transform: none;
    justify-self: center;
    max-width: 100%;
    z-index: 6;
}
.topbar>.stylebar {
    grid-area: style;
    position: relative;
    inset: auto;
    transform: none;
    justify-self: center;
    max-width: calc(100vw - 24px);
    z-index: 4;
}
@media(max-width:1050px) {
    .topbar {
        grid-template-columns: minmax(0,1fr) auto;
        grid-template-areas: 'tools tools' 'identity actions' 'style style';
        gap: 5px;
    }
    .topbar>.topgroup:first-child,.topbar>.topactions {
        height: auto;
    }
    .topbar>.topgroup:first-child .boardtitle {
        max-width: 100%;
    }
    .topbar>.stylebar {
        max-width: 100%;
    }
    .topbar>.toolbar {
        width: max-content;
        max-width: 100%;
    }
}
@media(max-width:700px) {
    .topbar {
        top: 6px;
        left: 6px;
        right: 6px;
    }
    .topbar>.topgroup:first-child .status {
        font-size: 10px;
    }
    .topbar>.toolbar {
        max-width: 100%;
    }
    .toolmenu {
        left: 50%;
    }
}
/* Сенсорное управление, безопасные отступы экрана и адаптивная компоновка. */
html,body {
    height: 100%;
    overscroll-behavior: none;
}
.boardapp {
    position: relative;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
}
.topbar {
    top: max(8px,env(safe-area-inset-top));
    left: max(8px,env(safe-area-inset-left));
    right: max(8px,env(safe-area-inset-right));
}
.rolelabel {
    display: none;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: #68758a;
}
.topgroup .logo {
    flex: none;
}
.topactions button {
    min-height: 36px;
}
.toolbar button,.bottomgroup button,.topgroup button {
    touch-action: manipulation;
}
.bottom {
    bottom: max(8px,env(safe-area-inset-bottom));
    left: max(8px,env(safe-area-inset-left));
    right: max(8px,env(safe-area-inset-right));
}
.participants {
    padding: 3px;
    flex-shrink: 0;
    max-width: none;
}
.participants button {
    border: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    font-size: 12px;
}
.avatar {
    flex: none;
}
.people-list {
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    pointer-events: auto;
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 6px 25px #24364e25;
    width: min(280px,90vw);
    max-height: 40dvh;
    overflow: auto;
    z-index: 8;
}
.personrow {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    overflow-wrap: anywhere;
}
.personrow small {
    display: block;
}
.selection-actions {
    position: absolute;
    z-index: 5;
    bottom: calc(max(8px,env(safe-area-inset-bottom)) + 58px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100% - 16px);
    width: max-content;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: white;
    box-shadow: 0 3px 18px #24364e12;
}
.selection-actions button {
    font-size: 12px;
    padding: 7px;
    min-height: 32px;
}
.selection-actions button[hidden] {
    display: none;
}
.selection-actions:not(.hidden)~.hint {
    display: none;
}
#styleToggle {
    display: none;
}
#selPaste {
    display: inline-block;
}
@media(min-width:1051px) {
    .topbar>.topgroup:first-child {
        width: max-content;
    }
    .topbar>.topactions {
        min-width: 0;
    }
}
@media(max-width:1050px) {
    .topbar>.topgroup:first-child {
        overflow: hidden;
    }
    .topbar>.topactions {
        align-self: start;
    }
    .topbar>.toolbar {
        justify-self: center;
    }
    .topbar>.stylebar {
        max-width: 100%;
    }
    .rolelabel {
        display: block;
    }
}
@media(max-width:700px),(pointer:coarse) and (max-width:1050px) {
    .topbar {
        grid-template-columns: minmax(0,1fr) auto;
        grid-template-areas: 'tools tools' 'identity actions' 'style style';
        gap: 5px;
        align-items: start;
    }
    .topbar>.toolbar {
        width: max-content;
        max-width: 100%;
        gap: 2px;
        padding: 3px;
        justify-content: center;
        border-radius: 11px;
    }
    .toolbar button {
        width: 44px;
        height: 44px;
        min-width: 44px;
        padding: 8px;
    }
    .toolbar button svg {
        width: 22px;
        height: 22px;
    }
    .toolbar .grouptrigger {
        width: 49px;
    }
    .toolmenu {
        grid-template-columns: repeat(4,44px);
        gap: 3px;
        padding: 5px;
    }
    .toolmenu#penMenu {
        grid-template-columns: repeat(2,44px);
    }
    .toolbar .toolmenu button {
        width: 44px;
    }
    .topbar>.topgroup:first-child,.topbar>.topactions {
        height: auto;
        min-height: 40px;
        padding: 3px;
        gap: 3px;
        align-items: center;
    }
    .topgroup button {
        font-size: 12px;
        min-height: 34px;
        padding: 5px 7px;
    }
    .topgroup .boardtitle {
        max-width: 100%;
        font-size: 12px;
    }
    .topgroup .status {
        font-size: 10px;
    }
    .rolelabel {
        display: none;
    }
    .topgroup .logo {
        height: 25px;
        width: 25px;
        font-size: 17px;
    }
    .topbar>.stylebar {
        display: none;
        grid-area: style;
        justify-self: end;
        width: max-content;
        max-width: 100%;
        padding: 7px;
        gap: 7px;
    }
    .topbar>.stylebar.mobile-open {
        display: flex;
    }
    .stylebar label {
        font-size: 12px;
        min-height: 36px;
    }
    .stylebar select {
        min-height: 36px;
        font-size: 14px;
    }
    .stylebar .swatch {
        width: 28px;
        height: 28px;
    }
    .stylebar input[type=color] {
        height: 34px;
        width: 34px;
    }
    #styleToggle {
        display: inline-block;
    }
    .bottom {
        display: grid;
        grid-template-columns: minmax(0,1fr) auto;
        align-items: end;
        gap: 4px;
    }
    .bottomgroup {
        gap: 2px;
        padding: 3px;
        max-width: 100%;
        justify-content: flex-start;
    }
    .bottomgroup button {
        font-size: 12px;
        min-height: 40px;
        min-width: 36px;
        padding: 5px 7px;
    }
    .bottomgroup select {
        font-size: 12px;
        min-height: 34px;
        max-width: 80px;
        padding: 4px;
    }
    .participants {
        max-width: 110px;
    }
    .participants button {
        flex-wrap: wrap;
        justify-content: center;
        min-height: 40px;
        gap: 2px;
    }
    .participants button .avatar {
        width: 20px;
        height: 20px;
    }
    .participants button .avatar:nth-of-type(n+3) {
        display: none;
    }
    .selection-actions {
        bottom: calc(max(8px,env(safe-area-inset-bottom)) + 105px);
    }
    .selection-actions button {
        min-height: 40px;
        font-size: 12px;
    }
    .hint {
        display: none;
    }
    .loginbox {
        padding: 22px;
        gap: 14px;
    }
    .loginbox input,.loginbox button,dialog input,dialog textarea,dialog select {
        font-size: 16px;
    }
    dialog {
        max-width: calc(100vw - 20px);
        max-height: calc(100dvh - 24px);
        overflow: auto;
        padding: 16px;
    }
    #editor {
        max-width: calc(100vw - 20px);
        max-height: calc(100dvh - 24px);
    }
    .mathbuttons button {
        min-height: 40px;
    }
    .mathbuttons.symbols button {
        min-width: 34px;
    }
    .mathfield {
        font-size: 18px;
    }
    .dash .cards {
        grid-template-columns: repeat(auto-fill,minmax(min(250px,100%),1fr));
    }
}
@media(max-width:400px) {
    .topgroup .status {
        display: none;
    }
    .topbar>.toolbar {
        gap: 1px;
    }
    .toolbar button {
        width: 42px;
        min-width: 42px;
        height: 44px;
    }
    .toolbar .grouptrigger {
        width: 46px;
    }
    .topactions #styleToggle span {
        display: none;
    }
    .bottomgroup {
        max-height: 100px;
        overflow: auto;
    }
    .selection-actions {
        bottom: calc(max(8px,env(safe-area-inset-bottom)) + 108px);
    }
}
@media(max-height:500px) and (pointer:coarse) {
    .topbar {
        grid-template-areas: 'tools tools' 'identity actions' 'style style';
    }
    .toolbar button {
        height: 38px;
        min-width: 38px;
        width: 38px;
    }
    .toolbar .grouptrigger {
        width: 44px;
    }
    .bottomgroup button {
        min-height: 34px;
    }
    .selection-actions {
        bottom: calc(max(8px,env(safe-area-inset-bottom)) + 55px);
    }
}
@media(min-width:1051px) {
    .topbar>.topactions:not(:has(#share)) {
        display: none;
    }
}
@media(min-width:701px) and (max-width:1050px) and (pointer:fine) {
    .topbar>.topactions:not(:has(#share)) {
        display: none;
    }
}
/* Профиль и уведомление о потере соединения. */
#profileButton {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.topbar>.topactions:not(:has(#share)) {
    display: flex;
}
.connection-notice {
    position: absolute;
    z-index: 15;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    width: min(440px,calc(100% - 24px));
    padding: 16px;
    background: #fff9e9;
    border: 1px solid #e6c77e;
    border-radius: 12px;
    box-shadow: 0 6px 24px #20283826;
    color: #63470b;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}
.connection-notice.hidden {
    display: none;
}
.connection-notice button {
    white-space: normal;
}
@media(max-width:700px) {
    #profileButton {
        max-width: 84px;
        font-size: 12px;
        padding: 7px;
    }
    .topactions {
        gap: 3px;
    }
    .topactions #share {
        padding: 7px;
    }
    .connection-notice {
        font-size: 14px;
    }
}
/* Панель конференции. */
#callButton.call-active {
    background: #e2f5e9;
    color: #176a3e;
    border-color: #a5dabb;
}
.call-panel {
    position: fixed;
    z-index: 12;
    right: max(10px,env(safe-area-inset-right));
    top: 110px;
    width: min(310px,calc(100vw - 20px));
    max-height: calc(100dvh - 180px);
    overflow: auto;
    background: white;
    border: 1px solid var(--line);
    border-radius: 13px;
    box-shadow: 0 10px 32px #20283825;
    padding: 12px;
    display: grid;
    gap: 10px;
    touch-action: pan-y;
}
.call-panel.hidden,.call-panel [hidden] {
    display: none!important;
}
.call-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.call-heading button {
    padding: 4px 12px;
}
.call-controls {
    display: grid;
    gap: 7px;
}
.call-controls label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    font-size: 12px;
}
.call-controls .call-check {
    justify-content: flex-start;
    font-size: 14px;
}
.call-controls select {
    max-width: 160px;
    font-size: 12px;
    padding: 5px;
}
.call-tile {
    background: #202838;
    border-radius: 8px;
    overflow: hidden;
    color: white;
    display: grid;
    position: relative;
    margin: 4px 0;
}
.call-tile video {
    width: 100%;
    max-height: 130px;
    object-fit: contain;
    display: block;
}
.call-tile span {
    position: absolute;
    bottom: 0;
    left: 0;
    padding: 3px 6px;
    background: #0009;
    font-size: 11px;
}
#callRoster,#callStatus {
    font-size: 12px;
    overflow-wrap: anywhere;
}
#callLeave {
    border-color: #e8c1c6;
}
#callMedia:empty,#callRoster:empty {
    display: none;
}
@media(max-width:1250px) {
    .topbar>.topactions {
        flex-wrap: wrap;
        justify-content: flex-end;
        max-width: 100%;
    }
}
@media(max-width:700px) {
    .call-panel {
        top: auto;
        bottom: calc(max(8px,env(safe-area-inset-bottom)) + 100px);
        max-height: calc(100dvh - 200px);
        width: min(310px,calc(100vw - 20px));
    }
    .call-panel button {
        min-height: 40px;
    }
    .topbar>.topactions {
        max-width: min(65vw,320px);
    }
    #callButton {
        padding: 5px 7px;
        font-size: 12px;
    }
}
@media(max-height:500px) {
    .call-panel {
        top: auto;
        bottom: 55px;
        max-height: calc(100dvh - 115px);
    }
}
/* Стикеры на холсте, числовые настройки и нижняя подсказка. */
.hint {
    bottom: env(safe-area-inset-bottom,0px);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    padding: 4px 10px;
    z-index: 4;
    max-width: calc(100% - 20px);
}
@media(min-width:1051px) and (pointer:fine) {
    .bottom {
        bottom: calc(25px + env(safe-area-inset-bottom,0px));
    }
    .selection-actions {
        bottom: calc(78px + env(safe-area-inset-bottom,0px));
    }
}
@media(max-width:1050px),(pointer:coarse) {
    .hint {
        display: none;
    }
}
.stylebar .number-style {
    gap: 4px;
}
.number-style input[type=number] {
    width: 60px;
    padding: 4px;
    font-size: 13px;
}
.number-style input[type=range] {
    width: 65px;
    padding: 0;
    accent-color: #3159d7;
    cursor: pointer;
}
.inline-note {
    position: absolute;
    z-index: 6;
    transform-origin: top left;
    pointer-events: auto;
    box-shadow: 0 0 0 2px #3159d7;
    border-radius: 1px;
    display: flex;
    flex-direction: column;
    overflow: visible;
}
.inline-note textarea {
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    min-height: 0;
    resize: none;
    margin: 0;
    padding: 12px;
    border: 0;
    border-radius: 0;
    font-family: system-ui,sans-serif;
    line-height: 1.3;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    outline: none!important;
    overflow: auto;
    touch-action: pan-y;
}
.note-actions {
    position: absolute;
    left: 0;
    top: 100%;
    display: flex;
    gap: 4px;
    white-space: nowrap;
    background: white;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 0 0 7px 7px;
    box-shadow: 0 3px 8px #24364e20;
}
.note-actions button {
    font-size: 13px;
    padding: 6px 9px;
}
@media(max-width:700px) {
    .stylebar .number-style input[type=number] {
        font-size: 16px;
        width: 62px;
    }
    .stylebar .number-style input[type=range] {
        width: 65px;
    }
    .note-actions button {
        min-height: 36px;
    }
    #focusStudents {
        font-size: 12px;
        padding: 5px 7px;
    }
    .topbar>.topactions {
        max-width: min(76vw,380px);
    }
}
.inline-note.actions-above .note-actions {
    top: auto;
    bottom: 100%;
    border-radius: 7px 7px 0 0;
}
/* Размер шрифта внутри стикера. */
.inline-note .note-actions {
    transform-origin: top left;
    flex-wrap: wrap;
    align-items: center;
    width: max-content;
    white-space: normal;
    gap: 4px;
    padding: 4px;
    border-radius: 8px;
    touch-action: manipulation;
}
.note-font-controls,.note-save-controls {
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}
.note-font-controls span {
    font-size: 12px;
    padding: 0 3px;
    color: #475569;
}
.note-font-controls input {
    width: 60px;
    height: 32px;
    padding: 3px 4px;
    font-size: 16px;
    text-align: center;
}
.note-font-controls button {
    min-width: 30px;
    font-size: 16px;
    padding: 4px 7px;
}
.note-save-controls button {
    min-height: 32px;
}
@media(pointer:coarse) {
    .note-font-controls input,.note-font-controls button,.note-save-controls button {
        min-height: 40px;
    }
    .note-font-controls button {
        min-width: 40px;
    }
}
/* Редакторы таблиц и таймера, адаптация верхних кнопок. */
.table-editor {
    width: min(850px,calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: 85dvh;
}
.table-editor form,.clock-editor form {
    display: grid;
    gap: 12px;
}
.table-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.table-options label {
    display: grid;
    gap: 4px;
    flex: 1;
    min-width: 100px;
    font-size: 12px;
}
.table-options input[type=number] {
    width: 100%;
    min-width: 0;
}
.table-options input[type=color] {
    height: 38px;
    width: 100%;
}
.table-scroll {
    overflow: auto;
    max-height: 48dvh;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.table-input-grid {
    display: grid;
    width: max-content;
    min-width: 100%;
    gap: 1px;
    background: #aeb9c9;
}
.table-input-grid textarea {
    border: 0;
    border-radius: 0;
    resize: vertical;
    min-height: 44px;
    width: 100%;
    min-width: 100px;
    max-width: 180px;
    padding: 8px;
    font-size: 16px;
    color: #202838;
}
.table-input-grid .dark-row {
    background: var(--row-dark);
}
.table-input-grid .light-row {
    background: var(--row-light);
}
.clock-editor {
    width: min(400px,calc(100vw - 24px));
}
.clock-editor output {
    font-size: 38px;
    font-variant-numeric: tabular-nums;
    text-align: center;
    padding: 12px;
}
.clock-editor label {
    display: grid;
    gap: 6px;
}
.clock-editor [hidden] {
    display: none;
}
#lessonClock {
    font-variant-numeric: tabular-nums;
}
#lessonClock.clock-running {
    color: #3159d7;
    background: #e8efff;
}
.topbar>.toolbar {
    flex-wrap: wrap;
}
@media(max-width:1450px) {
    .topbar>.topactions {
        flex-wrap: wrap;
        justify-content: flex-end;
        max-width: 100%;
    }
}
@media(max-width:700px) {
    .topbar>.topactions {
        max-width: min(76vw,380px);
    }
    #lessonClock {
        padding: 5px 7px;
        font-size: 12px;
    }
}
@media (min-width:701px) and (max-width:1200px) {
    .topbar {
        grid-template-columns: minmax(0,1fr) auto;
        grid-template-areas: 'tools tools' 'identity actions' 'style style';
    }
    .topbar>.topactions {
        height: auto;
        max-width: 100%;
        justify-content: flex-end;
    }
    .topbar>.stylebar {
        justify-self: center;
    }
}
