*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:        #1a3f6f;
    --primary-dark:   #122d52;
    --primary-light:  #e8eef6;
    --risk-mod:       #c96a0a;
    --risk-high:      #b91c1c;
    --safe-low:       #15803d;
    --safe-notable:   #14532d;
    --bg:             #f4f6f9;
    --card:           #ffffff;
    --border:         #dce1eb;
    --text:           #1e293b;
    --muted:          #64748b;
    --radius:         10px;
    --shadow:         0 2px 8px rgba(0,0,0,0.07);
}

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* ── Layout ── */
.page-container { max-width: 600px; margin: 0 auto; padding-bottom: 2rem; }

/* ── Header ── */
.site-header {
    background: var(--primary);
    color: #fff;
    padding: 0.9rem 1.25rem;
    text-align: center;
}
.institution {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.8;
    margin-bottom: 0.2rem;
}
.site-title { font-size: 1.05rem; font-weight: 700; }

/* ── Progress ── */
.progress-wrap {
    background: var(--primary-dark);
    padding: 0.55rem 1.25rem 0.4rem;
}
.progress-bar {
    height: 5px;
    background: rgba(255,255,255,0.25);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: #fff;
    border-radius: 3px;
    transition: width 0.4s;
}
.progress-label {
    color: rgba(255,255,255,0.7);
    font-size: 0.72rem;
    margin-top: 0.3rem;
    text-align: right;
}

/* ── Cards ── */
.content { padding: 1rem 1rem 0; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    margin-bottom: 0.9rem;
    box-shadow: var(--shadow);
}
.card h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    padding-bottom: 0.55rem;
    margin-bottom: 0.8rem;
    border-bottom: 2px solid var(--primary-light);
}
.card p { font-size: 0.93rem; color: var(--text); margin-bottom: 0.65rem; line-height: 1.65; }
.card p:last-child { margin-bottom: 0; }

.notice {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
    border-radius: 0 6px 6px 0;
    padding: 0.7rem 0.9rem;
    font-size: 0.88rem !important;
}

/* ── Form elements ── */
.form-group { margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }

label.field-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.38rem;
}

input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    padding-right: 2.4rem;
}
textarea { min-height: 90px; resize: vertical; }

/* ── Radio / Checkbox option rows ── */
.option-group { display: flex; flex-direction: column; gap: 0.45rem; }

.option-row {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.7rem 0.9rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.18s, background 0.18s;
    min-height: 48px;
    -webkit-user-select: none;
    user-select: none;
}
.option-row:hover { border-color: var(--primary); background: var(--primary-light); }
.option-row input[type="radio"],
.option-row input[type="checkbox"] {
    width: 20px; height: 20px;
    margin-top: 0.1rem;
    flex-shrink: 0;
    accent-color: var(--primary);
    cursor: pointer;
    padding: 0; border: none; background: none;
}
.option-row span { font-size: 0.93rem; line-height: 1.45; font-weight: 400; }

.option-row.has-info { flex-direction: column; gap: 0; }
.option-row.has-info .check-row {
    display: flex; align-items: flex-start; gap: 0.7rem; width: 100%;
}
.more-info-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0.3rem 0 0 2.35rem;
    text-decoration: underline;
    text-align: left;
}
.more-info-text {
    display: none;
    margin: 0.4rem 0 0 2.35rem;
    padding: 0.55rem 0.8rem;
    background: var(--primary-light);
    border-radius: 6px;
    font-size: 0.83rem;
    color: var(--text);
    line-height: 1.55;
}
.more-info-text.open { display: block; }

.other-input {
    margin-top: 0.5rem;
    margin-left: 2.35rem;
    width: calc(100% - 2.35rem);
    display: none;
}

