/* ============================================================
   Laufmal – design language inspired by Swiss trail signage:
   yellow signposts, white-red-white & white-blue-white markers,
   paper map tones, condensed grotesk + mono data.
   ============================================================ */

@font-face {
  font-family: 'Archivo';
  src: url('/vendor/fonts/archivo/archivo-latin-wdth-normal.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Archivo';
  src: url('/vendor/fonts/archivo/archivo-latin-ext-wdth-normal.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/vendor/fonts/mono/jetbrains-mono-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --paper: #f2efe6;
  --paper-2: #e8e3d6;
  --card: #fbfaf5;
  --ink: #171b18;
  --ink-2: #474e48;
  --ink-3: #7b827b;
  --line: #d8d1c1;
  --line-2: #c6bea9;
  --sign: #f7c900;
  --sign-2: #ffdc3a;
  --sign-ink: #171b18;
  --red: #d22b1f;
  --blue: #1f5ca8;
  --forest: #2d5a3d;
  --moss: #74903f;
  --ok: #2d7a4a;
  --danger: #c0281d;
  --shadow: 0 1px 0 rgba(23, 27, 24, .06), 0 8px 24px -12px rgba(23, 27, 24, .25);
  --font: 'Archivo', 'Helvetica Neue', Arial, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --r: 3px;
  --nav-h: 60px;
  --tab-h: 64px;
  --contour: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cg fill='none' stroke='%23171b18' stroke-opacity='.07' stroke-width='1'%3E%3Cpath d='M-20 60c40-30 80 20 120 0s70-50 160-10'/%3E%3Cpath d='M-20 80c40-30 85 25 125 3s70-48 155-6'/%3E%3Cpath d='M-20 100c45-28 90 30 130 8s70-45 150-2'/%3E%3Cpath d='M-20 150c50-20 70 40 120 20s80-60 160-20'/%3E%3Cpath d='M-20 170c50-20 75 42 125 22s80-58 155-18'/%3E%3Cpath d='M-20 200c55-15 80 35 130 18s80-50 150-10'/%3E%3Cpath d='M-20 20c35-20 75 15 115-5s80-40 165 0'/%3E%3C/g%3E%3C/svg%3E");
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #111412;
    --paper-2: #1a1e1b;
    --card: #181c19;
    --ink: #ece8dc;
    --ink-2: #b9b6ab;
    --ink-3: #868a82;
    --line: #2c312d;
    --line-2: #3b413c;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .7);
    --red: #ef4b3c;
    --blue: #5b93de;
    --forest: #6fae83;
    --ok: #5cbf83;
    --danger: #ff6a5c;
    --contour: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cg fill='none' stroke='%23ece8dc' stroke-opacity='.05' stroke-width='1'%3E%3Cpath d='M-20 60c40-30 80 20 120 0s70-50 160-10'/%3E%3Cpath d='M-20 80c40-30 85 25 125 3s70-48 155-6'/%3E%3Cpath d='M-20 100c45-28 90 30 130 8s70-45 150-2'/%3E%3Cpath d='M-20 150c50-20 70 40 120 20s80-60 160-20'/%3E%3Cpath d='M-20 170c50-20 75 42 125 22s80-58 155-18'/%3E%3Cpath d='M-20 200c55-15 80 35 130 18s80-50 150-10'/%3E%3Cpath d='M-20 20c35-20 75 15 115-5s80-40 165 0'/%3E%3C/g%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --paper: #111412;
  --paper-2: #1a1e1b;
  --card: #181c19;
  --ink: #ece8dc;
  --ink-2: #b9b6ab;
  --ink-3: #868a82;
  --line: #2c312d;
  --line-2: #3b413c;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .7);
  --red: #ef4b3c;
  --blue: #5b93de;
  --forest: #6fae83;
  --ok: #5cbf83;
  --danger: #ff6a5c;
  --contour: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cg fill='none' stroke='%23ece8dc' stroke-opacity='.05' stroke-width='1'%3E%3Cpath d='M-20 60c40-30 80 20 120 0s70-50 160-10'/%3E%3Cpath d='M-20 80c40-30 85 25 125 3s70-48 155-6'/%3E%3Cpath d='M-20 100c45-28 90 30 130 8s70-45 150-2'/%3E%3Cpath d='M-20 150c50-20 70 40 120 20s80-60 160-20'/%3E%3Cpath d='M-20 170c50-20 75 42 125 22s80-58 155-18'/%3E%3Cpath d='M-20 200c55-15 80 35 130 18s80-50 150-10'/%3E%3Cpath d='M-20 20c35-20 75 15 115-5s80-40 165 0'/%3E%3C/g%3E%3C/svg%3E");
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { overflow-x: clip; }
body {
  margin: 0;
  background: var(--paper);
  background-image: var(--contour);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body.modal-open { overflow: hidden; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.1; font-weight: 750; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); font-stretch: 80%; font-weight: 800; }
h2 { font-size: 1.35rem; font-stretch: 85%; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-feature-settings: 'zero' 0; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
::selection { background: var(--sign); color: var(--sign-ink); }

.ico { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }

/* ---------------- Layout ---------------- */

.topbar {
  position: sticky; top: 0; z-index: 900;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--ink);
}
.topbar-inner { max-width: 1180px; margin: 0 auto; height: 100%; display: flex; align-items: center; gap: 24px; padding: 0 20px; }
.brand { display: flex; align-items: center; text-decoration: none; }
.brand .sign { font-size: .95rem; padding: 6px 26px 6px 12px; }
.brand-time { font-family: var(--mono); font-size: .72rem; font-weight: 600; margin-left: 10px; color: var(--ink-2); }

.mainnav { display: flex; gap: 2px; flex: 1; }
.mainnav a {
  text-decoration: none; font-weight: 600; font-size: .92rem; padding: 8px 12px; border-radius: var(--r);
  color: var(--ink-2); display: flex; align-items: center; gap: 7px; position: relative;
}
.mainnav a:hover { color: var(--ink); background: var(--paper-2); }
.mainnav a.active { color: var(--ink); }
.mainnav a.active::after { content: ''; position: absolute; left: 12px; right: 12px; bottom: -11px; height: 4px; background: var(--red); }
.nav-right { display: flex; align-items: center; gap: 8px; }
.badge-dot {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font: 700 .68rem/1 var(--mono);
}

.page { max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }
.page.narrow { max-width: 760px; }
.page.full { max-width: none; padding: 0; }

.tabbar { display: none; }
.mainnav { min-width: 0; }

@media (max-width: 1200px) {
  .topbar-inner { gap: 14px; }
  .mainnav a { padding: 8px 9px; }
  .mainnav a .ico { display: none; }
}
@media (max-width: 1020px) {
  .nav-right .btn.primary .label-text { display: none; }
  .nav-right .btn.primary { padding-left: 12px; padding-right: 24px; }
  .mainnav a { font-size: .86rem; padding: 8px 7px; }
}

@media (max-width: 860px) {
  .mainnav, .nav-right .hide-sm { display: none; }
  .topbar-inner { justify-content: space-between; }
  .page { padding: 18px 14px calc(var(--tab-h) + 40px); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--card); border-top: 2px solid var(--ink);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    text-decoration: none; font-size: .68rem; font-weight: 600; color: var(--ink-3); position: relative;
  }
  .tabbar a .ico { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--ink); }
  .tabbar a.active::before { content: ''; position: absolute; top: -2px; left: 25%; right: 25%; height: 4px; background: var(--red); }
  .tabbar a.tab-add .ico { width: 26px; height: 26px; }
  .tabbar a.tab-add span.plate {
    background: var(--sign); color: var(--sign-ink); width: 48px; height: 36px; display: grid; place-items: center;
    clip-path: polygon(0 0, 78% 0, 100% 50%, 78% 100%, 0 100%);
  }
  .tabbar .badge-dot { position: absolute; top: 6px; right: calc(50% - 22px); }
}

/* ---------------- Signpost elements ---------------- */

.sign {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--sign); color: var(--sign-ink);
  font-weight: 800; font-stretch: 85%; letter-spacing: .01em; text-transform: uppercase;
  padding: 8px 34px 8px 14px;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%);
  line-height: 1.1;
}
.sign.left { clip-path: polygon(18px 0, 100% 0, 100% 100%, 18px 100%, 0 50%); padding: 8px 14px 8px 30px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0; }
.kicker { font: 600 .72rem/1 var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.kicker::before { content: ''; width: 18px; height: 6px; background: linear-gradient(var(--card) 0 33%, var(--red) 33% 66%, var(--card) 66%); outline: 1px solid var(--line-2); }

/* Difficulty marker: SAC scale on trail colors */
.diff { display: inline-flex; align-items: center; gap: 6px; font: 700 .75rem/1 var(--mono); }
.diff i { width: 20px; height: 12px; display: inline-block; outline: 1px solid var(--line-2); }
.diff-yellow i { background: var(--sign); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); outline: none; width: 14px; height: 14px; }
.diff-red i { background: linear-gradient(#fff 0 33%, #d22b1f 33% 67%, #fff 67%); }
.diff-blue i { background: linear-gradient(#fff 0 33%, #1f5ca8 33% 67%, #fff 67%); }

/* ---------------- Buttons & forms ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 650 .92rem/1 var(--font); padding: 11px 16px; min-height: 42px;
  border: 1.5px solid var(--ink); border-radius: var(--r); background: var(--card); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .08s, background .15s;
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--sign); color: var(--sign-ink); border-color: var(--sign);
  padding-right: 30px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%);
  border-radius: 0;
}
.btn.primary:hover { background: var(--sign-2); }
.btn.dark { background: var(--ink); color: var(--paper); }
.btn.dark:hover { background: var(--ink-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--paper-2); }
.btn.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn.small { min-height: 32px; padding: 7px 11px; font-size: .82rem; }
.btn.primary.small { padding-right: 24px; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r);
  border: 0; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; position: relative;
}
.icon-btn:hover { background: var(--paper-2); }
.icon-btn .badge-dot { position: absolute; top: 2px; right: 0; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label, .label { font: 600 .74rem/1.2 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.field .hint { font-size: .8rem; color: var(--ink-3); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input[type=email], select, textarea {
  font: 450 1rem/1.3 var(--font); color: var(--ink);
  background: var(--card); border: 1.5px solid var(--line-2); border-radius: var(--r);
  padding: 10px 12px; width: 100%; min-height: 44px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sign) 55%, transparent); }
input.code-input { font: 600 1.4rem/1 var(--mono); letter-spacing: .25em; text-align: center; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 180px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; margin-bottom: 12px; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--ink); }
form.busy { opacity: .7; pointer-events: none; }

/* Segmented control */
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: var(--r); overflow: hidden; background: var(--card); flex-wrap: wrap; }
.seg button, .seg a {
  font: 600 .82rem/1 var(--font); border: 0; background: transparent; color: var(--ink-2); padding: 9px 13px; cursor: pointer;
  text-decoration: none; border-right: 1px solid var(--line);
}
.seg > :last-child { border-right: 0; }
.seg button:hover, .seg a:hover { background: var(--paper-2); color: var(--ink); }
.seg .on { background: var(--ink); color: var(--paper); }
.seg .on:hover { background: var(--ink); color: var(--paper); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border: 1px solid var(--line-2);
  border-radius: 2px; font: 600 .78rem/1.2 var(--font); background: var(--card); text-decoration: none;
}
.chip .ico { width: 14px; height: 14px; }
.chip.peak { border-color: var(--ink); }
.chip.peak .ele { font-family: var(--mono); font-weight: 500; color: var(--ink-3); }
.tag { font: 600 .7rem/1 var(--mono); text-transform: uppercase; letter-spacing: .06em; padding: 4px 6px; border-radius: 2px; background: var(--paper-2); color: var(--ink-2); display: inline-flex; gap: 5px; align-items: center; }
.tag .ico { width: 12px; height: 12px; }
.tag.warn { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }

/* Stars */
.stars { display: inline-flex; gap: 1px; color: var(--line-2); }
.stars .on { color: var(--sign); }
.stars .on .ico { fill: var(--sign); stroke: var(--ink); stroke-width: 1.2; }
.stars .ico { width: 15px; height: 15px; }
.stars-input { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.stars-input input { position: absolute; opacity: 0; width: 0; }
.stars-input label { cursor: pointer; color: var(--line-2); }
.stars-input label .ico { width: 30px; height: 30px; }
.stars-input input:checked ~ label, .stars-input label:hover, .stars-input label:hover ~ label { color: var(--ink); }
.stars-input input:checked ~ label .ico, .stars-input label:hover .ico, .stars-input label:hover ~ label .ico { fill: var(--sign); }
.stars-input input:focus-visible + label { outline: 2px solid var(--blue); }

/* ---------------- Cards & panels ---------------- */

.panel { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r); padding: 20px; margin-bottom: 20px; }
.panel.tight { padding: 14px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { margin: 0; }
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 34px 0 14px; }
.section-title h2 { margin: 0; }
.section-title::after { content: ''; flex: 1; height: 2px; background: var(--ink); transform: translateY(-4px); }

.layout-2 { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
@media (max-width: 960px) { .layout-2 { grid-template-columns: 1fr; } }

/* Hike card */
.hike-list { display: flex; flex-direction: column; gap: 14px; }
.hike-card {
  display: grid; grid-template-columns: 150px minmax(0, 1fr); background: var(--card);
  border: 1.5px solid var(--line); border-radius: var(--r); overflow: hidden; text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.hike-card:hover { border-color: var(--ink); }
.hike-card .thumb { background: var(--paper-2); position: relative; border-right: 1.5px solid var(--line); }
.hike-card .thumb svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hike-card .body { padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hike-card .meta { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--ink-3); flex-wrap: wrap; }
.hike-card .meta .user-link { color: var(--ink); font-weight: 650; text-decoration: none; }
.hike-card h3 { margin: 0; font-size: 1.15rem; font-stretch: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hike-card .foot { display: flex; align-items: center; gap: 14px; margin-top: auto; font-size: .8rem; color: var(--ink-3); flex-wrap: wrap; }
.hike-card .foot span { display: inline-flex; align-items: center; gap: 4px; }
.hike-card .foot .liked { color: var(--red); }
.hike-card .foot .liked .ico { fill: var(--red); }
@media (max-width: 560px) {
  .hike-card { grid-template-columns: 96px minmax(0, 1fr); }
  .hike-card .body { padding: 11px 12px 10px; }
  .hike-card h3 { font-size: 1rem; white-space: normal; }
}

.route-thumb .shape { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.route-thumb .start { fill: var(--sign); stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.route-thumb .profile { fill: color-mix(in srgb, var(--ink) 12%, transparent); stroke: none; }

/* Stat line ("signpost" numbers) */
.statline { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat .v { font: 780 1.25rem/1.1 var(--font); font-stretch: 78%; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .v small { font: 500 .7rem/1 var(--mono); color: var(--ink-3); margin-left: 3px; }
.stat .k { font: 600 .64rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }

.bigstats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); border-top: 2px solid var(--ink); border-left: 1px solid var(--line); }
.bigstats .stat { padding: 14px 16px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--card); gap: 6px; }
.bigstats .stat .v { font-size: clamp(1.5rem, 3vw, 2.1rem); }
.bigstats .stat .ico { color: var(--ink-3); }

/* Avatar */
.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  font: 700 .78rem/1 var(--mono); color: #fff; flex: none; letter-spacing: .02em;
}
.avatar.sm { width: 26px; height: 26px; font-size: .64rem; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; }
.av-0 { background: #2d5a3d; } .av-1 { background: #1f5ca8; } .av-2 { background: #b23a24; }
.av-3 { background: #7a5c1e; } .av-4 { background: #5a4a8a; } .av-5 { background: #2f6f73; }
.user-link { font-weight: 650; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 650; }
.list .sub { font-size: .82rem; color: var(--ink-3); }

table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font: 600 .68rem/1.2 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 8px 10px; border-bottom: 2px solid var(--ink); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: color-mix(in srgb, var(--paper-2) 60%, transparent); }
.table-wrap { overflow-x: auto; }

/* Empty state */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty-art { width: 140px; color: var(--ink-3); margin: 0 auto 14px; }
.empty h3 { font-size: 1.2rem; }
.empty p { color: var(--ink-3); max-width: 420px; margin: 0 auto 18px; }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--paper-2), var(--card), var(--paper-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r); }
@keyframes sk { to { background-position: -200% 0; } }
.loading-line { height: 108px; margin-bottom: 14px; }

/* Toasts */
#toasts { position: fixed; z-index: 3000; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 20px); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (min-width: 861px) { #toasts { bottom: 28px; } }
.toast {
  background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: var(--r); font-weight: 550; font-size: .9rem;
  box-shadow: var(--shadow); max-width: min(92vw, 460px); animation: tin .2s ease-out; border-left: 5px solid var(--sign);
}
.toast-error { border-left-color: var(--red); }
.toast-ok { border-left-color: #4caf6e; }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .4s; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 2000; background: rgba(15, 18, 16, .55); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--card); width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; border: 2px solid var(--ink); border-radius: var(--r); box-shadow: var(--shadow); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1.5px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 18px; }

/* ---------------- Auth screens ---------------- */

.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  background: var(--ink); color: var(--paper); position: relative; overflow: hidden; display: flex; flex-direction: column;
  justify-content: space-between; padding: 40px;
}
.auth-art svg.ridge { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 60%; }
.auth-art .claim { position: relative; z-index: 1; font: 800 clamp(2.2rem, 4.6vw, 3.8rem)/0.98 var(--font); font-stretch: 70%; text-transform: uppercase; letter-spacing: -.01em; max-width: 520px; }
.auth-art .claim em { font-style: normal; color: var(--sign); }
.auth-art .posts { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.auth-art .posts .sign { font-size: .9rem; min-width: 260px; justify-content: space-between; }
.auth-art .posts .sign span.t { font-family: var(--mono); font-weight: 600; text-transform: none; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-form .box { width: min(400px, 100%); }
.auth-form h1 { font-size: 2rem; margin-bottom: 6px; }
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { min-height: 230px; padding: 24px; }
  .auth-art .posts { display: none; }
}

/* ---------------- Map ---------------- */

.map { width: 100%; height: 420px; background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: var(--r); z-index: 1; }
.map.tall { height: min(62vh, 620px); }
.leaflet-container { font-family: var(--font); }
.leaflet-bar a, .leaflet-control-layers { border-radius: var(--r) !important; }
.leaflet-control-layers { border: 1.5px solid var(--ink) !important; box-shadow: none !important; }
.leaflet-bar { border: 1.5px solid var(--ink) !important; box-shadow: none !important; }
.leaflet-popup-content-wrapper { border-radius: var(--r); border: 1.5px solid var(--ink); box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 10px 12px; font-size: .88rem; }
.leaflet-popup-content img { border-radius: 2px; max-width: 220px; }
.map-pin {
  width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--ink); background: var(--sign);
}
.map-pin.end { background: var(--red); border-color: #fff; outline: 2px solid var(--ink); }
.map-pin.hover { background: #fff; border-color: var(--red); width: 14px; height: 14px; }
.peak-pin { color: var(--ink); filter: drop-shadow(0 1px 0 #fff) drop-shadow(0 -1px 0 #fff) drop-shadow(1px 0 0 #fff) drop-shadow(-1px 0 0 #fff); }
.peak-pin svg { width: 22px; height: 22px; fill: var(--ink); }
.photo-pin { width: 34px; height: 34px; border: 2px solid #fff; outline: 1.5px solid var(--ink); border-radius: 2px; background-size: cover; background-position: center; }
.wp-pin {
  width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center;
  font: 700 .72rem/1 var(--mono); border: 2px solid var(--sign);
}

/* Elevation profile */
.profile-chart { position: relative; width: 100%; height: 170px; user-select: none; touch-action: pan-y; }
.profile-chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.profile-chart .area { fill: color-mix(in srgb, var(--forest) 22%, transparent); }
.profile-chart .line { fill: none; stroke: var(--ink); stroke-width: 1.8; vector-effect: non-scaling-stroke; }
.profile-chart .grid line { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.profile-chart .axis { font: 500 10px var(--mono); fill: var(--ink-3); }
.profile-chart .cursor { stroke: var(--red); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.profile-tip {
  position: absolute; top: 0; transform: translateX(-50%); background: var(--ink); color: var(--paper); font: 600 .72rem/1.3 var(--mono);
  padding: 4px 7px; border-radius: 2px; pointer-events: none; white-space: nowrap; z-index: 3;
}

/* Bar chart */
.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-template-rows: 100%; gap: 6px; align-items: stretch; height: 180px; padding-top: 18px; }
@media (max-width: 600px) {
  .bars { gap: 3px; }
  .bars .bar b { display: none; }
  .bars .bar span { font-size: .55rem; letter-spacing: -.02em; }
}
.bars .bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; position: relative; }
.bars .bar i { display: block; width: 100%; background: var(--ink); min-height: 2px; border-radius: 1px 1px 0 0; }
.bars .bar.top i { background: var(--sign); outline: 1.5px solid var(--ink); outline-offset: -1.5px; }
.bars .bar.empty i { background: var(--line); }
.bars .bar span { font: 600 .64rem/1 var(--mono); color: var(--ink-3); text-transform: uppercase; }
.bars .bar b { position: absolute; font: 600 .62rem/1 var(--mono); color: var(--ink-2); white-space: nowrap; }

/* Hike detail */
.hike-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.hike-head .who { display: flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--ink-3); margin-bottom: 10px; }
.hike-head h1 { margin: 0 0 10px; }
.hike-head .badges { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hike-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notes { white-space: pre-wrap; line-height: 1.6; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.photo-grid button { padding: 0; border: 0; background: var(--paper-2); aspect-ratio: 1; cursor: zoom-in; border-radius: 2px; overflow: hidden; position: relative; }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.photo-grid button:hover img { transform: scale(1.04); }
.photo-grid .nogps { position: absolute; left: 6px; bottom: 6px; font: 600 .62rem/1 var(--mono); text-transform: uppercase; letter-spacing: .05em; background: var(--red); color: #fff; padding: 3px 5px; border-radius: 2px; }
.photo-pin.placing { width: 44px; height: 44px; border: 3px solid var(--sign); outline: 2px solid var(--ink); cursor: grab; box-shadow: 0 6px 16px rgba(0,0,0,.35); }
.place-bar {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 10px;
  background: var(--card); border: 2px solid var(--ink); border-left: 8px solid var(--sign); border-radius: var(--r);
}
.place-bar img { width: 64px; height: 64px; object-fit: cover; border-radius: 2px; flex: none; }
.place-bar .grow { flex: 1; min-width: 200px; }
.place-bar input[type=range] { width: 100%; margin: 8px 0 4px; accent-color: var(--red); height: 28px; }
.place-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.lightbox { position: fixed; inset: 0; z-index: 2500; background: rgba(8, 10, 9, .94); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.lightbox img { max-height: calc(100vh - 120px); max-width: 100%; object-fit: contain; }
.lightbox .cap { color: #eee; margin-top: 12px; text-align: center; font-size: .9rem; }
.lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; background: rgba(255,255,255,.1); border: 0; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.lightbox .nav.prev { left: 16px; } .lightbox .nav.next { right: 16px; }
.lightbox .x { position: absolute; top: 14px; right: 14px; color: #fff; }
.lightbox .tools { position: absolute; top: 14px; left: 14px; display: flex; gap: 8px; }

.comment { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment .c-body { flex: 1; min-width: 0; }
.comment .c-head { font-size: .82rem; color: var(--ink-3); display: flex; gap: 8px; align-items: baseline; }
.comment p { margin: 3px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.like-btn.on { border-color: var(--red); color: var(--red); }
.like-btn.on .ico { fill: var(--red); }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--ink-3); border-radius: var(--r); padding: 44px 20px; text-align: center; background: var(--card);
  cursor: pointer; transition: all .15s; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.dropzone.over { border-color: var(--ink); background: color-mix(in srgb, var(--sign) 18%, var(--card)); }
.dropzone .ico { width: 40px; height: 40px; }
.dropzone strong { font-size: 1.15rem; }
.progress { height: 8px; background: var(--paper-2); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ink); width: 0; transition: width .2s; }
.progress.sign i { background: repeating-linear-gradient(90deg, var(--sign) 0 14px, var(--ink) 14px 16px); }
.result-ok { color: var(--ok); }
.result-err { color: var(--danger); }

/* Leaderboard */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 10px; align-items: end; margin-bottom: 22px; }
.podium .p { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; text-decoration: none; }
.podium .p .block {
  width: 100%; background: var(--card); border: 1.5px solid var(--ink); border-bottom: 0; display: grid; place-items: center;
  font: 800 2.4rem/1 var(--font); font-stretch: 70%;
}
.podium .p1 .block { height: 120px; background: var(--sign); color: var(--sign-ink); }
.podium .p2 .block { height: 88px; }
.podium .p3 .block { height: 64px; }
.podium .name { font-weight: 700; font-size: .92rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .val { font: 600 .8rem/1 var(--mono); color: var(--ink-2); }
.podium-base { height: 6px; background: var(--ink); margin-top: -22px; margin-bottom: 22px; }
.rank-list li.me { background: color-mix(in srgb, var(--sign) 22%, transparent); margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
.rank { font: 700 .9rem/1 var(--mono); width: 32px; color: var(--ink-3); }
.rank-val { font: 750 1.1rem/1 var(--font); font-stretch: 80%; font-variant-numeric: tabular-nums; text-align: right; }
.rank-val small { font: 500 .7rem var(--mono); color: var(--ink-3); margin-left: 3px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.filters select { width: auto; min-height: 38px; padding: 7px 10px; font-size: .88rem; }

/* Challenges */
.challenge { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 12px; position: relative; }
.challenge.done { border-color: var(--ok); }
.challenge h3 { margin: 0 0 4px; font-stretch: 88%; font-size: 1.1rem; }
.challenge .c-meta { font-size: .8rem; color: var(--ink-3); display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.trail-progress { position: relative; height: 18px; margin: 6px 0 8px; }
.trail-progress .track { position: absolute; left: 0; right: 0; top: 7px; height: 4px; background: repeating-linear-gradient(90deg, var(--line-2) 0 8px, transparent 8px 13px); }
.trail-progress .done { position: absolute; left: 0; top: 6px; height: 6px; background: var(--ink); border-radius: 3px; }
.trail-progress .flag { position: absolute; right: -2px; top: -4px; width: 18px; height: 14px; background: linear-gradient(#fff 0 33%, var(--red) 33% 67%, #fff 67%); outline: 1px solid var(--ink); }
.trail-progress .me { position: absolute; top: 1px; width: 16px; height: 16px; margin-left: -8px; background: var(--sign); border: 2px solid var(--ink); border-radius: 50%; }
.c-numbers { display: flex; justify-content: space-between; font: 600 .78rem/1 var(--mono); color: var(--ink-2); }

/* Stats page */
.records { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.record { background: var(--card); border: 1.5px solid var(--line); padding: 14px 16px; text-decoration: none; display: flex; flex-direction: column; gap: 4px; border-radius: var(--r); }
.record:hover { border-color: var(--ink); }
.record .rv { font: 800 1.7rem/1 var(--font); font-stretch: 75%; }
.record .rv small { font: 500 .75rem var(--mono); color: var(--ink-3); margin-left: 3px; }
.record .rt { font-size: .85rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekdays div { text-align: center; }
.weekdays i { display: block; height: 48px; border-radius: 2px; background: var(--ink); margin-bottom: 4px; }
.weekdays span { font: 600 .7rem var(--mono); color: var(--ink-3); }
.review-teaser {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 24px; margin-bottom: 24px;
  background: var(--ink); color: var(--paper); border-radius: var(--r); text-decoration: none; position: relative; overflow: hidden;
}
.review-teaser::after { content: ''; position: absolute; right: -40px; top: -40px; width: 200px; height: 200px; background: var(--sign); transform: rotate(45deg); opacity: .95; }
.review-teaser > * { position: relative; z-index: 1; }
.review-teaser h2 { margin: 0; font-size: 1.5rem; font-stretch: 75%; text-transform: uppercase; }
.review-teaser .btn { background: var(--paper); color: var(--ink); border-color: var(--paper); }

/* Year review – story slides */
.review { position: fixed; inset: 0; z-index: 1500; background: var(--ink); color: #fff; overflow: hidden; }
.review .bars-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 4px; z-index: 5; }
.review .bars-top i { flex: 1; height: 3px; background: rgba(255,255,255,.25); border-radius: 2px; overflow: hidden; }
.review .bars-top i.seen { background: #fff; }
.review .bars-top i.cur::after { content: ''; display: block; height: 100%; background: #fff; animation: rv-fill 7s linear forwards; }
@keyframes rv-fill { from { width: 0; } to { width: 100%; } }
.review .close { position: absolute; top: 24px; right: 14px; z-index: 6; color: inherit; }
.review .slide { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 70px max(28px, 8vw) 60px; opacity: 0; pointer-events: none; transition: opacity .45s; }
.review .slide.on { opacity: 1; pointer-events: auto; }
.review .slide .k { font: 600 .8rem/1 var(--mono); text-transform: uppercase; letter-spacing: .16em; opacity: .8; margin-bottom: 18px; }
.review .slide .huge { font: 850 clamp(4rem, 17vw, 12rem)/.85 var(--font); font-stretch: 62%; letter-spacing: -.02em; }
.review .slide .huge small { font-size: .3em; font-stretch: 80%; margin-left: .1em; }
.review .slide .t { font: 750 clamp(1.4rem, 4vw, 2.6rem)/1.1 var(--font); font-stretch: 80%; max-width: 900px; margin-top: 18px; }
.review .slide .s { font-size: clamp(1rem, 2.2vw, 1.25rem); opacity: .85; max-width: 640px; margin-top: 16px; }
.review .slide.on .huge, .review .slide.on .t { animation: rv-in .7s cubic-bezier(.2,.8,.2,1) both; }
.review .slide.on .t { animation-delay: .12s; }
@keyframes rv-in { from { transform: translateY(30px); opacity: 0; } }
.rv-yellow { background: var(--sign); color: var(--sign-ink); }
.rv-red { background: #c8281d; }
.rv-blue { background: #1b4f92; }
.rv-forest { background: #234a32; }
.rv-ink { background: #121513; }
.rv-paper { background: #f2efe6; color: #171b18; }
.review .tap { position: absolute; top: 0; bottom: 0; width: 35%; z-index: 4; }
.review .tap.l { left: 0; } .review .tap.r { right: 0; width: 65%; }
.review .peaklist { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-direction: column; gap: 8px; max-width: 560px; }
.review .peaklist li { display: flex; justify-content: space-between; gap: 16px; font: 700 clamp(1rem, 2.6vw, 1.5rem)/1.1 var(--font); font-stretch: 85%; border-bottom: 2px solid currentColor; padding-bottom: 6px; }
.review .peaklist li span:last-child { font-family: var(--mono); font-weight: 600; font-size: .8em; }
.review .mini-bars { display: flex; gap: 6px; align-items: flex-end; height: 160px; margin-top: 26px; max-width: 640px; }
.review .mini-bars i { flex: 1; background: currentColor; opacity: .3; min-height: 3px; }
.review .mini-bars i.top { opacity: 1; }
.review .summary-card { background: #f2efe6; color: #171b18; padding: 26px; max-width: 560px; border: 3px solid #171b18; }
.review .summary-card .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; margin-top: 16px; }
.review .summary-card .grid div b { display: block; font: 850 2.2rem/1 var(--font); font-stretch: 65%; }
.review .summary-card .grid div span { font: 600 .68rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: #6b6f69; }

/* Planner */
.planner { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: calc(100vh - var(--nav-h)); }
.planner .map { height: 100%; border: 0; border-radius: 0; }
.planner .side { border-left: 2px solid var(--ink); background: var(--paper); overflow-y: auto; padding: 18px; }
.planner .hint-box { font-size: .85rem; color: var(--ink-2); background: var(--paper-2); padding: 10px 12px; border-radius: var(--r); margin-bottom: 14px; }
@media (max-width: 860px) {
  .planner { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  .planner .side { border-left: 0; border-top: 2px solid var(--ink); padding-bottom: calc(var(--tab-h) + 30px); }
}

/* Admin */
.admin-tabs { margin-bottom: 20px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .9rem; }
.kv dt { color: var(--ink-3); font-family: var(--mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; padding-top: 2px; }
.kv dd { margin: 0; }
.code-box { font: 600 1.35rem/1.2 var(--mono); letter-spacing: .08em; background: var(--paper-2); border: 1.5px dashed var(--ink); padding: 14px; text-align: center; border-radius: var(--r); user-select: all; word-break: break-all; }
.qr-box { background: #fff; padding: 10px; width: 200px; margin: 0 auto 14px; border: 1.5px solid var(--ink); }
.qr-box svg { width: 100%; height: auto; display: block; }
.recovery { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font: 600 .95rem var(--mono); background: var(--paper-2); padding: 14px; border-radius: var(--r); }

.profile-head { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }
.profile-head .grow { flex: 1; min-width: 200px; }
.profile-head h1 { margin: 0 0 4px; }

.zone-circle { stroke: var(--red); }

/* small helpers */
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.right { text-align: right; }
.flex { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.hr { height: 1px; background: var(--line); margin: 18px 0; border: 0; }
.notice { padding: 12px 14px; border-left: 4px solid var(--sign); background: var(--card); margin-bottom: 16px; font-size: .9rem; }
.notice.warn { border-left-color: var(--red); }
.load-more { display: flex; justify-content: center; margin-top: 18px; }
