:root {
    --bg: #f5f3ee;
    --surface: #ffffff;
    --text: #172018;
    --muted: #69746a;
    --brand: #178a44;
    --brand-dark: #0f6f35;
    --line: rgba(23, 32, 24, 0.1);
    --shadow: 0 20px 70px rgba(19, 37, 23, 0.14);
    --scene-shadow: 0 22px 50px rgba(42, 46, 39, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top left, rgba(174, 227, 181, 0.55) 0, transparent 28%), linear-gradient(180deg, #f8f6f2 0%, #f1eee8 100%);
}

.shell {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 24px 16px 40px;
    overflow-x: clip;
}

.shell.compact {
    max-width: 760px;
}

.hero {
    min-height: 52vh;
    display: grid;
    align-content: center;
    gap: 18px;
    padding: 42px 0;
}

.card,
.panel,
.room-card {
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.card {
    padding: 28px;
}

.eyebrow {
    margin: 0;
    color: var(--brand-dark);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 12px;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.05;
}

h1 {
    font-size: clamp(36px, 8vw, 76px);
    max-width: 920px;
}

h2 {
    font-size: clamp(26px, 5vw, 42px);
}

h3 {
    font-size: 18px;
}

.lead {
    margin: 0;
    max-width: 680px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.55;
}

button,
.primary,
.secondary {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 20px;
    font-weight: 700;
    text-decoration: none;
}

.primary {
    background: var(--brand);
    color: white;
}

.primary:hover {
    background: var(--brand-dark);
}

.secondary {
    background: #eef4ee;
    color: var(--text);
}

.wide {
    width: 100%;
    margin-top: 12px;
}

.notice {
    padding: 16px;
    border-radius: 18px;
    background: #fff8e6;
    border: 1px solid #f3d27d;
}

.notice span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
}

.planner {
    display: grid;
    gap: 18px;
}

.planner-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.planner-titlebar {
    width: 100%;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 6px;
}

.planner-titlebar h2 {
    font-size: clamp(24px, 4.5vw, 36px);
}

.planner-settings {
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    box-shadow: 0 10px 24px rgba(23, 32, 24, 0.08);
}

.room-card {
    position: relative;
    overflow: hidden;
    min-height: 340px;
    display: grid;
    place-items: center;
    padding: 12px;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.room-stage {
    position: relative;
    width: min(100%, 430px);
    aspect-ratio: 240 / 463;
    border-radius: 0;
    overflow: hidden;
    background: #f7f6f1;
    box-shadow: none;
}

.room-photo,
.room-after-layer,
.room-zones,
.object-layer {
    position: absolute;
    inset: 0;
}

.room-photo {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: fill;
    z-index: 0;
}

.room-zones {
    width: 100%;
    height: 100%;
}

.room-after-layer {
    width: 100%;
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.12s ease;
    z-index: 1;
}

.compare-badge {
    position: absolute;
    right: 16px;
    top: 94px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 22px rgba(23, 32, 24, 0.12);
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    z-index: 4;
    display: none;
}

.compare-toggle {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    min-height: 38px;
    padding: 0 17px;
    background: rgba(255, 255, 255, 0.96);
    color: #151a16;
    font-size: 14px;
    box-shadow: 0 6px 18px rgba(23, 32, 24, 0.18);
}

.compare-toggle-top {
    top: 16px;
}

.object-layer {
    pointer-events: none;
    z-index: 2;
}

.room-stage.has-custom-photo {
    background: #101413;
}

.room-stage.has-custom-photo .room-surface {
    fill: transparent;
}

.room-stage.has-custom-photo .room-edge {
    stroke: rgba(255, 255, 255, 0.7);
    stroke-width: 1.2;
}

.placed-object {
    position: absolute;
    z-index: 2;
    display: block;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    border-radius: 4px;
    background: transparent !important;
    box-shadow: none;
    cursor: grab;
    pointer-events: auto;
    transform: translateY(-50%);
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

.placed-object:active {
    cursor: grabbing;
}

.placed-object.is-selected {
    outline: 2px dashed rgba(23, 138, 68, 0.85);
    outline-offset: 0;
}

.placed-object img {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 14px 18px rgba(23, 32, 24, 0.2));
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none;
}

.placed-object-label {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    background: rgba(255, 255, 255, 0.94);
    padding: 3px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(23, 32, 24, 0.14);
    pointer-events: none;
    z-index: 5;
}

.placed-object-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: white;
    border: 2px solid var(--brand);
    border-radius: 3px;
    pointer-events: auto;
    z-index: 5;
    touch-action: none;
}

.placed-object-handle.handle-se {
    right: -8px;
    bottom: -8px;
    cursor: nwse-resize;
}

.placed-object-handle.handle-sw {
    left: -8px;
    bottom: -8px;
    cursor: nesw-resize;
}

.room-zones .room-zone-surface,
.room-scene .room-zone-surface {
    fill: transparent;
    stroke: transparent;
    stroke-width: 0;
    vector-effect: non-scaling-stroke;
    cursor: pointer;
    transition: stroke 0.15s ease, stroke-width 0.15s ease;
}

.room-zone-anchor,
.room-scene .room-zone-anchor {
    fill: transparent;
    stroke: transparent;
    stroke-width: 0;
    pointer-events: none;
}

.room-zones .room-zone-surface:hover,
.room-scene .room-zone-surface:hover,
.room-zones .room-zone-surface.is-active,
.room-scene .room-zone-surface.is-active {
    fill: transparent;
    stroke: #2DB35D;
    stroke-width: 5;
}

.room-zones .room-zone-surface.has-material,
.room-scene .room-zone-surface.has-material {
    fill-opacity: 0.9;
    stroke: rgba(45, 179, 93, 0.5);
    stroke-width: 2;
}

.room-zones .room-zone-surface.has-material:hover,
.room-scene .room-zone-surface.has-material:hover,
.room-zones .room-zone-surface.has-material.is-active,
.room-scene .room-zone-surface.has-material.is-active {
    stroke: #2DB35D;
    stroke-width: 5;
}

.room-scene {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
}

/* ── Нарисованные поверхности комнаты ── */
.room-surface {
    pointer-events: none;
}

.room-ceiling {
    fill: #e8e6df;
}

.room-back-wall {
    fill: #f5f3ee;
}

.room-left-wall {
    fill: #ede9e2;
}

.room-right-wall {
    fill: #ece8e1;
}

.room-floor-bg {
    fill: #d8d2c6;
}

.room-edge {
    stroke: #c0bbb2;
    stroke-width: 1.5;
    pointer-events: none;
}


.zone-label {
    fill: #141815;
    font-size: 32px;
    font-weight: 600;
    line-height: 1.05;
    pointer-events: none;
    text-shadow: 0 1px 6px rgba(255, 255, 255, 0.9);
    transition: opacity 0.15s ease;
}

.room-zone-surface.has-material+.zone-label {
    opacity: 0;
}

.room-zone-surface.has-material:hover+.zone-label,
.room-zone-surface.has-material.is-active+.zone-label {
    opacity: 0.82;
}

.panel-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 18px;
}

