:root {
    --studio-ink: #172033;
    --studio-muted: #6b7486;
    --studio-line: #e5e9f0;
    --studio-surface: #ffffff;
    --studio-canvas: #e9edf3;
    --studio-accent: #4f46e5;
    --studio-accent-soft: #eef2ff;
    --studio-success: #16a26a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
    background: var(--studio-canvas);
    color: var(--studio-ink);
}

.studio-header {
    position: relative;
    z-index: 500;
    height: 68px;
    display: grid;
    grid-template-columns: minmax(230px, 1fr) minmax(290px, 440px) minmax(230px, 1fr);
    align-items: center;
    gap: 28px;
    padding: 0 24px;
    border-bottom: 1px solid var(--studio-line);
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

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

.studio-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(145deg, #6158ed, #4038c7);
    box-shadow: 0 5px 14px rgba(79, 70, 229, .24);
}

.studio-mark svg {
    width: 25px;
    height: 25px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.studio-product {
    font-size: 15px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -.01em;
}

.studio-subtitle {
    margin-top: 3px;
    color: var(--studio-muted);
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: .02em;
}

.studio-map-picker {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.studio-map-picker label {
    flex: 0 0 auto;
    color: #586174;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.studio-select-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.studio-select-wrap select {
    width: 100%;
    height: 40px;
    appearance: none;
    padding: 0 42px 0 13px;
    border: 1px solid #d9deea;
    border-radius: 9px;
    outline: none;
    background: #f8f9fc;
    color: var(--studio-ink);
    font: 600 13px/1 Roboto, "Helvetica Neue", Arial, sans-serif;
    cursor: pointer;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.studio-select-wrap select:hover {
    border-color: #b8c0d0;
    background: #fff;
}

.studio-select-wrap select:focus-visible {
    border-color: var(--studio-accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .13);
}

.studio-select-wrap select:disabled {
    cursor: wait;
    opacity: .7;
}

.studio-select-arrow {
    position: absolute;
    right: 13px;
    top: 10px;
    width: 20px;
    height: 20px;
    pointer-events: none;
    fill: none;
    stroke: #6f7788;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.studio-select-spinner {
    display: none;
    position: absolute;
    right: 15px;
    top: 13px;
    width: 14px;
    height: 14px;
    border: 2px solid #d8dbea;
    border-top-color: var(--studio-accent);
    border-radius: 50%;
    pointer-events: none;
    animation: studio-spin .7s linear infinite;
}

.studio-select-wrap.loading .studio-select-arrow {
    display: none;
}

.studio-select-wrap.loading .studio-select-spinner {
    display: block;
}

.studio-select-wrap.loading select {
    padding-right: 90px;
}

.studio-select-wrap.loading::after {
    content: "Loading";
    position: absolute;
    top: 14px;
    right: 38px;
    color: var(--studio-accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    pointer-events: none;
    text-transform: uppercase;
}

.studio-meta {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
    color: var(--studio-muted);
    font-size: 11px;
}

.studio-stats {
    white-space: nowrap;
}

.studio-save-state {
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    color: #536072;
    font-weight: 500;
}

.studio-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--studio-success);
    box-shadow: 0 0 0 3px rgba(22, 162, 106, .1);
}

.studio-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid #d8dbea;
    border-top-color: var(--studio-accent);
    border-radius: 50%;
    animation: studio-spin .7s linear infinite;
}

.studio-save-state.loading .studio-status-dot {
    display: none;
}

.studio-save-state.loading .studio-spinner {
    display: inline-block;
}

.studio-save-state.error .studio-status-dot {
    background: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, .1);
}

.studio-toast {
    position: fixed;
    z-index: 1000;
    left: 50%;
    bottom: 38px;
    transform: translate(-50%, 18px);
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 9px;
    background: #172033;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .24);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

.studio-toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.studio-loading-overlay {
    position: fixed;
    z-index: 450;
    top: 120px;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    place-items: center;
    background: rgba(31, 41, 55, .24);
    backdrop-filter: blur(1px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, visibility .18s ease;
}

.studio-loading-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.studio-loading-card {
    display: flex;
    align-items: center;
    gap: 13px;
    color: #111827;
}

.studio-loading-card > span:last-child {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.studio-loading-card strong {
    font-size: 13px;
    line-height: 1.25;
}

.studio-loading-card small {
    color: rgba(17, 24, 39, .75);
    font-size: 11px;
    line-height: 1.3;
    opacity: 1;
}

.studio-main-spinner {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    border: 3px solid rgba(17, 24, 39, .22);
    border-top-color: #111827;
    border-radius: 50%;
    animation: studio-spin .7s linear infinite;
}

.studio-header.loading::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--studio-accent) 45%, transparent 80%);
    background-size: 45% 100%;
    background-repeat: no-repeat;
    animation: studio-loading-bar 1.1s ease-in-out infinite;
}

#app {
    height: calc(100vh - 68px) !important;
    background: var(--studio-canvas) !important;
}

