:root {
    --zovoza: #3F3A3F;
    --zovoza-dark: #29252A;
    --accent: #C65B87;
    --accent-light: #F9EDF2;
    --text: #29262A;
    --muted: #777078;
    --border: #E8E3E7;
    --surface: #FFFFFF;
    --background: #F7F5F7;
    --success: #287A57;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 24px;
    background: #ECE9EC;
    color: var(--text);
}

button, input, select, textarea { font: inherit; }

.builder-shell {
    width: min(1120px, 100%);
    min-height: 760px;
    margin: 0 auto;
    overflow: hidden;
    background: var(--surface);
    border-radius: 18px;
    box-shadow: 0 18px 65px rgba(35, 27, 36, .13);
}

.builder-header {
    min-height: 76px;
    padding: 17px 34px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--zovoza);
    color: white;
}

.brand-name {
    font-size: 23px;
    font-weight: 800;
    letter-spacing: 3px;
}

.brand-caption {
    margin-top: 3px;
    font-size: 9px;
    letter-spacing: 2px;
    color: #E5DDE4;
}

.close-button {
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 50%;
    background: transparent;
    color: white;
    font-size: 25px;
    cursor: pointer;
}

.builder-intro {
    padding: 30px 42px 23px;
}

.eyebrow, .section-number {
    color: var(--accent);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.8px;
}

.builder-intro h1 {
    margin: 8px 0;
    font-size: clamp(25px, 4vw, 34px);
    letter-spacing: -.8px;
}

.builder-intro p, .section-heading p {
    color: var(--muted);
    line-height: 1.6;
    margin: 7px 0 0;
}

.step-navigation {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin: 0 42px;
    padding: 15px 0 22px;
    border-bottom: 1px solid var(--border);
}

.step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #A39CA4;
    min-width: 0;
}

.step-item span {
    width: 29px;
    height: 29px;
    flex: 0 0 29px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #F0EDF0;
    font-size: 12px;
    font-weight: 700;
}

.step-item small {
    font-size: 11px;
    font-weight: 650;
}

.step-item.active { color: var(--zovoza); }
.step-item.active span, .step-item.complete span {
    color: white;
    background: var(--accent);
}

.builder-message {
    display: none;
    margin: 18px 42px 0;
    padding: 11px 14px;
    border-radius: 8px;
    color: #8A334F;
    background: var(--accent-light);
    font-size: 13px;
}

.builder-message.visible { display: block; }

#renovationForm { padding: 0 42px; }

.builder-step {
    display: none;
    min-height: 420px;
    padding: 28px 0;
}

.builder-step.active { display: block; }

.section-heading { margin-bottom: 25px; }

.section-heading h2 {
    margin: 7px 0;
    font-size: 23px;
    letter-spacing: -.4px;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    color: var(--text);
    font-size: 13px;
    font-weight: 650;
}

.field > span { line-height: 1.4; }
.field small { color: var(--muted); font-size: 11px; font-weight: 400; }
.full-width { grid-column: 1 / -1; }

.field input, .field select, .field textarea {
    width: 100%;
    min-height: 45px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    background: white;
    color: var(--text);
    font-size: 13px;
    font-weight: 400;
}

.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(198,91,135,.1);
}

.room-list, .measurement-list, .work-selection-list,
.material-preference-list {
    display: grid;
    gap: 13px;
}

.room-card, .measurement-card, .work-room-card,
.material-room-card, .estimate-card {
    padding: 17px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: white;
}

.room-card {
    display: grid;
    grid-template-columns: 1fr 120px 38px;
    gap: 13px;
    align-items: center;
}

.room-card strong, .measurement-card h3,
.work-room-card h3, .material-room-card h3 {
    font-size: 14px;
}

.room-card p, .measurement-card p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.room-card input {
    width: 100%;
    min-height: 40px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
}

.remove-room {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 7px;
    background: #F8EEF2;
    color: #A43F67;
    cursor: pointer;
    font-size: 18px;
}

.add-room-row {
    display: flex;
    align-items: end;
    gap: 12px;
    margin-top: 18px;
}

.add-room-row .field { flex: 1; }

.measurement-card h3, .work-room-card h3,
.material-room-card h3 { margin: 0 0 13px; }

