.design-header {
    grid-template-columns: 190px minmax(240px, 1fr) auto;
    position: sticky;
    top: 0;
    z-index: 20;
}

.design-page {
    height: calc(100vh - 61px);
    display: grid;
    grid-template-columns: minmax(292px, 320px) minmax(520px, 1fr) minmax(292px, 320px);
    gap: 14px;
    overflow: hidden;
    padding: 14px;
    background:
        linear-gradient(90deg, rgba(180, 85, 60, 0.08), transparent 28%),
        linear-gradient(270deg, rgba(63, 130, 99, 0.08), transparent 26%),
        #f4f6f2;
}

.design-tools,
.design-order,
.design-workspace__body {
    scrollbar-width: thin;
    scrollbar-color: rgba(180, 85, 60, 0.48) rgba(44, 62, 80, 0.06);
}

.design-tools::-webkit-scrollbar,
.design-order::-webkit-scrollbar,
.design-workspace__body::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.design-tools::-webkit-scrollbar-track,
.design-order::-webkit-scrollbar-track,
.design-workspace__body::-webkit-scrollbar-track {
    background: rgba(44, 62, 80, 0.06);
    border-radius: 999px;
}

.design-tools::-webkit-scrollbar-thumb,
.design-order::-webkit-scrollbar-thumb,
.design-workspace__body::-webkit-scrollbar-thumb {
    border: 2px solid rgba(255, 255, 255, 0.75);
    border-radius: 999px;
    background: rgba(180, 85, 60, 0.56);
}

.design-tools::-webkit-scrollbar-thumb:hover,
.design-order::-webkit-scrollbar-thumb:hover,
.design-workspace__body::-webkit-scrollbar-thumb:hover {
    background: rgba(180, 85, 60, 0.78);
}

.design-tools,
.design-order,
.design-workspace {
    min-height: 0;
    border: 1px solid #dde2dc;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
}

