body {
    background: var(--bg-color);
    color: var(--dryft-text-color);
}

/* Local theme — mirrors /agent-test/. Lighter teal-blue panels, peach CTA. */
:root {
    --panel-bg-color: light-dark(#F7F4F0, #16313A);
    --panel-nested-bg-color: light-dark(#FAF9F7, #102932);
    --panel-border-color: light-dark(#ECECEF, rgba(255,255,255,0.08));
    --form-control-bg-color: light-dark(#FFFFFF, #102932);
    --form-control-border-color: light-dark(#E9E9F0, rgba(255,255,255,0.12));
    --form-control-color: var(--dryft-text-color);
    --btn-cta-text: #1A353B;
    --btn-cta-hover-bg: rgba(0,0,0,0.85);
    --btn-cta-hover-text: #FFC98B;
}

.submit_page {
    max-width: 860px;
    margin: 40px auto;
    padding: 0 20px;
}

/* Iommi default hides placeholders entirely. Restore them on focus so they
   act as instruction hints (e.g. "Ungefärligt årtal räcker..."). */
.submit_page .input_container input:focus::placeholder,
.submit_page .input_container textarea:focus::placeholder {
    color: var(--form-control-placeholder-color);
    font-size: 14px;
    opacity: 0.6;
}

/* Counter-override index.css `.panel .input_container { background-color: var(--bg-color); }`
   so input fields match the upload tiles (which use --form-control-bg-color). Scoped to
   .submit_page to avoid affecting other pages' panels. */
.submit_page .panel .input_container {
    background-color: var(--form-control-bg-color);
}

/* Image upload tiles — native input is visually hidden behind a clickable bordered tile.
   Single: one tile that becomes a preview on selection.
   Multi: thumbnails accumulate; the empty tile stays at the row's end as the "add more" affordance. */
.upload_grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--medium-gap);
}
.upload_tile {
    position: relative;
    width: 224px;
    height: 168px;
    border-radius: var(--border-radius-small);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--dryft-text-color);
    transition: border-color 120ms;
}
.upload_tile input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.upload_tile_icon,
.upload_tile_label {
    pointer-events: none;
}
.upload_tile_icon {
    width: 24px;
    height: 24px;
    margin-bottom: 6px;
}
.upload_tile_label {
    font-size: 13px;
    text-align: center;
    padding: 0 8px;
    line-height: 1.3;
    color: var(--form-control-placeholder-color);
}
.upload_empty {
    background-color: var(--form-control-bg-color);
    border: 1.5px dashed var(--form-control-border-color);
}
.upload_empty:hover,
.upload_drag_over {
    border-color: var(--dryft-text-color);
}
.upload_filled {
    background: var(--form-control-bg-color);
    border: 1px solid var(--form-control-border-color);
}
.upload_filled img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
/* A filled tile is inserted the moment a file is picked and the preview drops in once
   the file has been read. Only formats we slice a preview out of (DNG) read slowly
   enough for this to paint — a cached preview settles in a microtask. */
.upload_pending {
    background-image: linear-gradient(90deg, transparent, var(--form-control-border-color), transparent);
    background-size: 60% 100%;
    background-repeat: no-repeat;
    animation: upload_shimmer 1100ms ease-in-out infinite;
}
@keyframes upload_shimmer {
    from { background-position: -80% 0; }
    to { background-position: 180% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .upload_pending {
        animation: none;
    }
}
/* Shown when a file carries no preview we can extract. The file still uploads. */
.upload_unpreviewable {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
}
.upload_unpreviewable .upload_tile_label {
    overflow-wrap: anywhere;
}
.upload_remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.65);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 120ms;
}
.upload_remove:hover {
    background: rgba(0,0,0,0.9);
}
.upload_remove svg {
    width: 14px;
    height: 14px;
}
@media (max-width: 480px) {
    .upload_tile {
        width: calc(50% - var(--medium-gap) / 2);
    }
}

/* Textarea inside .input_container needs a min-height; the design system
   sizes single-line inputs to 52px, but a description textarea wants room. */
.submit_page .input_container:has(textarea) {
    height: auto;
}
.submit_page .input_container textarea {
    min-height: 120px;
    resize: vertical;
}

/* Error states for visually-hidden controls. Native <input> .is_invalid
   doesn't show because radio/checkbox pills hide the input behind a
   label, and file inputs are invisible behind upload tiles. So we add
   .has_error on the container instead. */
.submit_page .choice_group.has_error .btn_outline_primary:not(.btn_primary) {
    border-color: var(--danger-text-color);
    color: var(--danger-text-color);
}
.submit_page .upload_grid.has_error .upload_empty {
    border-color: var(--danger-text-color);
}
.submit_page .upload_grid.has_error .upload_tile_label {
    color: var(--danger-text-color);
}

/* Submit button — smooth, elegant hover. The shared .btn_cta swaps
   bg/text instantly, which feels abrupt for a primary CTA. Add a
   transition + a subtle lift + soft shadow to match the polish of
   the upload tiles and choice pills. */
.submit_page .btn_cta {
    transition:
        background-color 180ms ease,
        color 180ms ease,
        border-color 180ms ease,
        transform 180ms ease,
        box-shadow 180ms ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.submit_page .btn_cta:not(:disabled):not(.disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.submit_page .btn_cta:not(:disabled):not(.disabled):active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10);
}

/* Inline horizontal pair (e.g. Adress + Postnummer) */
.field_row {
    display: flex;
    gap: var(--medium-gap);
    flex-wrap: wrap;
}
.field_row > .field_grow { flex: 1 1 280px; min-width: 0; }
.field_row > .field_narrow { flex: 0 0 180px; }

/* 2-col grid for bathroom dimension/year inputs.
   Each grid cell is filled by an .input_container (52px floating-label box). */
.numbers_grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--medium-gap) var(--large-gap);
}
@media (max-width: 480px) {
    .numbers_grid { grid-template-columns: 1fr; }
}

