:root {
  --paper: #e7ede5;
  --surface: #f7f9f4;
  --surface-2: #d8e1d5;
  --ink: #17302a;
  --muted: #56706a;
  --rule: #c3cfc4;
  --pine: #1e3a34;
  --pine-ink: #e9efe7;
  --blaze: #f2b632;
  --pole: #7a6448;
  --warn: #a3321f;
  --ok: #2e6b5a;
  --lv-path: #2e6b5a;
  --lv-legendary: #7b4fa0;
  --lv-star1: #c9951a;
  --lv-star2: #c2661f;
  --lv-star3: #9e3526;
  --radius-s: 6px;
  --radius-m: 12px;
  --font-sign: "Barlow Semi Condensed", "Bahnschrift", "DIN Alternate", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Barlow", "Bahnschrift", "Segoe UI", system-ui, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #13211e;
    --surface: #1b2c28;
    --surface-2: #2a3e39;
    --ink: #e3ebe2;
    --muted: #9bb0a8;
    --rule: #30463f;
    --pine: #0f1c19;
    --pine-ink: #e3ebe2;
    --pole: #8f7858;
    --warn: #f08a6f;
    --ok: #7cc3a7;
    --lv-path: #4fa384;
    --lv-legendary: #a57ccc;
    --lv-star1: #e2b23a;
    --lv-star2: #e08a45;
    --lv-star3: #d7654f;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--blaze); outline-offset: 2px; }

/* ---------- Rahmen ---------- */
.frame { min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(.75rem + env(safe-area-inset-top)) 1rem .75rem;
  background: var(--pine); color: var(--pine-ink);
}
.brand { display: flex; align-items: center; gap: .55rem; font: 700 1.35rem/1 var(--font-sign); letter-spacing: .01em; }
.brand img { border-radius: 7px; }
.top-date { margin: 0; font-size: .9rem; opacity: .85; text-align: right; }
.date-short { display: none; }
@media (max-width: 480px) { .date-long { display: none; } .date-short { display: inline; } }

.nav {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom));
  background: var(--pine);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .35rem 0; border: 0; background: none; color: var(--pine-ink); opacity: .7;
  font: 600 .8rem/1 var(--font-sign); letter-spacing: .02em; cursor: pointer; border-radius: var(--radius-s);
}
.nav-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn[aria-current="page"] { opacity: 1; color: var(--blaze); }

.main { width: 100%; max-width: 920px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }

@media (min-width: 960px) {
  .frame { display: grid; grid-template-columns: 210px 1fr; grid-template-rows: auto 1fr; padding-bottom: 0; }
  .top { grid-column: 1 / -1; padding: .9rem 1.5rem; }
  .nav {
    position: sticky; top: 0; align-self: start; min-height: calc(100vh - 60px);
    display: flex; flex-direction: column; gap: .25rem; padding: 1.25rem .75rem; background: transparent;
    border-right: 1px solid var(--rule);
  }
  .nav-btn { flex-direction: row; gap: .7rem; padding: .6rem .75rem; color: var(--ink); opacity: .75; font-size: 1.05rem; }
  .nav-btn[aria-current="page"] { opacity: 1; color: var(--ink); background: var(--surface-2); }
  .nav-btn[aria-current="page"] svg { stroke: var(--lv-path); }
  .main { padding: 2rem 2rem 3rem; margin: 0; }
}

