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

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

.scanfix-intro h1 {
    max-width: 900px;
    margin-bottom: 1rem;
    font-size: clamp(3.2rem, 5.4vw, 4.8rem);
}

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

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

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

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

.scanfix-empty {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
    min-height: 520px;
}

.upload-panel,
.capture-guide {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(2rem, 5vw, 4.5rem);
}

.upload-panel {
    justify-content: flex-start;
    padding-top: 2rem;
    background:
        linear-gradient(145deg, rgba(216, 240, 103, .3), transparent 56%),
        var(--panel);
}

.upload-kicker {
    margin: 0 0 1rem;
    color: var(--green);
    font-size: .73rem;
    font-weight: 850;
    letter-spacing: .16em;
}

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

.upload-panel > p:not(.upload-kicker, .upload-status) {
    max-width: 560px;
    color: var(--muted);
    line-height: 1.6;
}

.file-button { width: max-content; margin-top: .7rem; }
.upload-status { min-height: 1.4rem; margin: 1rem 0 0; color: var(--danger); }

.capture-guide {
    color: #f1f6f2;
    background: #173e34;
}

.capture-guide h3 { margin: 2rem 0 .5rem; font-size: 1.4rem; }
.capture-guide p { max-width: 430px; margin: 0; color: #cbd9d3; line-height: 1.55; }

.paper-guide {
    position: relative;
    width: min(260px, 75%);
    aspect-ratio: 1 / 1.35;
    border: 1px solid rgba(255, 255, 255, .22);
}

.paper-guide div {
    position: absolute;
    inset: 12%;
    transform: rotate(-3deg);
    border-radius: .2rem;
    background:
        repeating-linear-gradient(to bottom, transparent 0 11%, rgba(23, 62, 52, .17) 11% 12%),
        #f3f1e9;
    box-shadow: 0 18px 40px rgba(5, 20, 16, .28);
}

.paper-guide span {
    position: absolute;
    z-index: 1;
    width: 34px;
    height: 34px;
    border-color: var(--lime);
    border-style: solid;
}

.paper-guide span:nth-child(1) { top: 0; left: 0; border-width: 3px 0 0 3px; }
.paper-guide span:nth-child(2) { top: 0; right: 0; border-width: 3px 3px 0 0; }
.paper-guide span:nth-child(3) { right: 0; bottom: 0; border-width: 0 3px 3px 0; }
.paper-guide span:nth-child(4) { bottom: 0; left: 0; border-width: 0 0 3px 3px; }

.scanfix-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(370px, .8fr);
}

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

.scan-stage-heading,
.controls-heading,
.result-preview > div:first-child {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
}

.scan-stage-heading h2,
.controls-heading h2 {
    margin: 0;
    font-size: clamp(1.45rem, 3vw, 2.15rem);
    letter-spacing: -.025em;
}

.scan-stage-heading p,
.result-preview p {
    margin: .35rem 0 0;
    color: #4f5d58;
    line-height: 1.45;
}

#scanfix-readiness {
    flex-shrink: 0;
    padding: .35rem .55rem;
    border-radius: .45rem;
    color: #204d40;
    background: #cce7d5;
    font-size: .78rem;
    font-weight: 800;
}

.scan-stage {
    position: relative;
    display: grid;
    place-items: center;
    min-height: min(66vh, 740px);
    margin-top: 1.25rem;
    overflow: hidden;
    border-radius: .75rem;
    background: #28332f;
    touch-action: none;
}

#scanfix-source {
    display: block;
    max-width: 100%;
    max-height: min(66vh, 740px);
    width: auto;
    height: auto;
    user-select: none;
}

#crop-outline {
    position: absolute;
    pointer-events: none;
    overflow: visible;
}

#crop-outline polygon {
    fill: rgba(216, 240, 103, .08);
    stroke: #d8f067;
    stroke-width: .7;
    vector-effect: non-scaling-stroke;
}

.corner-handle {
    position: absolute;
    z-index: 2;
    width: 28px;
    height: 28px;
    padding: 0;
    transform: translate(-50%, -50%);
    border: 3px solid #173e34;
    border-radius: 50%;
    background: #d8f067;
    box-shadow: 0 3px 10px rgba(7, 20, 16, .35);
    cursor: grab;
    touch-action: none;
}

.corner-handle:active { cursor: grabbing; }
.corner-handle:focus-visible { outline: 3px solid #f4f1e8; outline-offset: 3px; }
.keyboard-note { margin: .85rem 0 0; color: #4f5d58; font-size: .85rem; }

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

.controls-heading { margin-bottom: 1.25rem; }

#scanfix-form { display: grid; gap: 1rem; }
#scanfix-form fieldset {
    display: grid;
    gap: 1rem;
    margin: 0;
    padding: 1.1rem;
    border: 1px solid var(--line);
    border-radius: .75rem;
}

#scanfix-form legend {
    padding: 0 .35rem;
    font-weight: 850;
}

.scanfix-form-grid,
.range-stack { display: grid; gap: 1rem; }

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

.finish-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .55rem;
}

.finish-options label {
    display: flex;
    min-height: 50px;
    align-items: center;
    gap: .45rem;
    padding: .65rem;
    border: 1px solid var(--line);
    border-radius: .55rem;
    font-size: .84rem;
    cursor: pointer;
}

.finish-options input {
    width: auto;
    min-height: 0;
}

.range-stack label {
    grid-template-columns: 1fr auto;
    align-items: center;
}

.range-stack input { grid-column: 1 / -1; min-height: auto; padding: 0; }
.range-stack output { color: var(--muted); font-variant-numeric: tabular-nums; }

.result-preview {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: .75rem;
    background: #e5e9e5;
}

.result-preview h3 { margin: 0; }
#scanfix-result {
    display: block;
    width: 100%;
    max-height: 300px;
    margin-top: .9rem;
    object-fit: contain;
    background: white;
    box-shadow: 0 10px 25px rgba(23, 33, 30, .14);
}

.scanfix-status { min-height: 1.5rem; margin: .9rem 0 .4rem; color: var(--muted); }
.scanfix-status.error { color: var(--danger); }
.scanfix-actions { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; }

.scanfix-guidance {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: clamp(2rem, 7vw, 7rem);
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 1px solid var(--line);
}

.scanfix-guidance h2 {
    max-width: 560px;
    font-size: clamp(2rem, 4vw, 3.7rem);
    line-height: 1.02;
    letter-spacing: -.045em;
}

.scanfix-guidance > div { display: grid; gap: 1.25rem; }
.scanfix-guidance p { margin: 0; color: var(--muted); line-height: 1.55; }
.scanfix-guidance strong { color: var(--ink); }

@media (max-width: 980px) {
    .scanfix-workspace { grid-template-columns: 1fr; }
    .scan-stage { min-height: 520px; }
}

@media (max-width: 760px) {
    .scanfix-page main { width: min(100% - 28px, 1380px); }
    .scanfix-intro,
    .scanfix-empty,
    .scanfix-guidance { grid-template-columns: 1fr; }
    .scanfix-intro { align-items: start; }
    .scanfix-privacy { max-width: 520px; }
    .scanfix-empty { min-height: 0; }
    .capture-guide { min-height: 430px; }
    .scan-stage { min-height: 390px; }
    .finish-options { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
    .scan-stage-column { background: #202b27; }
    .scan-stage-heading p,
    .keyboard-note { color: #b5c2bc; }
    .result-preview { background: #202b27; }
    .result-preview p { color: #b5c2bc; }
    .scanfix-form-grid select { border-color: #60716a; background: #111a17; }
    #scanfix-readiness { color: #d9f2e5; background: #285645; }
}
