:root {
    --bg: #0f172a;
    --panel: #111827;
    --panel-soft: #1f2937;
    --surface: #f8fafc;
    --surface-grid: rgba(15, 23, 42, 0.06);
    --border: rgba(148, 163, 184, 0.25);
    --text: #e5e7eb;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --viewer: #94a3b8;
    --commenter: #f59e0b;
    --editor: #22c55e;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
select,
input[type="text"],
input[type="color"],
textarea {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

button {
    cursor: pointer;
    padding: 10px 12px;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, opacity 120ms ease;
}

button:hover,
select:hover,
input:hover,
textarea:hover {
    border-color: rgba(56, 189, 248, 0.5);
}

button:hover {
    transform: translateY(-1px);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.46;
    cursor: not-allowed;
    transform: none;
}

button.active {
    background: rgba(56, 189, 248, 0.18);
    border-color: rgba(56, 189, 248, 0.85);
}

button.ghost,
.link-button {
    background: transparent;
}

button.danger {
    border-color: rgba(239, 68, 68, 0.4);
}

input[type="text"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
}

input[type="color"] {
    width: 100%;
    min-height: 40px;
    padding: 4px;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

.app-shell {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: 100%;
    min-height: 0;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-right: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(17, 24, 39, 0.96));
    overflow: auto;
    min-height: 0;
}

.sidebar h1 {
    margin: 0;
    font-size: 24px;
}

.sidebar p {
    margin: 0;
    color: var(--muted);
}

.panel {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel h2,
.panel h3 {
    margin: 0;
    font-size: 14px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #cbd5e1;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.panel-grid.triple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.status-inline {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

.workspace {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.viewport-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
}

.workspace-header {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(12px);
}

.header-toggle-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.board-context-menu {
    position: fixed;
    z-index: 1200;
    min-width: 200px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.96);
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(18px);
}

.context-menu-item {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    border-radius: 10px;
}

body.sidebar-collapsed .header-toggle-button {
    background: rgba(56, 189, 248, 0.16);
    border-color: rgba(56, 189, 248, 0.55);
}

.badge,
.presence-chip,
.timer-chip,
.vote-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 13px;
}

.presence-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.presence-role {
    opacity: 0.8;
    font-size: 12px;
}

.role-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.role-dot.viewer {
    background: var(--viewer);
}

.role-dot.commenter {
    background: var(--commenter);
}

.role-dot.editor {
    background: var(--editor);
}

.workspace-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.viewport {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: auto;
    min-width: 0;
    min-height: 0;
    background:
        linear-gradient(var(--surface-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--surface-grid) 1px, transparent 1px),
        var(--surface);
    background-size: 24px 24px, 24px 24px, auto;
}

.floating-scrollbar {
    position: absolute;
    z-index: 40;
    border: 1px solid rgba(15, 23, 42, 0.14);
    background: rgba(248, 250, 252, 0.86);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(10px);
    scrollbar-color: rgba(15, 23, 42, 0.35) rgba(15, 23, 42, 0.08);
}

.floating-scrollbar.horizontal {
    left: 16px;
    right: 312px;
    bottom: 16px;
    height: 18px;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 999px;
}

.floating-scrollbar.vertical {
    top: 16px;
    right: 16px;
    bottom: 196px;
    width: 18px;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 999px;
}

.floating-scrollbar-content {
    min-width: 1px;
    min-height: 1px;
}

.floating-scrollbar.horizontal .floating-scrollbar-content {
    height: 1px;
}

.floating-scrollbar.vertical .floating-scrollbar-content {
    width: 1px;
}

.board-surface {
    position: relative;
    width: 5600px;
    height: 3600px;
    margin: 0;
}

.layer,
.svg-layer,
.cursor-layer {
    position: absolute;
    inset: 0;
}

.svg-layer {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.object-layer,
.comment-layer,
.cursor-layer {
    pointer-events: none;
}

.board-item,
.comment-pin,
.remote-cursor {
    pointer-events: auto;
}

.board-item {
    position: absolute;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    border: 2px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.12);
    overflow: hidden;
    user-select: none;
}

.board-item.selected {
    outline: 3px solid rgba(56, 189, 248, 0.85);
    outline-offset: 2px;
}

.board-item.primary-selected {
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2), 0 12px 36px rgba(15, 23, 42, 0.12);
}

.board-item[data-type="frame"] {
    background: rgba(255, 255, 255, 0.02);
    border: 2px dashed rgba(15, 23, 42, 0.35);
    box-shadow: none;
}

.board-item[data-type="sticky"] {
    padding: 12px;
    color: #1f2937;
    font-weight: 600;
}

.board-item[data-type="text"] {
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
}

.board-item[data-type="shape"] {
    background: rgba(56, 189, 248, 0.12);
    color: #0f172a;
    align-items: center;
    justify-content: center;
}

.board-item[data-shape="ellipse"] {
    border-radius: 999px;
}

.board-item[data-type="image"] {
    background: #fff;
}

.board-item[data-type="image"] img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.board-item[data-type="file"],
.board-item[data-type="mindmap"] {
    padding: 12px;
    background: #ffffff;
    color: #0f172a;
}

.board-item[data-type="mindmap"] {
    border-radius: 999px;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 600;
}

.board-item .object-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
}

.board-item .object-subtitle {
    color: #475569;
    font-size: 12px;
}

.board-item .frame-label {
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.05);
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.object-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.object-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: auto;
}

.vote-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    gap: 4px;
    align-items: center;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
    background: rgba(15, 23, 42, 0.85);
    color: #fff;
}