/* Consent row gets a bit more space */
.consent-row { align-items: flex-start; background: #fafbff; }
.consent-row span { font-size: 0.88rem; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.85rem 1.75rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    min-height: 50px;
    letter-spacing: 0.02em;
    transition: background 0.18s, opacity 0.18s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary { background: #fff; color: var(--text); border: 2px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

.btn-success { background: #15803d; color: #fff; }
.btn-success:hover:not(:disabled) { background: #14532d; }

.btn-outline-danger { background: #fff; color: var(--risk-high); border: 2px solid #fca5a5; }
.btn-outline-danger:hover:not(:disabled) { background: #fef2f2; }

/* ── Nav buttons ── */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    margin-top: 1.1rem;
}
.nav-buttons.end { justify-content: flex-end; }

/* ── Map pages ── */
.map-question {
    padding: 1rem 1rem 0.6rem;
}
.map-question h2 {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--primary);
}
.map-question.risk h2  { color: var(--risk-high); }
.map-question.safe h2  { color: var(--safe-low); }

.instructions {
    margin: 0 1rem 0.7rem;
    padding: 0.7rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.83rem;
    color: var(--muted);
    line-height: 1.6;
}

/* toolbar above map */
.map-toolbar {
    display: flex;
    gap: 0.45rem;
    margin: 0 1rem 0.5rem;
}
.tool-btn {
    flex: 1;
    padding: 0.55rem 0.4rem;
    border: 2px solid var(--border);
    border-radius: 7px;
    background: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    color: var(--text);
    min-height: 42px;
    transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.tool-btn:hover { border-color: var(--primary); color: var(--primary); }
.tool-btn:active { background: var(--primary-light); }

/* Map wrapper + Leaflet container */
.map-wrap {
    position: relative;
    margin: 0 1rem;
}

#map {
    height: 52vh;
    min-height: 270px;
    max-height: 430px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    overflow: hidden;
    cursor: grab;
}
#map.drawing { cursor: crosshair; }

/* Layer switcher (inside map, top-left) */
.layer-switch {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 450;
    display: flex;
    background: #fff;
    border-radius: 6px;
    padding: 3px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.22);
    gap: 2px;
}
.layer-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    font-size: 0.73rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    color: var(--muted);
    background: transparent;
    min-height: 30px;
    transition: background 0.18s, color 0.18s;
}
.layer-btn.active { background: var(--primary); color: #fff; }

/* Drawing overlay (inside map) */
.draw-overlay {
    position: absolute;
    inset: 0;
    z-index: 400;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
    border-radius: var(--radius);
    overflow: hidden;
}
.draw-overlay.active { display: flex; }

.draw-banner {
    background: rgba(15,23,42,0.72);
    color: #fff;
    font-size: 0.82rem;
    padding: 0.45rem 0.9rem;
    text-align: center;
    pointer-events: none;
    line-height: 1.4;
}
.draw-actions {
    display: flex;
    gap: 0.45rem;
    padding: 0.45rem;
    pointer-events: all;
    background: rgba(15,23,42,0.45);
}
.draw-actions .btn {
    flex: 1;
    min-height: 46px;
    font-size: 0.85rem;
    padding: 0.55rem;
}

/* Draw mode buttons (below map) */
.draw-modes {
    display: flex;
    gap: 0.6rem;
    margin: 0.7rem 1rem 0;
}
.draw-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.8rem 0.5rem;
    border: 2.5px solid transparent;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    min-height: 52px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    transition: all 0.2s;
}
.draw-btn .swatch {
    width: 14px; height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(0,0,0,0.25);
}

/* Risk colours */
.btn-draw-risk {
    background: rgba(201,106,10,0.1);
    color: #9a4c04;
    border-color: #c96a0a;
}
.btn-draw-risk.active, .btn-draw-risk:hover {
    background: rgba(201,106,10,0.22);
    border-color: #9a4c04;
}
.btn-draw-risk .swatch { background: #fdba74; }

.btn-draw-highrisk {
    background: rgba(185,28,28,0.09);
    color: #991b1b;
    border-color: #b91c1c;
}
.btn-draw-highrisk.active, .btn-draw-highrisk:hover {
    background: rgba(185,28,28,0.2);
    border-color: #991b1b;
}
.btn-draw-highrisk .swatch { background: #fca5a5; }

/* Safe colours */
.btn-draw-low {
    background: rgba(21,128,61,0.09);
    color: #166534;
    border-color: #15803d;
}
.btn-draw-low.active, .btn-draw-low:hover {
    background: rgba(21,128,61,0.2);
    border-color: #166534;
}
.btn-draw-low .swatch { background: #86efac; }

.btn-draw-verylow {
    background: rgba(20,83,45,0.09);
    color: #14532d;
    border-color: #166534;
}
.btn-draw-verylow.active, .btn-draw-verylow:hover {
    background: rgba(20,83,45,0.2);
    border-color: #14532d;
}
.btn-draw-verylow .swatch { background: #4ade80; }

/* Legend */
.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem 1.2rem;
    margin: 0.55rem 1rem 0;
}
.legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.76rem; color: var(--muted); }
.legend-swatch { width: 22px; height: 12px; border-radius: 3px; border-width: 2px; border-style: solid; }

/* Certainty slider */
.slider-section { margin: 0.9rem 1rem 0; }
.slider-section .field-label { font-size: 0.9rem; margin-bottom: 0.5rem; }
.slider-row { display: flex; align-items: center; gap: 0.75rem; }

input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    cursor: pointer;
    padding: 0;
    border: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.22);
    cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.22);
    cursor: pointer;
}

.slider-value {
    width: 40px; height: 40px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.05rem;
    flex-shrink: 0;
}
.slider-endpoints {
    display: flex;
    justify-content: space-between;
    font-size: 0.73rem;
    color: var(--muted);
    margin-top: 0.3rem;
}

/* Reasons textarea */
.reasons-section { margin: 0.9rem 1rem 0; }
.reasons-section .field-label { font-size: 0.9rem; margin-bottom: 0.5rem; }

/* ── Thank you ── */
.thankyou-card {
    text-align: center;
    padding: 2rem 1.5rem;
    margin: 1rem 1rem 0;
}
.thankyou-card .tick {
    width: 64px; height: 64px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2rem;
}
.thankyou-card h2 { font-size: 1.4rem; color: var(--primary); margin-bottom: 0.65rem; }
.thankyou-card p { font-size: 0.93rem; color: var(--muted); margin-bottom: 0.5rem; }

/* ── Spray status bar ── */
.spray-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--primary-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    margin: 0.55rem 1rem 0;
    font-size: 0.87rem;
    color: var(--text);
}
.spray-status button {
    padding: 0.3rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: inherit;
    min-height: 32px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.18s;
}
.spray-status button:hover { background: var(--primary-dark); }

.hidden { display: none !important; }
