.editor-page main {
    width: min(1380px, calc(100% - 40px));
    padding-top: 3rem;
}

.tool-intro {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(250px, .55fr);
    gap: clamp(2rem, 6vw, 7rem);
    align-items: end;
    margin-bottom: 3rem;
}

.tool-intro h1 {
    max-width: 880px;
    margin-bottom: 1rem;
    font-size: clamp(3.2rem, 7vw, 6.5rem);
}

.tool-summary {
    max-width: 640px;
    margin: 0;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1.55;
}

.privacy-note {
    padding: 1.35rem 0 0 1.5rem;
    border-left: 3px solid var(--green);
}

.privacy-note p {
    margin: .5rem 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.restore-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem 1.2rem;
    border: 1px solid #98ad63;
    border-radius: .85rem;
    background: #f1f6d9;
}

.restore-banner p { margin: .25rem 0 0; color: #516047; }
.inline-actions { display: flex; align-items: center; gap: .8rem; flex-shrink: 0; }

.photo-tool {
    min-height: 520px;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: var(--panel);
    box-shadow: 0 28px 80px rgba(23, 33, 30, .09);
    overflow: hidden;
}

.upload-state {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
    min-height: 520px;
}

.upload-copy,
.photo-guidance {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(2rem, 7vw, 6rem);
}

.upload-copy {
    background:
        linear-gradient(145deg, rgba(216, 240, 103, .28), transparent 56%),
        var(--panel);
}

.upload-copy h2 {
    max-width: 650px;
    margin: 0 0 1rem;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1.02;
    letter-spacing: -.045em;
}

.upload-copy p { max-width: 520px; color: var(--muted); line-height: 1.6; }
.file-button { width: max-content; margin-top: .8rem; }
.photo-guidance { background: #173e34; color: #f5f7f1; }
.photo-guidance h3 { margin: 0 0 1.2rem; font-size: 1.45rem; }
.photo-guidance ul { display: grid; gap: 1rem; margin: 0; padding-left: 1.2rem; line-height: 1.5; }
.photo-guidance .fine-print { color: #c7d5cf; }

.editor-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr);
}

.preview-column {
    min-width: 0;
    padding: clamp(1.2rem, 3vw, 2.4rem);
    background: #dfe4df;
}

.preview-heading,
.panel-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
}

.preview-heading h2,
.control-heading h2 {
    margin: 0;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    letter-spacing: -.025em;
}

.canvas-stage {
    position: relative;
    display: grid;
    place-items: center;
    min-height: min(68vh, 760px);
    margin-top: 1.3rem;
    padding: clamp(1rem, 4vw, 2.5rem);
    border-radius: .85rem;
    background:
        linear-gradient(45deg, rgba(255,255,255,.18) 25%, transparent 25% 75%, rgba(255,255,255,.18) 75%),
        linear-gradient(45deg, rgba(255,255,255,.18) 25%, transparent 25% 75%, rgba(255,255,255,.18) 75%),
        #303b37;
    background-position: 0 0, 12px 12px;
    background-size: 24px 24px;
    overflow: hidden;
    touch-action: none;
}

#photo-canvas {
    display: block;
    max-width: 100%;
    max-height: min(64vh, 700px);
    width: auto;
    height: auto;
    border-radius: .35rem;
    box-shadow: 0 18px 55px rgba(7, 20, 16, .34);
    cursor: grab;
}

#photo-canvas.dragging { cursor: grabbing; }

.drag-hint {
    position: absolute;
    bottom: 1.1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: .45rem .7rem;
    border-radius: .5rem;
    color: #edf2ee;
    background: rgba(16, 31, 26, .82);
    font-size: .78rem;
    pointer-events: none;
}

.canvas-description {
    margin: 1rem 0 0;
    color: #485550;
    font-size: .9rem;
    line-height: 1.5;
}

.controls-column {
    min-width: 0;
    padding: clamp(1.4rem, 3vw, 2.5rem);
}

.control-heading { margin-bottom: 1.2rem; }

#editor-controls {
    display: grid;
    gap: 1.2rem;
}

#editor-controls fieldset {
    display: grid;
    gap: .8rem;
    margin: 0;
    padding: 1.1rem;
    border: 1px solid var(--line);
    border-radius: .85rem;
}

#editor-controls legend {
    padding: 0 .35rem;
    font-size: .95rem;
    font-weight: 850;
}

select,
.custom-size input {
    width: 100%;
    min-height: 46px;
    padding: .65rem .75rem;
    border: 1px solid #9da9a4;
    border-radius: .55rem;
    color: var(--ink);
    background: #fefefc;
    font: inherit;
}