.vote-action {
    margin-left: 6px;
    border: none;
    border-radius: 999px;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.resize-handle {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #fff;
    cursor: nwse-resize;
}

.connector-line {
    stroke: #334155;
    stroke-width: 3;
    fill: none;
    marker-end: url(#arrowhead);
    cursor: pointer;
}

.connector-line.selected,
.pen-line.selected {
    stroke: var(--accent);
}

.pen-line {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 4;
    cursor: pointer;
}

.comment-pin {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 999px;
    background: #f8fafc;
    color: #0f172a;
    border: 2px solid rgba(15, 23, 42, 0.2);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.15);
    font-size: 12px;
    font-weight: 700;
}

.comment-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    background: rgba(15, 23, 42, 0.18);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comment-card.resolved {
    opacity: 0.65;
}

.comment-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.remote-cursor {
    position: absolute;
    transform: translate(-2px, -2px);
    pointer-events: none;
}

.remote-cursor::before {
    content: "";
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22);
}

.remote-cursor span {
    position: absolute;
    top: 12px;
    left: 8px;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.88);
    color: white;
    font-size: 12px;
}

.selection-box {
    position: absolute;
    border: 1px solid rgba(56, 189, 248, 0.95);
    background: rgba(56, 189, 248, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
    pointer-events: none;
}

.minimap-card {
    position: sticky;
    right: 16px;
    bottom: 16px;
    margin-left: auto;
    width: 268px;
    padding: 10px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(12px);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.22);
    z-index: 30;
}

.minimap-header {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #cbd5e1;
    margin-bottom: 8px;
}

.minimap-stage {
    position: relative;
    width: 240px;
    height: 154px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    background: #f8fafc;
}

.minimap-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.minimap-viewport-rect {
    position: absolute;
    border: 2px solid rgba(56, 189, 248, 0.95);
    background: rgba(56, 189, 248, 0.08);
    pointer-events: none;
    border-radius: 4px;
}

.helper-text,
.muted {
    color: var(--muted);
    font-size: 12px;
}

.hidden {
    display: none !important;
}

body.conference-linked-mode #usernameField,
body.conference-linked-mode #roleField {
    display: none;
}

body.conference-linked-mode .sidebar .panel[data-panel="acl"] {
    display: none;
}

body.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
}

body.sidebar-collapsed .sidebar {
    display: none !important;
}

body.sidebar-collapsed.embed-mode .sidebar {
    display: none !important;
}

.download-link {
    color: var(--accent);
    text-decoration: none;
}

.download-link:hover {
    text-decoration: underline;
}


body.embed-mode .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
}

body.embed-mode .sidebar {
    display: grid;
    grid-template-columns: minmax(0, 2.35fr) minmax(320px, 1fr);
    grid-template-rows: min-content min-content;
    grid-auto-flow: dense;
    align-items: start;
    gap: 10px;
    padding: 14px 16px 20px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 300px;
    overflow: auto;
    scrollbar-gutter: stable both-edges;
    overscroll-behavior: contain;
}

body.embed-mode .sidebar label {
    display: grid;
    gap: 4px;
    font-size: 12px;
}

body.embed-mode .sidebar .panel {
    min-width: 0;
    padding: 10px 12px 12px;
    gap: 8px;
}

body.embed-mode .sidebar .panel[data-panel="intro"],
body.embed-mode .sidebar .panel[data-panel="auth"],
body.embed-mode .sidebar .panel[data-panel="acl"],
body.embed-mode .sidebar .panel[data-panel="comments"],
body.embed-mode .sidebar .panel[data-panel="connection"],
body.conference-linked-mode .sidebar .panel[data-panel="connection"] {
    display: none;
}

body.sidebar-collapsed.embed-mode .sidebar {
    display: none !important;
}

body.embed-mode .sidebar .panel[data-panel="tools"] {
    grid-column: 1;
    grid-row: 1 / span 2;
}

body.embed-mode .sidebar .panel[data-panel="templates"] {
    grid-column: 2;
    grid-row: 1;
}

body.embed-mode .sidebar .panel[data-panel="inspector"] {
    grid-column: 2;
    grid-row: 2;
}

body.embed-mode .sidebar .panel h2,
body.embed-mode .sidebar .panel h3 {
    display: none;
}

body.embed-mode .sidebar button,
body.embed-mode .sidebar select,
body.embed-mode .sidebar input[type="text"],
body.embed-mode .sidebar textarea {
    font-size: 12px;
}

body.embed-mode .sidebar button {
    min-height: 38px;
    padding: 8px 10px;
    line-height: 1.15;
    white-space: normal;
    text-align: center;
}

body.embed-mode .sidebar input[type="text"],
body.embed-mode .sidebar textarea,
body.embed-mode .sidebar select {
    padding: 8px 10px;
}

body.embed-mode .sidebar textarea {
    min-height: 74px;
}

body.embed-mode .tool-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

body.embed-mode .action-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

body.embed-mode .session-grid,
body.embed-mode .compact-color-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.embed-mode .inspector-actions {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

body.embed-mode .panel[data-panel="tools"] > .helper-text,
body.embed-mode .panel[data-panel="templates"] > .muted,
body.embed-mode #permissionHint {
    display: none;
}

body.embed-mode #selectionInfo {
    font-size: 11px;
}

body.embed-mode .workspace-header {
    padding: 10px 12px;
}

body.embed-mode .viewport {
    scrollbar-width: none;
}

body.embed-mode .viewport::-webkit-scrollbar {
    width: 0;
    height: 0;
}

body.embed-mode .minimap-card {
    width: 220px;
}

body.embed-mode .minimap-stage {
    width: 192px;
    height: 124px;
}

