:root {
    /* Brand */
    --primary: #2f5233;
    --primary-hover: #264227;
    --primary-weak: #e7ede2;
    --accent: #bf7a3a;
    --accent-hover: #a76a31;
    --accent-weak: #f3e7d4;
    --green-soft: #6b8e4e;

    /* Neutrals */
    --bg: #f4f1ea;
    --surface: #ffffff;
    --surface-alt: #faf8f3;
    --text: #2b2a26;
    --muted: #6f6a60;
    --border: #e6e1d6;
    --border-strong: #d6cfc0;

    /* Semantic */
    --success: #3c7d3a;
    --success-bg: #e7f4dc;
    --success-text: #2c5a17;
    --warning: #9a6b08;
    --warning-bg: #faecc9;
    --error: #a3342b;
    --error-bg: #f7e2df;
    --error-text: #a3342b;

    /* Aliase für Bestandscode (nicht entfernen) */
    --warn-bg: #faecc9;
    --warn-text: #7a5a04;

    /* Radii & Shadows */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 14px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 3px rgba(43,42,38,.06);
    --shadow-card: 0 4px 14px rgba(43,42,38,.10);

    /* Layout */
    --max: 520px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.site-header .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 0.10em;
    color: var(--text);
}
.site-header .brand:hover { text-decoration: none; }
.site-header .brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--primary);
    color: #f4f1ea;
    font-size: 17px;
    line-height: 1;
    letter-spacing: 0;
}
.site-header nav a {
    margin-left: 16px;
    color: var(--muted);
}

.container {
    max-width: var(--max);
    margin: 32px auto;
    padding: 0 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s ease;
}
.card:hover { box-shadow: var(--shadow-card); }

.card h1 {
    margin-top: 0;
    font-size: 24px;
}

form label {
    display: block;
    margin-bottom: 14px;
    font-weight: 500;
}

form input[type="email"],
form input[type="password"],
form input[type="text"] {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}
form input:focus {
    outline: 2px solid color-mix(in srgb, var(--primary) 30%, transparent);
    border-color: var(--primary);
}

