:root {
    --bg: #0f1216;
    --panel: #151a21;
    --panel-2: #0d1117;
    --text: #e6edf3;
    --muted: #9aa4b2;
    --accent: #3b82f6;
    --danger: #ef4444;
    --border: #1f2937;
    --shadow: 0 6px 24px rgba(0, 0, 0, .35);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, -apple-system, Segoe UI, Roboto, Inter, system-ui, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

.app {
    display: flex;
    gap: 14px;
    height: 100%;
    padding: 14px;
}

.panel {
    background: linear-gradient(180deg, var(--panel), var(--panel-2));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Левая панель — камера */
.camera {
    flex: 1 1 55%;
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 320px;
}

.camera header, .chat header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
}

.camera header h2, .chat header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.camera .viewport {
    position: relative;
    flex: 1;
    background: #000;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.full-fixed-textarea {
    width: 100%;
    height: 90%;
    resize: none;         /* запрещаем ручное изменение размера */
    border: none;
    padding: 10px;
    font-size: 16px;
    box-sizing: border-box;
    outline: none;
    background-color: #0b1220;
    color: var(--text);
}

.camera .controls {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.btn {
    appearance: none;
    border: 1px solid var(--border);
    background: #0b1220;
    color: var(--text);
    padding: 10px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform .06s ease, background .2s ease, border-color .2s ease;
    font-weight: 600;
    font-size: 14px;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: #2b3442;
}

.btn:disabled {
    cursor: not-allowed;
    background: #000000;
    border-color: #000000;
    color: var(--muted);
}

.btn.primary:disabled {
    cursor: not-allowed;
    background: #373737;
    border-color: #373737;
    color: var(--muted);
}

.btn:active {
    transform: translateY(0);
}

.btn.primary {
    background: var(--accent);
    border-color: #2463d6;
}

.btn.primary.edit {
    background: #a59c27;
    border-color: #494210;
}

.btn.primary.accept {
    background: #10b981;
    border-color: #167054;
}

.btn.danger {
    background: var(--danger);
    border-color: #b91c1c;
}

/* Правая панель — чат */
.chat {
    flex: 1 1 45%;
    display: flex;
    flex-direction: column;
    min-width: 320px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg {
    max-width: 80%;
    padding: 10px 12px;
    border-radius: 14px;
    line-height: 1.35;
    border: 1px solid var(--border);
}

.msg.user {
    margin-left: auto;
    background: #1a2332;
}

.msg.bot {
    margin-right: auto;
    background: #0e1623;
}

.msg .meta {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 6px;
}

.composer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.input {
    width: 100%;
    resize: none;
    min-height: 44px;
    max-height: 160px;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #0b1220;
    color: var(--text);
    outline: none;
    line-height: 1.4;
    font-size: 14px;
}

.inputMini {
    width: 100%;
    resize: none;
    min-height: 44px;
    max-height: 44px;
    padding: 0px 12px;
    border-radius: 12px;
    border: 3px solid var(--border);
    background: #0b1220;
    color: var(--text);
    outline: none;
    line-height: 1;
    font-size: 14px;
    margin-bottom: 0;
    margin-top: 16px;
}

/* Респонсив */
@media (max-width: 980px) {
    .app {
        flex-direction: column;
    }

    .camera, .chat {
        min-height: 50vh;
    }
}

/* Иконка-индикатор */
.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 10px;
}

.dot.on {
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, .15);
}

.dot.off {
    background: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, .15);
}

.notice {
    padding: 10px 14px;
    border: 1px dashed #374151;
    color: var(--muted);
    border-radius: 12px;
    font-size: 14px;
}

.qrcode {
    margin-top: 20px;
    margin-bottom: 0px;
}

/* ===== Попап ===== */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
    z-index: 1000;
}

.popup-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.popup {
    background: #1f2937;
    color: var(--text);
    border-radius: var(--radius);
    padding: 20px;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow);
    animation: fadeIn .3s ease;
}

.popup h3 {
    margin-top: 0;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.popup img {
    width: 24px;
    height: 24px;
}

.popup p {
    margin: 12px 0 0;
    font-size: 14px;
}

.popup button {
    margin-top: 16px;
}

@keyframes fadeIn {
    from {
        transform: scale(.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.chatImage {
    max-width: 350px;
    max-height: 350px;
    object-fit: contain;
    object-position: top;
    /*display: block;*/
}

.passwordField {
    -webkit-text-security: disc; /* работает в Chrome/WebKit */
}

/*@media not (pointer: coarse) {*/
/*    math-field::part(virtual-keyboard-toggle) {*/
/*        display: none;*/
/*    }*/
/*}*/

math-field::part(menu-toggle) {
    display: none;
}

math-field {
    background: #0e1623;
    border: #0e1623;
    color: var(--text);
/*    text-align: center;*/
/*    --primary: white;*/
/*    --latex-color: white;*/
/*    --correct-color: white;*/
    --caret-color: white;
    --selection-background-color: lightgoldenrodyellow;
    --selection-color: black;
    --contains-highlight-background-color: black;
}

svg {
    width: 100%;
}