@media (max-width: 1240px) {
    .app-shell {
        grid-template-columns: 340px 1fr;
    }

    .minimap-card {
        width: 220px;
    }

    .minimap-stage {
        width: 192px;
        height: 124px;
    }

    body.embed-mode .sidebar {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-rows: min-content min-content;
        max-height: 340px;
    }

    body.embed-mode .sidebar .panel[data-panel="tools"] {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    body.embed-mode .sidebar .panel[data-panel="templates"] {
        grid-column: 1;
        grid-row: 2;
    }

    body.embed-mode .sidebar .panel[data-panel="inspector"] {
        grid-column: 2;
        grid-row: 2;
    }

    body.embed-mode .tool-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        max-height: 52vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .minimap-card {
        display: none;
    }

    .floating-scrollbar.horizontal {
        right: 16px;
    }

    .floating-scrollbar.vertical {
        bottom: 16px;
    }

    body.embed-mode .sidebar {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        max-height: 46vh;
    }

    body.embed-mode .sidebar .panel[data-panel="tools"],
    body.embed-mode .sidebar .panel[data-panel="templates"],
    body.embed-mode .sidebar .panel[data-panel="inspector"] {
        grid-column: auto;
        grid-row: auto;
    }

    body.embed-mode .tool-grid,
    body.embed-mode .action-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}


/* === 2025 design refresh based on attached component references === */
:root {
    --bg: #eef1f5;
    --panel: #ffffff;
    --panel-soft: #f7f8fa;
    --surface: #ffffff;
    --surface-grid: rgba(16, 24, 40, 0.05);
    --border: #d6dbe3;
    --text: #101828;
    --muted: #667085;
    --accent: #2f80ed;
    --success: #16a34a;
    --danger: #ef4444;
    --warning: #f59e0b;
    --viewer: #98a2b3;
    --commenter: #f59e0b;
    --editor: #16a34a;
    --shadow-s: 0 10px 24px rgba(15, 23, 42, 0.06);
    --shadow-m: 0 22px 44px rgba(15, 23, 42, 0.12);
}

html,
body {
    background: linear-gradient(180deg, #f4f6f9 0%, #edf1f6 100%);
    color: var(--text);
}

button,
select,
input[type="text"],
input[type="color"],
textarea {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

button {
    min-height: 40px;
    padding: 9px 12px;
    font-weight: 600;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 0 1px 1px rgba(16, 24, 40, 0.04);
}

button:hover {
    transform: translateY(-1px);
    border-color: #c4ccda;
    background: #f9fafb;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(47, 128, 237, 0.14);
}

button.active,
button[aria-pressed="true"] {
    background: linear-gradient(180deg, #3f8cff 0%, #2f80ed 100%);
    color: #ffffff;
    border-color: #2f80ed;
    box-shadow: 0 12px 24px rgba(47, 128, 237, 0.22);
}

button.ghost,
.link-button {
    background: #ffffff;
}

button.danger {
    color: #b42318;
    border-color: rgba(239, 68, 68, 0.26);
    background: linear-gradient(180deg, #ffffff 0%, #fff5f5 100%);
}

button.danger:hover {
    background: #fef2f2;
    border-color: rgba(239, 68, 68, 0.42);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.52;
}

input[type="text"],
textarea,
select {
    min-height: 40px;
    padding: 10px 12px;
    background: #ffffff;
}

input[type="color"] {
    min-height: 40px;
    padding: 4px;
}

textarea {
    min-height: 92px;
    line-height: 1.45;
    resize: vertical;
}

.app-shell {
    background: transparent;
}

.sidebar {
    gap: 14px;
    padding: 20px;
    border-right: 1px solid rgba(214, 219, 227, 0.9);
    background: rgba(244, 246, 249, 0.96);
}

.sidebar h1 {
    font-size: 28px;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: #101828;
}

.sidebar p {
    font-size: 14px;
    line-height: 1.55;
    color: var(--muted);
}

.panel {
    background: var(--panel);
    border: 1px solid #e2e7ef;
    border-radius: 18px;
    padding: 16px;
    gap: 10px;
    box-shadow: var(--shadow-s);
}

.panel h2,
.panel h3 {
    font-size: 13px;
    line-height: 18px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    color: #111827;
}

.panel label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.panel-grid {
    gap: 8px;
}

.status-inline {
    color: var(--muted);
    font-size: 12px;
}

.workspace-header {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(214, 219, 227, 0.9);
    background: rgba(255, 255, 255, 0.84);
    backdrop-filter: blur(18px);
}

.header-toggle-button {
    color: #ffffff;
    border-color: #2f80ed;
    background: linear-gradient(180deg, #3f8cff 0%, #2f80ed 100%);
    box-shadow: 0 12px 24px rgba(47, 128, 237, 0.2);
}

body.sidebar-collapsed .header-toggle-button {
    color: var(--accent);
    border-color: rgba(47, 128, 237, 0.24);
    background: #ffffff;
    box-shadow: 0 10px 22px rgba(47, 128, 237, 0.12);
}

.badge,
.presence-chip,
.timer-chip,
.vote-chip {
    border: 1px solid #dbe2ea;
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
    box-shadow: 0 1px 1px rgba(16, 24, 40, 0.04);
}

.presence-role {
    color: var(--muted);
}

.board-context-menu {
    min-width: 220px;
    padding: 8px;
    border: 1px solid #d7dde7;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow-m);
    backdrop-filter: blur(22px);
}

.context-menu-item {
    justify-content: flex-start;
    text-align: left;
    color: #111827;
    background: #ffffff;
    box-shadow: none;
}

.context-menu-item + .context-menu-item {
    margin-top: 6px;
}

.viewport {
    background:
        linear-gradient(var(--surface-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--surface-grid) 1px, transparent 1px),
        var(--surface);
    background-size: 24px 24px, 24px 24px, auto;
}

.floating-scrollbar {
    z-index: 52;
    border: 1px solid rgba(214, 219, 227, 0.96);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(18px);
}

.floating-scrollbar.horizontal {
    left: 16px;
    right: 16px;
    bottom: 16px;
    height: 16px;
}

.floating-scrollbar.vertical {
    top: 16px;
    right: 16px;
    bottom: 222px;
    width: 16px;
}

body.minimap-hidden .floating-scrollbar.vertical {
    bottom: 16px;
}

.board-item {
    border: 1px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.12);
}

.board-item[data-type="frame"] {
    border-color: rgba(15, 23, 42, 0.22);
}

.comment-pin {
    border: 1px solid rgba(15, 23, 42, 0.16);
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.comment-card {
    border: 1px solid #dbe2ea;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.remote-cursor span {
    background: rgba(17, 24, 39, 0.92);
}

.minimap-card {
    display: block;
    position: absolute;
    right: 16px;
    bottom: 44px;
    margin-left: 0;
    width: 250px;
    padding: 12px;
    border-radius: 18px;
    border: 1px solid rgba(214, 219, 227, 0.96);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow-m);
    backdrop-filter: blur(20px);
    z-index: 51;
}

body.minimap-hidden .minimap-card {
    display: none !important;
}

.minimap-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    color: #111827;
}

.minimap-hint {
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.minimap-stage {
    width: 226px;
    height: 144px;
    border-radius: 14px;
    border: 1px solid #dbe2ea;
    background: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.minimap-viewport-rect {
    border-color: rgba(47, 128, 237, 0.95);
    background: rgba(47, 128, 237, 0.1);
}

.helper-text,
.muted {
    color: var(--muted);
    font-size: 12px;
    line-height: 18px;
}

.download-link {
    color: #156ee8;
    font-weight: 600;
}

body.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
}

body.embed-mode .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
}

body.embed-mode .sidebar {
    grid-template-columns: minmax(0, 2.55fr) minmax(320px, 1fr);
    grid-template-rows: min-content min-content;
    grid-auto-flow: dense;
    align-items: start;
    gap: 12px;
    padding: 12px 16px 18px;
    border-right: none;
    border-bottom: 1px solid rgba(214, 219, 227, 0.9);
    max-height: 318px;
    overflow: auto;
    scrollbar-gutter: stable both-edges;
    overscroll-behavior: contain;
    background: rgba(244, 246, 249, 0.94);
}

body.embed-mode .sidebar label {
    gap: 4px;
    font-size: 11px;
}

body.embed-mode .sidebar .panel {
    min-width: 0;
    padding: 10px 12px 12px;
    gap: 8px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

body.embed-mode .sidebar .panel h2,
body.embed-mode .sidebar .panel h3 {
    display: none;
}

body.embed-mode .sidebar button,
body.embed-mode .sidebar select,
body.embed-mode .sidebar input[type="text"],
body.embed-mode .sidebar textarea {
    font-size: 12px;
}

body.embed-mode .sidebar button {
    min-height: 38px;
    padding: 8px 10px;
    line-height: 1.15;
    white-space: normal;
    text-align: center;
}

body.embed-mode .sidebar input[type="text"],
body.embed-mode .sidebar textarea,
body.embed-mode .sidebar select {
    padding: 8px 10px;
}

body.embed-mode .sidebar textarea {
    min-height: 72px;
}

body.embed-mode .tool-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

body.embed-mode .action-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

body.embed-mode .session-grid,
body.embed-mode .compact-color-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.embed-mode .inspector-actions {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

body.embed-mode #selectionInfo {
    font-size: 11px;
}

body.embed-mode .workspace-header {
    padding: 10px 14px;
}

body.embed-mode .viewport {
    scrollbar-width: none;
}

body.embed-mode .viewport::-webkit-scrollbar {
    width: 0;
    height: 0;
}

body.embed-mode .minimap-card {
    width: 232px;
    right: 14px;
    bottom: 42px;
}

body.embed-mode .minimap-stage {
    width: 208px;
    height: 132px;
}

body.embed-mode .floating-scrollbar.vertical {
    bottom: 210px;
}

body.embed-mode.minimap-hidden .floating-scrollbar.vertical,
body.minimap-hidden.embed-mode .floating-scrollbar.vertical {
    bottom: 16px;
}

#toggleMinimapBtn {
    white-space: normal;
}

@media (max-width: 1240px) {
    body.embed-mode .sidebar {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        max-height: 348px;
    }

    body.embed-mode .sidebar .panel[data-panel="tools"] {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    body.embed-mode .sidebar .panel[data-panel="templates"] {
        grid-column: 1;
        grid-row: 2;
    }

    body.embed-mode .sidebar .panel[data-panel="inspector"] {
        grid-column: 2;
        grid-row: 2;
    }

    body.embed-mode .tool-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    body.embed-mode .action-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .sidebar {
        max-height: 52vh;
        padding: 16px;
    }

    .minimap-card {
        display: block;
        width: 214px;
        right: 12px;
        bottom: 40px;
        padding: 10px;
    }

    .minimap-stage {
        width: 192px;
        height: 122px;
    }

    .floating-scrollbar.horizontal {
        right: 12px;
        left: 12px;
    }

    .floating-scrollbar.vertical {
        top: 12px;
        right: 12px;
        bottom: 194px;
    }

    body.minimap-hidden .floating-scrollbar.vertical {
        bottom: 12px;
    }

    body.embed-mode .sidebar {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        max-height: 48vh;
    }

    body.embed-mode .sidebar .panel[data-panel="tools"],
    body.embed-mode .sidebar .panel[data-panel="templates"],
    body.embed-mode .sidebar .panel[data-panel="inspector"] {
        grid-column: auto;
        grid-row: auto;
    }

    body.embed-mode .tool-grid,
    body.embed-mode .action-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    body.embed-mode .floating-scrollbar.vertical {
        bottom: 190px;
    }

    body.embed-mode.minimap-hidden .floating-scrollbar.vertical,
    body.minimap-hidden.embed-mode .floating-scrollbar.vertical {
        bottom: 12px;
    }
}

@media (max-width: 720px) {
    .workspace-header {
        padding: 12px;
    }

    .minimap-card {
        width: 196px;
        right: 10px;
        bottom: 38px;
    }

    .minimap-stage {
        width: 174px;
        height: 110px;
    }

    .floating-scrollbar.vertical {
        width: 14px;
        bottom: 176px;
        right: 10px;
    }

    .floating-scrollbar.horizontal {
        height: 14px;
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    body.minimap-hidden .floating-scrollbar.vertical {
        bottom: 10px;
    }

    body.embed-mode .floating-scrollbar.vertical {
        bottom: 172px;
    }

    body.embed-mode.minimap-hidden .floating-scrollbar.vertical,
    body.minimap-hidden.embed-mode .floating-scrollbar.vertical {
        bottom: 10px;
    }
}

/* === 2026 UI polish aligned with DS_Store design kit === */
:root {
    --bg: #f5f5f5;
    --panel: #ffffff;
    --panel-soft: #fafafa;
    --surface: #ffffff;
    --surface-grid: rgba(217, 217, 217, 0.52);
    --border: #d9d9d9;
    --text: #171a1d;
    --muted: #6f7277;
    --accent: #2781f3;
    --success: #16a34a;
    --danger: #ff5a76;
    --warning: #f59e0b;
    --viewer: #98a2b3;
    --commenter: #ff9f0a;
    --editor: #16a34a;
    --shadow-s: 0 10px 24px rgba(23, 26, 29, 0.06);
    --shadow-m: 0 20px 40px rgba(23, 26, 29, 0.12);
}

html,
body {
    background:
        radial-gradient(circle at top left, rgba(39, 129, 243, 0.06), transparent 36%),
        linear-gradient(180deg, #fafafa 0%, #f2f2f2 100%);
    color: var(--text);
}

body {
    font-size: 13px;
    line-height: 1.38;
}

button,
select,
input[type="text"],
input[type="password"],
input[type="color"],
textarea {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 0 rgba(23, 26, 29, 0.04);
}

button {
    min-height: 40px;
    padding: 9px 12px;
    font-weight: 600;
    letter-spacing: 0;
    background: linear-gradient(180deg, #ffffff 0%, #f7f7f7 100%);
}

button:hover,
select:hover,
input:hover,
textarea:hover {
    border-color: #c8ccd2;
}

button:hover {
    background: #fcfcfc;
    box-shadow: 0 10px 20px rgba(23, 26, 29, 0.08);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 2px solid rgba(39, 129, 243, 0.22);
    outline-offset: 2px;
    border-color: rgba(39, 129, 243, 0.92);
}

button.primary,
button.active,
.header-toggle-button.primary,
#toggleBoardBtn.primary {
    color: #ffffff;
    border-color: var(--accent);
    background: linear-gradient(180deg, #4a93f3 0%, var(--accent) 100%);
    box-shadow: 0 10px 22px rgba(39, 129, 243, 0.2);
}

button.primary:hover,
button.active:hover,
.header-toggle-button.primary:hover,
#toggleBoardBtn.primary:hover {
    border-color: #1f73dd;
    background: linear-gradient(180deg, #5a9bf4 0%, #2b86fb 100%);
    box-shadow: 0 14px 28px rgba(39, 129, 243, 0.24);
}

button.ghost,
.link-button {
    background: #ffffff;
}

button.danger {
    color: #b42318;
    border-color: rgba(255, 90, 118, 0.32);
    background: linear-gradient(180deg, #fff7f8 0%, #ffecef 100%);
}

button.danger:hover {
    border-color: rgba(255, 90, 118, 0.42);
    background: #fff3f5;
}

input[type="text"],
input[type="password"],
textarea,
select {
    padding: 10px 12px;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
    color: #9aa0a6;
}

select {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #9aa0a6 50%),
        linear-gradient(135deg, #9aa0a6 50%, transparent 50%),
        linear-gradient(180deg, #ffffff 0%, #f7f7f7 100%);
    background-position:
        calc(100% - 18px) calc(50% - 2px),
        calc(100% - 12px) calc(50% - 2px),
        0 0;
    background-size: 6px 6px, 6px 6px, 100% 100%;
    background-repeat: no-repeat;
    padding-right: 34px;
}

.app-shell {
    background: transparent;
}

.sidebar {
    gap: 14px;
    padding: 18px;
    border-right: 1px solid rgba(217, 217, 217, 0.92);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0%, rgba(248, 248, 248, 0.92) 100%);
    backdrop-filter: blur(20px);
}

.sidebar h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--text);
}

.sidebar p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.panel {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #e3e3e3;
    border-radius: 16px;
    padding: 14px;
    gap: 10px;
    box-shadow: var(--shadow-s);
}

.panel h2,
.panel h3 {
    margin: 0;
    font-size: 13px;
    line-height: 18px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text);
}

.panel label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.panel-grid {
    gap: 8px;
}

.status-inline,
.helper-text,
.muted,
#selectionInfo,
#aclSummary,
#timerSummary,
#voteSummary,
#commentsList {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.workspace-header {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(217, 217, 217, 0.94);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(18px);
}

.header-toggle-button {
    gap: 8px;
    border-radius: 10px;
}

body.sidebar-collapsed .header-toggle-button {
    color: var(--accent);
    border-color: rgba(39, 129, 243, 0.26);
    background: #ffffff;
    box-shadow: 0 10px 22px rgba(39, 129, 243, 0.1);
}

.badge,
.presence-chip,
.timer-chip,
.vote-chip {
    border: 1px solid #e0e0e0;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    box-shadow: 0 1px 0 rgba(23, 26, 29, 0.04);
}

.presence-role {
    color: var(--muted);
}

.board-context-menu {
    min-width: 220px;
    padding: 8px;
    border: 1px solid #e1e1e1;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-m);
    backdrop-filter: blur(18px);
}

.context-menu-item {
    justify-content: flex-start;
    text-align: left;
    min-height: 38px;
    color: var(--text);
    background: #ffffff;
    box-shadow: none;
}

.context-menu-item:hover {
    background: #f7f8fa;
}

.viewport {
    background:
        linear-gradient(var(--surface-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--surface-grid) 1px, transparent 1px),
        var(--surface);
    background-size: 24px 24px, 24px 24px, auto;
}

.right-overlay-stack {
    position: absolute;
    top: 16px;
    right: 16px;
    bottom: 44px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 12px;
    min-height: 0;
    z-index: 66;
    pointer-events: none;
}

.right-overlay-stack > * {
    pointer-events: auto;
}

body.minimap-hidden .right-overlay-stack {
    bottom: 16px;
}

.floating-scrollbar {
    border: 1px solid rgba(217, 217, 217, 0.96);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 14px 28px rgba(23, 26, 29, 0.12);
    backdrop-filter: blur(18px);
    z-index: 67;
}

.floating-scrollbar.horizontal {
    left: 16px;
    right: 16px;
    bottom: 16px;
    height: 16px;
}

.floating-scrollbar.vertical {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    width: 16px;
    flex: 1 1 auto;
    min-height: 168px;
    max-height: 100%;
}

body.minimap-hidden .floating-scrollbar.vertical {
    bottom: auto;
}

.board-item {
    border: 1px solid rgba(23, 26, 29, 0.12);
    box-shadow: 0 14px 32px rgba(23, 26, 29, 0.12);
}

.board-item[data-type="frame"] {
    border-color: rgba(23, 26, 29, 0.22);
}

.comment-pin {
    border: 1px solid rgba(23, 26, 29, 0.16);
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(23, 26, 29, 0.12);
}

.comment-card {
    border: 1px solid #e0e0e0;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(23, 26, 29, 0.08);
}

.remote-cursor span {
    background: rgba(23, 26, 29, 0.94);
}

.minimap-card {
    display: block;
    position: relative;
    right: auto;
    bottom: auto;
    width: 252px;
    margin-left: 0;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(217, 217, 217, 0.96);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-m);
    backdrop-filter: blur(18px);
    z-index: 66;
}

body.minimap-hidden .minimap-card {
    display: none !important;
}

.minimap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eeeeee;
    color: var(--text);
}

.minimap-title {
    font-size: 13px;
    line-height: 18px;
    font-weight: 700;
}

.minimap-hint {
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.minimap-stage {
    position: relative;
    width: 228px;
    height: 146px;
    border-radius: 12px;
    border: 1px solid #e3e3e3;
    background:
        linear-gradient(rgba(217, 217, 217, 0.4) 1px, transparent 1px),
        linear-gradient(90deg, rgba(217, 217, 217, 0.4) 1px, transparent 1px),
        linear-gradient(180deg, #fcfcfc 0%, #f7f7f7 100%);
    background-size: 16px 16px, 16px 16px, auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.minimap-viewport-rect {
    border-color: rgba(39, 129, 243, 0.96);
    background: rgba(39, 129, 243, 0.12);
    border-radius: 6px;
}

.download-link {
    color: var(--accent);
    font-weight: 600;
}

body.embed-mode .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
}

body.embed-mode .sidebar {
    display: grid;
    grid-template-columns: minmax(0, 2.15fr) minmax(320px, 1fr);
    grid-template-rows: min-content min-content;
    grid-auto-flow: dense;
    align-items: start;
    gap: 12px;
    padding: 12px 14px 14px;
    border-right: none;
    border-bottom: 1px solid rgba(217, 217, 217, 0.94);
    max-height: 298px;
    overflow: auto;
    scrollbar-gutter: stable both-edges;
    overscroll-behavior: contain;
    background: rgba(248, 248, 248, 0.96);
}

body.embed-mode .sidebar label {
    gap: 4px;
    font-size: 11px;
}

body.embed-mode .sidebar .panel {
    min-width: 0;
    padding: 10px 12px 12px;
    gap: 8px;
    border-radius: 14px;
    box-shadow: 0 8px 18px rgba(23, 26, 29, 0.06);
}

body.embed-mode .sidebar .panel h2,
body.embed-mode .sidebar .panel h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 22px;
    margin: 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #ededed;
    font-size: 12px;
    line-height: 16px;
}

body.embed-mode .sidebar .panel[data-panel="intro"],
body.embed-mode .sidebar .panel[data-panel="auth"],
body.embed-mode .sidebar .panel[data-panel="acl"],
body.embed-mode .sidebar .panel[data-panel="comments"],
body.embed-mode .sidebar .panel[data-panel="connection"],
body.conference-linked-mode .sidebar .panel[data-panel="connection"] {
    display: none;
}

body.embed-mode .sidebar .panel[data-panel="tools"] {
    grid-column: 1;
    grid-row: 1 / span 2;
}

body.embed-mode .sidebar .panel[data-panel="templates"] {
    grid-column: 2;
    grid-row: 1;
}

body.embed-mode .sidebar .panel[data-panel="inspector"] {
    grid-column: 2;
    grid-row: 2;
}

body.embed-mode .sidebar button,
body.embed-mode .sidebar select,
body.embed-mode .sidebar input[type="text"],
body.embed-mode .sidebar textarea {
    font-size: 12px;
}

body.embed-mode .sidebar button {
    min-height: 34px;
    padding: 7px 10px;
    line-height: 1.15;
    white-space: normal;
    text-align: center;
    border-radius: 8px;
}

body.embed-mode .sidebar input[type="text"],
body.embed-mode .sidebar input[type="password"],
body.embed-mode .sidebar textarea,
body.embed-mode .sidebar select {
    padding: 8px 10px;
    border-radius: 8px;
}

body.embed-mode .sidebar textarea {
    min-height: 66px;
}

body.embed-mode .tool-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
}

body.embed-mode .tool-grid .tool-button,
body.embed-mode #uploadBtn,
body.embed-mode #duplicateBtn {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 11px;
}

body.embed-mode .action-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

body.embed-mode .session-grid,
body.embed-mode .compact-color-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

body.embed-mode .inspector-actions {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

body.embed-mode #selectionInfo {
    font-size: 11px;
}

body.embed-mode .workspace-header {
    padding: 12px 14px;
}

body.embed-mode .viewport {
    scrollbar-width: none;
}

body.embed-mode .viewport::-webkit-scrollbar {
    width: 0;
    height: 0;
}

body.embed-mode .right-overlay-stack {
    top: 14px;
    right: 14px;
    bottom: 42px;
    gap: 10px;
}

body.embed-mode.minimap-hidden .right-overlay-stack,
body.minimap-hidden.embed-mode .right-overlay-stack {
    bottom: 14px;
}

body.embed-mode .minimap-card {
    width: 238px;
}

body.embed-mode .minimap-stage {
    width: 214px;
    height: 136px;
}

body.embed-mode .floating-scrollbar.horizontal {
    left: 14px;
    right: 14px;
    bottom: 14px;
}

body.embed-mode .floating-scrollbar.vertical {
    min-height: 124px;
}

#toggleMinimapBtn {
    white-space: normal;
}

#toggleMinimapBtn.active {
    color: #ffffff;
    border-color: var(--accent);
    background: linear-gradient(180deg, #4a93f3 0%, var(--accent) 100%);
}

@media (max-width: 1240px) {
    body.embed-mode .sidebar {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        max-height: 340px;
    }

    body.embed-mode .sidebar .panel[data-panel="tools"] {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    body.embed-mode .sidebar .panel[data-panel="templates"] {
        grid-column: 1;
        grid-row: 2;
    }

    body.embed-mode .sidebar .panel[data-panel="inspector"] {
        grid-column: 2;
        grid-row: 2;
    }

    body.embed-mode .tool-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .sidebar {
        padding: 16px;
    }

    .right-overlay-stack {
        top: 12px;
        right: 12px;
        bottom: 40px;
        gap: 10px;
    }

    body.minimap-hidden .right-overlay-stack {
        bottom: 12px;
    }

    .minimap-card {
        width: 220px;
        padding: 10px;
    }

    .minimap-stage {
        width: 198px;
        height: 126px;
    }

    .floating-scrollbar.horizontal {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .floating-scrollbar.vertical {
        min-height: 116px;
    }

    body.embed-mode .sidebar {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        max-height: 48vh;
    }

    body.embed-mode .sidebar .panel[data-panel="tools"],
    body.embed-mode .sidebar .panel[data-panel="templates"],
    body.embed-mode .sidebar .panel[data-panel="inspector"] {
        grid-column: auto;
        grid-row: auto;
    }

    body.embed-mode .tool-grid,
    body.embed-mode .action-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    body.embed-mode .right-overlay-stack {
        top: 12px;
        right: 12px;
        bottom: 40px;
    }

    body.embed-mode.minimap-hidden .right-overlay-stack,
    body.minimap-hidden.embed-mode .right-overlay-stack {
        bottom: 12px;
    }
}

@media (max-width: 720px) {
    .workspace-header {
        padding: 12px;
    }

    .right-overlay-stack {
        right: 10px;
        top: 10px;
        bottom: 38px;
        gap: 8px;
    }

    body.minimap-hidden .right-overlay-stack {
        bottom: 10px;
    }

    .minimap-card {
        width: 204px;
    }

    .minimap-stage {
        width: 182px;
        height: 116px;
    }

    .floating-scrollbar.vertical {
        width: 14px;
    }

    .floating-scrollbar.horizontal {
        height: 14px;
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    body.embed-mode .right-overlay-stack {
        right: 10px;
        top: 10px;
        bottom: 38px;
    }

    body.embed-mode.minimap-hidden .right-overlay-stack,
    body.minimap-hidden.embed-mode .right-overlay-stack {
        bottom: 10px;
    }
}


/* v7 bugfix overrides */
.selection-handle-layer {
    pointer-events: none;
    z-index: 14;
}

.selection-handle-layer .resize-handle {
    position: absolute;
    right: auto;
    bottom: auto;
    width: 16px;
    height: 16px;
    pointer-events: auto;
    box-shadow: 0 0 0 2px rgba(39, 129, 243, 0.18), 0 10px 22px rgba(39, 129, 243, 0.22);
}

.slider-field {
    gap: 6px;
}

.range-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-row input[type="range"] {
    flex: 1 1 auto;
    width: 100%;
    accent-color: var(--accent);
    margin: 0;
}

.range-value {
    min-width: 48px;
    text-align: right;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

#commentsList {
    max-height: 260px;
    overflow: auto;
    padding-right: 4px;
}

body.embed-mode .sidebar {
    max-height: 356px;
}

body.embed-mode .sidebar .panel[data-panel="comments"] {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 3;
    max-height: 178px;
    overflow: hidden;
}

body.embed-mode #commentsList {
    max-height: 118px;
}

body.embed-mode .right-overlay-stack {
    left: 5px;
    right: auto;
    align-items: flex-start;
}

body.embed-mode .floating-scrollbar.vertical {
    left: 5px;
    align-self: flex-start;
}

body.embed-mode .minimap-card {
    margin-left: 0;
}

body.embed-mode .slider-field {
    gap: 4px;
}

body.embed-mode .range-row {
    gap: 8px;
}

body.embed-mode .range-value {
    min-width: 40px;
    font-size: 11px;
}

@media (max-width: 1240px) {
    body.embed-mode .sidebar .panel[data-panel="comments"] {
        grid-column: 1 / -1;
        grid-row: 3;
    }
}

@media (max-width: 960px) {
    body.embed-mode .sidebar {
        max-height: 390px;
    }

    body.embed-mode .right-overlay-stack {
        left: 5px;
        right: auto;
    }
}

@media (max-width: 720px) {
    body.embed-mode .right-overlay-stack {
        left: 5px;
        right: auto;
    }
}

/* v8 overlay/layer corrections */
.board-surface {
    isolation: isolate;
}

#connectorLayer {
    z-index: 10;
}

#objectLayer {
    z-index: 20;
}

#penLayer {
    z-index: 30;
}

#commentLayer {
    z-index: 40;
}

