/* Tracollect: shared and desktop styles. The phone layout lives in mobile.css, which
   base.html loads with media="(max-width: 700px)". Colours and sizes are tokens, so the
   dark theme and every component draw from one palette. */
:root {
    --bg: #f3f5f9;
    --surface: #ffffff;
    --fg: #1f2430;
    --muted: #6b7280;
    --line: #e2e6ee;
    --panel: #f3f5f9;
    --accent: #3b5bdb;
    --accent-strong: #2f4ab8;
    --accent-soft: #e8edfb;
    --accent-line: #c7d2f3;
    --on-accent: #ffffff;
    --danger: #c62828;
    --error-bg: #fdecec;
    --error-line: #f3b9b9;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f1217;
        --surface: #171b22;
        --fg: #e6e8ee;
        --muted: #9aa3b2;
        --line: #2a303b;
        --panel: #1e242e;
        --accent: #7d9bff;
        --accent-strong: #a3b8ff;
        --accent-soft: #202a44;
        --accent-line: #35415e;
        --on-accent: #0b0e14;
        --danger: #ff7b7b;
        --error-bg: #3a1f1f;
        --error-line: #6b3030;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0f1217;
    --surface: #171b22;
    --fg: #e6e8ee;
    --muted: #9aa3b2;
    --line: #2a303b;
    --panel: #1e242e;
    --accent: #7d9bff;
    --accent-strong: #a3b8ff;
    --accent-soft: #202a44;
    --accent-line: #35415e;
    --on-accent: #0b0e14;
    --danger: #ff7b7b;
    --error-bg: #3a1f1f;
    --error-line: #6b3030;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

/* --- base --- */
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}
.page { max-width: 1140px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
h1 { font-size: 1.5rem; letter-spacing: -0.01em; margin: 0.2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 0.6rem; }
a { color: var(--accent); }
p { margin: 0.4rem 0 0.8rem; }
code { font-size: 0.9em; background: var(--panel); padding: 0.05rem 0.35rem; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* One look for every button; the secondary and danger variants adjust it below. */
button {
    font: inherit;
    line-height: 1.2;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: var(--on-accent);
    cursor: pointer;
}
button:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button:disabled { opacity: 0.55; cursor: default; }
input, select, textarea {
    font: inherit;
    color: var(--fg);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    box-sizing: border-box;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"], input[type="radio"], input[type="range"], input[type="file"] { border: none; background: none; padding: 0; box-shadow: none; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* --- site header --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1100; /* above Leaflet's controls (1000) */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.25rem;
    padding: 0.6rem max(1.25rem, calc(50% - 570px + 1.25rem));
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-size: 1.2rem; font-weight: 700; color: var(--fg); text-decoration: none; }
.brand::before { content: ""; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.site-nav { display: flex; gap: 0.25rem; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 0.35rem 0.75rem; border-radius: 999px; font-weight: 500; }
.site-nav a:hover { color: var(--fg); background: var(--panel); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 0.7rem; font-size: 0.9rem; color: var(--muted); }
.user-name { font-weight: 500; color: var(--fg); }
.logout-form { display: inline; }
button#logout-btn { background: none; border-color: var(--line); color: var(--muted); padding: 0.3rem 0.7rem; font-size: 0.9rem; }
button#logout-btn:hover { color: var(--fg); background: var(--panel); border-color: var(--line); }

.flashes { list-style: none; padding: 0; margin: 0 0 1rem; }
.flash { padding: 0.6rem 0.9rem; border-radius: 8px; background: var(--accent-soft); border-left: 3px solid var(--accent); margin-bottom: 0.4rem; }
.flash.error { background: var(--error-bg); border-left-color: var(--danger); }
.error { color: var(--danger); }

/* --- cards --- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 0.6rem; font-size: 1.1rem; }
.muted { color: var(--muted); font-size: 0.9rem; font-weight: normal; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.5rem 0 0; }

/* --- track list: map, toolbar, table --- */
#map {
    height: 460px;
    width: 100%;
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.toolbar { display: flex; flex-direction: column; gap: 0.7rem; padding: 0.9rem 1rem; }
.toolbar .chips, .toolbar .filters, .toolbar #search, .toolbar .bulk-bar { margin: 0; }
.map-tools { display: flex; gap: 0.5rem; margin: 0; }
.map-tools .chip:disabled { opacity: 0.5; cursor: default; }
#search { width: 100%; padding: 0.6rem 0.8rem; font-size: 1rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { padding: 0.3rem 0.8rem; font-size: 0.9rem; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }
.chip:hover { color: var(--fg); background: var(--panel); border-color: var(--line); }
.chip.selected, .chip.selected:hover { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.chip-tag { font-style: italic; }

.filters { display: flex; gap: 2rem; }
.filter-group { flex: 1; }
.filter-group label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }
.range-slider { position: relative; height: 36px; padding: 0 9px; }
.range-slider::before { content: ''; position: absolute; top: 15px; left: 9px; right: 9px; height: 6px; background: var(--line); border-radius: 3px; }
.range-slider input[type="range"] {
    position: absolute;
    width: calc(100% - 18px);
    left: 9px;
    top: 0;
    margin: 0;
    padding: 0;
    height: 36px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    z-index: 2;
}
.range-slider input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.3); cursor: pointer; margin-top: -6px; }
.range-slider input[type="range"]::-moz-range-thumb { pointer-events: auto; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.3); cursor: pointer; }
.range-slider input[type="range"]::-webkit-slider-runnable-track { height: 6px; background: transparent; border-radius: 3px; }
.range-slider input[type="range"]::-moz-range-track { height: 6px; background: transparent; border-radius: 3px; }