button {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
button:hover { background: var(--primary-hover); }
button.btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error   { background: var(--error-bg);   color: var(--error-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }

.flash {
    background: var(--success-bg);
    color: var(--success-text);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.muted { color: var(--muted); }
.field-error {
    display: block;
    color: var(--error-text);
    margin-top: 4px;
    font-size: 12px;
}

.profile {
    margin: 16px 0 24px;
    display: grid;
    grid-template-columns: 130px 1fr;
    row-gap: 8px;
    column-gap: 12px;
}
.profile dt { color: var(--muted); font-weight: 500; }
.profile dd { margin: 0; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    margin-left: 4px;
}
.badge-warn { background: var(--warn-bg);    color: var(--warn-text); }
.badge-ok   { background: var(--success-bg); color: var(--success-text); }

.site-footer {
    text-align: center;
    color: var(--muted);
    padding: 24px;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: #f0f1ed;
    padding: 1px 6px;
    border-radius: 4px;
}

/* =====================================================================
   M2 Phase 6: Routes web UI
   ===================================================================== */

.container--wide { max-width: 920px; }

.site-header nav {
    display: flex;
    align-items: center;
    gap: 16px;
}
.site-header nav a { margin-left: 0; }
.site-header .nav-form {
    margin: 0;
    display: inline-flex;
    align-items: center;
}
.site-header .nav-button {
    background: transparent;
    color: var(--muted);
    border: 0;
    padding: 0;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.site-header .nav-button:hover { color: var(--primary); text-decoration: underline; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}
.page-header h1 { margin: 0; }
.header-actions { display: flex; gap: 8px; }

.btn-primary {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
}
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary {
    display: inline-block;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
}
.btn-secondary:hover { background: #f5f6f2; text-decoration: none; }
.btn-accent {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    border: 0;
    cursor: pointer;
}
.btn-accent:hover { background: var(--accent-hover); text-decoration: none; }
.btn-link {
    background: transparent;
    color: var(--primary);
    border: 0;
    padding: 0;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }
.btn-danger {
    background: #fff;
    color: var(--error-text);
    border: 1px solid #f3c0c0;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
}
.btn-danger:hover { background: var(--error-bg); }

.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
.inline-form  { display: inline-block; margin: 0; }

form textarea, form select, form input[type="file"] {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
}
form textarea { resize: vertical; }

.alert-warn {
    background: var(--warn-bg);
    color: var(--warn-text);
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.alert-warn p { margin: 0 0 8px 0; }
.alert-warn p:last-child { margin-bottom: 0; }

.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.data-table th {
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.data-table tr:last-child td { border-bottom: 0; }
.row-actions { white-space: nowrap; text-align: right; }

.tag-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag {
    display: inline-block;
    background: #eef2e8;
    color: var(--primary-hover);
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 12px;
}

.level { display: inline-block; border-radius: var(--radius-pill); padding: 2px 10px; font-size: 12px; font-weight: 600; }
.level-easy   { background: #e7f4dc; color: #2c5a17; }
.level-medium { background: #faecc9; color: #7a5a04; }
.level-hard   { background: #f7e2df; color: #8a1f1f; }
.tag-new      { background: var(--accent-weak); color: #8a4f1c; }

.badge-private  { background: #ebeef0; color: #555c6e; }
.badge-unlisted { background: #fff3cd; color: var(--warn-text); }
.badge-public   { background: var(--success-bg); color: var(--success-text); }
.badge-active   { background: var(--success-bg); color: var(--success-text); }
.badge-revoked  { background: var(--error-bg); color: var(--error-text); }
.badge-expired  { background: #ebeef0; color: #555c6e; }

.profile--wide { grid-template-columns: 180px 1fr; }
.share-url {
    display: block;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    word-break: break-all;
    font-size: 13px;
}
.route-description {
    background: #f9faf6;
    padding: 12px 14px;
    border-radius: 8px;
    margin: 16px 0;
}
.shared-flag {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    margin-bottom: 4px;
}

/* M3 Phase 6: Discovery / Profile / Feed */
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.empty-state {
    padding: 24px;
    text-align: center;
    background: #f9faf6;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    margin: 16px 0;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    background: #f9faf6;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}
.filter-form label {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    font-size: 13px;
    color: var(--muted);
}
.filter-form input[type="text"],
.filter-form select {
    margin-top: 4px;
    padding: 8px 10px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    min-width: 160px;
}

.pagination {
    display: flex;
    gap: 16px;
    margin: 16px 0;
}

.profile-header { padding: 24px 0 16px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.profile-header h1 { font-size: 28px; margin: 0; }
.profile-display-name { font-size: 17px; color: var(--text); margin: 4px 0; }
.profile-stats {
    list-style: none;
    padding: 0;
    margin: 12px 0 16px;
    display: flex;
    gap: 24px;
    color: var(--muted);
    font-size: 14px;
}
.profile-stats li strong { color: var(--text); font-size: 18px; }
.profile-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.profile-self-hint { font-style: italic; }

.like-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.like-count strong { color: var(--text); }

.comments { margin-top: 32px; }
.comment-form textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
    resize: vertical;
}
.comment-list { list-style: none; padding: 0; margin: 16px 0 0; }
.comment {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: 0; }
.comment-head { display: flex; gap: 10px; align-items: baseline; }
.comment-date { font-size: 13px; }
.comment-body { margin-top: 4px; white-space: pre-wrap; }
.comment-delete { font-size: 13px; color: var(--error-text); }

.notif-badge {
    display: inline-block;
    min-width: 18px;
    padding: 1px 6px;
    margin-left: 2px;
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
    color: #fff;
    background: #d33;
    border-radius: 999px;
}
.heat-bar {
    display: block;
    min-width: 4px;
    height: 14px;
    border-radius: 3px;
    background: linear-gradient(90deg, #ffd24d, #ff7a1a, #d33);
}

.notif-list { list-style: none; padding: 0; margin: 16px 0 0; }
.notif-item {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fff;
}
.notif-item.notif-unread { border-left: 3px solid #d33; background: #fffaf8; }
.notif-sub { margin-top: 2px; font-size: 14px; }
.notif-date { font-size: 12px; margin-top: 4px; }

.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    background: #eee;
}
.avatar-preview img {
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    background: #eee;
}
.avatar-preview { margin: 12px 0; }

/* --- Karten (Leaflet) -------------------------------------------------- */
.map {
    width: 100%;
    height: 420px;
    margin: 16px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #e8ebe4;
    z-index: 0; /* hält die Karte unter Header/Overlays */
}
.map--detail { height: 360px; }
.map--full   { height: 520px; }
.map-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
    padding: 16px;
}
/* Surface-Score-Legende für eingefärbte Tracks */
.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 4px 0 16px;
    font-size: 13px;
    color: var(--muted);
}
.map-legend .swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    margin-right: 4px;
    vertical-align: -2px;
}

/* --- Route-Insights (Höhenprofil + Untergrund-Verteilung) -------------- */
.route-insights {
    margin: 8px 0 24px;
}
.route-insights .insight-block {
    margin-top: 16px;
}
.insight-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.insight-head h3 {
    margin: 0;
    font-size: 15px;
}
.insight-head .muted {
    font-size: 13px;
}

.elev-chart {
    width: 100%;
    height: 160px;
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(180deg, #f6f8f3 0%, #eef1ea 100%);
}
.elev-area {
    fill: rgba(21, 128, 61, 0.18);
    stroke: none;
}
.elev-line {
    fill: none;
    stroke: #15803d;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}
.elev-axis {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.surface-bar {
    display: flex;
    width: 100%;
    height: 18px;
    border-radius: 9px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #e8ebe4;
}
.surface-seg { height: 100%; }
.surface-legend {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 4px 16px;
}
.surface-legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.surface-legend .swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex: 0 0 auto;
}
.surface-legend .surface-label { flex: 1 1 auto; }
.surface-legend .surface-pct { font-variant-numeric: tabular-nums; font-weight: 600; }
.surface-legend .surface-km { font-variant-numeric: tabular-nums; }

/* --- Wegpunkt-Hinweise --------------------------------------------------- */
.route-hints { margin: 8px 0 24px; }
.route-hints .hint-km-cell {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}
.route-hints .hint-dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: -1px;
}

/* --- Discover-Karte: BBox-Zeichnen --------------------------------------- */
.ge-bbox-btn {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 5px 9px;
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    color: #1f2937;
}
.ge-bbox-btn:hover { background: #f3f4f6; }
.ge-bbox-btn.is-active {
    background: #1d4ed8;
    color: #fff;
    border-color: #1d4ed8;
}
.map.ge-bbox-mode { cursor: crosshair; }
.map.ge-bbox-mode .leaflet-grab { cursor: crosshair; }

/* --- Surface-Check (M9): Belags-Profil einer hochgeladenen Route -------- */
.surface-result { margin-top: 24px; }
.surface-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin: 12px 0 16px;
}
.surface-stat { min-width: 200px; flex: 1 1 220px; }
.surface-stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.surface-stat-label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
}
.coverage-bar {
    margin: 8px 0 4px;
    width: 100%;
    height: 12px;
    border-radius: 6px;
    background: #e8ebe4;
    border: 1px solid var(--border);
    overflow: hidden;
}
.coverage-bar > span {
    display: block;
    height: 100%;
    background: #15803d;
}
.bucket-list {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    font-size: 14px;
}
.bucket-list li { display: flex; align-items: center; gap: 8px; }
.bucket-list .swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex: 0 0 auto;
}
.bucket-list .swatch-paved  { background: #15803d; }
.bucket-list .swatch-mixed  { background: #eab308; }
.bucket-list .swatch-gravel { background: #b91c1c; }
.surface-actions { margin-top: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

