.image-layout-page {
    width: min(1480px, calc(100% - 32px));
    margin: 32px auto 48px;
}

.tool-intro {
    margin-bottom: 20px;
}

.tool-intro h1 {
    margin: 0 0 10px;
    font-size: 2rem;
    color: #3b1026;
}

.tool-intro p {
    margin: 0;
    color: #5b4250;
    line-height: 1.8;
}

.tool-unavailable {
    background: #ffffff;
    border: 1px solid #ead4dd;
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 10px 30px rgba(80, 30, 50, 0.06);
}

.upload-start {
    margin-top: 18px;
}

.drop-zone {
    background: linear-gradient(180deg, #fffafc 0%, #fff 100%);
    border: 2px dashed #d69ab0;
    border-radius: 24px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.is-dragover {
    border-color: #9f1239;
    background: #fff5f8;
    transform: translateY(-1px);
}

.drop-zone p {
    margin: 14px 0 10px;
    font-size: 1rem;
}

.drop-zone small {
    display: inline-block;
    color: #6c4f5f;
    line-height: 1.7;
}

.editor-layout {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    margin-top: 20px;
}

.options-panel,
.layout-editor-shell,
.layers-panel {
    background: #ffffff;
    border: 1px solid #ead4dd;
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(80, 30, 50, 0.06);
}

.options-panel {
    overflow: hidden;
}

.options-panel__sticky {
    padding: 22px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.options-panel h2 {
    margin: 0 0 18px;
    font-size: 1.2rem;
    color: #431326;
}

.option-section + .option-section {
    margin-top: 18px;
}

.option-section {
    border: 1px solid #f0dde4;
    border-radius: 16px;
    overflow: hidden;
    background: #fffdfd;
}

.option-heading {
    padding: 12px 16px;
    background: #fff4f7;
    border-bottom: 1px solid #f2dfe7;
    font-weight: 700;
    color: #5b1f36;
}

.option-body {
    padding: 16px;
}

.field-row,
.field-stack {
    margin-bottom: 14px;
}

.field-row:last-child,
.field-stack:last-child {
    margin-bottom: 0;
}

.field-row label,
.field-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #523441;
    font-size: 0.95rem;
}

.field-row input[type="text"],
.field-row input[type="number"],
.field-row select,
.field-stack textarea,
.field-stack input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #d7c1cb;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.95rem;
    background: #ffffff;
}

.field-row input[type="range"] {
    width: 100%;
}

.field-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-inline input[type="number"] {
    min-width: 0;
}

.field-inline span {
    color: #6f5561;
    white-space: nowrap;
}

.field-row--double {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.field-row--color .color-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-input-wrap input[type="color"] {
    width: 52px;
    min-width: 52px;
    height: 42px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid #d7c1cb;
    background: #fff;
}

.check-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: #543844;
    margin-bottom: 12px;
    user-select: none;
}

.check-option:last-child {
    margin-bottom: 0;
}

.check-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.check-option__mark {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1px solid #c9a9b8;
    background: #fff;
    position: relative;
    flex-shrink: 0;
}

.check-option input:checked + .check-option__mark::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 4px;
    background: #9f1239;
}

.notice-box {
    border-radius: 12px;
    background: #fff6f8;
    border: 1px solid #efdae3;
    padding: 12px 14px;
    color: #6c4b5a;
    line-height: 1.7;
    font-size: 0.93rem;
}

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.layer-button-row {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.layer-button-row > button {
    width: 100%;
    justify-content: center;
    min-width: 0;
}

.layer-danger-button {
    border-color: #d9a3b4;
    background: #fff7f9;
    color: #9f1239;
}

.layer-danger-button:hover:not(:disabled) {
    border-color: #9f1239;
    background: #fff0f4;
    color: #7f0e2e;
}

.process-button {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.image-workspace {
    min-width: 0;
}

.workspace-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.workspace-toolbar__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.file-count {
    display: inline-block;
    margin-left: 12px;
    color: #775a67;
    font-size: 0.92rem;
}

.process-message {
    margin-bottom: 14px;
    border-radius: 14px;
    padding: 12px 16px;
    border: 1px solid #f0dce5;
    background: #fffdfd;
    color: #5c4250;
}

.process-message.is-success {
    background: #f2fbf4;
    border-color: #bfe2c8;
    color: #245c34;
}

.process-message.is-error {
    background: #fff5f6;
    border-color: #efc0cb;
    color: #8c213e;
}

.layout-editor-shell {
    padding: 18px;
}

.layout-stage-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.layout-stage-toolbar__right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.zoom-label,
.layout-stage-meta {
    color: #634653;
    font-weight: 600;
}

.layout-editor-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 18px;
}

.layout-canvas-panel {
    min-width: 0;
}

.layout-stage-viewport {
    min-height: 720px;
    background: linear-gradient(135deg, #f9eef2 25%, #f6e8ed 25%, #f6e8ed 50%, #f9eef2 50%, #f9eef2 75%, #f6e8ed 75%, #f6e8ed 100%);
    background-size: 24px 24px;
    border-radius: 18px;
    border: 1px solid #ecdce3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: auto;
}

.layout-stage {
    position: relative;
    width: 1080px;
    height: 1080px;
    background: #ffffff;
    box-shadow: 0 18px 50px rgba(74, 29, 46, 0.16);
    transform-origin: center center;
}

.layout-stage.is-transparent {
    background: transparent;
}

.layout-stage-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #8d6b79;
    font-size: 1rem;
    pointer-events: none;
}

.layout-layer-host {
    position: absolute;
    inset: 0;
}

.layout-layer {
    position: absolute;
    box-sizing: border-box;
    user-select: none;
    touch-action: none;
    transform-origin: center center;
}

.layout-layer::after {
    content: '';
    position: absolute;
    inset: -1px;
    border: 1px dashed transparent;
    border-radius: inherit;
    pointer-events: none;
}

.layout-layer.is-selected::after {
    border-color: #9f1239;
}

.layout-layer__content {
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: inherit;
    box-sizing: border-box;
    background: transparent;
}

.layout-layer__image {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
    pointer-events: none;
}

.layout-layer__text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 4px;
    box-sizing: border-box;
    line-height: 1.4;
    pointer-events: none;
}

