#canvas-app {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at top, rgba(255, 193, 214, 0.18), transparent 26%),
        linear-gradient(180deg, #fcfbf8 0%, #f9f7f4 100%);
}

#canvas-app::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 181, 205, 0.32) 1px, transparent 1px);
    background-size: 22px 22px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.7;
}

#canvas-viewport {
    position: absolute;
    inset: 0;
    transform-origin: 0 0;
    z-index: 1;
}

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 76px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 1000;
    gap: 14px;
    box-shadow: 0 10px 34px rgba(255, 143, 171, 0.04);
}

.sidebar-toggle {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.78);
    color: var(--text-secondary);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
}

.sidebar-toggle:hover {
    background: white;
    border-color: rgba(255, 143, 171, 0.35);
    color: var(--pink-dark);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #ffd6a5, #ff8fab);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: white;
    font-size: 16px;
    box-shadow: 0 8px 22px rgba(255, 143, 171, 0.24);
    flex-shrink: 0;
}

.logo-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.logo-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}

.logo-subtitle {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.2;
}

.top-actions {
    display: flex;
    gap: 10px;
    margin-left: auto;
    position: relative;
    align-items: center;
}

.btn {
    padding: 10px 18px;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.72);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.22s ease;
    font-family: inherit;
    font-weight: 600;
}

.btn:hover {
    background: white;
    border-color: rgba(255, 143, 171, 0.3);
    color: var(--pink-dark);
    transform: translateY(-1px);
}

.btn:focus-visible,
.top-panel-button:focus-visible,
.share-link-row button:focus-visible,
.settings-segment button:focus-visible,
.settings-grid button:focus-visible {
    outline: 2px solid rgba(232, 93, 138, 0.38);
    outline-offset: 3px;
}

.btn-primary {
    background: linear-gradient(135deg, #ff8fab, #e85d8a);
    color: white;
    border: none;
    box-shadow: 0 10px 24px rgba(232, 93, 138, 0.22);
}

.btn-primary:hover {
    color: white;
    background: linear-gradient(135deg, #ef7b9b, #d95984);
}

.btn-avatar {
    padding: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ffb0cb, #c8b5d8);
    color: white;
    border: none;
    box-shadow: 0 10px 24px rgba(184, 169, 201, 0.22);
    line-height: 1;
}

.btn-icon {
    padding: 0;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.top-action-popovers {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    z-index: 1250;
    pointer-events: none;
}

.top-action-panel {
    width: min(360px, calc(100vw - 24px));
    padding: 16px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 248, 245, 0.94));
    box-shadow: 0 22px 54px rgba(36, 39, 58, 0.16);
    color: var(--text);
    pointer-events: auto;
}

.top-action-panel h2 {
    margin: 5px 0 6px;
    color: var(--text);
    font-size: 16px;
    line-height: 1.25;
}

.top-action-panel p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 12.5px;
    line-height: 1.55;
}

.top-panel-kicker {
    color: var(--pink-dark);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.top-panel-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
}

.top-panel-button,
.share-link-row button,
.settings-segment button,
.settings-grid button {
    min-height: 36px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.76);
    color: var(--text-secondary);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.top-panel-button:hover,
.share-link-row button:hover,
.settings-segment button:hover,
.settings-grid button:hover,
.settings-segment button.is-active {
    border-color: rgba(255, 143, 171, 0.28);
    background: linear-gradient(135deg, rgba(255, 143, 171, 0.12), rgba(184, 169, 201, 0.1));
    color: var(--text);
}