#selectionHandleLayer {
    z-index: 50;
    pointer-events: none;
}

#selectionHandleLayer .resize-handle {
    pointer-events: auto;
}

#cursorLayer {
    z-index: 60;
}

.right-overlay-stack {
    position: absolute;
    inset: 0;
    display: block;
    z-index: 66;
    pointer-events: none;
}

.right-overlay-stack > * {
    position: absolute;
    pointer-events: auto;
}

.floating-scrollbar.horizontal {
    left: 16px;
    right: 16px;
    bottom: 16px;
}

.floating-scrollbar.vertical {
    top: 16px;
    right: 16px;
    bottom: 252px;
    width: 16px;
    min-height: 168px;
    max-height: none;
}

body.minimap-hidden .floating-scrollbar.vertical {
    bottom: 16px;
}

.minimap-card {
    position: absolute;
    right: 44px;
    bottom: 40px;
    margin: 0;
}

body.embed-mode .right-overlay-stack {
    inset: 0;
}

body.embed-mode .floating-scrollbar.horizontal {
    left: 14px;
    right: 14px;
    bottom: 14px;
}

body.embed-mode .floating-scrollbar.vertical {
    left: 5px;
    right: auto;
    top: 14px;
    bottom: 242px;
    width: 16px;
    min-height: 136px;
    max-height: none;
    align-self: auto;
}

