:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #ecebe5;
  --border: #dedbd2;
  --text: #1d211f;
  --muted: #6b716c;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --accent-soft: #dce9e3;
  --track: #e4572e;
  --track-2: #2e86ab;
  --track-3: #7a9e3e;
  --track-4: #a23b72;
  /* official trail grades, Austrian convention: blue, red, black */
  --diff-leicht: #2f6fd1;
  --diff-mittel: #d1342f;
  --diff-schwer: #1b1b1b;
  --ok: #2e7d32;
  --ok-soft: #e1f2e2;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  --warn: #9a6200;
  --warn-soft: #fbefd5;
  --shadow: 0 1px 2px rgb(29 33 31 / .06), 0 4px 16px rgb(29 33 31 / .05);
  --radius: 14px;
  --radius-sm: 9px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111413;
    --surface: #1a1e1c;
    --surface-2: #232825;
    --border: #2e3431;
    --text: #eef1ef;
    --muted: #9aa39e;
    --accent: #7fc2a8;
    --accent-ink: #0d1a15;
    --accent-soft: #1d3029;
    --track: #ff7a50;
    --track-2: #5ab4d6;
    --track-3: #a5cc5f;
    --track-4: #d76aa8;
    --diff-leicht: #5b93f0;
    --diff-mittel: #f0625d;
    --diff-schwer: #0a0a0a;
    --ok: #81c784;
    --ok-soft: #173020;
    --bad: #f28b82;
    --bad-soft: #3a1714;
    --warn: #f2c14e;
    --warn-soft: #33290f;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--bg); color: var(--text); }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 720; }
