:root {
  --bg: #f2f4f4;
  --surface: #ffffff;
  --surface-2: #e7ebec;
  --ink: #152026;
  --muted: #56636b;
  --faint: #8a969d;
  --line: #dbe1e3;
  --accent: #00786a;
  --accent-ink: #ffffff;
  --gain: #00786a;
  --loss: #b23b25;
  --shadow: 0 1px 2px rgba(21, 32, 38, .06), 0 4px 16px rgba(21, 32, 38, .05);

  --fs-xs: .8125rem;
  --fs-s: .875rem;
  --fs-m: 1rem;
  --fs-l: 1.1875rem;
  --fs-xl: 1.5rem;

  --r-s: 8px;
  --r-m: 14px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111619;
    --surface: #182025;
    --surface-2: #1f292f;
    --ink: #e4e9eb;
    --muted: #a1adb3;
    --faint: #75828a;
    --line: #29343a;
    --accent: #3bbfab;
    --accent-ink: #08201c;
    --gain: #3bbfab;
    --loss: #ef8670;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--faint) transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--fs-m)/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-variant-numeric: tabular-nums;
  caret-color: var(--accent);
  accent-color: var(--accent);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
a { color: inherit; text-underline-offset: .18em; text-decoration-thickness: 1px; }
button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code { font-size: .9em; background: var(--surface-2); padding: .05em .35em; border-radius: 4px; }
h2 { font-size: var(--fs-l); font-weight: 700; letter-spacing: -.01em; margin: 2.5rem 0 .75rem; }

.icon { width: 1.05em; height: 1.05em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-fill { fill: currentColor; stroke: none; }

/* Kopf und Navigation */
.top { background: var(--bg); position: sticky; top: 0; z-index: 10; padding-top: env(safe-area-inset-top); }
.top-inner, .nav-inner, .wrap { max-width: 46rem; margin: 0 auto; padding-left: 1.25rem; padding-right: 1.25rem; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1.25rem; padding-bottom: .9rem; }
.identity { min-width: 0; }
.identity h1 { font-size: var(--fs-xl); line-height: 1.15; letter-spacing: -.025em; margin: 0; font-weight: 750; }
.identity h1 a { text-decoration: none; }
.identity h1 a:hover { text-decoration: underline; }
.stand { margin: .2rem 0 0; color: var(--muted); font-size: var(--fs-s); }
.stand.is-bad { color: var(--loss); }

.nav { border-bottom: 1px solid var(--line); }
.nav-inner { display: flex; gap: 1.5rem; overflow-x: auto; scrollbar-width: none; }
.nav-inner::-webkit-scrollbar { display: none; }
.nav button {
  background: none; border: 0; padding: .6rem 0 .7rem; cursor: pointer; white-space: nowrap;
  color: var(--muted); font-weight: 600; font-size: var(--fs-s); position: relative;
  transition: color .15s var(--ease);
}
.nav button:hover { color: var(--ink); }
.nav button::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px;
  background: var(--ink); transform: scaleX(0); transition: transform .2s var(--ease);
}
.nav button[aria-selected="true"] { color: var(--ink); }
.nav button[aria-selected="true"]::after { transform: scaleX(1); }

.wrap { padding-top: 1.5rem; padding-bottom: 3rem; }
.view > h2:first-child, .view > .chips:first-child { margin-top: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border-radius: 999px; padding: .55rem 1rem; border: 1px solid transparent; cursor: pointer;
  font-weight: 650; font-size: var(--fs-s); white-space: nowrap; text-decoration: none;
  transition: background-color .15s var(--ease), opacity .15s var(--ease), transform .12s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn[disabled] { cursor: default; opacity: .5; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:not([disabled]):hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--ink); border-color: var(--faint); }
.btn-block { width: 100%; padding: .75rem 1rem; font-size: var(--fs-m); }
.btn.is-loading .icon { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Hinweise */
.notice {
  display: flex; gap: .6rem; align-items: flex-start; margin: 0 0 1.25rem; padding: .75rem .9rem;
  border-radius: var(--r-s); font-size: var(--fs-s);
}
.notice p { margin: 0; }
.notice .icon { margin-top: .15em; }
.notice.is-ok { background: color-mix(in srgb, var(--gain) 11%, var(--surface)); color: var(--ink); }
.notice.is-ok .icon { color: var(--gain); }
.notice.is-bad { background: color-mix(in srgb, var(--loss) 11%, var(--surface)); color: var(--ink); }
.notice.is-bad .icon { color: var(--loss); }

/* Übersicht */
.totals { margin: 0 0 .25rem; font-size: var(--fs-l); color: var(--muted); line-height: 1.45; }
.totals strong { color: var(--ink); font-weight: 750; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: 0 0 1rem; }
.chip {
  border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: .32rem .8rem; font-size: var(--fs-s); cursor: pointer; color: var(--muted);
  transition: border-color .15s var(--ease), color .15s var(--ease), background-color .15s var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--faint); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 600; }

.panel { background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow); }
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow); overflow: hidden; }
.rows > li + li { border-top: 1px solid var(--line); }

