* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    margin: 0;
    color: #1a1a1a;
    background: #f5f5f0;
}

header {
    padding: 1rem 1.5rem 0.5rem;
    background: #fff;
    border-bottom: 1px solid #e5e5e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-meta {
    color: #888;
    font-size: 0.8rem;
}

.ghost-btn {
    padding: 0.4rem 0.75rem;
    background: transparent;
    color: #2c5530;
    border: 1px solid #c5c5c0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}

.ghost-btn:hover {
    background: #f0f0eb;
    border-color: #a5a59f;
}

h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.tagline {
    margin: 0.25rem 0 0;
    color: #777;
    font-size: 0.9rem;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e5e5e0;
}

.controls label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: #444;
}

.controls input[type="text"],
.controls input[type="number"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
}

.controls input[type="text"] { width: 11ch; }
.controls input[type="number"] { width: 6ch; }

.walk-type {
    display: flex;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.walk-type label { cursor: pointer; }

.controls-note {
    font-size: 0.8rem;
    color: #888;
    margin-left: auto;
    font-style: italic;
}

button#find-routes-btn {
    padding: 0.5rem 1rem;
    background: #2c5530;
    color: #fff;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

button#find-routes-btn:hover { background: #3a6a3f; }
button#find-routes-btn:disabled { background: #999; cursor: not-allowed; }

#status-bar {
    padding: 0.5rem 1.5rem;
    background: #f9f9f5;
    color: #666;
    font-size: 0.85rem;
    min-height: 1.5rem;
}

#draw-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.5rem;
    background: #fff8e1;
    border-bottom: 1px solid #e7d89a;
    font-size: 0.85rem;
    color: #5c4a00;
}

.draw-hint {
    flex: 1 1 auto;
    min-width: 280px;
}

.ghost-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#draw-toolbar .ghost-btn {
    background: #fff;
}

body.draw-mode #map {
    cursor: crosshair;
}

.user-waypoint-marker {
    background: #2c5530;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-weight: 600;
    font-size: 0.78rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.35);
    border: 2px solid #fff;
}

.user-waypoint-marker-wrap.waypoint-bad .user-waypoint-marker,
.user-waypoint-marker-wrap.waypoint-bad > .user-waypoint-marker {
    background: #dc2626;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.35), 0 1px 2px rgba(0,0,0,0.35);
}

.blown-legs-panel {
    border-color: #dc2626;
    background: #fff4f4;
}

.blown-legs-panel h3 { color: #8a2233; }

.blown-legs-panel p {
    font-size: 0.85rem;
    color: #5a1722;
    margin: 0.3rem 0;
    line-height: 1.4;
}

.blown-legs-list {
    margin: 0.5rem 0;
}

.blown-leg-row {
    background: #fff;
    border: 1px solid #f1c0c0;
    border-radius: 4px;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
    color: #5a1722;
    line-height: 1.4;
}

.blown-leg-row strong {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.15rem;
}

.blown-legs-hint {
    font-style: italic;
    color: #8a2233;
}

.user-walk-panel {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid #2c5530;
    border-radius: 6px;
}

.user-walk-panel h3 {
    margin: 0 0 0.4rem;
    font-size: 1rem;
    color: #2c5530;
}

.diagnosis-summary {
    font-weight: 600;
    margin: 0.4rem 0 0.6rem;
    color: #1a1a1a;
}

.diagnosis-reason {
    display: flex;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.3rem;
    font-size: 0.82rem;
    line-height: 1.4;
    background: #fafaf7;
}

.diagnosis-reason.triggered {
    background: #fcecec;
    color: #8a2233;
    border: 1px solid #f1c0c0;
}

.diagnosis-reason.passed {
    background: #f1f8f2;
    color: #2c5530;
    border: 1px solid #c6deca;
}

.diagnosis-icon {
    flex: 0 0 auto;
    font-weight: 700;
}

.diagnosis-body {
    flex: 1 1 auto;
}

.diagnosis-body strong {
    display: block;
    margin-bottom: 0.15rem;
    font-size: 0.8rem;
}

.diagnosis-delta {
    margin-top: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: #fff;
    border: 1px dashed #c5c5c0;
    border-radius: 4px;
    font-size: 0.78rem;
    color: #333;
}

.diagnosis-delta strong {
    color: #2c5530;
    font-size: 0.78rem;
}

.diagnosis-delta-rationale {
    margin-top: 0.3rem;
    color: #555;
    line-height: 1.4;
}

#status-bar.error {
    background: #fcecec;
    color: #b00020;
}

main {
    display: grid;
    grid-template-columns: 1fr 380px;
    height: calc(100vh - 175px);
    min-height: 500px;
}

#map {
    height: 100%;
    background: #ddd;
}

#route-panel {
    background: #fff;
    border-left: 1px solid #e5e5e0;
    overflow-y: auto;
    padding: 1rem;
}

#route-panel h2 {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
}

