/* Gymmer – ruhige Sportuhr-Ästhetik: neutrale Flächen, eine Glut-Farbe als Akzent, große Zahlen in Geist.
   Folgt dem System (hell/dunkel); data-theme überschreibt. */
:root {
  --bg: #eceef1;          /* Beton */
  --surface: #ffffff;
  --surface-2: #e3e6ea;
  --line: #d6dae0;
  --ink: #121418;
  --mist: #646a74;
  --accent: #e8482a;      /* Glut */
  --accent-soft: #fbe3dc;
  --on-accent: #ffffff;
  --done: #12a06b;
  --done-soft: #d9f2e7;
  --danger: #c8322b;
  --shadow: 0 1px 2px rgba(18, 20, 24, .06), 0 8px 24px -12px rgba(18, 20, 24, .12);
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --pad: 16px;
  --nav-h: 64px;
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1013; --surface: #171a1f; --surface-2: #22262c; --line: #2b3038;
    --ink: #f1f2f4; --mist: #8d939c; --accent: #ff6440; --accent-soft: #3a1f19; --on-accent: #ffffff;
    --done: #2fc98b; --done-soft: #15302a; --danger: #ff6b62;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1013; --surface: #171a1f; --surface-2: #22262c; --line: #2b3038;
  --ink: #f1f2f4; --mist: #8d939c; --accent: #ff6440; --accent-soft: #3a1f19; --on-accent: #ffffff;
  --done: #2fc98b; --done-soft: #15302a; --danger: #ff6b62;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); overscroll-behavior-y: none; }
body.fullscreen { padding-bottom: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.1; margin: 0; letter-spacing: -0.02em; text-wrap: balance; }
h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--mist); }
.small { font-size: .84rem; }
.num { font-variant-numeric: tabular-nums; }

#app { max-width: 540px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 20px) max(16px, env(safe-area-inset-right, 0px)) 28px max(16px, env(safe-area-inset-left, 0px)); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* ---------- Flächen */
.panel { background: var(--surface); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 999px; padding: 4px 11px; font-size: .82rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Buttons: eine Akzentfarbe, sonst neutral */
.btn { border: 0; border-radius: 999px; padding: 13px 22px; font-weight: 600; font-size: 1rem; background: var(--surface-2); color: var(--ink); transition: transform .08s, background .15s; display: inline-flex; gap: 8px; align-items: center; justify-content: center; }
.btn:active { transform: scale(.97); }
.btn.fire { background: var(--accent); color: var(--on-accent); }
.btn.hot { background: var(--ink); color: var(--bg); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 14px; font-size: .88rem; }
.btn:disabled { opacity: .4; }
.linkbtn { background: none; border: 0; color: var(--mist); padding: 6px 0; font-weight: 500; }
.linkbtn:hover { color: var(--ink); }

/* ---------- Formulare */
label.f { display: block; }
label.f span { display: block; font-size: .84rem; color: var(--mist); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=password], input[type=number] {
  width: 100%; min-width: 0; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; font-size: 1rem;
}
input:focus { border-color: var(--ink); outline: none; }
.pwrow { display: flex; gap: 8px; align-items: center; }
.pwrow input { flex: 1; }
.err { color: var(--danger); font-weight: 500; min-height: 1.4em; font-size: .92rem; }

/* ---------- Login */
.auth { min-height: calc(100dvh - 80px); display: flex; flex-direction: column; justify-content: center; }
.brand { font-size: 3.2rem; font-weight: 700; letter-spacing: -0.05em; line-height: .95; display: flex; align-items: center; gap: 10px; }
.brand b { color: inherit; font-weight: 700; }
.brand-mark { width: 52px; height: 52px; flex: none; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.seg button { border: 0; background: none; padding: 9px; border-radius: 999px; font-weight: 600; color: var(--mist); }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.avatars { display: flex; flex-wrap: wrap; gap: 8px; }
.avatars button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); font-size: 1.35rem; }
.avatars button[aria-pressed=true] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

