/* ==========================================================
   Seitenrahmen: Seitenleiste, Kopfzeile, Tab-Leiste, Anmeldung
   ========================================================== */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

/* ---------- Seitenleiste ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 2px;
  padding: 26px 16px 18px;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 10px 26px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font: 600 19px/1 var(--font-display);
}
.brand-name { font: 600 21px/1.1 var(--font-display); letter-spacing: -.01em; }
.brand-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); padding: 14px 12px 6px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px;
  padding: 10px 12px; border: 0; border-radius: 12px; background: none;
  color: var(--text-2); font-weight: 500; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.nav-item.active .i { color: var(--text); }
.nav-item .count { margin-left: auto; }

.sidebar-foot { margin-top: auto; display: grid; gap: 4px; padding-top: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 6px 4px 12px; }
.user-chip b { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); padding: 6px 12px 0; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.status-dot.on { background: var(--green); }

/* ---------- Inhalt ---------- */
.content { min-width: 0; padding: 30px clamp(18px, 3.5vw, 48px) 80px; }
.page { max-width: 1240px; margin: 0 auto; animation: fade-up .35s var(--ease); }
.topbar { max-width: 1240px; margin: 0 auto 26px; display: flex; align-items: flex-end; gap: 16px; padding-right: 70px; min-height: 54px; }
.topbar h1 { font-size: clamp(26px, 3vw, 34px); }
.topbar .sub { color: var(--text-2); font-size: 14.5px; margin-top: 6px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Tab-Leiste (iPad hochkant, Handy) ---------- */
.tabbar { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding: 22px 20px calc(110px + env(safe-area-inset-bottom)); }
  .topbar { margin-bottom: 20px; padding-right: 60px; min-height: 46px; }
  .tabbar {
    position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom));
    width: min(680px, calc(100% - 24px));
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
    padding: 6px; border-radius: 22px;
    background: var(--glass); border: 1px solid var(--border-strong);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
  }
  .tab {
    position: relative; display: grid; justify-items: center; gap: 3px; padding: 9px 0 7px; min-height: 56px;
    border: 0; background: none; border-radius: 16px; color: var(--text-3); font-size: 11px; font-weight: 500;
  }
  .tab .i { width: 22px; height: 22px; }
  .tab.active { color: var(--text); background: var(--surface-2); }
  .tab .badge { position: absolute; top: 3px; right: calc(50% - 22px); }
}

/* ---------- Notfall-Knopf ---------- */
.panic-btn {
  position: fixed; z-index: 9000; top: 28px; right: 28px;
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--card);
  background: #c0473a; color: #fff; font: 700 22px/1 var(--font); display: grid; place-items: center; padding: 0 0 1px;
  box-shadow: 0 0 0 1px rgba(192, 71, 58, .35), 0 6px 18px -6px rgba(140, 40, 30, .6);
  transition: transform .15s var(--ease);
}
.panic-btn:active { transform: scale(.92); }
@media (max-width: 900px) { .panic-btn { top: 20px; right: 18px; } }

/* ---------- Notfall-Bildschirm ---------- */
.panic { position: fixed; inset: 0; z-index: 2147483647; background: #000; display: flex; align-items: center; justify-content: center; cursor: none; user-select: none; -webkit-user-select: none; touch-action: none; }
.panic-update { display: flex; flex-direction: column; align-items: center; gap: 56px; transform: translateY(-2vh); }
.panic-logo { width: clamp(70px, 11vw, 120px); fill: #fff; padding: 20px; box-sizing: content-box; margin: -20px; cursor: default; }
.panic-bar { width: clamp(150px, 22vw, 240px); height: 5px; border-radius: 3px; background: #3c3c3e; overflow: hidden; }
.panic-bar div { height: 100%; width: 0; background: #fff; border-radius: 3px; transition: width 1s linear; }
.panic img { width: 100%; height: 100%; object-fit: cover; }
body.panicking { overflow: hidden; }

/* ---------- Anmeldung ---------- */
body.logged-out .app, body.logged-out .tabbar { display: none; }
.login {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px;
}
.login-box { width: min(560px, 100%); display: grid; gap: 26px; animation: fade-up .4s var(--ease); }
.login-brand { text-align: center; display: grid; justify-items: center; gap: 12px; }
.login-brand .brand-mark { width: 64px; height: 64px; border-radius: 20px; font-size: 32px; }
.login-brand h1 { font-size: clamp(38px, 6vw, 52px); }
.login-brand p { color: var(--text-2); }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 26px; box-shadow: var(--shadow-lg); display: grid; gap: 18px; }
.login-card h2 { font-size: 21px; }
.who { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 480px) { .who { grid-template-columns: repeat(2, 1fr); } }
.who button {
  display: grid; justify-items: center; gap: 8px; padding: 16px 6px 14px; min-height: 104px;
  border: 1px solid var(--border); border-radius: 18px; background: var(--inset); color: var(--text);
  font-weight: 600; font-size: 14.5px; transition: background .15s, border-color .15s, transform .1s;
}
.who button:active { transform: scale(.97); }
.who button.sel { border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 1px var(--accent); }
.who .avatar { width: 46px; height: 46px; border-radius: 15px; font-size: 17px; }
.login-pw { display: grid; gap: 12px; }
.login-pw .row .input { flex: 1; }
.login-err { color: var(--red); font-size: 13.5px; font-weight: 500; min-height: 20px; }
.login-pw.wrong .input { animation: shake .35s; border-color: var(--red); }
.login-foot { text-align: center; font-size: 12.5px; color: var(--text-3); }

/* ---------- Ergänzungen ---------- */

body.has-panic .topbar { padding-right: 70px; }
.panic-btn[hidden] { display: none; }
.panic-update[hidden], .panic img[hidden] { display: none; }
.panic-fill { height: 100%; width: 0; background: #fff; border-radius: 3px; transition: width 1s linear; }
.panic-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
html:has(body.panicking), body.panicking { overflow: hidden; }
.status-dot.warn { background: var(--amber); }
.user-chip .avatar.img, .avatar.img { background-size: cover; background-position: center; color: transparent; }
@media (min-width: 901px) { .topbar .btn.tb-theme { display: none; } }

/* Notfall-Knopf verschieben */
body.panic-editing .panic-btn { cursor: grab; touch-action: none; outline: 3px dashed #c0473a; outline-offset: 6px; animation: none; }
body.panic-editing #app, body.panic-editing #gameLayer { pointer-events: none; }
.panic-edit-bar { position: fixed; z-index: 8999; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%); width: min(420px, calc(100% - 32px));
  display: grid; gap: 10px; padding: 14px 16px; border-radius: 18px; background: var(--card); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); }
.panic-edit-bar .row { display: flex; align-items: center; gap: 10px; }
.panic-edit-bar .row .btn { flex: 1; }
