/* Подключение: <link rel="stylesheet" href="/constructor/constructor.css"> */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --black: #000000;
    --white: #ffffff;
    --bg: #f2f2ef;
    --viewport-canvas-bg: #c2c2be;
    --gray: #f9f9f9;
    --gray-dark: #757575;
    --red: #e72f51;
    --font-sans: 'General Sans', sans-serif;
    --font-logo: 'Unbounded', 'General Sans', sans-serif;
}
html {
    height: 100%;
    background: var(--bg);
}
body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--black);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    min-height: 100dvh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Top bar */
.top-bar {
    flex-shrink: 0;
    background: var(--black);
    color: var(--white);
    font-size: 10px;
    font-weight: 300;
    padding: 6px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.top-bar a { color: var(--white); text-decoration: none; opacity: 0.7; transition: opacity 0.2s; }
.top-bar a:hover { opacity: 1; }

/* Header */
header {
    flex-shrink: 0;
    background: var(--white);
    border-bottom: 1px solid var(--black);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
    position: relative;
}
.logo {
    font-family: var(--font-logo);
    text-transform: uppercase;
    font-weight: 600;
    font-size: clamp(13px, 3.5vw, 18px);
    letter-spacing: 0.18em;
    text-decoration: none;
    color: var(--black);
}
.logo sup { font-size: 0.5em; vertical-align: super; margin-left: 2px; letter-spacing: normal; }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.header-actions a, .header-actions button {
    background: none; border: none; cursor: pointer; color: var(--black);
    font-family: var(--font-sans); font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.08em; font-weight: 300; text-decoration: none;
    padding: 8px 16px; border: 1px solid var(--black); transition: all 0.2s;
}
.header-actions a:hover, .header-actions button:hover {
    background: var(--black); color: var(--white);
}
.btn-primary {
    background: var(--black) !important; color: var(--white) !important;
}
.btn-primary:hover { background: #333 !important; }
.btn-outline {
    background: var(--white) !important;
    color: var(--black) !important;
}
.btn-outline:hover {
    background: var(--black) !important;
    color: var(--white) !important;
}

/* Main layout: заполняет всё под шапкой без calc (иначе на мобильных — полоска снизу) */
.app-layout {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 340px;
    min-width: 340px;
    background: var(--white);
    border-right: 1px solid var(--black);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--black);
    flex-shrink: 0;
}
.sidebar-tab {
    flex: 1;
    padding: 10px 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 400;
    text-align: center;
    cursor: pointer;
    background: var(--white);
    color: var(--black);
    border: none;
    border-right: 1px solid var(--black);
    font-family: var(--font-sans);
    transition: all 0.2s;
}
.sidebar-tab:last-child { border-right: none; }
.sidebar-tab.active { background: var(--black); color: var(--white); }
.sidebar-tab:not(.active):hover { background: var(--gray); }

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}
.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.panel { display: none; }
.panel.active { display: block; }

.section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 400;
    color: var(--gray-dark);
    margin-bottom: 12px;
}

.section-block { margin-bottom: 24px; }

/* Garment selector */
.garment-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.garment-option {
    border: 1px solid #e0e0e0;
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--white);
}
.garment-option:hover { border-color: var(--black); }
.garment-option.active { border-color: var(--black); background: var(--gray); }
.garment-option svg { width: 40px; height: 40px; margin-bottom: 6px; }
.garment-option .garment-type-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 8px;
}
.garment-option span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 400; }

/* Color swatches */
.color-swatches {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.color-swatch {
    width: 32px; height: 32px;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border: 2px solid var(--black); }
.color-swatch.active::after {
    content: ''; position: absolute; inset: 2px;
    border: 1px solid var(--white);
}

/* Input */
.field-label {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
    font-weight: 400; color: var(--gray-dark); margin-bottom: 6px; display: block;
}
.text-input, .number-input, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--black);
    background: var(--gray);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 300;
    outline: none;
    transition: box-shadow 0.15s;
}
.text-input:focus, .number-input:focus, select:focus {
    box-shadow: 0 0 0 1px var(--black);
}
.number-input {
    -moz-appearance: textfield;
    appearance: textfield;
}
.number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
}

.range-row {
    display: flex; align-items: center; gap: 10px;
}
.range-row input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 1px;
    background: var(--black); outline: none;
}
.range-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px; height: 14px;
    background: var(--black); border-radius: 50%; cursor: pointer;
}
.range-value {
    font-size: 11px; font-weight: 300; min-width: 30px; text-align: right;
}

.btn-action {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--black);
    background: var(--white);
    font-family: var(--font-sans);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}
.btn-action:hover { background: var(--black); color: var(--white); }
.btn-action.danger { border-color: var(--red); color: var(--red); }
.btn-action.danger:hover { background: var(--red); color: var(--white); }