.top-panel-button.is-primary {
    border: none;
    background: linear-gradient(135deg, #ff8fab, #e85d8a);
    color: white;
    box-shadow: 0 10px 22px rgba(232, 93, 138, 0.18);
}

.share-link-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.top-panel-status {
    min-height: 16px;
    margin-top: 10px;
    color: var(--pink-dark);
    font-size: 11px;
    font-weight: 700;
}

.settings-panel {
    width: min(340px, calc(100vw - 24px));
}

.settings-group {
    margin-top: 14px;
}

.settings-group > span {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.settings-segment {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 5px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.58);
}

.settings-segment button {
    border-color: transparent;
    background: transparent;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.sidebar {
    position: fixed;
    top: 76px;
    left: 0;
    width: var(--sidebar-w);
    height: calc(100vh - 76px);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(18px);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    z-index: 1000;
    padding: 12px 12px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-scrim {
    display: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 4px 6px;
}

.sidebar-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-title::before {
    content: '✦';
    font-size: 10px;
    color: var(--pink);
}

.sidebar-close {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.75);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.sidebar-close:hover {
    background: rgba(255, 143, 171, 0.1);
    border-color: rgba(255, 143, 171, 0.35);
    color: var(--pink-dark);
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    color: var(--text-secondary);
    position: relative;
}

.layer-item:hover {
    background: rgba(255, 143, 171, 0.06);
    color: var(--text);
}

.layer-item.active {
    background: linear-gradient(135deg, rgba(255, 143, 171, 0.12), rgba(184, 169, 201, 0.08));
    color: var(--pink-dark);
    font-weight: 700;
}

.layer-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    background: linear-gradient(180deg, #ff8fab, #b8a9c9);
    border-radius: 0 3px 3px 0;
}

.layer-icon {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
}

.layer-eye {
    margin-left: auto;
    opacity: 0.3;
    font-size: 11px;
    transition: opacity 0.2s ease;
}

.layer-item:hover .layer-eye {
    opacity: 0.55;
}

.sidebar-console-card {
    margin-top: 10px;
    padding: 14px;
    border-radius: 18px;
    background: linear-gradient(160deg, #1f2240, #17192c);
    color: #f4dbe4;
    box-shadow: 0 20px 40px rgba(16, 18, 40, 0.28);
}

.sidebar-console-line {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: rgba(255, 214, 228, 0.7);
    margin-bottom: 8px;
}

.sidebar-console-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    color: #ff9fbe;
    margin-bottom: 8px;
}

.sidebar-console-role {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    line-height: 1.55;
    color: rgba(255, 236, 243, 0.88);
}

.sidebar-console-quote {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    line-height: 1.55;
    color: rgba(255, 236, 243, 0.82);
    margin-bottom: 10px;
}

.sidebar-console-link {
    width: 100%;
    margin-top: 2px;
    padding: 9px 11px;
    border-radius: 12px;
    border: 1px solid rgba(255, 143, 171, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #ff8fab;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.sidebar-footer {
    margin-top: 10px;
    padding-top: 8px;
}

.sidebar-minimap-shell {
    margin-top: 6px;
}

@media (max-width: 1180px) {
    :root {
        --sidebar-w: 244px;
    }

    .top-bar {
        padding: 0 16px;
    }

    .top-actions {
        gap: 8px;
    }

    .btn {
        padding: 10px 14px;
    }
}

@media (max-width: 900px) {
    :root {
        --sidebar-w: min(88vw, 320px);
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .sidebar-close {
        display: inline-flex;
    }

    .sidebar-scrim {
        display: block;
        position: fixed;
        top: 76px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.34);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 999;
    }

    .sidebar-scrim.is-open {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar {
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        box-shadow: 0 28px 60px rgba(0, 0, 0, 0.22);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }
}

@media (max-width: 767px) {
    .top-bar {
        height: 68px;
        padding: 0 12px;
    }

    .logo-title {
        font-size: 14px;
        white-space: nowrap;
    }

    .logo-subtitle {
        font-size: 11px;
    }

    .logo-icon {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }

    .top-actions {
        gap: 6px;
    }

    .top-actions .btn {
        min-height: 36px;
        padding: 8px 12px;
        border-radius: 12px;
        font-size: 12px;
    }

    .top-actions .btn-avatar,
    .top-actions .btn-icon {
        display: inline-flex;
        width: 36px;
        height: 36px;
        padding: 0;
    }

    .sidebar {
        top: 68px;
        height: calc(100vh - 68px);
    }

    .sidebar-scrim {
        top: 68px;
    }
}

@media (max-width: 430px) {
    .logo-copy {
        display: none;
    }
}