h2 { font-size: 1.08rem; font-weight: 650; }
p { margin: .5rem 0; }
code { font-family: var(--mono); font-size: .85em; background: var(--surface-2); padding: .1em .4em; border-radius: 6px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* header */
.top { position: sticky; top: 0; z-index: 1000; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.top-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: .5rem; padding: .5rem 16px; }
.brand { display: flex; align-items: center; gap: .45rem; font-weight: 760; text-decoration: none; letter-spacing: -.02em; flex: none; }
.brand img { width: 26px; height: 26px; }
.nav { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: .4rem .65rem; border-radius: var(--radius-sm); text-decoration: none; color: var(--muted); font-weight: 560; white-space: nowrap; font-size: .93rem; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current] { background: var(--accent-soft); color: var(--accent); }
.badge { display: inline-block; min-width: 1.3em; padding: 0 .35em; margin-left: .25rem; border-radius: 99px; background: var(--track); color: #fff; font-size: .75rem; text-align: center; line-height: 1.45; }
.logout { flex: none; }
.main { max-width: 1180px; margin: 0 auto; padding: 1.2rem 16px 4rem; }
.bare { max-width: 420px; margin: 0 auto; padding: 12vh 16px; }

/* blocks */
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.head .sub { color: var(--muted); margin-top: .2rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.card + .card, .stack > * + * { margin-top: 1rem; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 860px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.spacer { flex: 1; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: .5rem; }

/* forms */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .48rem .9rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 560; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn.wide { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: default; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .45rem .65rem; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
textarea { width: 100%; min-height: 7rem; resize: vertical; line-height: 1.45; }
.field { display: grid; gap: .25rem; margin-bottom: .75rem; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1; min-width: 10rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { padding: .28rem .7rem; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); text-decoration: none; font-size: .88rem; color: var(--muted); }
.chip[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.saved { font-size: .8rem; color: var(--muted); min-height: 1.2em; }

/* activity list */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: grid; grid-template-columns: 2.2rem minmax(0, 1fr) auto; gap: .2rem .8rem; align-items: center; padding: .7rem .4rem; border-bottom: 1px solid var(--border); text-decoration: none; }
.item:hover { background: var(--surface-2); }
.item .ico { font-size: 1.3rem; text-align: center; grid-row: span 2; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { color: var(--muted); font-size: .85rem; grid-column: 2; }
.item .stats { grid-row: span 2; text-align: right; font-size: .88rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.item .stats b { color: var(--text); font-weight: 600; }
.tag { display: inline-block; padding: 0 .45rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: .78rem; font-weight: 600; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.pager { display: flex; gap: .5rem; justify-content: center; align-items: center; margin-top: 1rem; }

/* stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: .5rem; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: .55rem .7rem; }
.stat .k { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 1.15rem; font-weight: 680; font-variant-numeric: tabular-nums; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .5rem .55rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.notes { white-space: normal; min-width: 12rem; color: var(--muted); font-size: .88rem; }
tr.best td { font-weight: 650; }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; vertical-align: -1px; }
tr.dim td { opacity: .5; }

/* maps & charts */
tv-map, tv-profile, tv-dropzone, tv-fit-local, tv-outbox, tv-offline-save { display: block; }
.map { height: 420px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); z-index: 0; }
.map.tall { height: calc(100vh - 210px); min-height: 360px; }
.map.small { height: 260px; }
@media (max-width: 600px) { .map { height: 320px; } }
.profile { height: 170px; margin-top: .75rem; }
.leaflet-container { font: inherit; }
.leaflet-tooltip { font-size: .82rem; }
.sketch { width: 160px; height: 110px; flex: none; background: var(--surface-2); border-radius: var(--radius-sm); }
.sketch polyline { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; opacity: .85; }
.sketch .l0 { stroke: var(--track); }
.sketch .l1 { stroke: var(--track-2); stroke-dasharray: 5 3; }
.sketch .l2 { stroke: var(--track-3); }
.sketch .l3 { stroke: var(--track-4); }

/* tours */
.tour-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.tour-card { display: flex; gap: .8rem; align-items: center; text-decoration: none; padding: .75rem; }
.tour-card .sketch { width: 96px; height: 70px; }
.tour-card .name { font-weight: 650; }
.tour-card:hover { border-color: var(--accent); }

/* suggestions */
.sugg { display: flex; gap: 1rem; align-items: flex-start; }
.sugg .body { flex: 1; min-width: 0; }
.sugg h3 { font-size: 1rem; margin-bottom: .2rem; }
.sugg .members { list-style: none; padding: 0; margin: .4rem 0 .6rem; display: grid; gap: .2rem; }
.sugg .members label { display: flex; gap: .5rem; align-items: center; font-size: .9rem; }
@media (max-width: 600px) { .sugg { flex-direction: column; } .sugg .sketch { width: 100%; height: 140px; } }
.section-title { margin: 1.6rem 0 .7rem; display: flex; align-items: baseline; gap: .5rem; }

/* upload / local */
.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 2rem 1rem; text-align: center; background: var(--surface); transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input[type=file] { display: none; }
.results { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .3rem; font-size: .9rem; }
.results li { display: flex; gap: .5rem; align-items: baseline; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: .5rem 0; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }
.status-imported { color: var(--ok); }
.status-duplicate, .status-skipped { color: var(--muted); }
.status-failed { color: var(--bad); }
.match-hint { padding: .6rem .8rem; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); margin: .75rem 0; }
.offline-banner { display: none; background: var(--warn-soft); color: var(--warn); text-align: center; padding: .3rem; font-size: .85rem; }
body.is-offline .offline-banner { display: block; }

/* login */
.login { text-align: center; }
.login .field { text-align: left; }
.login img { width: 56px; height: 56px; }
.alert { padding: .6rem .8rem; border-radius: var(--radius-sm); background: var(--bad-soft); color: var(--bad); }

/* toast */
#toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 2000; max-width: calc(100vw - 32px); }
.toast { padding: .65rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); background: var(--surface); border: 1px solid var(--border); animation: toast 4s forwards; }
.toast.ok { border-color: var(--ok); color: var(--ok); }
.toast.bad { border-color: var(--bad); color: var(--bad); }
@keyframes toast { 0%, 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
details > summary { cursor: pointer; color: var(--muted); }

/* official routes ridden (activity and tour pages) */
.ref-hits { list-style: none; margin: 0 0 .4rem; padding: 0; }
.ref-hits li { padding: .3rem 0; border-bottom: 1px solid var(--border); }
.ref-hits li:last-child { border-bottom: 0; }
.diff { display: inline-block; width: .7rem; height: .7rem; margin-right: .35rem; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 2.5px var(--border); vertical-align: -.05rem; }
.diff-leicht { background: var(--diff-leicht); }
.diff-mittel { background: var(--diff-mittel); }
.diff-schwer { background: var(--diff-schwer); }