.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.5rem 0.8rem; background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 8px; font-size: 0.9rem; }
.bulk-bar select, .bulk-bar button { padding: 0.3rem 0.6rem; }
.bulk-bar button { border-color: var(--accent); background: var(--surface); color: var(--accent); }
.bulk-bar button:hover { background: var(--accent); color: var(--on-accent); }

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
th {
    cursor: pointer;
    user-select: none;
    background: var(--panel);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}
th:hover, th[aria-sort] { color: var(--fg); }
th[aria-sort]::after { margin-left: 0.3rem; font-size: 0.65rem; vertical-align: middle; }
th[aria-sort="ascending"]::after { content: "\25B2"; }
th[aria-sort="descending"]::after { content: "\25BC"; }
.num-col { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: var(--panel); }
.track-link { color: inherit; text-decoration: none; font-weight: 500; }
.track-link:hover { text-decoration: underline; color: var(--accent); }
.desc { color: var(--muted); font-size: 0.8em; font-weight: normal; }
.download-link { text-decoration: none; font-size: 1.2rem; color: var(--muted); }
.download-link:hover { color: var(--accent); }
.komoot-link { text-decoration: none; font-size: 1.1rem; }
.checkbox-col { width: 2rem; text-align: center; padding: 0.5rem 0.25rem; cursor: default; }
th.checkbox-col input { cursor: pointer; vertical-align: middle; }
.color-dot { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; border-radius: 6px; }
.color-dot input { cursor: pointer; }
.select-col { text-align: center; width: 2rem; }
.select-col input { cursor: pointer; }
.tags { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; margin-left: 0.4rem; vertical-align: middle; }
.tag { font-size: 0.72rem; padding: 0.05rem 0.45rem; border-radius: 999px; background: var(--panel); border: 1px solid var(--accent-line); color: var(--muted); }
.comment-count { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.comment-count span { margin-left: 0.15rem; }
.variants { font-size: 0.72rem; padding: 0.05rem 0.5rem; border-radius: 999px; border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent); white-space: nowrap; vertical-align: middle; }
.variants:hover, .variants.selected { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* --- inline editor and track management --- */
.edit-btn { border: none; background: none; padding: 0.1rem 0.3rem; font-size: 1.1rem; color: var(--accent); }
.edit-btn:hover { color: var(--accent-strong); background: var(--accent-soft); border-radius: 6px; }
.edit-form { display: flex; flex-direction: column; gap: 0.3rem; }
.edit-form input { padding: 0.3rem 0.5rem; font-size: 0.9rem; }
.edit-form button { padding: 0.3rem 0.6rem; font-size: 0.85rem; align-self: flex-start; }
.edit-cancel, .edit-share { background: var(--surface); color: var(--accent); }
.edit-cancel:hover, .edit-share:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.edit-delete { color: var(--danger); background: var(--surface); border-color: var(--danger); }
.edit-delete:hover { background: var(--error-bg); color: var(--danger); border-color: var(--danger); }
.edit-projects { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; margin: 0.25rem 0; font-size: 0.85rem; font-weight: normal; }
.edit-projects label { display: inline-flex; align-items: center; gap: 0.2rem; cursor: pointer; }
.track-name:has(.edit-form) { max-width: none; white-space: normal; overflow: visible; }
.share-banner { background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 8px; padding: 0.5rem 0.8rem; color: var(--fg); }

/* --- login and registration --- */
.login-box {
    width: min(380px, 92vw);
    margin: 3rem auto;
    padding: 1.5rem 1.6rem 1.8rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.login-box h1 { margin-top: 0; font-size: 1.35rem; }
.login-box label { display: block; margin: 0.9rem 0 0; font-size: 0.9rem; color: var(--muted); }
.login-box input { display: block; width: 100%; margin-top: 0.3rem; padding: 0.55rem 0.7rem; }
.login-box button { width: 100%; margin-top: 1.2rem; padding: 0.6rem; }

/* --- settings --- */
.account-facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1.2rem; margin: 0 0 1rem; padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.account-facts dt { font-weight: 600; color: var(--muted); font-size: 0.9rem; }
.account-facts dd { margin: 0; }
.account-facts ul { margin: 0; padding-left: 1.1rem; }
.account-form { max-width: 440px; margin-bottom: 1rem; padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.account-form label { display: block; margin: 0.6rem 0 0; font-size: 0.9rem; color: var(--muted); }
.account-form input:not([type="radio"]) { display: block; width: 100%; margin-top: 0.3rem; }
.theme-form label { display: flex; align-items: center; gap: 0.5rem; color: var(--fg); margin: 0.3rem 0; }
.account-form button { margin-top: 1rem; }

/* --- projects --- */
.project-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 1rem; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem 1rem; margin: 0.6rem 0; }
.inline-form label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--muted); }
.inline-form input, .inline-form select { min-width: 10rem; }
.inline { display: inline; }
.danger button { border-color: var(--danger); background: var(--surface); color: var(--danger); margin-top: 0.6rem; }
.danger button:hover { background: var(--error-bg); color: var(--danger); border-color: var(--danger); }
.members, .shares { margin: 0.8rem 0; }
.chips.static .chip, .chip.static { background: var(--panel); border: 1px solid var(--accent-line); border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.9rem; list-style: none; display: inline-flex; align-items: center; gap: 0.3rem; margin: 0.2rem 0.3rem 0.2rem 0; }
.chip.static button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0; }
.chip.static button:hover { color: var(--danger); background: none; }
ul.chips { padding: 0; margin: 0.3rem 0; }
.share-list { list-style: none; padding: 0; margin: 0.4rem 0; }
.share-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.3rem 0; }
.share-url { font-size: 0.85rem; padding: 0.3rem 0.5rem; width: min(100%, 28rem); color: var(--fg); }
.share-list button, td.actions button, table.plain .inline button { font-size: 0.85rem; padding: 0.25rem 0.6rem; border-color: var(--line); background: var(--surface); color: var(--fg); }
.share-list button:hover, td.actions button:hover, table.plain .inline button:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* --- admin --- */
.admin-sections { list-style: none; padding: 0; display: grid; gap: 0.6rem; }
.admin-sections li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; box-shadow: var(--shadow); }
.admin-sections a { font-weight: 600; text-decoration: none; }
table.plain { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.plain th, table.plain td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.plain th { cursor: default; }
table.plain tr.disabled td { color: var(--muted); }
td.actions form { margin-right: 0.3rem; }
td.actions .danger button { border-color: var(--danger); color: var(--danger); margin-top: 0; }

/* --- statistics --- */
table.stats { width: 100%; }
table.stats th { cursor: default; }
.bar-col { width: 30%; min-width: 8rem; }
.bar { height: 0.9rem; min-width: 2px; background: var(--accent); border-radius: 3px; opacity: 0.85; }
.longest { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- track detail page --- */
.track-page h1 { margin-bottom: 0.3rem; }
.track-facts { display: flex; flex-wrap: wrap; gap: 0.3rem 1.4rem; margin: 0.4rem 0 0.8rem; padding: 0; list-style: none; color: var(--muted); font-size: 0.95rem; }
.track-facts b { color: var(--fg); font-weight: 600; }
.track-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin: 0.5rem 0 1rem; }
.track-links a { color: var(--accent); text-decoration: none; font-size: 1rem; }
.track-links a:hover { text-decoration: underline; }
.track-page #map { height: 55vh; min-height: 280px; }
.track-desc { max-width: 60rem; white-space: pre-line; }
.profile { position: relative; width: 100%; height: 220px; margin: 1rem 0; padding: 0.6rem 0.6rem 0.2rem; box-sizing: border-box; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.profile svg { width: 100%; height: 100%; display: block; }
.profile .area { fill: var(--accent); fill-opacity: 0.2; }
.profile .line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.profile .axis { stroke: var(--line); stroke-width: 1; }
.profile .label { fill: var(--muted); font-size: 11px; }
.profile .cursor { stroke: var(--fg); stroke-width: 1; stroke-dasharray: 3 3; }
.profile .readout { fill: var(--fg); font-size: 12px; font-weight: 600; }

/* --- comments --- */
.comments { margin: 1.5rem 0; max-width: 60rem; }
.comment-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.comment { display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.6rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.comment-meta { grid-column: 1; font-size: 0.85rem; color: var(--muted); }
.comment-meta b { color: var(--fg); }
.comment-text { grid-column: 1; white-space: pre-line; }
.comment form { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
.comment-delete { border: none; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; padding: 0 0.3rem; }
.comment-delete:hover { color: var(--danger); background: none; }
.comment-form { display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start; }
.comment-form textarea { width: 100%; resize: vertical; }

/* --- tablets --- */
@media (max-width: 1100px) {
    .page { padding: 1rem 0.9rem 2.5rem; }
    .filters { gap: 1rem; }
}

@media (pointer: coarse) {
    button, .chip, .edit-btn, select, input[type="submit"] { min-height: 2.5rem; }
    .edit-btn { font-size: 1.4rem; padding: 0 0.4rem; }
    .chip.static button { min-height: 1.6rem; }
    th { padding-top: 0.7rem; padding-bottom: 0.7rem; }
}