/* Upload area */
.upload-area {
    border: 1px dashed #ccc;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--gray);
}
.upload-area:hover { border-color: var(--black); }
.upload-area svg { width: 28px; height: 28px; margin: 0 auto 8px; color: var(--gray-dark); }
.upload-area p { font-size: 11px; color: var(--gray-dark); font-weight: 300; }

/* Canvas viewport */
.viewport {
    flex: 1;
    position: relative;
    background: var(--viewport-canvas-bg);
    overflow: hidden;
}
.viewport-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.garment-pan-root {
    position: absolute;
    inset: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.garment-stack {
    position: relative;
    display: inline-block;
    line-height: 0;
    max-width: 100%;
    max-height: 100%;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-drag: none;
}
.garment-move {
    position: relative;
    display: inline-block;
    line-height: 0;
    transform-origin: center center;
    will-change: transform;
}
#garment-canvas {
    display: block;
    pointer-events: none;
    user-select: none;
}
.garment-src-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}
#design-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: auto;
    touch-action: none;
    cursor: grab;
    display: block;
    user-select: none;
    -webkit-user-select: none;
}
#design-layer.dragging-garment,
#design-layer.dragging-design {
    cursor: grabbing;
}
.garment-loader-wrap {
    position: absolute;
    inset: 0;
    z-index: 12;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--viewport-canvas-bg);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.55s ease, visibility 0.55s ease;
}
.garment-loader-wrap.is-visible {
    opacity: 1;
    visibility: visible;
}
#garment-loader-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.garment-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: stretch;
    gap: 0;
    border: 1px solid var(--black);
    background: var(--white);
    z-index: 15;
}
.garment-ctrl-btn {
    min-width: 36px;
    padding: 8px 10px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    background: var(--white);
    color: var(--black);
    border: none;
    border-right: 1px solid var(--black);
    font-family: var(--font-sans);
    transition: background 0.15s;
}
.garment-ctrl-btn:last-child { border-right: none; }
.garment-ctrl-btn:hover { background: var(--gray); }
.garment-ctrl-reset {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 400;
    padding: 8px 10px;
}
.view-toggles {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100% - 24px);
    gap: 0;
    border: 1px solid var(--black);
    background: var(--white);
    z-index: 10;
}
.view-btn {
    padding: 8px 16px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 400;
    cursor: pointer;
    background: var(--white);
    color: var(--black);
    border: none;
    border-right: 1px solid var(--black);
    font-family: var(--font-sans);
    transition: all 0.2s;
}
.view-btn:last-child { border-right: none; }
.view-btn.active { background: var(--black); color: var(--white); }
.view-btn:not(.active):hover { background: var(--gray); }

/* Layers list */
#layers-list {
    min-height: 8px;
}
#layers-list.layer-dnd-active {
    outline: 1px dashed rgba(0, 0, 0, 0.2);
    outline-offset: 2px;
    border-radius: 2px;
}
.layer-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid #e0e0e0;
    margin-bottom: 4px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, opacity 0.15s;
    font-size: 12px;
    font-weight: 300;
    background: var(--white);
}
.layer-item:hover { border-color: var(--black); }
.layer-item.active { border-color: var(--black); background: var(--gray); }
.layer-item.layer-dragging {
    opacity: 0.45;
}
.layer-item.layer-drop-before {
    box-shadow: inset 0 2px 0 0 var(--black);
}
.layer-item.layer-drop-after {
    box-shadow: inset 0 -2px 0 0 var(--black);
}
.layer-drag-handle {
    flex-shrink: 0;
    width: 18px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    color: var(--gray-dark);
    font-size: 11px;
    letter-spacing: -2px;
    user-select: none;
    border: 1px solid transparent;
    border-radius: 2px;
}
.layer-drag-handle:hover {
    border-color: #ddd;
    background: var(--gray);
    color: var(--black);
}
.layer-drag-handle:active {
    cursor: grabbing;
}
.layer-icon {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
}
.layer-thumb {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: block;
    border: 1px solid #e0e0e0;
    border-radius: 2px;
    background: #f5f5f5;
    object-fit: contain;
}
.layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-delete {
    background: none; border: none; cursor: pointer; font-size: 14px;
    color: var(--gray-dark); padding: 2px; transition: color 0.15s;
}
.layer-delete:hover { color: var(--red); }

.empty-state {
    text-align: center; padding: 30px 10px;
    font-size: 12px; font-weight: 300; color: var(--gray-dark);
    line-height: 1.6;
}