#app .app-navbar {
    height: 52px !important;
    min-height: 52px !important;
    display: flex;
    align-items: center;
    padding: 7px 14px !important;
    border-bottom: 1px solid var(--studio-line);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04) !important;
}

#app .app-main {
    height: calc(100vh - 120px) !important;
    max-height: calc(100vh - 120px) !important;
    background: var(--studio-canvas) !important;
}

#app .app-main .app-canvas-area {
    background: var(--studio-canvas) !important;
}

#app .app-main .app-properties {
    min-width: 330px !important;
    width: 330px !important;
    border-left: 1px solid var(--studio-line);
    background: #f8f9fb !important;
    box-shadow: -4px 0 16px rgba(15, 23, 42, .06) !important;
}

#app .app-main .app-canvas-area .app-status-bar {
    height: 28px !important;
    flex-basis: 28px !important;
    padding: 5px 10px !important;
    border-top: 1px solid var(--studio-line) !important;
    background: rgba(255, 255, 255, .96) !important;
    color: #778093 !important;
    font-size: 11px;
}

.c-toolbar {
    align-items: center;
    height: 100%;
}

.c-toolbar .group {
    align-items: center;
    margin-right: 10px !important;
    padding-right: 10px !important;
    border-right-color: var(--studio-line) !important;
}

.c-toolbar .group:last-of-type {
    border-right: 0 !important;
}

.c-toolbar .bunt-icon-button,
.group-title .bunt-icon-button {
    border-radius: 8px !important;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.c-toolbar .bunt-icon-button:hover:not(.disabled),
.group-title .bunt-icon-button:hover:not(.disabled) {
    background: #f0f2f7 !important;
}

.c-toolbar .current-tool {
    border: 0 !important;
    background: var(--studio-accent-soft) !important;
    box-shadow: inset 0 0 0 1px rgba(79, 70, 229, .18);
}

.c-toolbar .current-tool .mdi {
    color: var(--studio-accent) !important;
    opacity: 1 !important;
}

.c-toolbar .bunt-button {
    min-width: 62px;
    height: 32px;
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    background: #fff;
    color: #475267;
    font-size: 12px;
    line-height: 32px;
}

.group-title {
    height: 38px !important;
    margin: 13px 12px 2px 16px !important;
    color: #3c4658 !important;
    font-size: 11px !important;
    letter-spacing: .065em;
    text-transform: uppercase;
}

.c-tree-zone a,
.c-tree-category a {
    margin: 2px 8px;
    padding: 0 9px !important;
    border-radius: 7px;
    color: #3f495b;
    font-weight: 500 !important;
}

.c-tree-zone a:hover,
.c-tree-category a:hover {
    background: #eef1f6 !important;
}

.c-tree-zone a.selected {
    background: var(--studio-accent-soft) !important;
    color: #4038c7;
}

.c-toolbox p {
    color: var(--studio-muted) !important;
}

.toolbox-row {
    padding-right: 14px !important;
}

.bunt-input-container .bunt-input,
.bunt-select .bunt-input {
    border-radius: 7px;
}

.bunt-dialog-container .bunt-backdrop,
.prompt-container .backdrop {
    background: rgba(15, 23, 42, .44) !important;
    backdrop-filter: blur(2px);
}

.prompt-wrapper {
    border-radius: 14px !important;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .22) !important;
}

@keyframes studio-spin {
    to { transform: rotate(360deg); }
}

@keyframes studio-loading-bar {
    from { background-position: -60% 0; }
    to { background-position: 160% 0; }
}

@media (max-width: 980px) {
    .studio-header {
        grid-template-columns: auto minmax(260px, 1fr);
        gap: 18px;
    }

    .studio-meta {
        display: none;
    }
}

@media (max-width: 700px) {
    .studio-header {
        height: 60px;
        padding: 0 12px;
        grid-template-columns: 42px 1fr;
        gap: 10px;
    }

    .studio-brand > div:last-child,
    .studio-map-picker label {
        display: none;
    }

    #app {
        height: calc(100vh - 60px) !important;
    }

    #app .app-main {
        height: calc(100vh - 112px) !important;
        max-height: calc(100vh - 112px) !important;
    }

    .studio-loading-overlay {
        top: 112px;
    }
}

@media print {
    .studio-header,
    .studio-loading-overlay,
    .studio-toast {
        display: none !important;
    }

    #app {
        height: 100vh !important;
    }
}