.layout-layer__label {
    position: absolute;
    top: -26px;
    left: 0;
    padding: 2px 8px;
    font-size: 12px;
    color: #ffffff;
    background: #9f1239;
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(80, 16, 39, 0.18);
    pointer-events: none;
}

.layout-layer__handle,
.layout-layer__rotate {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border: 2px solid #9f1239;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.layout-layer__handle {
    z-index: 3;
}

.layout-layer__handle--nw { top: -7px; left: -7px; cursor: nwse-resize; }
.layout-layer__handle--ne { top: -7px; right: -7px; cursor: nesw-resize; }
.layout-layer__handle--sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.layout-layer__handle--se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.layout-layer__rotate {
    top: -34px;
    left: 50%;
    transform: translateX(-50%);
    cursor: grab;
}

.layout-layer__rotate::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -18px;
    width: 2px;
    height: 18px;
    background: #9f1239;
    transform: translateX(-50%);
}

.layout-guides,
.snap-guide {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.guide,
.snap-guide {
    position: absolute;
}

.guide--v,
.snap-guide--vertical {
    top: 0;
    bottom: 0;
    width: 1px;
}

.guide--h,
.snap-guide--horizontal {
    left: 0;
    right: 0;
    height: 1px;
}

.layout-guides .guide {
    background: rgba(159, 18, 57, 0.18);
}

.guide--center-v { left: 50%; }
.guide--center-h { top: 50%; }
.guide--third-v1 { left: 33.3333%; }
.guide--third-v2 { left: 66.6666%; }
.guide--third-h1 { top: 33.3333%; }
.guide--third-h2 { top: 66.6666%; }

.snap-guide {
    background: rgba(30, 136, 229, 0.85);
    z-index: 20;
}

.layers-panel {
    padding: 16px;
    min-width: 0;
}

.layers-panel__header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    color: #553543;
}

.layers-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 640px;
    overflow-y: auto;
}

.layer-card {
    border: 1px solid #ead4dd;
    border-radius: 14px;
    padding: 12px;
    background: #fffdfd;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.layer-card.is-selected {
    border-color: #9f1239;
    box-shadow: 0 8px 18px rgba(130, 25, 58, 0.12);
    background: #fff7fa;
}

.layer-card__head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

.layer-card__title {
    font-weight: 700;
    color: #4a1a2e;
    word-break: break-word;
}

.layer-card__type {
    font-size: 0.8rem;
    color: #7e5e6a;
    white-space: nowrap;
}

.layer-card__meta {
    margin-top: 6px;
    font-size: 0.82rem;
    color: #795a67;
}

.upload-progress,
.upload-feedback {
    margin-top: 14px;
}

.upload-progress__bar {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: #f1e4e9;
}

.upload-progress__bar > span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #9f1239 0%, #d53f71 100%);
}

.upload-progress__text,
.upload-feedback {
    margin-top: 8px;
    color: #684c58;
}

.is-hidden {
    display: none !important;
}

@media (max-width: 1280px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }

    .options-panel__sticky {
        position: static;
        max-height: none;
    }

    .layout-editor-main {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .image-layout-page {
        width: min(100%, calc(100% - 24px));
        margin: 20px auto 32px;
    }

    .workspace-toolbar,
    .layout-stage-toolbar,
    .layers-panel__header {
        flex-direction: column;
        align-items: stretch;
    }

    .workspace-toolbar__actions,
    .layout-stage-toolbar__right {
        justify-content: flex-start;
    }

    .field-row--double {
        grid-template-columns: 1fr;
    }

    .layout-stage-viewport {
        min-height: 460px;
        padding: 12px;
    }
}