select:focus,
.custom-size input:focus,
input[type="range"]:focus-visible {
    outline: 3px solid rgba(23, 107, 85, .28);
    outline-offset: 2px;
}

.field-help,
.fine-print {
    margin: 0;
    color: var(--muted);
    font-size: .82rem;
    line-height: 1.5;
}

.authority-link {
    width: max-content;
    color: var(--green-dark);
    font-size: .82rem;
    font-weight: 750;
    text-underline-offset: .18em;
}

.custom-size {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem 1rem;
}

.range-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: .25rem;
}

.range-label output {
    color: var(--green);
    font-size: .82rem;
    font-variant-numeric: tabular-nums;
}

input[type="range"] {
    width: 100%;
    min-height: 30px;
    accent-color: var(--green);
}

.background-field {
    display: grid;
    gap: .65rem;
    margin-top: .4rem;
}

.field-label { font-weight: 700; }
.swatch-options { display: flex; flex-wrap: wrap; gap: .55rem; }
.swatch-options label { display: flex; flex-direction: row; align-items: center; gap: .4rem; font-size: .8rem; }
.swatch-options input { width: 1rem; min-height: 1rem; }

.swatch {
    width: 1.25rem;
    height: 1.25rem;
    border: 1px solid #89928e;
    border-radius: 50%;
}

.swatch.white { background: #f7f7f4; }
.swatch.grey { background: #e8eaeb; }
.swatch.blue { background: #dce8f1; }

.export-panel {
    margin-top: 1.2rem;
    padding: 1.2rem;
    border-radius: .85rem;
    color: #eef4f0;
    background: #173e34;
}

.export-panel h3 { margin: 0 0 .55rem; }
.export-panel > p { color: #c8d5cf; line-height: 1.5; }
.export-panel .fine-print { color: #c8d5cf; }
.export-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin: 1rem 0 .8rem; }
.export-panel .button-primary { background: #d8f067; color: #17211e; }
.export-panel .button-primary:hover { background: #c5df54; }
.export-panel .button-secondary { border-color: #8ba59a; color: #f4f7f3; background: transparent; }

.project-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
}

.danger-text { color: #922f2f; }

.tool-status {
    min-height: 0;
    padding: 0 1.4rem;
}

.tool-status:not(:empty) {
    min-height: 48px;
    padding-block: .8rem;
    border-top: 1px solid var(--line);
    color: var(--green-dark);
    background: #edf5e8;
}

.tool-status.error {
    color: #8a2d2d;
    background: #fff0ef;
}

.button[disabled] {
    cursor: wait;
    opacity: .65;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 960px) {
    .tool-intro { grid-template-columns: 1fr; gap: 1.5rem; }
    .privacy-note { max-width: 620px; }
    .editor-workspace { grid-template-columns: 1fr; }
    .preview-column { min-height: auto; }
    .canvas-stage { min-height: 520px; }
}

@media (max-width: 720px) {
    .editor-page main { width: min(100% - 20px, 1380px); padding-top: 2rem; }
    .tool-intro h1 { font-size: clamp(2.7rem, 14vw, 4.2rem); }
    .upload-state { grid-template-columns: 1fr; }
    .upload-copy, .photo-guidance { padding: 2rem 1.4rem; }
    .photo-guidance { min-height: 310px; }
    .restore-banner { align-items: stretch; flex-direction: column; }
    .inline-actions { flex-wrap: wrap; }
    .canvas-stage { min-height: 430px; padding: 1rem; }
    #photo-canvas { max-height: 58vh; }
    .preview-heading { align-items: center; }
    .export-actions { grid-template-columns: 1fr; }
    .project-actions { align-items: flex-start; flex-direction: column; }
}

@media (prefers-color-scheme: dark) {
    .editor-page {
        --ink: #e8eee9;
        --muted: #a9b7b1;
        --paper: #111816;
        --panel: #18231f;
        --line: #34443e;
        --green: #77c8a7;
        --green-dark: #9bd8bd;
        --lime: #cbe45e;
        background:
            radial-gradient(circle at 90% 6%, rgba(155, 188, 71, .13), transparent 24rem),
            var(--paper);
    }

    .upload-copy {
        background:
            linear-gradient(145deg, rgba(155, 188, 71, .1), transparent 56%),
            var(--panel);
    }

    .preview-column { background: #222e2a; }
    .canvas-description { color: #b9c7c0; }
    select, .custom-size input { border-color: #60716a; color: var(--ink); background: #111a17; }
    .restore-banner { border-color: #667a38; background: #26301b; }
    .restore-banner p { color: #bfcaaf; }
    .tool-status:not(:empty) { color: #bee7d3; background: #193127; }
    .tool-status.error { color: #ffc2bd; background: #3c201f; }
    .danger-text { color: #ffaaa3; }
}