body.embed-mode.minimap-hidden .floating-scrollbar.vertical,
body.minimap-hidden.embed-mode .floating-scrollbar.vertical {
    bottom: 14px;
}

body.embed-mode .minimap-card {
    position: absolute;
    left: 29px;
    right: auto;
    bottom: 40px;
    width: 238px;
    margin: 0;
}

body.embed-mode .minimap-stage {
    width: 214px;
    height: 136px;
}

@media (max-width: 980px) {
    .floating-scrollbar.horizontal {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .floating-scrollbar.vertical {
        top: 12px;
        right: 12px;
        bottom: 228px;
        min-height: 140px;
    }

    body.minimap-hidden .floating-scrollbar.vertical {
        bottom: 12px;
    }

    .minimap-card {
        right: 40px;
        bottom: 36px;
        width: 220px;
    }

    .minimap-stage {
        width: 198px;
        height: 126px;
    }

    body.embed-mode .floating-scrollbar.horizontal {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    body.embed-mode .floating-scrollbar.vertical {
        left: 5px;
        top: 12px;
        bottom: 216px;
        min-height: 124px;
    }

    body.embed-mode.minimap-hidden .floating-scrollbar.vertical,
    body.minimap-hidden.embed-mode .floating-scrollbar.vertical {
        bottom: 12px;
    }

    body.embed-mode .minimap-card {
        left: 29px;
        bottom: 36px;
        width: 220px;
    }

    body.embed-mode .minimap-stage {
        width: 198px;
        height: 126px;
    }
}

@media (max-width: 720px) {
    .floating-scrollbar.horizontal {
        left: 10px;
        right: 10px;
        bottom: 10px;
        height: 14px;
    }

    .floating-scrollbar.vertical {
        top: 10px;
        right: 10px;
        bottom: 206px;
        width: 14px;
        min-height: 116px;
    }

    body.minimap-hidden .floating-scrollbar.vertical {
        bottom: 10px;
    }

    .minimap-card {
        right: 32px;
        bottom: 34px;
        width: 204px;
    }

    .minimap-stage {
        width: 182px;
        height: 116px;
    }

    body.embed-mode .floating-scrollbar.horizontal {
        left: 10px;
        right: 10px;
        bottom: 10px;
        height: 14px;
    }

    body.embed-mode .floating-scrollbar.vertical {
        left: 5px;
        top: 10px;
        bottom: 194px;
        width: 14px;
        min-height: 108px;
    }

    body.embed-mode.minimap-hidden .floating-scrollbar.vertical,
    body.minimap-hidden.embed-mode .floating-scrollbar.vertical {
        bottom: 10px;
    }

    body.embed-mode .minimap-card {
        left: 27px;
        bottom: 34px;
        width: 204px;
    }

    body.embed-mode .minimap-stage {
        width: 182px;
        height: 116px;
    }
}

#connectorLayer,
#penLayer {
    pointer-events: none;
}

#connectorLayer .connector-line,
#penLayer .pen-line {
    pointer-events: auto;
}

.floating-scrollbar.horizontal,
.floating-scrollbar.vertical {
    position: absolute;
}

.floating-scrollbar.vertical {
    flex: none;
}