#route-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.route-section-header {
    list-style: none;
    padding: 0.9rem 0 0.3rem;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c5530;
    border-bottom: 1px solid #d5d5d0;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.route-section-header:first-child {
    padding-top: 0;
}

.route-section-sub {
    font-weight: 400;
    font-size: 0.75rem;
    color: #888;
}

.route-start-badge {
    font-size: 0.76rem;
    border-radius: 4px;
    padding: 2px 6px;
    margin: 0.3rem 0 0.25rem;
    display: inline-block;
}

/* Postcode-start walks — positive signal, green tint. */
.route-start-badge.route-start-door {
    color: #1f5c2e;
    background: #e7f5eb;
    border: 1px solid #a7d4b4;
}

/* Anchor walks — amber tint, indicates a drive is involved. */
.route-start-badge.route-start-drive {
    color: #5c4a00;
    background: #fff8e1;
    border: 1px solid #e7d89a;
}

.anchor-marker {
    background: #d97706;
    color: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    line-height: 26px;
    text-align: center;
    font-size: 0.9rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.35);
    border: 2px solid #fff;
}

.route-item {
    border: 1px solid #e5e5e0;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: #fafaf7;
}

.route-item:hover {
    background: #f0f0eb;
    border-color: #c5c5c0;
}

.route-item.selected {
    background: #eaf3ec;
    border-color: #2c5530;
}

.route-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.route-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1a1a1a;
}

.route-meta {
    font-size: 0.8rem;
    color: #666;
    white-space: nowrap;
}

.route-bearing {
    display: inline-block;
    background: #e5e5e0;
    color: #444;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.4rem;
}

.route-meta-row {
    margin-bottom: 0.4rem;
}

.surface-bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    background: #e5e5e0;
    margin: 0.4rem 0 0.2rem;
}

.surface-seg {
    display: block;
    height: 100%;
}

.surface-legend {
    font-size: 0.7rem;
    color: #888;
    margin-bottom: 0.4rem;
}

.feature-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.3rem;
}

.feature-chip {
    background: #f0f0eb;
    border: 1px solid #d5d5d0;
    color: #555;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 0.72rem;
    white-space: nowrap;
}

.feature-chip.muted {
    background: transparent;
    border-color: transparent;
    color: #999;
}

.poi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.4rem 0 0.2rem;
}

.poi-pill {
    font-size: 0.78rem;
    color: #444;
    background: #fff;
    border: 1px solid #e5e5e0;
    border-radius: 4px;
    padding: 1px 6px;
    line-height: 1.4;
}

.poi-detail {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px dashed #e5e5e0;
    font-size: 0.8rem;
    color: #555;
    line-height: 1.5;
}

.poi-detail > div { margin-bottom: 0.2rem; }

/* --- Feedback form --- */
.feedback-form {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #fafaf7;
    border: 1px solid #e5e5e0;
    border-radius: 6px;
}

.feedback-form strong {
    font-size: 0.9rem;
}

.fb-stars {
    margin: 0.4rem 0;
    display: flex;
    gap: 0.15rem;
}

.fb-star {
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 1.3rem;
    color: #d5b100;
    padding: 0 0.15rem;
    line-height: 1;
}

.fb-star:not(.filled) {
    color: #c5c5c0;
}

.fb-label {
    display: block;
    font-size: 0.78rem;
    color: #555;
    margin: 0.5rem 0 0;
}

.fb-label textarea {
    display: block;
    width: 100%;
    margin-top: 0.2rem;
    padding: 0.35rem 0.5rem;
    font-family: inherit;
    font-size: 0.85rem;
    border: 1px solid #d5d5d0;
    border-radius: 4px;
    resize: vertical;
}

.fb-gift {
    margin-top: 0.6rem;
    font-size: 0.85rem;
    color: #555;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.fb-gift-btn {
    padding: 0.2rem 0.6rem;
    background: #fff;
    border: 1px solid #d5d5d0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
}

.fb-gift-btn.active {
    background: #eaf3ec;
    border-color: #2c5530;
    color: #2c5530;
    font-weight: 600;
}

.fb-save {
    margin-top: 0.6rem;
    padding: 0.4rem 0.8rem;
    background: #2c5530;
    color: #fff;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}

.fb-save:hover {
    background: #3a6a3f;
}

.fb-status {
    margin-left: 0.6rem;
    font-size: 0.8rem;
    color: #2c5530;
}

.features-detail {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px dashed #e5e5e0;
    font-size: 0.8rem;
    color: #555;
    line-height: 1.5;
}

.route-description {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.4;
    margin: 0.4rem 0 0;
}

#route-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e5e0;
    font-size: 0.85rem;
    color: #555;
}

#route-details:empty { display: none; }

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e5e5e0;
    border-top-color: #2c5530;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 1rem auto;
}

.hidden { display: none; }

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

@media (max-width: 800px) {
    main {
        grid-template-columns: 1fr;
        height: auto;
    }
    #map { height: 50vh; }
    #route-panel { max-height: 50vh; }
}