/* ---------- Heute: der Ring ist das eine große Element */
.hero-ring { position: relative; width: min(74vw, 300px); aspect-ratio: 1; max-width: 100%; margin: 4px auto 0; }
.hero-ring svg.ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.hero-ring .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.flame-svg { width: 30%; transform-origin: 50% 90%; transition: transform .6s cubic-bezier(.3,1.5,.5,1); color: var(--accent); }
.flame-svg .outer { fill: currentColor; animation: flick 1.8s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.flame-svg .inner { fill: var(--surface); opacity: .55; animation: flick 1.2s ease-in-out infinite alternate-reverse; transform-origin: 50% 100%; }
.flame-svg.cold { color: var(--line); }
.flame-svg.cold .outer, .flame-svg.cold .inner { animation: none; }
@keyframes flick { from { transform: scale(1, 1); } to { transform: scale(.97, 1.04); } }
.ring-pts { font-size: 3.4rem; font-weight: 700; letter-spacing: -0.05em; line-height: 1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.ring-sub { color: var(--mist); font-weight: 500; font-size: .9rem; }
.streak-line { text-align: center; font-size: 1.05rem; font-weight: 600; }
.streak-line .n { color: var(--accent); font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.risk { text-align: center; background: var(--accent-soft); color: var(--ink); border-radius: var(--r-md); padding: 12px 14px; font-weight: 500; }

.lvl { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.lvl .badge-lv { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-weight: 700; font-size: 1.3rem; background: var(--ink); color: var(--bg); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

.spark { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; align-items: end; height: 84px; }
.spark i { display: block; border-radius: 4px; background: var(--surface-2); min-height: 4px; }
.spark i.hit { background: var(--accent); }
.spark i.today { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--ink); }
.spark-labels { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; font-size: .66rem; color: var(--mist); text-align: center; margin-top: 6px; }

.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.quick button { border: 0; background: var(--surface); box-shadow: var(--shadow); border-radius: var(--r-md); padding: 12px 14px; display: flex; gap: 10px; align-items: center; text-align: left; font-size: .9rem; font-weight: 600; line-height: 1.2; min-width: 0; }
.quick .qi { font-size: 1.3rem; flex: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .ico { font-size: 1.25rem; width: 30px; text-align: center; flex: none; }
.pts { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Training */
.ex-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ex { border: 0; text-align: left; background: var(--surface); box-shadow: var(--shadow); border-radius: var(--r-lg); padding: 16px; display: grid; gap: 4px; min-height: 128px; align-content: space-between; }
.ex .ei { font-size: 1.8rem; }
.ex .en { font-weight: 650; font-size: 1.02rem; line-height: 1.15; }
.ex .ep { color: var(--mist); font-size: .82rem; }
.ex .sensor { color: var(--done); font-size: .78rem; font-weight: 600; }

.methods { display: grid; gap: 8px; }
.method { border: 0; box-shadow: inset 0 0 0 1.5px var(--line); background: var(--surface); border-radius: var(--r-md); padding: 14px 16px; text-align: left; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; }
.method[aria-pressed=true] { box-shadow: inset 0 0 0 2px var(--ink); }
.method .mi { font-size: 1.4rem; grid-row: span 2; align-self: center; }
.method b { font-size: 1rem; font-weight: 600; }
.method small { color: var(--mist); }

/* ---------- Workout-Session */
.session { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 14px) max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom) + 16px) max(16px, env(safe-area-inset-left, 0px)); z-index: 20; }
.session .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.session .stage { flex: 1; display: grid; place-items: center; position: relative; }
.counter { font-size: min(44vw, 14rem); font-weight: 700; line-height: .85; font-variant-numeric: tabular-nums; text-align: center; letter-spacing: -0.06em; }
.counter.bump { animation: bump .22s ease-out; }
@keyframes bump { from { transform: scale(1.12); color: var(--accent); } to { transform: scale(1); } }
.counter-unit { text-align: center; font-weight: 500; color: var(--mist); margin-top: 8px; }
.session .live-pts { text-align: center; font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.session .hint { text-align: center; color: var(--mist); max-width: 36ch; margin: 0 auto; }
.tapzone { position: absolute; inset: 0; border: 0; background: transparent; border-radius: var(--r-lg); box-shadow: inset 0 0 0 1.5px var(--line); }
.tapzone:active { background: var(--accent-soft); }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; position: relative; }
.meter > i { position: absolute; inset: 0 auto 0 0; background: var(--done); transition: width .08s linear; }
.meter > b { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); }
.countdown { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 40; font-size: 11rem; font-weight: 700; letter-spacing: -0.06em; font-variant-numeric: tabular-nums; }
.ctrl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.manual-pad { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 10px; }
.manual-pad .btn { padding: 20px 0; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* ---------- Feier */
.celebrate { text-align: center; }
.celebrate .big { font-size: 5rem; font-weight: 700; letter-spacing: -0.06em; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.newbadge { display: flex; gap: 12px; align-items: center; background: var(--surface); box-shadow: var(--shadow); border-radius: var(--r-md); padding: 12px 14px; text-align: left; animation: pop .45s cubic-bezier(.3,1.4,.5,1) both; }
.newbadge .bi { font-size: 1.7rem; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* ---------- Team */
.team-head { display: grid; gap: 10px; }
.code { font-size: 1.7rem; font-weight: 600; letter-spacing: .16em; font-variant-numeric: tabular-nums; font-family: 'Geist Mono', ui-monospace, monospace; }
.members { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.member { display: grid; grid-template-columns: 22px 44px minmax(0, 1fr) auto; align-items: center; gap: 12px; background: var(--surface); box-shadow: var(--shadow); border-radius: var(--r-md); padding: 10px 12px; }
.member .rank { font-weight: 700; color: var(--mist); text-align: center; font-variant-numeric: tabular-nums; }
.member:nth-child(1) .rank { color: var(--accent); }
.member .av { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 1.35rem; position: relative; }
.member .av.done::after { content: '✓'; position: absolute; right: -2px; bottom: -2px; width: 18px; height: 18px; border-radius: 50%; background: var(--done); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--surface); }
.member .mn { font-weight: 600; line-height: 1.2; }
.member .ms { font-size: .8rem; color: var(--mist); }
.member .mbar { height: 4px; border-radius: 99px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.member .mbar i { display: block; height: 100%; background: var(--done); }
.cheer { border: 0; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); font-size: 1.1rem; }
.cheer:disabled { background: var(--surface-2); color: var(--mist); }
.me-tag { font-size: .7rem; background: var(--surface-2); border-radius: 99px; padding: 1px 8px; margin-left: 6px; color: var(--mist); font-weight: 500; vertical-align: 2px; }
.teamfire { border-radius: var(--r-lg); padding: 16px 18px; background: var(--ink); color: var(--bg); }
.teamfire .muted { color: color-mix(in srgb, var(--bg) 65%, var(--ink)); }
.teamfire .bar { background: color-mix(in srgb, var(--bg) 18%, var(--ink)); }
.emoji-pick { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.emoji-pick button { width: 50px; height: 50px; font-size: 1.5rem; border-radius: 50%; border: 0; background: var(--surface-2); }
.team-tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.team-tabs button { white-space: nowrap; }
.team-tabs button[aria-pressed=true] { background: var(--ink); color: var(--bg); }
details > summary { cursor: pointer; }

/* ---------- Ich */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.bdg { background: var(--surface); box-shadow: var(--shadow); border-radius: var(--r-md); padding: 12px 8px; text-align: center; }
.bdg .bi { font-size: 1.7rem; }
.bdg .bn { font-weight: 600; font-size: .82rem; line-height: 1.15; margin-top: 4px; }
.bdg.locked { opacity: .4; filter: grayscale(1); box-shadow: none; background: var(--surface-2); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; text-align: center; }
.stats b { display: block; font-size: 1.7rem; font-weight: 700; letter-spacing: -0.04em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stats span { font-size: .78rem; color: var(--mist); }
.heat { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); }
.heat i.l1 { background: color-mix(in srgb, var(--accent) 28%, var(--surface-2)); }
.heat i.l2 { background: color-mix(in srgb, var(--accent) 60%, var(--surface-2)); }
.heat i.l3 { background: var(--accent); }
table.admin { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.admin td, table.admin th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; }

/* ---------- Dialog */
dialog { border: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--ink); padding: 22px; width: min(92vw, 420px); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .4); }
dialog::backdrop { background: rgba(10, 12, 15, .55); }

/* ---------- Navigation mit Linien-Icons */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom) env(safe-area-inset-left, 0px); background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); z-index: 10; }
#tabs[hidden] { display: none; }
#tabs button { border: 0; background: none; font-size: .72rem; font-weight: 500; color: var(--mist); display: grid; justify-items: center; align-content: center; gap: 3px; }
#tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs button[aria-current=page] { color: var(--ink); }
#tabs button[aria-current=page] svg { stroke: var(--accent); }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--bg); font-weight: 500; padding: 11px 18px; border-radius: 999px; transition: .25s; z-index: 50; max-width: 90vw; text-align: center; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; width: 100%; height: 100%; }

/* ---------- Demo-Leiste (nur in der Demo vorhanden) */
#demoBar { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); background: var(--surface-2); font-size: .78rem; color: var(--mist); }
#demoBar b { color: var(--ink); }
#demoBar button { border: 0; background: var(--surface); border-radius: 99px; padding: 5px 12px; font-size: .78rem; font-weight: 600; flex: none; }
body.fullscreen #demoBar { display: none; }

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