/* Single short-medium input (sqm) — constrain its width. */
.medium_field { max-width: 280px; }

.choice_group {
    display: flex;
    gap: var(--close-gap);
    flex-wrap: wrap;
}
.choice_group input[type="radio"],
.choice_group input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Conditional reveal: entry AND exit both fade+slide via the modern
   `transition-behavior: allow-discrete` + `@starting-style` pattern.
   - transition on display + allow-discrete defers display:none until after the fade
   - @starting-style provides the initial values when transitioning INTO .visible */
.domain_section,
.decision[data-show-when] {
    display: none;
    opacity: 0;
    transform: translateY(-6px);
    transition:
        opacity 200ms ease-out,
        transform 200ms ease-out,
        display 200ms ease-out allow-discrete;
}
.domain_section.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
    margin-top: var(--large-gap);
}
.decision[data-show-when].visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}
@starting-style {
    .domain_section.visible,
    .decision[data-show-when].visible {
        opacity: 0;
        transform: translateY(-6px);
    }
}

/* Målning floor cards — each floor (one PaintingSubmission) is a delineated nested
   card. Add/remove reuse the same 200ms fade + 6px slide as the section reveal above;
   the repeater JS toggles .floor_enter / .floor_leave to trigger it. */
.floor_card {
    background-color: var(--panel-nested-bg-color);
    border: 1px solid var(--panel-border-color);
    border-radius: 16px;
    padding: var(--medium-gap);
    margin-top: var(--medium-gap);
    transition: opacity 200ms ease-out, transform 200ms ease-out;
}
.floor_card.floor_enter,
.floor_card.floor_leave {
    opacity: 0;
    transform: translateY(-6px);
}

.floor_card_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--close-gap);
}
.floor_card_title {
    font-weight: 600;
}

/* Remove control — a corner icon button (was a .btn .btn_ghost text link). Muted by
   default, turns danger-red on hover/focus. */
.floor_remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: var(--muted-color);
    cursor: pointer;
    transition: color 150ms ease, background-color 150ms ease;
}
.floor_remove:hover,
.floor_remove:focus-visible {
    color: var(--danger-text-color);
    background-color: color-mix(in srgb, var(--danger-text-color) 12%, transparent);
}
.floor_remove svg {
    width: 18px;
    height: 18px;
}

/* Badrum bathroom cards — same treatment as the målning floor cards above, one
   card per BathroomSubmission. Duplicated under its own names rather than
   sharing `.floor_card`'s so the bathroom and målning repeaters stay fully
   independent markup. */
.bathroom_card {
    background-color: var(--panel-nested-bg-color);
    border: 1px solid var(--panel-border-color);
    border-radius: 16px;
    padding: var(--medium-gap);
    margin-top: var(--medium-gap);
    transition: opacity 200ms ease-out, transform 200ms ease-out;
}
.bathroom_card.bathroom_enter,
.bathroom_card.bathroom_leave {
    opacity: 0;
    transform: translateY(-6px);
}

.bathroom_card_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--close-gap);
}
.bathroom_card_title {
    font-weight: 600;
}

.bathroom_remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: var(--muted-color);
    cursor: pointer;
    transition: color 150ms ease, background-color 150ms ease;
}
.bathroom_remove:hover,
.bathroom_remove:focus-visible {
    color: var(--danger-text-color);
    background-color: color-mix(in srgb, var(--danger-text-color) 12%, transparent);
}
.bathroom_remove svg {
    width: 18px;
    height: 18px;
}