.measurement-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.measurement-result {
    margin-top: 12px;
    padding: 10px;
    border-radius: 7px;
    background: var(--background);
    color: var(--zovoza);
    font-size: 12px;
}

.standard-area-result {
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 7px;
    background: var(--accent-light);
    color: var(--zovoza);
    font-size: 12px;
    line-height: 1.5;
}

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

.choice-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.45;
}

.choice-card:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-light);
}

.choice-card input { accent-color: var(--accent); margin-top: 2px; }

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

.preference-card {
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 9px;
}

.preference-card label {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 10px 0;
    font-size: 12px;
    cursor: pointer;
}

.preference-card input { accent-color: var(--accent); }

.preference-card select, .preference-card input[type="text"] {
    width: 100%;
    min-height: 39px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
}

.estimate-summary { display: grid; gap: 12px; }

.estimate-row {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.estimate-row strong { text-align: right; }

.estimate-notice {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 18px 0;
    padding: 15px;
    border-radius: 9px;
    background: var(--accent-light);
    color: #74354E;
    font-size: 12px;
    line-height: 1.5;
}

.final-quote-note {
    padding: 13px;
    background: var(--background);
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.builder-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 18px 0 26px;
    border-top: 1px solid var(--border);
}

#stepCounter { color: var(--muted); font-size: 12px; }

.button {
    min-height: 43px;
    padding: 10px 20px;
    border: 0;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.button:disabled { opacity: .45; cursor: not-allowed; }

.button-primary { color: white; background: var(--zovoza); }
.button-primary:hover { background: var(--zovoza-dark); }
.button-secondary {
    color: var(--zovoza);
    background: #F0EDF0;
}
.button-secondary:hover { background: #E8E3E8; }

.builder-loading {
    padding: 20px 42px;
    color: var(--muted);
    font-size: 13px;
}

[hidden] { display: none !important; }

@media (max-width: 720px) {
    body { padding: 0; background: white; }
    .builder-shell {
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
    }
    .builder-header { padding: 15px 19px; }
    .builder-intro { padding: 25px 20px 18px; }
    .step-navigation {
        margin: 0 20px;
        gap: 3px;
    }
    .step-item { flex-direction: column; gap: 5px; }
    .step-item small { font-size: 9px; }
    .step-item span { width: 26px; height: 26px; flex-basis: 26px; }
    #renovationForm { padding: 0 20px; }
    .builder-message { margin-left: 20px; margin-right: 20px; }
    .builder-step { min-height: 0; padding: 24px 0; }
    .form-grid { grid-template-columns: 1fr; gap: 15px; }
    .full-width { grid-column: auto; }
    .room-card { grid-template-columns: 1fr 75px 32px; gap: 8px; }
    .measurement-grid { grid-template-columns: 1fr 1fr; }
    .work-options, .preference-grid { grid-template-columns: 1fr; }
    .add-room-row { align-items: stretch; }
    .add-room-row .button { padding: 8px 12px; }
    .builder-footer { padding-bottom: 22px; }
}

@media (max-width: 380px) {
    .step-item small { font-size: 8px; }
    .measurement-grid { grid-template-columns: 1fr; }
    .button { padding-left: 13px; padding-right: 13px; }
}


/* Renovation builder modal and property selectors */
html {
    width: 100%;
    height: 100%;
}

body {
    width: 100%;
    min-height: 100vh;
    height: 100vh;
    padding: 5vh 5vw;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: rgba(35, 29, 36, .48);
}

.builder-shell {
    width: 90vw;
    height: 90vh;
    max-width: 1440px;
    min-height: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 24px 90px rgba(20, 15, 22, .28);
}

.builder-header,
.builder-intro,
.step-navigation,
.builder-message,
.builder-footer {
    flex-shrink: 0;
}

#renovationForm:not([hidden]) {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.builder-step.active {
    display: block;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.builder-footer {
    flex-shrink: 0;
}

.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;
}

.field-label {
    display: block;
    margin-bottom: 11px;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.property-picker {
    margin-bottom: 26px;
}

.property-type-cards {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 3px 2px 12px;
    scrollbar-width: thin;
}

.property-type-card {
    min-width: 126px;
    min-height: 104px;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.property-type-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.property-type-card.selected {
    border: 2px solid var(--accent);
    background: var(--accent-light);
}

.property-type-icon {
    font-size: 27px;
    line-height: 1.2;
}

.property-type-name {
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
}

.area-picker {
    max-width: 620px;
}

.area-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 2px 0 14px;
}

.area-option {
    min-height: 43px;
    padding: 10px 17px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
    color: var(--zovoza);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.area-option:hover,
.area-option.selected {
    border-color: var(--accent);
    background: var(--accent-light);
    color: #8e3d60;
}

.custom-area-field {
    max-width: 340px;
    margin-top: 8px;
}

.property-details-grid {
    align-items: start;
}

#propertyAreaHint {
    display: block;
    margin-top: 9px;
    color: var(--muted);
    line-height: 1.5;
}

@media (max-width: 720px) {
    body {
        padding: 5vh 5vw;
        background: rgba(35, 29, 36, .48);
    }

    .builder-shell {
        width: 90vw;
        height: 90vh;
        min-height: 0;
        border-radius: 18px;
        box-shadow: 0 16px 55px rgba(20, 15, 22, .25);
    }

    .builder-header { padding: 13px 17px; }
    .builder-intro { padding: 17px 19px 12px; }
    .builder-intro h1 { font-size: 23px; }
    .builder-intro p { font-size: 12px; }

    .step-navigation {
        margin: 0 16px;
        padding: 10px 0 13px;
        gap: 3px;
    }

    .step-item { flex-direction: column; gap: 4px; }
    .step-item small { font-size: 8px; }
    .step-item span { width: 24px; height: 24px; flex-basis: 24px; }

    #renovationForm { padding: 0 18px; }
    .builder-message { margin-left: 18px; margin-right: 18px; }
    .builder-step { min-height: 0; padding: 19px 0; }
    .section-heading { margin-bottom: 18px; }
    .section-heading h2 { font-size: 20px; }
    .form-grid { grid-template-columns: 1fr; gap: 14px; }
    .full-width { grid-column: auto; }
    .property-type-card { min-width: 108px; min-height: 91px; }
    .property-type-icon { font-size: 24px; }
    .area-options { gap: 8px; }
    .area-option { padding: 9px 13px; }
    .builder-footer { padding: 12px 0 15px; }
    .room-card { grid-template-columns: 1fr 75px 32px; gap: 8px; }
    .measurement-grid { grid-template-columns: 1fr 1fr; }
    .work-options, .preference-grid { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
    .step-item small { font-size: 7px; }
    .measurement-grid { grid-template-columns: 1fr; }
    .property-type-card { min-width: 96px; }
}

/* Mobile: two cards per row in Rooms and Work steps */
@media (max-width: 600px) {
    #roomList,
    #workSelectionList {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
        gap: 10px;
    }

    #roomList .room-card {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 7px;
        min-width: 0;
        padding: 12px;
    }

    #roomList .room-card strong {
        overflow-wrap: anywhere;
    }

    #workSelectionList .work-room-card {
        min-width: 0;
        padding: 12px;
    }

    #workSelectionList .work-options {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    #workSelectionList .choice-card {
        min-width: 0;
        padding: 10px;
        overflow-wrap: anywhere;
    }

    #workSelectionList .choice-card span {
        min-width: 0;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 380px) {
    #roomList,
    #workSelectionList {
        gap: 8px;
    }

    #roomList .room-card,
    #workSelectionList .work-room-card {
        padding: 9px;
    }
}

/* Mobile viewport and popup scrolling correction */
@media (max-width: 720px) {
    html,
    body {
        height: 100%;
        min-height: 0;
    }

    body {
        height: 100dvh;
        padding: 3dvh 5vw;
        box-sizing: border-box;
        overflow: hidden;
    }

    .builder-shell {
        height: 94dvh;
        max-height: 94dvh;
        min-height: 0;
        box-sizing: border-box;
    }

    #renovationForm:not([hidden]) {
        flex: 1 1 0%;
        min-height: 0;
        height: 0;
        box-sizing: border-box;
    }

    .builder-step.active {
        flex: 1 1 0%;
        min-height: 0;
        max-height: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        padding-bottom: 36px;
    }

    .builder-footer {
        position: relative;
        z-index: 2;
        flex-shrink: 0;
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
}
