:root {
    --stone: #ede7dc;
    --stone-dark: #ddd4c4;
    --card: #fffdf9;
    --ink: #2b2621;
    --ink-soft: #6b6255;
    --forest: #3a5a40;
    --forest-dark: #2c4530;
    --timber: #b9814f;
    --timber-light: #e4c9a4;
    --line: #e2d9c8;
    --error: #a33d2c;
    --radius: 10px;
    font-family: "Space Grotesk", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--stone);
    background-image:
        repeating-linear-gradient(90deg, rgba(0,0,0,0.015) 0 2px, transparent 2px 68px);
    color: var(--ink);
    line-height: 1.5;
}

.wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 32px 20px 80px;
}

.site-header {
    text-align: left;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 3px solid var(--forest);
}

.site-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.history-link {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    text-decoration: none;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    padding: 6px 14px;
    white-space: nowrap;
    margin-top: 4px;
}

.history-link:hover {
    color: var(--forest-dark);
    border-color: var(--forest);
}

.site-header h1 {
    font-size: clamp(28px, 5vw, 38px);
    line-height: 1.15;
    margin: 0 0 10px;
    letter-spacing: -0.02em;
    color: var(--forest-dark);
}

.site-header p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 16px;
    max-width: 46ch;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 18px;
    box-shadow: 0 1px 0 rgba(43,38,33,0.03);
}

.card h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 19px;
    margin: 0 0 6px;
    color: var(--ink);
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--forest);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.hint {
    color: var(--ink-soft);
    font-size: 13.5px;
    margin: 0 0 14px;
}

/* Drop zone */
.drop-zone {
    position: relative;
    border: 2px dashed var(--timber);
    border-radius: var(--radius);
    background: #fbf7f0;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color .15s ease, background .15s ease;
}

.drop-zone.drag-over {
    border-color: var(--forest);
    background: #eef3ec;
}

.drop-icon { font-size: 30px; margin-bottom: 6px; }
#dropZoneEmpty { text-align: center; padding: 24px; color: var(--ink-soft); }
#dropZoneEmpty strong { color: var(--ink); }
#dropZoneEmpty p { margin: 4px 0; }

.photo-preview {
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    display: block;
}

.remove-photo {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(43,38,33,0.75);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

/* Colour swatches */
.swatch-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

@media (max-width: 480px) {
    .swatch-grid { grid-template-columns: repeat(3, 1fr); }
}

.swatch {
    cursor: pointer;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.swatch input { position: absolute; opacity: 0; width: 0; height: 0; }

.swatch-img {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    border: 2px solid transparent;
    box-shadow: inset 0 0 0 1px rgba(43,38,33,0.08);
    transition: border-color .12s ease, transform .12s ease;
}

.swatch input:checked + .swatch-img {
    border-color: var(--forest);
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(58,90,64,0.25);
}

.swatch-label {
    font-size: 12.5px;
    color: var(--ink-soft);
}

.swatch input:checked ~ .swatch-label {
    color: var(--forest-dark);
    font-weight: 600;
}

/* Option pills */
.option-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.option-pill {
    position: relative;
    cursor: pointer;
}

.option-pill input { position: absolute; opacity: 0; width: 0; height: 0; }

.option-pill span {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1.5px solid var(--line);
    background: #fff;
    font-size: 14px;
    color: var(--ink);
    transition: all .12s ease;
}

.option-pill input:checked + span {
    border-color: var(--forest);
    background: var(--forest);
    color: #fff;
}

.option-pill.checkbox input:checked + span {
    border-color: var(--timber);
    background: var(--timber);
    color: #fff;
}

textarea {
    width: 100%;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 14.5px;
    resize: vertical;
    background: #fff;
    color: var(--ink);
}

/* Measurements */
.measure-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.measure-field {
    flex: 1 1 140px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--ink-soft);
    font-weight: 600;
}

.measure-field input {
    border: 1.5px solid var(--line);
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
}

.measure-field input:focus {
    outline: 2px solid var(--forest);
    outline-offset: 1px;
}

textarea:focus, .drop-zone:focus-within {
    outline: 2px solid var(--forest);
    outline-offset: 1px;
}

.generate-btn {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--forest);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background .15s ease, transform .1s ease;
}

.generate-btn:hover { background: var(--forest-dark); }
.generate-btn:active { transform: scale(0.99); }
.generate-btn:disabled { background: #a9a396; cursor: not-allowed; }

.generate-btn.loading .btn-text::after {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 10px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    vertical-align: -2px;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.form-error {
    color: var(--error);
    background: #fbeae6;
    border: 1px solid #f0c9c0;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 14px;
}

/* Results */
.result-card { margin-top: 28px; }

.before-after {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (max-width: 560px) {
    .before-after { grid-template-columns: 1fr; }
}

.ba-col h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    margin: 0 0 8px;
}

.ba-col img {
    width: 100%;
    border-radius: 8px;
    display: block;
    border: 1px solid var(--line);
}

.result-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.btn-secondary {
    padding: 11px 18px;
    border-radius: 8px;
    border: 1.5px solid var(--timber);
    background: #fff;
    color: var(--timber);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    text-align: center;
}

.btn-secondary:hover { background: var(--timber-light); }

/* Notes / feedback box */
.note-box {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.note-box label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 8px;
}

.note-box label .hint {
    display: inline;
    font-weight: 400;
    margin: 0;
}

.note-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.note-row textarea {
    flex: 1 1 240px;
    min-width: 200px;
}

.note-status {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--forest-dark);
}

.note-status.error { color: var(--error); }

/* Zoomable result images */
.ba-col img.zoomable {
    cursor: zoom-in;
    transition: opacity .1s ease;
}
.ba-col img.zoomable:hover {
    opacity: 0.92;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(20,17,14,0.92);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    cursor: zoom-out;
}

.lightbox[hidden] {
    display: none;
}

.lightbox img {
    max-width: 100%;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    cursor: zoom-in;
    transition: transform .2s ease;
    touch-action: pinch-zoom;
}

.lightbox img.zoomed-in {
    max-width: none;
    max-height: none;
    cursor: zoom-out;
}

.lightbox-hint {
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    margin-top: 14px;
}

.lightbox-close {
    position: absolute;
    top: 18px;
    right: 22px;
    background: none;
    border: none;
    color: #fff;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
    padding: 6px 10px;
}
