/* ==========================================================================
   Zeitliga – Design-System
   ========================================================================== */

:root {
  --bg: #09090e;
  --bg-elev: #0f0f16;
  --surface: #13131c;
  --surface-2: #1a1a25;
  --surface-3: #232331;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #ededf4;
  --muted: #9797ad;
  --faint: #5f5f73;
  --violet: #8b5cf6;
  --violet-2: #a78bfa;
  --blue: #3b82f6;
  --accent: var(--violet);
  --grad: linear-gradient(135deg, #8b5cf6 0%, #6366f1 50%, #3b82f6 100%);
  --grad-stop: linear-gradient(135deg, #f43f5e 0%, #c026d3 100%);
  --accent-soft: rgba(139, 92, 246, 0.14);
  --danger: #f43f5e;
  --success: #22c55e;
  --gold: #fbbf24;
  --silver: #cbd5e1;
  --bronze: #e0915a;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.8);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --topbar-h: 64px;
  --tabbar-h: 0px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f6fb;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f1f7;
  --surface-3: #e6e6f0;
  --border: rgba(20, 20, 50, 0.08);
  --border-strong: rgba(20, 20, 50, 0.16);
  --text: #15151f;
  --muted: #5e5e74;
  --faint: #9a9ab0;
  --accent-soft: rgba(139, 92, 246, 0.1);
  --shadow: 0 18px 40px -24px rgba(40, 30, 90, 0.35);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
svg { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.gold { color: var(--gold); letter-spacing: 1px; }
:focus-visible { outline: 2px solid var(--violet-2); outline-offset: 2px; border-radius: 6px; }

.backdrop-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(59, 130, 246, 0.11), transparent 60%);
}
:root[data-theme="light"] .backdrop-glow { opacity: 0.6; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 24px;
  padding: env(safe-area-inset-top) max(20px, calc((100vw - 1180px) / 2)) 0;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.is-auth .topbar, .is-auth .tabbar, .is-booting .topbar, .is-booting .tabbar { display: none; }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: -0.02em; font-size: 1.1rem; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px; background: var(--grad); position: relative;
  box-shadow: 0 6px 18px -6px rgba(139, 92, 246, 0.7);
}
.brand-mark::after {
  content: ""; position: absolute; inset: 7px; border-radius: 50%;
  border: 2.5px solid #fff; border-top-color: transparent; transform: rotate(-30deg);
}
.brand-mark-lg { width: 56px; height: 56px; border-radius: 17px; }
.brand-mark-lg::after { inset: 14px; border-width: 4px; }

.nav { display: flex; gap: 4px; }
.nav a {
  position: relative; text-decoration: none; color: var(--muted); font-weight: 550;
  padding: 8px 14px; border-radius: 10px; transition: color 0.2s, background 0.2s;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--text); background: var(--surface-2); }
.nav a.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -13px; height: 2px;
  border-radius: 2px; background: var(--grad);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.live-dot span { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.live-dot.online { color: var(--muted); }
.live-dot.online span { background: var(--success); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); animation: live 2s infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }

.menu { position: relative; }
.menu-btn {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; transition: border-color 0.2s;
}
.menu-btn:hover { border-color: var(--border-strong); }
.menu-name { font-weight: 600; font-size: 0.9rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow);
  animation: pop 0.18s var(--ease);
}
.menu-pop a, .menu-pop button {
  display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 9px;
  text-decoration: none; background: none; border: 0; cursor: pointer; font-size: 0.92rem;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); }
.menu-pop .danger { color: var(--danger); }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }

