.canvas-scroll {
    position: relative;
    min-height: 0;
    overflow: auto;
    padding: 6px;
}

.canvas-scroll.is-pan-mode,
.canvas-scroll.is-pan-mode * {
    cursor: grab;
}

body.is-panning .canvas-scroll.is-pan-mode,
body.is-panning .canvas-scroll.is-pan-mode * {
    cursor: grabbing;
}

.office-stage-host {
    width: max-content;
    min-width: 100%;
    min-height: 100%;
    display: grid;
    place-items: center;
}

.office-stage-viewport {
    position: relative;
}

.office-stage {
    position: relative;
    width: 2200px;
    height: 1400px;
    overflow: hidden;
    transform-origin: top left;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background-color: var(--bg-soft);
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    box-shadow: inset 0 0 0 1px rgba(13, 124, 139, 0.02);
}

.office-stage-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 32px 32px;
    opacity: 0.9;
    pointer-events: none;
}

.links-layer,
.devices-layer,
.stage-empty {
    position: absolute;
    inset: 0;
}

.links-layer {
    width: 100%;
    height: 100%;
    z-index: 2;
}

.devices-layer {
    z-index: 3;
}

.link-line {
    stroke: rgba(8, 76, 88, 0.72);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke 0.16s ease, stroke-width 0.16s ease;
}

.link-group {
    cursor: pointer;
}

.link-group:hover .link-line,
.link-group.is-selected .link-line {
    stroke: var(--warm);
    stroke-width: 4;
}

.link-label {
    fill: var(--text);
    font-size: 17px;
    font-family: "IBM Plex Sans", sans-serif;
    font-weight: 600;
    stroke: var(--panel-strong);
    stroke-width: 6px;
    paint-order: stroke fill;
    pointer-events: none;
}

.device-node {
    position: absolute;
    display: grid;
    grid-template-columns: 28px 1fr;
    align-items: center;
    gap: 6px;
    width: 104px;
    min-height: 68px;
    padding: 7px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--panel-strong);
    box-shadow: 0 4px 12px rgba(17, 37, 56, 0.08);
    cursor: move;
    transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.device-node:hover {
    transform: translateY(-1px);
}

.device-node.is-selected {
    border-color: rgba(216, 122, 72, 0.72);
    box-shadow: 0 8px 20px rgba(216, 122, 72, 0.14);
}

.device-icon {
    width: 28px;
    height: 28px;
}

.device-node-meta {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.device-node-meta strong,
.device-node-meta span,
.device-node-meta em {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-node-meta strong {
    font-size: 11px;
}

.device-node-meta span,
.device-node-meta em {
    color: var(--muted);
    font-size: 10px;
    font-style: normal;
}

.device-node-meta em {
    color: var(--brand-strong);
}

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

.palette-item {
    display: grid;
    gap: 5px;
    justify-items: center;
    padding: 8px 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel-subtle);
    color: var(--text);
}

.palette-item img {
    width: 26px;
    height: 26px;
}

.palette-item span {
    font-size: 11px;
    font-weight: 600;
}

.palette-item.is-active {
    border-color: rgba(13, 124, 139, 0.36);
    background: rgba(13, 124, 139, 0.10);
    box-shadow: 0 10px 18px rgba(13, 124, 139, 0.10);
}

.device-form {
    display: grid;
    gap: 10px;
}

.selection-box {
    position: absolute;
    z-index: 4;
    border: 1px dashed var(--brand);
    background: rgba(13, 124, 139, 0.06);
    pointer-events: none;
}

.stage-empty {
    z-index: 5;
    display: grid;
    place-items: center;
    gap: 10px;
    padding: 20px;
    text-align: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.44));
    color: var(--muted);
}

html[data-theme="dark"] .stage-empty {
    background: linear-gradient(135deg, rgba(14, 18, 22, 0.64), rgba(14, 18, 22, 0.42));
}

.stage-empty h3 {
    color: var(--text);
    font-size: 24px;
}

.stage-empty p {
    max-width: 320px;
    line-height: 1.55;
}

@media (max-width: 900px) {
    .canvas-scroll {
        padding: 6px;
    }
}