.day { margin-bottom: 1.25rem; }
.day h3 { font-size: var(--fs-xs); font-weight: 650; color: var(--muted); margin: 0 0 .4rem; }
.event { display: flex; align-items: center; gap: .7rem; padding: .65rem .95rem; }
.event .icon { font-size: 1.1rem; }
.event.gain .icon { color: var(--gain); }
.event.loss .icon { color: var(--loss); }
.event .what { color: var(--muted); }
.event a { font-weight: 650; text-decoration: none; }
.event a:hover { text-decoration: underline; }
.tag {
  margin-left: auto; flex: none; font-size: var(--fs-xs); color: var(--muted);
  background: var(--surface-2); border-radius: 999px; padding: .1rem .55rem; white-space: nowrap;
}
.tag.is-warn { color: var(--loss); background: color-mix(in srgb, var(--loss) 12%, var(--surface)); }

.empty { color: var(--muted); background: var(--surface); border-radius: var(--r-m); padding: 1rem 1.1rem; margin: 0; box-shadow: var(--shadow); }
.empty strong { color: var(--ink); display: block; margin-bottom: .15rem; }

.chart { padding: 1rem 1rem .8rem; }
.chart svg { display: block; width: 100%; height: 150px; overflow: visible; }
.chart .axis { font-size: 11px; fill: var(--faint); }
.legend { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); margin-top: .6rem; }
.legend i { display: inline-block; width: .9rem; border-top: 2px solid; vertical-align: middle; margin-right: .4rem; }

/* Beiträge */
.post > button {
  display: grid; grid-template-columns: 4rem 1fr auto; gap: .9rem; align-items: center; width: 100%;
  background: none; border: 0; padding: .8rem .95rem; text-align: left; cursor: pointer;
  transition: background-color .15s var(--ease);
}
.post > button:hover { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.thumb {
  width: 4rem; height: 4rem; border-radius: var(--r-s); object-fit: cover; background: var(--surface-2);
  display: grid; place-items: center; color: var(--faint);
}
.post-main { min-width: 0; }
.post-cap {
  margin: 0; font-weight: 600; font-size: var(--fs-s); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-cap.is-empty { color: var(--muted); font-weight: 500; }
.post-meta { margin: .15rem 0 .35rem; font-size: var(--fs-xs); color: var(--muted); }
.metrics { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: var(--fs-s); }
.metric { display: inline-flex; align-items: center; gap: .3rem; }
.metric .icon { color: var(--faint); font-size: .95em; }
.metric .delta { color: var(--gain); font-size: var(--fs-xs); }
.metric.is-gain { color: var(--gain); font-weight: 650; }
.metric.is-gain .icon { color: var(--gain); }
.chev { color: var(--faint); transition: transform .2s var(--ease); }
.post > button[aria-expanded="true"] .chev { transform: rotate(180deg); }

.post-detail { padding: 0 .95rem 1rem; display: grid; gap: 1rem; }
.post-detail .chart { box-shadow: none; background: var(--bg); padding: .75rem .75rem .6rem; }
.post-detail .chart svg { height: 110px; }
.detail-label { font-size: var(--fs-xs); color: var(--muted); margin: 0 0 .4rem; font-weight: 600; }
.split { display: flex; height: .55rem; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.split span:first-child { background: var(--ink); }
.split span:last-child { background: var(--accent); }
.split-legend { display: flex; justify-content: space-between; gap: 1rem; font-size: var(--fs-xs); color: var(--muted); margin-top: .4rem; }
.split-legend b { color: var(--ink); font-weight: 650; }
.detail-link { font-size: var(--fs-s); display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; }

/* Listen */
.subtabs { margin: 0 0 1rem; }
.subtabs .chip { white-space: nowrap; flex: none; }
.subtabs .chip .count { opacity: .65; margin-left: .3rem; }
.list-intro { color: var(--muted); font-size: var(--fs-s); margin: 0 0 .9rem; max-width: 62ch; }
.list-tools { display: flex; gap: .5rem; margin-bottom: .9rem; }
.input {
  width: 100%; padding: .6rem .85rem; border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--surface); transition: border-color .15s var(--ease);
}
.input:hover { border-color: var(--faint); }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.input::placeholder { color: var(--faint); }

.person { display: flex; align-items: center; gap: .75rem; padding: .6rem .95rem; }
.avatar {
  flex: none; width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: var(--fs-xs); color: var(--muted); background: var(--surface-2); text-transform: uppercase;
}
.who { min-width: 0; flex: 1; }
.who a { font-weight: 650; text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who a:hover { text-decoration: underline; }
.who span { color: var(--muted); font-size: var(--fs-s); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat { flex: none; font-size: var(--fs-s); color: var(--muted); display: inline-flex; gap: .7rem; }
.stat span { display: inline-flex; align-items: center; gap: .25rem; }
.stat .icon { color: var(--faint); }
.more { display: block; width: 100%; margin-top: .75rem; }

/* Login */
.login { max-width: 22rem; margin: 0 auto; padding: 18vh 1.25rem 2rem; }
.login h1 { font-size: var(--fs-xl); letter-spacing: -.02em; margin: 0 0 .25rem; }
.login-sub { color: var(--muted); margin: 0 0 1.5rem; font-size: var(--fs-s); }
.field-label { display: block; font-size: var(--fs-s); font-weight: 600; margin-bottom: .35rem; }
.login .input { margin-bottom: 1rem; padding: .7rem .9rem; }
.field-error { color: var(--loss); font-size: var(--fs-s); margin: 0 0 1rem; }

.foot { margin-top: 3.5rem; font-size: var(--fs-s); color: var(--muted); }

@media (min-width: 40rem) {
  .identity h1 { font-size: 1.75rem; }
  .thumb { width: 4.5rem; height: 4.5rem; }
  .post > button { grid-template-columns: 4.5rem 1fr auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
