.layout {
    display: flex;
    align-items: stretch;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

.with-fixed-sidebar {
    margin-right: 0;
}

.detail-stage {
    height: calc(100vh - var(--header-height));
    width: 100%;
    max-width: none;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 0;
    background: var(--sidebar);
    overflow: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.detail-stage::-webkit-scrollbar {
    display: none;
}

.detail-canvas {
    position: relative;
    display: block;
    height: 100%;
    width: auto;
    flex: 0 0 auto;
    line-height: 0;
}

.detail-image {
    display: block;
    width: auto;
    max-width: none;
    max-height: none;
    height: 100%;
}

.fixed-sidebar {
    position: static;
    inset: auto;
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: #c4bdba;
    border-left: 1px solid #fff;
}

.detail-overlay-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.detail-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.point-button {
    position: absolute;
    z-index: 2;
    transform: translate(-50%, -50%);
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.95);
    background: rgba(7, 133, 58, 0.92);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 0 0 6px rgba(7, 133, 58, 0.14);
    transition: transform 0.2s ease, background 0.2s ease;
}

.point-button:hover,
.point-button.is-active {
    background: #1d2130;
    transform: translate(-50%, -50%) scale(1.08);
}

.sidebar-shell {
    width: 100%;
    max-width: none;
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    min-height: 0;
    padding: 0;
    font-size: 1.05rem;
    justify-content: flex-start;
    overflow: hidden;
    container: sidebar-shell / inline-size;
}

.sidebar-placeholder {
    margin: auto 0;
}

.sidebar-browser {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-browser.is-folder-mode {
    padding: 1rem;
}

.sidebar-browser.is-material-mode {
    padding: 0;
}

.sidebar-placeholder[hidden],
.sidebar-browser[hidden],
.sidebar-path[hidden],
.category-list[hidden],
.materials-list[hidden],
.materials-empty[hidden],
.sidebar-path-button[hidden] {
    display: none !important;
}

.sidebar-path {
    position: relative;
    display: flex;
    min-height: 3rem;
    margin-bottom: 1rem;
    align-items: center;
    justify-content: center;
}

.sidebar-path-button {
    position: absolute;
    left: 0;
    border: 0;
    border-radius: 0;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    background: transparent;
    color: #1d2130;
    cursor: pointer;
}

.sidebar-path-button::before {
    content: "";
    position: absolute;
    left: 0.95rem;
    top: 50%;
    width: 0.72rem;
    height: 0.72rem;
    border-left: 0.16rem solid currentColor;
    border-bottom: 0.16rem solid currentColor;
    transform: translateY(-50%) rotate(45deg);
}

.sidebar-path-title {
    display: block;
    max-width: calc(100% - 5rem);
    overflow: hidden;
    color: #1d2130;
    font-size: 1rem;
    font-weight: 400;
    text-align: center;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.category-list,
.materials-list {
    display: grid;
    gap: 0.8rem;
    width: 100%;
    min-height: 0;
    align-content: start;
    align-items: start;
    grid-auto-rows: min-content;
    overflow-y: auto;
}

.materials-list {
    flex: 1 1 auto;
    grid-template-columns: 1fr;
    gap: 0;
    align-content: start;
    align-items: start;
}

@container sidebar-shell (min-width: 32rem) {
    .materials-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.category-list {
    flex: 1 1 auto;
}

.category-choice,
.material-chip {
    width: 100%;
    border: 0;
    border-radius: 1.1rem;
    overflow: hidden;
    cursor: pointer;
    text-align: left;
}

.category-choice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 1rem 1.05rem;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 10px 24px rgba(29, 33, 48, 0.08);
}

.category-choice-name,
.category-choice-count {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

.category-choice-name {
    gap: 0.65rem;
    color: #1d2130;
    font-size: 1rem;
    font-weight: 700;
}

.category-choice-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-choice-count {
    flex: 0 0 auto;
    gap: 0.38rem;
    color: #6c6c6c;
    font-size: 0.92rem;
}

.category-section {
    display: grid;
    gap: 0.55rem;
}

.category-section-title {
    margin: 0;
    padding: 0.35rem 0;
    color: #1d2130;
    font-size: 1rem;
    font-weight: 400;
    text-align: center;
    text-transform: uppercase;
}

.material-chip {
    position: relative;
    height: 6.25rem;
    padding: 0;
    border-radius: 0;
    background: transparent;
}

.material-chip-preview {
    display: block;
    width: 100%;
    height: 100%;
    background: #d9d9d9;
    overflow: hidden;
}

.material-chip-image,
.material-chip-fallback {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.material-chip-fallback {
    background: linear-gradient(135deg, #d8d8d8 0%, #b8b8b8 100%);
}

.material-chip-label {
    position: absolute;
    top: 0.6rem;
    right: 0;
    bottom: 0.6rem;
    width: 8.9rem;
    display: flex;
    align-items: center;
    padding: 0.55rem 1rem;
    background: rgba(29, 33, 48, 0.52);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    transition: background 0.2s ease, transform 0.2s ease;
}

.material-chip:hover .material-chip-label,
.material-chip.is-active .material-chip-label {
    background: rgba(29, 33, 48, 0.9);
    transform: translateX(-0.2rem);
}

.materials-empty {
    color: #666;
    padding: 1rem 0;
}

@media (max-width: 1100px) {
    .layout {
        display: block;
        height: auto;
        overflow: visible;
    }

    .detail-stage {
        width: auto;
        max-width: none;
        height: auto;
        min-height: auto;
        padding: 2rem 0;
    }

    .detail-canvas {
        width: 100%;
        height: auto;
    }

    .detail-image {
        width: 100%;
        height: auto;
        max-height: none;
    }

    .fixed-sidebar {
        position: static;
        width: auto;
        min-width: 0;
        height: auto;
    }

    .sidebar-shell {
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .sidebar-browser {
        height: auto;
    }

    .category-list,
    .materials-list {
        overflow-y: visible;
    }

    .materials-list {
        grid-template-columns: 1fr;
    }
}

/* ---------- Анимации (доработка) ---------- */
.detail-overlay {
    opacity: 0;
    transition: opacity 0.6s cubic-bezier(.22, .8, .2, 1);
}

.detail-overlay.is-on {
    opacity: 1;
}

.detail-canvas::after {
    content: "";
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    z-index: 3;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-top-color: #f9bf29;
    opacity: 0;
    transition: opacity 0.2s;
    animation: cw-spin 0.8s linear infinite;
    pointer-events: none;
}

.detail-canvas.is-loading::after {
    opacity: 1;
}

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

.point-button::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid rgba(7, 133, 58, 0.8);
    animation: cw-ping 2s cubic-bezier(0, 0, .2, 1) infinite;
    pointer-events: none;
}

.point-button.is-active::before {
    border-color: rgba(249, 191, 41, 0.9);
}

@keyframes cw-ping {
    0% { transform: scale(1); opacity: 0.9; }
    80%, 100% { transform: scale(2); opacity: 0; }
}

.point-button {
    animation: cw-pop 0.6s cubic-bezier(.34, 1.56, .64, 1) both;
    animation-delay: 0.4s;
}

@keyframes cw-pop {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0); }
}

.stage-label {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    line-height: 1.3;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s, transform 0.4s cubic-bezier(.22, .8, .2, 1);
    pointer-events: none;
}

.stage-label.is-visible {
    opacity: 1;
    transform: none;
}

.stage-label span {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    align-self: flex-start;
    padding: 0.45rem 0.9rem 0.45rem 0.45rem;
    border-radius: 999px;
    background: rgba(29, 33, 48, 0.82);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
}

.stage-label b {
    display: inline-grid;
    place-items: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: #07853a;
    font-size: 0.8rem;
}

.category-choice,
.material-chip {
    animation: cw-in 0.45s cubic-bezier(.22, .8, .2, 1) both;
    animation-delay: calc(var(--i, 0) * 40ms);
}

@keyframes cw-in {
    from { opacity: 0; transform: translateX(24px); }
}

.category-choice {
    transition: transform 0.25s cubic-bezier(.22, .8, .2, 1), box-shadow 0.25s, background 0.25s;
}

.category-choice:hover {
    transform: translateY(-2px);
    background: #fff;
    box-shadow: 0 14px 28px rgba(29, 33, 48, 0.14);
}

.material-chip-image {
    transition: transform 0.6s cubic-bezier(.22, .8, .2, 1);
}

.material-chip:hover .material-chip-image {
    transform: scale(1.08);
}

.material-chip.is-active::after {
    content: "✓";
    position: absolute;
    left: 0.8rem;
    top: 50%;
    width: 1.8rem;
    height: 1.8rem;
    margin-top: -0.9rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #f9bf29;
    color: #1d2130;
    font-weight: 800;
    animation: cw-pop-check 0.4s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes cw-pop-check {
    from { transform: scale(0); }
}

.sidebar-placeholder .sidebar-icon {
    animation: cw-float 3s ease-in-out infinite;
}

@keyframes cw-float {
    50% { transform: translateY(-8px); }
}

.detail-image {
    animation: cw-fade 0.8s ease both;
}

@keyframes cw-fade {
    from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Похожие оттенки */
.sim-box { margin: 0 0 14px; padding: 12px; border-radius: 16px; background: rgba(249,191,41,.12); box-shadow: inset 0 0 0 1px rgba(249,191,41,.45); animation: sim-in .4s ease both; }
@keyframes sim-in { from { opacity: 0; transform: translateY(-6px); } }
.sim-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; font-weight: 700; line-height: 1.3; }
.sim-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.sim-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sim-chip { display: grid; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.sim-chip img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); transition: transform .2s; }
.sim-chip:hover img { transform: translateY(-2px); outline: 2px solid #f9bf29; }
.sim-chip span { font-size: 11px; font-weight: 600; line-height: 1.2; overflow: hidden; }
.sim-chip small { display: block; opacity: .6; font-weight: 500; }