/* ---------- Typografie ---------- */
.h-page { margin: 0 0 1rem; font: 700 2rem/1.1 var(--font-sign); letter-spacing: -.005em; }
.h-section { margin: 2rem 0 .75rem; font: 700 1.5rem/1.15 var(--font-sign); }
.h-sub { margin: 0 0 .6rem; font: 700 1.25rem/1.2 var(--font-sign); }
.h-mini { margin: 1.25rem 0 .5rem; font: 600 1.02rem/1.2 var(--font-sign); color: var(--muted); }
.lede, .hint { color: var(--muted); max-width: 68ch; margin: 0 0 1rem; }
.hint { font-size: .92rem; }
.hint-strong { color: var(--ink); background: var(--surface-2); padding: .5rem .7rem; border-radius: var(--radius-s); }
.warn { color: var(--warn); margin: .35rem 0 0; font-size: .95rem; }
.ok { color: var(--ok); }
p { max-width: 70ch; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .5rem 1rem; border-radius: var(--radius-s); border: 2px solid transparent;
  font: 600 1rem/1.1 var(--font-sign); letter-spacing: .02em; cursor: pointer; text-decoration: none;
}
.btn-ink { background: var(--pine); color: #f4f7f2; }
.btn-ink:hover { background: #2a4d45; }
.btn-quiet { background: transparent; border-color: var(--rule); color: var(--ink); }
.btn-quiet:hover { border-color: var(--muted); }
.btn-danger { background: transparent; border-color: var(--warn); color: var(--warn); }
.row, .row-end { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .9rem; }
.row-end { justify-content: flex-end; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- Wegweiser ---------- */
.signpost { position: relative; display: grid; gap: .6rem; padding-left: 22px; margin-top: .25rem; }
.signpost::before {
  content: ""; position: absolute; left: 6px; top: -10px; bottom: -22px; width: 9px;
  background: var(--pole); border-radius: 3px 3px 0 0;
}
.sign {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem;
  padding: 1rem 3.2rem 1rem 1.1rem;
  clip-path: polygon(0 0, calc(100% - 34px) 0, 100% 50%, calc(100% - 34px) 100%, 0 100%);
}
.sign--main { background: var(--blaze); color: #17302a; padding-top: 1.1rem; padding-bottom: 1.2rem; }
.sign--alt { background: var(--surface-2); color: var(--ink); padding-top: .7rem; padding-bottom: .7rem; margin-right: 14%; }
.sign-body { flex: 1 1 18rem; min-width: 0; }
.sign-intro { margin: 0 0 .1rem; font: 600 .95rem/1.2 var(--font-sign); opacity: .8; }
.sign-course { margin: 0; font: 700 clamp(1.6rem, 5.5vw, 2.5rem)/1.02 var(--font-sign); letter-spacing: -.01em; overflow-wrap: anywhere; }
.sign--alt .sign-course { font-size: 1.2rem; line-height: 1.15; }
.sign-where { margin: .35rem 0 0; font: 600 1.1rem/1.3 var(--font-sign); display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.sign--alt .sign-where { font-size: .98rem; margin-top: .15rem; }
.sign-why { margin: .55rem 0 0; font-size: .93rem; line-height: 1.45; max-width: 62ch; }
.sign--main .btn-ink { background: #17302a; }
.sign--alt .btn-quiet { min-height: 38px; padding: .3rem .8rem; border-color: color-mix(in srgb, var(--ink) 35%, transparent); }

.chip { display: inline-block; padding: .1rem .5rem; border-radius: 4px; color: #fff; font: 600 .9rem/1.35 var(--font-sign); letter-spacing: .02em; }
.chip-path { background: #2e6b5a; }
.chip-legendary { background: #6f4396; }
.chip-star1 { background: #8a6410; }
.chip-star2 { background: #a4531a; }
.chip-star3 { background: #9e3526; }

.forecast { margin: 1.6rem 0 0 22px; color: var(--muted); font-size: .92rem; }
.notice, .empty { background: var(--surface); border-left: 5px solid var(--blaze); padding: .8rem 1rem; margin-bottom: 1rem; border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.notice p, .empty p { margin: 0 0 .6rem; }

/* ---------- Tagesziele ---------- */
.goals { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; align-items: start; counter-reset: goal; }
@media (min-width: 760px) { .goals { grid-template-columns: 1fr 1fr; } }
.goal {
  position: relative; counter-increment: goal;
  background: var(--surface); border-radius: var(--radius-m); padding: .9rem 1rem 1rem 3.1rem;
  border: 1px solid var(--rule);
}
.goal::before {
  content: counter(goal); position: absolute; left: .9rem; top: .95rem;
  width: 1.5rem; height: 1.5rem; display: grid; place-items: center;
  font: 700 .9rem/1 var(--font-sign); color: var(--pine-ink); background: var(--muted); border-radius: 4px;
}
.goal.is-done::before { content: "✓"; background: var(--ok); color: var(--surface); }
.goal.is-urgent { border-color: var(--warn); }
.goal.is-urgent::before { background: var(--warn); }
.goal-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; min-height: 1.75rem; }
.goal h3 { margin: 0; font: 700 1.2rem/1.15 var(--font-sign); }
.goal-main { margin: .45rem 0 0; font-weight: 500; }
.goal-sub { margin: .3rem 0 0; color: var(--muted); font-size: .92rem; }
.goal-count { font: 700 1.2rem/1 var(--font-sign); }
.goal .btn { margin-top: .6rem; }
.sublist { margin: .55rem 0 0; padding: 0 0 0 1rem; font-size: .93rem; }
.sublist li { margin: .2rem 0; }
.sublist li::marker { color: var(--muted); }

.toggle {
  border: 2px solid var(--rule); background: transparent; border-radius: 999px; padding: .3rem .8rem; min-height: 36px;
  font: 600 .92rem/1 var(--font-sign); cursor: pointer; white-space: nowrap;
}
.toggle[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: var(--surface); }

.pips { display: flex; gap: .35rem; }
.pip { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--rule); background: transparent; cursor: pointer; padding: 0; }
.pip[aria-pressed="true"] { background: var(--lv-star1); border-color: var(--lv-star1); }

.meter { position: relative; height: 10px; margin: .7rem 0 .1rem; background: var(--surface-2); border-radius: 5px; }
.meter-fill { position: absolute; inset: 0 auto 0 0; background: var(--lv-path); border-radius: 5px; }
.meter-mark { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; background: var(--ink); border-radius: 2px; }

.badge { font: 600 .85rem/1 var(--font-sign); padding: .3rem .55rem; border-radius: 4px; white-space: nowrap; }
.badge-hold { background: var(--surface-2); }
.badge-climb { background: var(--blaze); color: #17302a; }
.badge-tournament { background: var(--lv-legendary); color: #fff; }

details.quick { margin-top: .7rem; }
details.quick summary { cursor: pointer; font: 600 .95rem/1.3 var(--font-sign); color: var(--muted); }
details.quick[open] summary { margin-bottom: .5rem; }

/* ---------- Formulare ---------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 1rem 1.1rem 1.1rem; margin-bottom: 1rem; }
.grid-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem .8rem; }
.field { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.field-label { font: 600 .88rem/1.25 var(--font-sign); color: var(--muted); }
.field-hint { font-size: .8rem; color: var(--muted); }
input[type="text"], input[type="number"], input[type="url"], input[type="date"], select {
  width: 100%; min-height: 42px; padding: .4rem .55rem; border: 1px solid var(--rule); border-radius: var(--radius-s);
  background: var(--paper); color: var(--ink);
}
input:focus-visible, select:focus-visible { outline-offset: 0; }
.check { display: flex; align-items: flex-start; gap: .5rem; margin: .5rem 0 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: .12rem 0 0; accent-color: var(--lv-path); flex: none; }
.checks { display: flex; flex-wrap: wrap; gap: 0 1.25rem; margin-top: .4rem; }
.radios .check { margin-top: .6rem; }

/* ---------- Kurse ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .5rem; }
.page-head .h-page { margin: 0; }
.course-list { display: grid; gap: 1rem; }
.course.is-paused { opacity: .7; }
.course-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .75rem; }
.course-name { margin: 0; font: 700 1.45rem/1.1 var(--font-sign); }
.course-meta { margin: .15rem 0 0; color: var(--muted); font-size: .9rem; }
.course-pct { text-align: right; line-height: 1.05; }
.course-pct strong { display: block; font: 700 1.6rem/1 var(--font-sign); white-space: nowrap; }
.course-pct span { font-size: .8rem; color: var(--muted); }
.course-next { margin: .8rem 0 .6rem; font-size: .93rem; }

.levels { display: grid; gap: 0; }
.lvl { display: grid; gap: .35rem; padding: .7rem 0 .75rem; border-top: 1px solid var(--rule); }
.lvl:first-child { border-top: 0; padding-top: .2rem; }
.lvl-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.lvl-name { display: flex; align-items: center; gap: .45rem; font: 700 1.08rem/1.2 var(--font-sign); white-space: nowrap; }
.dot { width: 11px; height: 11px; border-radius: 2px; flex: none; }
.dot-path, .bar-path { background: var(--lv-path); }
.dot-legendary, .bar-legendary { background: var(--lv-legendary); }
.dot-star1, .bar-star1 { background: var(--lv-star1); }
.dot-star2, .bar-star2 { background: var(--lv-star2); }
.dot-star3, .bar-star3 { background: var(--lv-star3); }
.btn-mini {
  min-height: 36px; padding: .25rem .75rem; border: 1px solid var(--rule); border-radius: var(--radius-s);
  background: var(--paper); font: 600 .92rem/1 var(--font-sign); letter-spacing: .02em; cursor: pointer;
}
.btn-mini:hover { border-color: var(--muted); }
.pos { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.pos-word { font: 600 1rem/1 var(--font-sign); color: var(--muted); }
.pos { column-gap: .6rem; }
.pos select { width: auto; flex: 1 1 12rem; max-width: 16rem; font-weight: 600; }
.pos-unit { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.pos input[type="number"] { width: 5.2rem; text-align: center; font-weight: 600; }
.bar { position: relative; height: 10px; margin: .2rem 0 0; background: var(--surface-2); border-radius: 3px; }
.bar-open {
  position: absolute; inset: 0 auto 0 0; border-radius: 3px;
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--muted) 45%, transparent) 0 2px, transparent 2px 6px);
}
.bar-done { position: absolute; inset: 0 auto 0 0; border-radius: 3px; }
.bar-target { position: absolute; top: -5px; bottom: -5px; width: 3px; margin-left: -1.5px; background: var(--ink); border-radius: 2px; }
.lvl-info { margin: 0; font-size: .88rem; color: var(--muted); }
.lvl.is-behind .lvl-info { color: var(--warn); }
.course-edit { margin-top: .5rem; }

.editor { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--rule); }
.fetch-row { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; margin-bottom: .6rem; }
.fetch-row .field { flex: 1 1 18rem; }
.add { border: 2px solid var(--blaze); }

.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--rule); font-size: .95rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 1rem; width: max-content; max-width: calc(100% - 2rem);
  padding: .65rem .8rem .65rem 1rem; border-radius: var(--radius-s); background: var(--ink); color: var(--paper); font-size: .93rem;
}
.toast button { border: 0; background: none; color: var(--blaze); font: 600 .95rem/1 var(--font-sign); cursor: pointer; padding: .4rem; }
@media (min-width: 960px) { .toast { bottom: 1.5rem; } }

@media (prefers-reduced-motion: no-preference) {
  .intro .sign--main { animation: swing .5s cubic-bezier(.2, .8, .3, 1.2) both; transform-origin: 0 50%; }
  @keyframes swing { from { transform: rotate(-4deg) translateX(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
}