/* Headings sit at the top of their container — no browser-default margin
   pushing them around. Spacing is handled by the panel's padding (for h2s)
   and explicit mt_large classes on sub-sections (for h3s). */
.submit_page h2,
.submit_page h3 {
    margin-top: 0;
    margin-bottom: 0;
}

/* Form → success transition. On a valid submit the form fades out and
   the success screen fades in with a spring-easing checkmark. The
   actual POST fires in the background (fire-and-forget) — the user
   doesn't wait the 30s the pipeline takes. */
.submit_page #form_wrapper {
    transition: opacity 350ms ease-out, transform 350ms ease-out;
}
.submit_page #form_wrapper.fading_out {
    opacity: 0;
    transform: translateY(-12px);
    pointer-events: none;
}

#success_screen {
    padding: 80px 20px;
    text-align: center;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 450ms ease-out, transform 450ms ease-out;
}
#success_screen.visible {
    opacity: 1;
    transform: translateY(0);
}
/* Present from the first frame but scaled to 0, so it holds its own space and
   nothing below it moves when it pops. It pops on #success_state.done — once
   the lead is actually released — rather than the moment the screen appears,
   which used to congratulate the submitter while the POST was still in flight
   and might yet fail. */
.success_check {
    width: 96px;
    height: 96px;
    margin: 0 auto 28px;
    border-radius: 50%;
    background: var(--success-color);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0);
    /* Spring-overshoot curve (exits past 1.0 then settles) — gives the
       checkmark a "pop" instead of a flat fade-in. */
    transition: transform 550ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
#success_state.done .success_check {
    transform: scale(1);
}
.success_check svg {
    width: 48px;
    height: 48px;
}
#success_screen h2 {
    font-size: 28px;
    margin-bottom: 12px;
}
#success_screen p {
    font-size: 17px;
    color: var(--form-control-placeholder-color);
    max-width: 440px;
    margin: 0 auto;
    line-height: 1.5;
}

.failure_icon {
    width: 96px;
    height: 96px;
    margin: 0 auto 28px;
    border-radius: 50%;
    background: var(--danger-color);
    color: var(--danger-contrast-color);
    display: flex;
    align-items: center;
    justify-content: center;
}
.failure_icon svg {
    width: 48px;
    height: 48px;
}
#failure_state #retry_button,
#upload_failure_state #upload_retry_button {
    margin-top: 24px;
}

#success_screen .upload_progress {
    margin: 24px auto 0;
    max-width: 320px;
    transition: opacity 250ms ease-out;
}
/* Faded on completion rather than removed: dropping the bar and the hint out
   of flow would jerk the checkmark and the thank-you copy upwards at the exact
   moment they land. */
#success_state.done .upload_progress,
#success_state.done .upload_progress_hint {
    opacity: 0;
    pointer-events: none;
}

.upload_progress_track {
    height: 6px;
    border-radius: 999px;
    background: var(--form-control-border-color);
    overflow: hidden;
}
.upload_progress_fill {
    height: 100%;
    /* A rounded cap at 0% so an unstarted bar reads as a bar rather than as an
       empty box. It is a cap, not a progress claim. */
    min-width: 6px;
    border-radius: 999px;
    background: var(--success-color);
    /* Width is driven frame by frame from JS, which is already smooth; the
       sheen is what says "still working" while a single large file is in
       flight and the fill has nowhere to move yet. */
    background-image: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
    background-size: 80px 100%;
    background-repeat: no-repeat;
    animation: upload_bar_sheen 1200ms ease-in-out infinite;
}
#success_state.done .upload_progress_fill {
    animation: none;
}
@keyframes upload_bar_sheen {
    from { background-position: -80px 0; }
    to { background-position: calc(100% + 80px) 0; }
}
@media (prefers-reduced-motion: reduce) {
    .upload_progress_fill {
        animation: none;
    }
}

#success_screen .upload_progress_hint {
    margin-top: 12px;
    font-size: 14px;
    transition: opacity 250ms ease-out;
}

/* Per-file rejections (wrong format, too large, not a picture). Distinct from
   the .has_error "you must supply a file" state: this one names files the
   submitter chose and we refused, so it lists one line per file. */
.upload_rejections {
    list-style: none;
    margin: 8px 0 0 0;
    padding: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--danger-text-color);
}
.upload_rejections:empty {
    display: none;
}
.upload_rejections li {
    overflow-wrap: anywhere;
}
.upload_rejections li::before {
    content: '⚠ ';
}