/* ---------- Tab-Leiste (mobil) ---------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  :root { --tabbar-h: 66px; --topbar-h: 56px; }
  .nav { display: none; }
  .menu-name, .live-dot { display: none; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(4, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border-top: 1px solid var(--border);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    text-decoration: none; color: var(--faint); font-size: 0.7rem; font-weight: 600; transition: color 0.2s;
  }
  .tabbar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a.active { color: var(--text); }
  .tabbar a.active svg { stroke: var(--violet-2); }
}

/* ---------- Layout ---------- */
.view { max-width: 1180px; margin: 0 auto; padding: 32px 20px 56px; display: grid; gap: 20px; align-content: start; outline: none; }
.view-enter { animation: enter 0.35s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 760px) { .view { padding: 20px 14px 32px; gap: 16px; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.page-head p.muted { margin-top: 6px; max-width: 560px; }
.section-head { margin: 8px 0 12px; }
.eyebrow { color: var(--violet-2); font-size: 0.76rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

/* ---------- Buttons & Formulare ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: 0.93rem; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s, opacity 0.2s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 22px -10px rgba(139, 92, 246, 0.8); }
.btn-primary:hover { box-shadow: 0 10px 28px -8px rgba(139, 92, 246, 0.9); }
.btn-ghost { background: var(--surface-2); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 0.82rem; border-radius: 9px; }
.btn.is-loading { color: transparent; position: relative; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5); border-top-color: #fff; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; flex: none; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; color: var(--muted);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; position: relative; }
.field > span { font-size: 0.86rem; font-weight: 600; }
.field em { font-style: normal; color: var(--faint); font-weight: 500; margin-left: 4px; }
.field input, .field textarea, .week-select select {
  width: 100%; padding: 12px 14px; border-radius: 12px; outline: none;
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field textarea:focus, .week-select select:focus { border-color: var(--violet); box-shadow: 0 0 0 4px var(--accent-soft); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field-error, .form-error { color: var(--danger); font-size: 0.84rem; }
.form-error { padding: 10px 12px; border-radius: 10px; background: rgba(244, 63, 94, 0.1); }
.counter { position: absolute; right: 10px; bottom: 8px; font-size: 0.72rem; color: var(--faint); }
.hint-text { font-size: 0.82rem; color: var(--muted); }

.segmented {
  display: inline-flex; padding: 4px; gap: 4px; border-radius: 13px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.segmented button {
  border: 0; background: none; cursor: pointer; padding: 8px 14px; border-radius: 9px;
  font-weight: 600; font-size: 0.88rem; color: var(--muted); transition: background 0.2s, color 0.2s;
}
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.4); }
:root[data-theme="light"] .segmented button[aria-selected="true"] { box-shadow: 0 2px 6px -2px rgba(40, 30, 90, 0.25); }

.chip, .pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.pill-live { color: var(--success); background: rgba(34, 197, 94, 0.08); border-color: rgba(34, 197, 94, 0.25); }
.pill-live span { width: 6px; height: 6px; border-radius: 50%; background: var(--success); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.you {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--violet-2); vertical-align: middle;
}
kbd { font: 600 0.75rem var(--mono); padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-2); }

/* ---------- Avatar ---------- */
.avatar {
  --hue: 260;
  display: inline-grid; place-items: center; flex: none; border-radius: 50%; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, hsl(var(--hue) 70% 58%), hsl(calc(var(--hue) + 40) 70% 46%));
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.8rem; }
.avatar-md { width: 36px; height: 36px; font-size: 0.95rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.4rem; }
.avatar-xl { width: 84px; height: 84px; font-size: 2.1rem; }
.user-link { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 600; }
.user-link:hover span { color: var(--violet-2); }

/* ---------- Timer ---------- */
.timer-page { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.timer-stage {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: clamp(24px, 6vw, 56px) 16px; border-radius: 28px;
  background: radial-gradient(600px 300px at 50% 0%, var(--accent-soft), transparent 70%), var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.clock {
  font-size: clamp(3.4rem, 13vw, 7.2rem); font-weight: 650; letter-spacing: -0.04em; line-height: 1;
  font-variant-numeric: tabular-nums; margin: 8px 0 clamp(24px, 5vw, 40px);
  background: linear-gradient(180deg, var(--text) 30%, color-mix(in srgb, var(--text) 55%, transparent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  transition: transform 0.4s var(--ease);
}
.clock.pop { animation: clockpop 0.5s var(--ease); }
@keyframes clockpop { 40% { transform: scale(1.04); } }
.is-running .clock { background: linear-gradient(180deg, #fff 20%, var(--violet-2)); -webkit-background-clip: text; background-clip: text; }
:root[data-theme="light"] .is-running .clock { background: linear-gradient(180deg, #2a1a5e 20%, var(--violet)); -webkit-background-clip: text; background-clip: text; }

.timer-btn {
  --size: clamp(180px, 42vw, 228px);
  position: relative; width: var(--size); height: var(--size); border-radius: 50%; border: 0; padding: 0;
  background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; isolation: isolate;
}
.timer-ring { position: absolute; inset: -18px; width: calc(100% + 36px); height: calc(100% + 36px); transform: rotate(-90deg); pointer-events: none; }
.ring-track { fill: none; stroke: var(--border-strong); stroke-width: 2.5; }
.ring-progress { fill: none; stroke: var(--violet-2); stroke-width: 3; stroke-linecap: round; opacity: 0; transition: opacity 0.4s; }
.is-running .ring-progress { opacity: 1; stroke: #f472b6; }

.timer-core {
  position: absolute; inset: 0; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: var(--grad); color: #fff; overflow: hidden;
  box-shadow: 0 24px 60px -18px rgba(139, 92, 246, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.25), inset 0 -8px 24px rgba(0, 0, 0, 0.18);
  transition: transform 0.25s var(--ease), box-shadow 0.4s, background 0.4s;
}
.timer-core::before { content: ""; position: absolute; inset: 0; background: var(--grad-stop); opacity: 0; transition: opacity 0.45s var(--ease); z-index: -1; }
.timer-btn:hover .timer-core { transform: scale(1.025); }
.timer-btn:active .timer-core { transform: scale(0.96); }
.timer-btn.busy .timer-core { transform: scale(0.97); }
.is-running .timer-core { background: transparent; box-shadow: 0 24px 60px -18px rgba(244, 63, 94, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.is-running .timer-core::before { opacity: 1; }
.timer-btn::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; z-index: -1;
  background: var(--grad); filter: blur(28px); opacity: 0.35; transition: opacity 0.4s;
}
.is-running .timer-btn::before { background: var(--grad-stop); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.65; transform: scale(1.08); } }

.timer-label { font-size: 1.35rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.timer-icon { width: 34px; height: 34px; position: relative; }
.timer-icon::before {
  content: ""; position: absolute; inset: 0; margin: auto; width: 0; height: 0;
  border-style: solid; border-width: 15px 0 15px 25px; border-color: transparent transparent transparent #fff;
  transform: translateX(3px); transition: all 0.3s var(--ease);
}
.is-running .timer-icon::before { width: 26px; height: 26px; border: 0; border-radius: 6px; background: #fff; transform: none; }
.ripple {
  position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--violet-2); pointer-events: none;
  animation: ripple 0.7s var(--ease) forwards;
}
@keyframes ripple { from { transform: scale(1); opacity: 0.8; } to { transform: scale(1.45); opacity: 0; } }

.hint { margin-top: clamp(28px, 5vw, 40px); color: var(--faint); font-size: 0.85rem; }
.timer-summary { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }
.summary-chip {
  display: flex; flex-direction: column; gap: 1px; padding: 10px 16px; border-radius: 14px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); min-width: 120px;
}
.summary-chip span { font-size: 0.76rem; }
.summary-chip strong { font-size: 1rem; font-variant-numeric: tabular-nums; }

.live-card h2 { font-size: 1rem; }
.live-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.live-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin: 0 -10px; border-radius: 10px; animation: enter 0.3s var(--ease); }
.live-list li:hover { background: var(--surface-2); }
.live-time { margin-left: auto; font: 600 0.88rem var(--mono); color: var(--success); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .timer-page { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .hint { display: none; } }

/* ---------- Statistik-Karten ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px; min-height: 112px; box-shadow: var(--shadow);
  transition: transform 0.2s var(--ease), border-color 0.2s;
}
.stat:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.stat-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.stat-label svg { width: 17px; height: 17px; fill: none; stroke: var(--violet-2); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.stat-value { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 0.72rem; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.stat-sub { color: var(--muted); font-size: 0.8rem; margin-top: auto; }
.stat-accent { background: radial-gradient(240px 120px at 100% 0%, rgba(139, 92, 246, 0.22), transparent 70%), var(--surface); border-color: rgba(139, 92, 246, 0.3); }
@media (max-width: 760px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { min-height: 96px; padding: 14px; }
  .stat-value { font-size: 1.25rem; }
  .stat-accent { grid-column: span 2; }
}

/* ---------- Balken ---------- */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; height: 190px; align-items: end; }
.bar-col { display: grid; grid-template-rows: 20px 1fr 22px; height: 100%; text-align: center; gap: 6px; }
.bar-value { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { position: relative; border-radius: 10px; background: var(--surface-2); overflow: hidden; }
.bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--h); min-height: 0; border-radius: 10px;
  background: linear-gradient(180deg, var(--violet-2), var(--blue)); opacity: 0.55;
  animation: grow 0.8s var(--ease) both;
}
.is-today .bar { opacity: 1; box-shadow: 0 0 24px -4px rgba(139, 92, 246, 0.7); }
.bar-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.is-today .bar-label { color: var(--text); }
@keyframes grow { from { height: 0; } }

/* ---------- Historie ---------- */
.history { list-style: none; margin: 0; padding: 0; display: grid; }
.history-head, .history-row { display: grid; grid-template-columns: 170px 110px 1fr 84px; gap: 16px; align-items: center; }
.history-head { padding: 0 12px 10px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); font-weight: 650; border-bottom: 1px solid var(--border); }
.history-row { padding: 12px; border-bottom: 1px solid var(--border); border-radius: 10px; transition: background 0.15s; }
.history-row:hover { background: var(--surface-2); }
.history-row:last-child { border-bottom: 0; }
.h-date { display: flex; flex-direction: column; font-size: 0.9rem; }
.h-date span { font-size: 0.8rem; }
.h-dur { font: 600 0.95rem var(--mono); font-variant-numeric: tabular-nums; }
.h-link { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.h-link a { color: var(--violet-2); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.h-link a:hover { text-decoration: underline; }
.h-link .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-actions { display: flex; gap: 6px; justify-content: flex-end; }
.history + .btn { margin-top: 14px; }
@media (max-width: 760px) {
  .history-head { display: none; }
  .history-row { grid-template-columns: 1fr auto; grid-template-areas: "date dur" "link actions"; gap: 8px 12px; padding: 12px 4px; }
  .h-date { grid-area: date; } .h-dur { grid-area: dur; text-align: right; } .h-link { grid-area: link; } .h-actions { grid-area: actions; align-self: end; }
}

/* ---------- Rangliste ---------- */
#lb { display: grid; gap: 16px; }
.week-bar { display: flex; align-items: center; gap: 10px; padding: 10px; }
.week-select { flex: 1; }
.week-select select {
  appearance: none; -webkit-appearance: none; cursor: pointer; text-align: center; font-weight: 650;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239797ad' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
  border: 1px solid var(--border); padding: 9px 36px;
}
.lb-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.lb-summary .summary-chip { min-width: 0; }
.motivation {
  padding: 12px 16px; border-radius: 14px; font-weight: 550;
  background: linear-gradient(90deg, var(--accent-soft), transparent); border-left: 3px solid var(--violet);
}
.boards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.board-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.board-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; background: var(--accent-soft); }
.board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.board-row {
  display: grid; grid-template-columns: 34px 1fr auto; grid-template-rows: auto 4px; column-gap: 12px; row-gap: 8px;
  align-items: center; padding: 10px 12px; border-radius: 13px; border: 1px solid transparent;
  animation: enter 0.4s var(--ease) both;
}
.board-row:nth-child(2) { animation-delay: 0.03s; } .board-row:nth-child(3) { animation-delay: 0.06s; }
.board-row:nth-child(4) { animation-delay: 0.09s; } .board-row:nth-child(5) { animation-delay: 0.12s; }
.board-row:hover { background: var(--surface-2); }
.board-row.is-me { background: var(--accent-soft); border-color: rgba(139, 92, 246, 0.35); }
.board-row.top-1 { background: linear-gradient(90deg, rgba(251, 191, 36, 0.1), rgba(251, 191, 36, 0.02)); border-color: rgba(251, 191, 36, 0.16); }
.board-row.top-1.is-me { border-color: rgba(251, 191, 36, 0.4); }
.board-user { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; min-width: 0; }
.board-user > span:not(.avatar):not(.you) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-user:hover > span:not(.you) { color: var(--violet-2); }
.board-metric { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; font-variant-numeric: tabular-nums; }
.board-metric strong { font-size: 0.98rem; }
.board-metric .muted { font-size: 0.76rem; }
.board-bar { grid-column: 2 / 4; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.board-bar span { display: block; height: 100%; width: var(--w); border-radius: 4px; background: var(--grad); animation: widen 0.9s var(--ease) both; }
.top-1 .board-bar span { background: linear-gradient(90deg, #f59e0b, var(--gold)); }
@keyframes widen { from { width: 0; } }
.rank {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; grid-row: span 2;
  font-weight: 750; font-size: 0.9rem; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums;
}
.rank-1 { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #3b2500; box-shadow: 0 6px 18px -6px rgba(245, 158, 11, 0.7); }
.rank-2 { background: linear-gradient(135deg, #f1f5f9, #94a3b8); color: #1e293b; }
.rank-3 { background: linear-gradient(135deg, #f3b98a, #b8692e); color: #2b1300; }
@media (max-width: 900px) { .boards { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .lb-summary { grid-template-columns: repeat(2, 1fr); gap: 10px; } .week-select select { padding: 9px 30px 9px 10px; font-size: 0.85rem; background-position: right 8px center; } .week-bar { gap: 6px; padding: 8px; } }

/* ---------- Community ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.new-posts {
  margin-left: auto; border: 0; cursor: pointer; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 0.85rem;
  background: var(--grad); color: #fff; animation: enter 0.3s var(--ease);
}
.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.feed + .btn { margin-top: 16px; }
.post { display: flex; flex-direction: column; gap: 14px; transition: border-color 0.2s, transform 0.2s var(--ease); }
.post:hover { border-color: var(--border-strong); }
.post.flash { animation: flash 1s var(--ease); }
@keyframes flash { 0% { box-shadow: 0 0 0 2px var(--violet); } 100% { box-shadow: var(--shadow); } }
.post-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.post-meta { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; color: var(--muted); margin-left: auto; }
.chip-time { font-variant-numeric: tabular-nums; }
.post-link {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 13px; text-decoration: none;
  background: var(--surface-2); border: 1px solid var(--border); transition: border-color 0.2s, background 0.2s;
}
.post-link:hover { border-color: rgba(139, 92, 246, 0.5); background: var(--accent-soft); }
.post-favicon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; font-weight: 750; background: var(--grad); color: #fff; }
.post-url { display: flex; flex-direction: column; min-width: 0; }
.post-url strong, .post-url span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-url span { font-size: 0.8rem; color: var(--muted); }
.ext { width: 18px; height: 18px; margin-left: auto; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.post-desc { color: var(--text); opacity: 0.9; overflow-wrap: anywhere; }
.rating { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.rating-summary { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.rating-note { font-size: 0.82rem; color: var(--muted); }
.rating-prompt { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; }
.stars { position: relative; display: inline-block; line-height: 1; letter-spacing: 1px; }
.stars-sm { font-size: 0.95rem; } .stars-md { font-size: 1.15rem; }
.stars-base { color: var(--surface-3); }
.stars-fill { position: absolute; inset: 0 auto 0 0; overflow: hidden; white-space: nowrap; color: var(--gold); }
.star-input { display: inline-flex; flex-direction: row-reverse; }
.star-input button {
  border: 0; background: none; cursor: pointer; font-size: 1.35rem; line-height: 1; padding: 2px; color: var(--surface-3);
  transition: color 0.12s, transform 0.12s var(--ease);
}
.star-input button:hover, .star-input button:hover ~ button, .star-input button:focus-visible, .star-input button:focus-visible ~ button { color: var(--gold); }
.star-input button:hover { transform: scale(1.2); }
.star-input.busy { opacity: 0.5; pointer-events: none; }
@media (max-width: 760px) { .feed { grid-template-columns: 1fr; } .star-input button { font-size: 1.6rem; padding: 3px; } }

/* ---------- Profile & Teilnehmer ---------- */
.profile-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.profile-info { display: grid; gap: 6px; flex: 1; min-width: 200px; }
.profile-info .pill { justify-self: start; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.mini-list li:last-child { border-bottom: 0; }
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.user-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; text-decoration: none; transition: transform 0.2s var(--ease), border-color 0.2s; }
.user-card:hover { transform: translateY(-3px); border-color: rgba(139, 92, 246, 0.45); }
.user-card.is-me { border-color: rgba(139, 92, 246, 0.35); }
.user-card-name { font-weight: 700; font-size: 1.05rem; }
.user-card-stats { display: flex; gap: 14px; font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.user-card-stats strong { color: var(--text); }
@media (max-width: 760px) { .user-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } .user-card { padding: 16px 10px; } .user-card-stats { flex-direction: column; gap: 2px; } }

/* ---------- Anmeldung ---------- */
.view-auth { min-height: 100dvh; align-content: center; }
.auth { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; max-width: 960px; margin: 0 auto; width: 100%; }
.auth-hero { display: grid; gap: 16px; }
.auth-hero h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-hero p { font-size: 1.08rem; max-width: 420px; }
.auth-card { display: grid; gap: 20px; padding: 28px; }
.auth-card .segmented { width: 100%; }
.auth-card .segmented button { flex: 1; }
.demo-hint { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 0.84rem; }
@media (max-width: 760px) { .auth { grid-template-columns: 1fr; gap: 28px; } .auth-hero { text-align: center; justify-items: center; } .auth-card { padding: 20px; } }

/* ---------- Modal ---------- */
.modal {
  width: min(460px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--border-strong); border-radius: 22px;
  background: var(--surface); color: var(--text); box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.7);
}
.modal[open] { animation: modalIn 0.32s var(--ease); }
.modal.closing { animation: modalOut 0.16s ease forwards; }
.modal::backdrop { background: rgba(5, 5, 10, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(0.97); } }
@keyframes modalOut { to { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal-body { padding: 26px; display: grid; gap: 14px; }
.modal-title { font-size: 1.3rem; text-align: center; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.modal-actions .btn { flex: 1; }
.session-modal { display: grid; gap: 10px; }
.session-modal .form { margin-top: 10px; }
.modal-clock {
  text-align: center; font-size: 2.8rem; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.check-badge { width: 54px; height: 54px; margin: 0 auto 2px; border-radius: 50%; display: grid; place-items: center; background: rgba(34, 197, 94, 0.14); animation: badge 0.5s var(--ease); }
.check-badge svg { width: 28px; height: 28px; fill: none; stroke: var(--success); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; animation: draw 0.5s 0.15s var(--ease) both; }
@keyframes badge { from { transform: scale(0.4); opacity: 0; } }
@keyframes draw { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
@media (max-width: 760px) {
  .modal { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 22px 22px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
  .modal[open] { animation: sheetIn 0.32s var(--ease); }
  @keyframes sheetIn { from { transform: translateY(100%); } }
  .modal-body { padding: 22px 18px; }
}

/* ---------- Leere Zustände, Loader, Toasts ---------- */
.empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 36px 16px; }
.empty-icon { width: 46px; height: 46px; border-radius: 14px; background: var(--accent-soft); position: relative; margin-bottom: 4px; }
.empty-icon::after { content: ""; position: absolute; inset: 13px; border-radius: 50%; border: 2.5px solid var(--violet-2); border-top-color: transparent; }
.empty-title { font-weight: 650; }
.empty .btn { margin-top: 8px; }
.loader { display: flex; gap: 6px; justify-content: center; padding: 40px; grid-column: 1 / -1; }
.loader span:not(.sr-only) { width: 8px; height: 8px; border-radius: 50%; background: var(--violet-2); animation: dot 1s infinite ease-in-out; }
.loader span:nth-child(2) { animation-delay: 0.15s; } .loader span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

.toasts { position: fixed; left: 50%; bottom: calc(24px + var(--tabbar-h) + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(420px, calc(100vw - 28px)); pointer-events: none; }
.toast {
  padding: 12px 16px; border-radius: 13px; font-size: 0.9rem; font-weight: 550; text-align: center;
  background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow); color: var(--text);
  opacity: 0; transform: translateY(10px); transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast-success { border-color: rgba(34, 197, 94, 0.4); }
.toast-error { border-color: rgba(244, 63, 94, 0.5); }
.noscript { padding: 40px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
.is-auth .view { padding-top: calc(32px + env(safe-area-inset-top)); }

/* Checkbox "Angemeldet bleiben" */
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.9rem; font-weight: 550; user-select: none; width: fit-content; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box {
  width: 20px; height: 20px; border-radius: 6px; flex: none; display: grid; place-items: center;
  background: var(--bg-elev); border: 1px solid var(--border-strong); transition: background 0.15s, border-color 0.15s;
}
.check-box::after {
  content: ""; width: 10px; height: 6px; border: 2px solid #fff; border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform 0.15s var(--ease);
}
.check input:checked + .check-box { background: var(--grad); border-color: transparent; }
.check input:checked + .check-box::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.check input:focus-visible + .check-box { outline: 2px solid var(--violet-2); outline-offset: 2px; }

/* ---------- Admin ---------- */
.menu-pop [hidden] { display: none; }
.menu-pop .menu-admin { color: var(--gold); font-weight: 600; }
.badge {
  display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 6px; vertical-align: middle;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--surface-3); color: var(--muted);
}
.badge-admin { background: rgba(251, 191, 36, 0.14); color: var(--gold); }
.badge-live { background: rgba(34, 197, 94, 0.12); color: var(--success); }
h1 .badge { font-size: 0.75rem; letter-spacing: 0.06em; }
.danger-text { color: var(--danger); }
.notice { padding: 12px 14px; border-radius: 12px; background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.25); font-size: 0.9rem; }

.admin-counts { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 900px) { .admin-counts { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) { .admin-counts { grid-template-columns: repeat(2, 1fr); } }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch-row > span { display: grid; gap: 2px; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; cursor: pointer; margin: 0;
  width: 48px; height: 28px; border-radius: 999px; position: relative;
  background: var(--surface-3); border: 1px solid var(--border-strong); transition: background 0.2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); transition: transform 0.2s var(--ease);
}
.switch:checked { background: var(--grad); border-color: transparent; }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.6; }

.admin-search { margin-bottom: 8px; }
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-row { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--border); border-radius: 10px; }
.admin-row:last-child { border-bottom: 0; }
.admin-row:hover { background: var(--surface-2); }
.admin-row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.admin-row-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 650; }
.admin-row-name a { text-decoration: none; }
.admin-row-name a:hover { color: var(--violet-2); }

.admin-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 12px; border-top: 1px dashed rgba(251, 191, 36, 0.3); }
.admin-bar .badge { margin-right: auto; }

.admin-user { display: grid; gap: 14px; }
.admin-user-head { display: flex; align-items: center; gap: 14px; }
.admin-user-head .modal-title { text-align: left; }
.admin-user-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px; font-size: 0.88rem; color: var(--muted); padding: 12px; border-radius: 12px; background: var(--surface-2); }
.admin-user-stats strong { color: var(--text); }
.admin-user .pill { justify-self: start; }
.admin-actions { display: grid; gap: 8px; }
.admin-actions .btn { width: 100%; }

.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-right { display: inline-flex; align-items: center; gap: 10px; }
.mini-list .icon-btn { width: 30px; height: 30px; }
[hidden] { display: none !important; }
/* Lange Inhalte (z. B. Links) dürfen das Seitenraster nicht verbreitern */
.view { grid-template-columns: minmax(0, 1fr); }
.view > *, .feed > *, .post, .post-link, .boards > * { min-width: 0; }
@media (max-width: 760px) { .feed { grid-template-columns: minmax(0, 1fr); } }