.design-tools,
.design-order {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.design-panel-heading,
.design-order__heading {
    padding: 18px 18px 14px;
    border-bottom: 1px solid #edf0ec;
}

.design-panel-heading p,
.design-order__heading p {
    color: #b4553c;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.design-panel-heading h1,
.design-order__heading h2 {
    color: #2C3E50;
    font-family: "Playwrite AU TAS", cursive;
    font-size: 24px;
    line-height: 1.25;
}

.design-tool-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid #dde2dc;
}

.design-tool-tabs button {
    min-height: 58px;
    display: grid;
    place-items: center;
    gap: 4px;
    border: 0;
    color: #56666e;
    background: white;
    font-size: 11px;
    font-weight: 900;
}

.design-tool-tabs button i {
    font-size: 16px;
}

.design-tool-tabs button.is-active {
    color: #b4553c;
    box-shadow: inset 0 -3px 0 #b4553c;
}

.design-tool-panel {
    display: none;
    gap: 15px;
    min-height: max-content;
    padding: 18px;
}

.design-tool-panel.is-active {
    display: grid;
}

.design-tool-panel h2 {
    color: #2C3E50;
    font-size: 19px;
}

.design-hint {
    color: #66767d;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.55;
}

.template-list,
.quick-images {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.template-card,
.quick-image-button {
    min-height: 82px;
    border: 1px solid #dde2dc;
    border-radius: 6px;
    overflow: hidden;
    background: white;
}

.template-card {
    display: grid;
    gap: 8px;
    padding: 10px;
    text-align: left;
}

.template-card.is-active {
    border-color: #b4553c;
    box-shadow: 0 0 0 3px rgba(180, 85, 60, 0.12);
}

.template-card__swatch {
    height: 42px;
    border-radius: 4px;
}

.template-card strong {
    color: #2C3E50;
    font-size: 13px;
}

.quick-image-button img,
.asset-card img {
    width: 100%;
    height: 86px;
    object-fit: cover;
}

.asset-library,
.element-palette {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.asset-card,
.asset-add-button,
.element-card {
    border: 1px solid #dde2dc;
    border-radius: 6px;
    background: white;
    cursor: grab;
}

.asset-card {
    overflow: hidden;
    text-align: left;
}

.asset-card span {
    display: block;
    padding: 8px 10px 10px;
    color: #4d5f67;
    font-size: 12px;
    font-weight: 900;
}

.asset-card:active {
    cursor: grabbing;
}

.asset-add-button,
.element-card {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: #2C3E50;
    font-weight: 900;
}

.element-card {
    min-height: 76px;
    flex-direction: column;
}

.element-card i {
    color: #b4553c;
    font-size: 22px;
}

.upload-box {
    min-height: 132px;
    display: grid;
    place-items: center;
    gap: 8px;
    border: 1px dashed #b7c2bd;
    border-radius: 8px;
    color: #56666e;
    background: #fbfcfb;
    font-weight: 800;
    text-align: center;
    cursor: pointer;
}

.upload-box--compact {
    min-height: 112px;
}

.upload-box input {
    display: none;
}

.upload-box i {
    color: #b4553c;
    font-size: 28px;
}

.design-field {
    display: grid;
    gap: 7px;
    color: #4d5f67;
    font-size: 13px;
    font-weight: 900;
}

.design-field input,
.design-field textarea,
.design-field select {
    width: 100%;
    border: 1px solid #cfd8d3;
    border-radius: 4px;
    padding: 11px 12px;
    outline: 0;
    color: #22313a;
    background: white;
}

.design-field input:focus,
.design-field textarea:focus,
.design-field select:focus {
    border-color: #2C3E50;
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

.design-field input[type="color"] {
    height: 46px;
    padding: 4px;
}

.design-field input[type="range"] {
    accent-color: #b4553c;
    padding-inline: 0;
}

.design-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #4d5f67;
    font-weight: 800;
}

.design-workspace {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    overscroll-behavior: contain;
    background:
        linear-gradient(rgba(44, 62, 80, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(44, 62, 80, 0.04) 1px, transparent 1px),
        #f9faf8;
    background-size: 28px 28px;
}

.design-workspace__body {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
}

.design-workspace__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid #dde2dc;
    background: rgba(255, 255, 255, 0.82);
}

.design-workspace__bar p {
    color: #b4553c;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.design-workspace__bar strong {
    color: #2C3E50;
    font-size: 18px;
}

.workspace-switches {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.preview-actions,
.orientation-actions {
    position: relative;
    display: inline-flex;
    border: 1px solid #cfd8d3;
    border-radius: 999px;
    padding: 4px;
    background: white;
    isolation: isolate;
}

.preview-actions::before,
.orientation-actions::before {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    z-index: -1;
    border-radius: 999px;
    background: #2C3E50;
    box-shadow: 0 8px 18px rgba(44, 62, 80, 0.18);
    transition:
        transform 0.28s ease,
        width 0.28s ease,
        background-color 0.28s ease;
}

.preview-actions::before {
    width: calc(50% - 4px);
}

.orientation-actions::before {
    width: calc(50% - 4px);
    background: #3f8263;
}

.preview-actions[data-side-switch="back"]::before,
.orientation-actions[data-orientation-switch="landscape"]::before {
    transform: translateX(100%);
}

.preview-actions button,
.orientation-actions button {
    min-height: 36px;
    border: 0;
    border-radius: 999px;
    padding: 0 16px;
    color: #56666e;
    background: transparent;
    font-weight: 900;
    transition: color 0.22s ease;
}

.orientation-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.preview-actions button.is-active,
.orientation-actions button.is-active {
    color: white;
}

.postcard-stage {
    min-width: max-content;
    min-height: max-content;
    display: grid;
    place-items: center;
    overflow: visible;
    padding: 28px;
    perspective: 1600px;
}

.postcard-flipper {
    position: relative;
    width: min(620px, 62vh);
    min-width: 360px;
    aspect-ratio: 4 / 6;
    transform-style: preserve-3d;
    transition:
        width 0.42s ease,
        aspect-ratio 0.42s ease,
        transform 0.75s cubic-bezier(.2, .7, .2, 1);
}

.postcard-flipper[data-paper-size="5x7"] {
    aspect-ratio: 5 / 7;
}

.postcard-flipper[data-paper-size="square"] {
    aspect-ratio: 1 / 1;
    width: min(680px, 68vh);
}

.postcard-flipper[data-orientation="landscape"] {
    aspect-ratio: 6 / 4;
    width: min(760px, 78vh);
}

.postcard-flipper[data-paper-size="5x7"][data-orientation="landscape"] {
    aspect-ratio: 7 / 5;
}

.postcard-flipper[data-paper-size="square"][data-orientation="landscape"] {
    aspect-ratio: 1 / 1;
}

.postcard-flipper.is-back {
    transform: rotateY(180deg);
}

.postcard-flipper.is-orientation-changing {
    animation: postcard-orientation-turn 0.48s cubic-bezier(.2, .7, .2, 1);
}

.postcard-flipper.is-back.is-orientation-changing {
    animation: postcard-orientation-turn-back 0.48s cubic-bezier(.2, .7, .2, 1);
}

@keyframes postcard-orientation-turn {
    0% {
        transform: rotateY(0deg) rotateZ(0deg) scale(1);
    }

    45% {
        transform: rotateY(0deg) rotateZ(7deg) scale(0.94);
    }

    100% {
        transform: rotateY(0deg) rotateZ(0deg) scale(1);
    }
}

@keyframes postcard-orientation-turn-back {
    0% {
        transform: rotateY(180deg) rotateZ(0deg) scale(1);
    }

    45% {
        transform: rotateY(180deg) rotateZ(-7deg) scale(0.94);
    }

    100% {
        transform: rotateY(180deg) rotateZ(0deg) scale(1);
    }
}

.postcard-preview {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border: 10px solid #fff;
    border-radius: 8px;
    color: #2C3E50;
    background: #f8efe5;
    box-shadow: 0 26px 70px rgba(44, 62, 80, 0.22);
    backface-visibility: hidden;
}

.postcard-layer-canvas {
    position: absolute;
    inset: 0;
}

.postcard-preview--back {
    display: grid;
    grid-template-columns: 1fr 42%;
    gap: 24px;
    padding: 34px;
    transform: rotateY(180deg);
}

.postcard-flipper[data-paper-edge="deckle"] .postcard-preview {
    border-style: dashed;
}

.postcard-flipper[data-paper-edge="rounded"] .postcard-preview {
    border-radius: 24px;
}

.postcard-flipper[data-border-style="thin"] .postcard-preview::after,
.postcard-flipper[data-border-style="stamp"] .postcard-preview::after {
    content: "";
    position: absolute;
    inset: 18px;
    pointer-events: none;
    border: 1px solid rgba(44, 62, 80, 0.2);
}

.postcard-flipper[data-border-style="stamp"] .postcard-preview::after {
    border-style: dashed;
}

.postcard-layer {
    position: absolute;
    touch-action: none;
    cursor: grab;
    user-select: none;
    transform:
        translate(0, 0)
        rotate(var(--layer-rotation, 0deg));
    transform-origin: center;
}

.postcard-layer.is-dragging {
    cursor: grabbing;
    z-index: 5;
}

.postcard-layer--image {
    left: var(--layer-x, 40px);
    top: var(--layer-y, 40px);
    width: var(--layer-width, 220px);
    height: var(--layer-height, 150px);
    border-radius: 0px;
    background: center / cover no-repeat;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.postcard-layer--image[data-image-fit="contain"] {
    background-size: contain;
    background-color: rgba(255, 255, 255, 0.56);
}

.postcard-layer--image[data-image-fit="fill"] {
    background-size: 100% 100%;
}

.postcard-layer--text {
    left: var(--layer-x, 52px);
    top: var(--layer-y, 310px);
    width: var(--layer-width, 260px);
    min-height: var(--layer-height, 80px);
    display: grid;
    gap: 12px;
    color: inherit;
}

.postcard-layer--text [contenteditable] {
    min-height: var(--layer-height, 80px);
    outline: 0;
    color: inherit;
    font-size: var(--object-font-size, 36px);
    font-weight: var(--object-font-weight, 900);
    font-style: var(--object-font-style, normal);
    line-height: 1.12;
    text-align: var(--object-text-align, left);
    white-space: pre-wrap;
}

.postcard-layer.is-selected {
    outline: 2px dashed #2C3E50;
    outline-offset: 4px;
}

.layer-handle {
    position: absolute;
    z-index: 6;
    display: none;
    border: 1px solid #2C3E50;
    background: #fff;
}

.postcard-layer.is-selected .layer-handle {
    display: grid;
}

.layer-handle--resize {
    right: -9px;
    bottom: -9px;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
}

.layer-handle--rotate {
    top: 50%;
    left: 50%;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: #2C3E50;
    background: rgba(255, 255, 255, 0.58);
    border-color: rgba(44, 62, 80, 0.34);
    box-shadow: 0 8px 22px rgba(44, 62, 80, 0.12);
    backdrop-filter: blur(4px);
    font-size: 12px;
    opacity: 0.72;
    cursor: grab;
    transform: translate(-50%, -50%);
}

.layer-handle--rotate:hover {
    opacity: 1;
}

.postcard-layer:not(.is-selected) .layer-handle {
    display: none;
}

.postcard-layer--qr {
    right: auto;
    bottom: auto;
    left: var(--layer-x, 80px);
    top: var(--layer-y, 90px);
    width: var(--layer-width, 74px);
    height: var(--layer-height, 74px);
    display: grid;
    place-items: center;
    align-content: center;
    gap: 4px;
    border: 1px solid rgba(44, 62, 80, 0.16);
    border-radius: 6px;
    color: #2C3E50;
    background: rgba(255, 255, 255, 0.88);
    font-size: 26px;
    text-align: center;
}

.postcard-layer--qr > span:not(.layer-handle) {
    max-width: 100%;
    overflow: hidden;
    color: #56666e;
    font-size: 10px;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.design-order {
    gap: 0;
    padding: 0;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.96);
}

.design-right-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    border-bottom: 1px solid #dde2dc;
    background: #fff;
}

.design-right-tabs button {
    min-height: 58px;
    display: grid;
    place-items: center;
    gap: 4px;
    border: 0;
    color: #56666e;
    background: #fff;
    font-size: 11px;
    font-weight: 900;
}

.design-right-tabs button i {
    font-size: 16px;
}

.design-right-tabs button.is-active {
    color: #b4553c;
    box-shadow: inset 0 -3px 0 #b4553c;
}

.design-side-card {
    display: grid;
    gap: 15px;
    min-height: max-content;
    padding: 18px;
    background: transparent;
}

.design-order .right-tab-panel {
    display: none;
}

.design-order .right-tab-panel.is-active {
    display: grid;
}

.design-order__heading {
    margin: 0;
    padding: 18px 18px 14px;
    border-bottom: 1px solid #edf0ec;
    border-radius: 0;
    background: transparent;
}

.design-order__card {
    display: grid;
    gap: 8px;
    border-radius: 8px;
    padding: 18px;
    color: #2C3E50;
    background: linear-gradient(135deg, #fff1e8, #edf6ef);
}

.design-order__card p {
    color: #b4553c;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.design-order__card strong {
    font-size: 32px;
}

.design-order__card span {
    color: #56666e;
    line-height: 1.55;
}

.quantity-control {
    display: grid;
    gap: 7px;
    color: #4d5f67;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.quantity-stepper {
    width: 100%;
    height: 48px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    border: 1px solid #cfd8d3;
    border-radius: 999px;
    padding: 4px;
    background: white;
}

.quantity-stepper button {
    border: 0;
    border-radius: 999px;
    color: #2C3E50;
    background: #eef3ef;
}

.quantity-stepper input {
    width: 100%;
    border: 0;
    outline: 0;
    color: #2C3E50;
    background: transparent;
    text-align: center;
    font-size: 17px;
    font-weight: 900;
}

.design-button {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border-radius: 4px;
    padding: 0 14px;
    font-weight: 900;
}

.design-button--secondary {
    border: 1px solid #b4553c;
    color: #b4553c;
    background: #fff6f1;
}

.design-button--primary {
    border: 1px solid #3f8263;
    color: white;
    background: #3f8263;
}

.design-button--dark {
    border: 1px solid #2C3E50;
    color: white;
    background: #2C3E50;
}

.design-feedback {
    min-height: 22px;
    color: #3f8263;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.5;
}

.object-properties {
    min-height: 230px;
    align-content: start;
}

.object-properties__heading {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    border-bottom: 0;
    border-radius: 0;
    background: transparent;
}

.object-properties__heading p {
    color: #b4553c;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.object-properties__heading h2 {
    color: #2C3E50;
    font-size: 20px;
}

.property-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.empty-properties {
    min-height: 210px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    color: #8b999f;
    text-align: center;
    font-weight: 800;
}

.empty-properties i {
    font-size: 42px;
    opacity: 0.5;
}

@media (max-width: 1180px) {
    .design-page {
        grid-template-columns: 290px minmax(420px, 1fr);
        overflow-y: auto;
    }

    .design-order {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: 1fr;
    }

    .design-order__heading,
    .design-order__card,
    .design-feedback {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .design-header {
        position: sticky;
    }

    .design-page {
        height: auto;
        min-height: calc(100vh - 61px);
        grid-template-columns: 1fr;
        overflow: visible;
        padding: 12px;
    }

    .design-workspace {
        order: -1;
        min-height: 540px;
    }

    .design-workspace__bar {
        align-items: stretch;
        flex-direction: column;
    }

    .workspace-switches,
    .preview-actions,
    .orientation-actions {
        width: 100%;
    }

    .preview-actions button,
    .orientation-actions button {
        flex: 1;
    }

    .postcard-stage {
        min-width: 0;
        padding: 18px;
    }

    .postcard-flipper {
        width: min(100%, 360px);
        min-width: 0;
    }

    .postcard-preview--back {
        grid-template-columns: 1fr;
        padding: 24px;
    }

    .postcard-layer--text [contenteditable] {
        font-size: min(var(--object-font-size, 34px), 34px);
    }

    .design-tools,
    .design-order {
        max-height: none;
    }

    .design-tool-panel {
        max-height: none;
    }

    .design-order {
        grid-template-columns: 1fr;
    }

    .design-order__heading,
    .design-order__card,
    .design-feedback {
        grid-column: auto;
    }
}