/* 2D overlay canvas */
#overlay-canvas {
    position: absolute;
    top: 0; left: 0;
    pointer-events: none;
    z-index: 5;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .sidebar { width: 280px; min-width: 280px; }
    .app-layout {
        flex-direction: column-reverse;
    }
    .sidebar {
        width: 100%; min-width: 100%;
        height: 45%;
        border-right: none;
        border-top: 1px solid var(--black);
    }
    .viewport {
        height: 55%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }
    .view-toggles {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        max-width: none;
        width: 100%;
        flex-shrink: 0;
        order: -1;
        margin: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        border-bottom: 1px solid var(--black);
    }
    .view-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 9px 4px;
        font-size: 8px;
        letter-spacing: 0.06em;
    }
    .viewport-stage {
        position: relative;
        inset: auto;
        flex: 1;
        min-height: 0;
        width: 100%;
    }

    header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 12px;
    }
    .logo {
        align-self: center;
        width: 100%;
        max-width: 100%;
        text-align: center;
        white-space: nowrap;
        font-size: clamp(8px, 2.7vw, 15px);
        letter-spacing: 0.05em;
        line-height: 1.2;
    }
    .header-actions {
        width: 100%;
        justify-content: stretch;
        gap: 8px;
    }
    .header-actions button {
        flex: 1 1 0;
        min-width: 0;
        padding: 9px 6px;
        font-size: 9px;
        letter-spacing: 0.06em;
    }

    .garment-controls {
        bottom: 8px;
        right: 8px;
    }
    .garment-ctrl-btn {
        min-width: 32px;
        padding: 7px 8px;
    }
    .garment-ctrl-reset {
        font-size: 8px;
        padding: 7px 6px;
    }
}

/* Color picker row */
.color-picker-row {
    display: flex; align-items: center; gap: 8px; margin-top: 8px;
}
.color-picker-row input[type="color"] {
    width: 32px; height: 32px; border: 1px solid var(--black);
    padding: 0; cursor: pointer; background: none;
}
.color-picker-row span { font-size: 11px; font-weight: 300; color: var(--gray-dark); }

/* Design elements list */
.design-el-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border: 1px solid #e0e0e0;
    margin-bottom: 4px; cursor: pointer; transition: all 0.15s;
}
.design-el-item:hover { border-color: var(--black); }
.design-el-item.selected { border-color: var(--black); background: var(--gray); }

.inline-row { display: flex; gap: 8px; }
.inline-row > * { flex: 1; }

/* Модалка заявки с конструктора */
.ctor-order-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
}
.ctor-order-overlay.is-open {
    display: flex;
}
.ctor-order-dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 92vh;
    overflow-y: auto;
    background: var(--white);
    border: 1px solid var(--black);
    padding: 28px 24px 24px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12);
}
.ctor-order-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 1px solid var(--black);
    background: var(--white);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--black);
    transition: background 0.2s, color 0.2s;
}
.ctor-order-close:hover {
    background: var(--black);
    color: var(--white);
}
.ctor-order-title {
    font-family: var(--font-logo);
    font-size: 14px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin: 0 36px 12px 0;
    font-weight: 600;
}
.ctor-order-lead {
    font-size: 12px;
    font-weight: 300;
    line-height: 1.5;
    color: var(--gray-dark);
    margin: 0 0 20px;
}
.ctor-order-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ctor-order-form.is-busy {
    pointer-events: none;
    opacity: 0.72;
}
.ctor-order-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    color: var(--gray-dark);
    margin-top: 8px;
}
.ctor-order-label:first-of-type {
    margin-top: 0;
}
.ctor-order-input,
.ctor-order-textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--black);
    padding: 10px 12px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 300;
    background: var(--white);
}
.ctor-order-textarea {
    resize: vertical;
    min-height: 72px;
}
.ctor-order-input:focus,
.ctor-order-textarea:focus {
    outline: 1px solid var(--black);
    outline-offset: 0;
}
.ctor-order-error {
    font-size: 12px;
    color: #b00020;
    margin: 8px 0 0;
}
.ctor-order-progress {
    margin-top: 12px;
}
.ctor-order-progress-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 8px;
    font-weight: 500;
}
.ctor-order-progress-track {
    height: 4px;
    background: #e5e5e5;
    overflow: hidden;
}
.ctor-order-progress-bar {
    height: 100%;
    width: 0;
    background: var(--black);
    transition: width 0.12s ease-out;
}
.ctor-order-progress-bar.is-indeterminate {
    width: 35%;
    animation: ctorOrderIndet 1s ease-in-out infinite;
}
@keyframes ctorOrderIndet {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}
.ctor-order-submit {
    margin-top: 16px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: var(--black);
    color: var(--white);
    font-family: var(--font-sans);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    cursor: pointer;
    transition: background 0.2s;
}
.ctor-order-submit:hover:not(:disabled) {
    background: #333;
}
.ctor-order-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}
.ctor-order-submit-muted {
    background: var(--white);
    color: var(--black);
    border: 1px solid var(--black);
}
.ctor-order-submit-muted:hover:not(:disabled) {
    background: var(--black);
    color: var(--white);
}
.ctor-order-success {
    text-align: center;
    padding: 8px 0 0;
}
.ctor-order-success-title {
    font-family: var(--font-logo);
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin: 0 0 12px;
}
.ctor-order-success-text {
    font-size: 13px;
    font-weight: 300;
    line-height: 1.5;
    margin: 0 0 20px;
    color: var(--gray-dark);
}