.controls-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.86);
}

.object-toolbar {
    display: grid;
    grid-template-columns: 1fr minmax(160px, 260px) auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid rgba(23, 138, 68, 0.28);
    border-radius: 24px;
    background: rgba(236, 248, 238, 0.92);
}

.object-toolbar[hidden] {
    display: none;
}

.object-toolbar strong,
.object-toolbar span {
    display: block;
}

.object-toolbar span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 14px;
}

.range-control {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.file-control {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.file-control input {
    max-width: min(240px, 100%);
}

.photo-controls {
    display: grid;
    gap: 8px;
    align-items: start;
}

.selection-toolbar {
    display: grid;
    gap: 8px;
    align-items: start;
}

.photo-reset,
.material-reset {
    min-height: 40px;
    padding: 0 16px;
    justify-self: start;
}

.photo-reset {
    margin-top: 0;
}

.photo-reset:disabled,
.material-reset:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.range-control input {
    accent-color: var(--brand);
    width: 100%;
}

.range-control.compact {
    gap: 4px;
}

.segmented {
    display: inline-flex;
    gap: 6px;
    padding: 4px;
    border-radius: 999px;
    background: #eef4ee;
    justify-self: start;
}

.segmented .secondary {
    min-height: 40px;
    background: transparent;
}

.segmented .secondary.is-active {
    background: var(--surface);
    color: var(--brand-dark);
    box-shadow: 0 6px 18px rgba(23, 32, 24, 0.1);
}

.panel {
    padding: 18px;
}

.panel-hint {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.4;
}

.catalog-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.catalog-item {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fbfdfb;
    text-align: left;
}

.catalog-button {
    width: 100%;
    min-height: 0;
    display: block;
    cursor: pointer;
}

.catalog-button:hover,
.catalog-button.is-selected {
    border-color: rgba(23, 138, 68, 0.5);
    box-shadow: 0 10px 24px rgba(23, 138, 68, 0.12);
}

.object-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.object-card-actions .secondary {
    min-height: 38px;
    padding: 0 14px;
    font-size: 13px;
}

.catalog-item strong {
    display: block;
}

.catalog-item span {
    color: var(--muted);
    font-size: 14px;
}

.catalog-section-title {
    margin: 8px 0 0;
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.catalog-empty {
    padding: 12px;
    border: 1px dashed var(--line);
    border-radius: 16px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.72);
}

.cart-line,
.cart-total {
    display: grid;
    grid-template-columns: 1fr 78px auto;
    gap: 10px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.cart-line strong,
.cart-line span {
    display: block;
}

.cart-line span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.cart-line input {
    width: min(78px, 100%);
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0 10px;
    font-weight: 700;
}

.cart-total {
    grid-template-columns: 1fr auto;
    border-bottom: 0;
    font-size: 18px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%) translateY(80px);
    opacity: 0;
    padding: 12px 16px;
    border-radius: 999px;
    background: #172018;
    color: white;
    transition: 0.2s ease;
    z-index: 10;
}

.toast.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.project-state {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fbfdfb;
}

.project-summary,
.project-cart,
.project-qr {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
}

.project-summary[hidden],
.project-cart[hidden],
.project-qr[hidden] {
    display: none;
}

.project-summary p {
    margin: 0 0 8px;
}

.project-qr img {
    display: block;
    border-radius: 16px;
}

.side-panel {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 28px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
}

.bottom-nav {
    display: flex;
    height: 52px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    min-height: 0;
    padding: 0 4px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.tab-btn.is-active {
    color: var(--brand);
    background: rgba(23, 138, 68, 0.06);
}

.bottom-drawer {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.drawer-tab-content {
    padding: 16px;
    overflow-y: auto;
    max-height: 44vh;
}

.drawer-tab-content[hidden] {
    display: none;
}

.cta-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    flex-shrink: 0;
}

.cta-total {
    flex: 1;
    font-weight: 800;
    font-size: 15px;
    color: var(--brand-dark);
}

.cta-strip .primary {
    white-space: nowrap;
}

@media (max-width: 760px) {
    .planner-header {
        align-items: stretch;
    }

    .panel-grid {
        grid-template-columns: 1fr;
    }

    .room-card {
        border-radius: 22px;
        min-height: 250px;
        padding: 0;
    }

    .compare-badge {
        right: 10px;
        top: 86px;
        font-size: 12px;
    }

    .planner-titlebar {
        min-height: 44px;
        padding: 0;
    }

    .planner-titlebar h2 {
        font-size: 23px;
    }

    .planner-settings {
        width: 34px;
        min-width: 34px;
        min-height: 34px;
        font-size: 15px;
    }

    .room-stage {
        width: min(100%, 400px);
    }

    .compare-toggle {
        min-height: 38px;
        padding-inline: 16px;
        font-size: 14px;
    }

    .zone-label {
        font-size: 34px;
    }

    .controls-panel {
        grid-template-columns: 1fr;
    }

    .object-toolbar {
        grid-template-columns: 1fr;
    }

    .panel {
        border-radius: 24px 24px 0 0;
    }

    .cart-line {
        grid-template-columns: 1fr 68px;
    }

    .cart-line>strong:last-child {
        grid-column: 1 / -1;
        justify-self: end;
    }
}

@media (max-width: 420px) {
    .shell {
        padding-inline: 12px;
    }

    .hero {
        min-height: 46vh;
        padding: 30px 0;
    }

    .card {
        padding: 20px;
    }

    .object-card-actions,
    .actions {
        flex-direction: column;
    }

    .object-card-actions .secondary,
    .actions .secondary,
    .actions .primary {
        width: 100%;
    }

    .room-stage {
        border-radius: 0;
    }
}

@media (min-width: 768px) {
    .planner {
        display: grid;
        grid-template-columns: 1fr 300px;
        grid-template-areas:
            "header header"
            "canvas side"
            "controls side"
            "toolbar side";
        gap: 18px;
        align-items: start;
    }

    .planner-header {
        grid-area: header;
    }

    .room-card {
        grid-area: canvas;
        min-height: min(82vh, 860px);
    }

    .controls-panel {
        grid-area: controls;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .object-toolbar {
        grid-area: toolbar;
        grid-template-columns: 1fr;
    }

    .side-panel {
        grid-area: side;
        align-self: start;
        position: sticky;
        top: 12px;
    }

    .drawer-tab-content {
        max-height: calc(100vh - 260px);
    }
}

@media (min-width: 1200px) {
    .planner {
        grid-template-columns: 1fr 360px;
    }

    .room-stage {
        width: min(100%, 520px);
    }
}