:root {
  --bg: #0a0d13;
  --bg-soft: #10151f;
  --card: #131824;
  --card-hi: #1a2130;
  --line: rgba(255,255,255,.07);
  --text: #e8eaf0;
  --muted: #9aa3b5;
  --gold: #e8b34b;
  --petrol: #3ec6b8;
  --danger: #e86a6a;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(10,13,19,.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: .2px; }
.top-actions { display: flex; gap: 6px; }
.iconbtn {
  width: 48px; height: 48px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.iconbtn:active { background: var(--card-hi); }
.iconbtn.on { color: var(--gold); }
.iconbtn.small { width: 40px; height: 40px; }

/* Suche */
.searchbar {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 16px;
  background: rgba(10,13,19,.85);
  border-bottom: 1px solid var(--line);
  position: sticky; top: calc(59px + env(safe-area-inset-top)); z-index: 29;
}
.searchbar input {
  flex: 1; height: 48px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 0 16px; font-size: 16px; outline: none;
}
.searchbar input:focus { border-color: var(--gold); }

/* Tabs */
.tabs {
  display: flex; gap: 22px; padding: 10px 16px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { white-space: nowrap; flex: 0 0 auto; }
.tab {
  padding: 10px 2px 12px;
  background: none; border: 0; border-radius: 0;
  border-bottom: 2.5px solid transparent;
  color: var(--muted);
  font-size: 15px; font-weight: 600;
  min-height: 44px;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab .count {
  font-size: 11px; font-weight: 700; line-height: 1;
  color: var(--muted); background: rgba(255,255,255,.07);
  padding: 3px 7px; border-radius: 999px;
}
.tab.on .count { color: var(--gold); background: rgba(232,179,75,.14); }
.tab.on { background: none; color: var(--text); border-bottom-color: var(--gold); }

.live { padding: 6px 18px 0; font-size: 12.5px; color: var(--muted); min-height: 20px; }
.live .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--petrol); }
.live.off .dot { background: var(--muted); }

/* Rails (Angepinnt / Zuletzt) */
/* Katalog-Grid */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(2, 1fr);
  padding: 14px 16px 8px;
}
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  text-decoration: none; position: relative;
  transition: transform .15s ease, border-color .15s ease;
}
.card:active { transform: scale(.98); border-color: rgba(232,179,75,.4); }
.card .imgwrap { position: relative; display: block; }
.card img {
  width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block;
  background: var(--bg-soft);
}
.card .lock {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(10,13,19,.75);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.card h3 { font-size: 15px; font-weight: 700; line-height: 1.3; }
.card p {
  font-size: 13px; color: var(--muted); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .open {
  margin-top: auto; padding-top: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--gold);
  display: inline-flex; align-items: center; gap: 6px;
}
.card .arch-btn {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(10,13,19,.85); color: var(--text);
  font-size: 12px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line);
}
.pinbtn {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(10,13,19,.75); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.pinbtn.on { color: var(--gold); }

/* Geteilt */
.shared { padding: 14px 16px; }
.shared-intro { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.shared-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.shared-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
.shared-card .imgwrap { position: relative; display: block; }
.shared-card .imgwrap img {
  width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block;
  background: var(--bg-soft);
}
.shared-card .body { padding: 11px 13px 13px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.shared-badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  max-width: calc(100% - 16px);
  font-size: 10.5px; font-weight: 700; letter-spacing: .2px;
  color: var(--petrol); background: rgba(10,13,19,.82);
  border: 1px solid rgba(62,198,184,.35);
  padding: 3px 8px; border-radius: 999px;
}
.shared-card small { color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.shared-card h3 { font-size: 14.5px; line-height: 1.3; overflow-wrap: break-word; }
.shared-card p {
  font-size: 12.5px; color: var(--muted); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.shared-card .open { font-size: 13.5px; font-weight: 600; color: var(--gold); text-decoration: none; padding-top: 3px; margin-top: auto; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* Sheets */
.backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4,6,10,.6);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--bg-soft);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line);
  padding: 12px 22px calc(22px + env(safe-area-inset-bottom));
  max-height: 85vh; overflow-y: auto;
  animation: up .25s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-grip {
  width: 42px; height: 5px; border-radius: 3px;
  background: rgba(255,255,255,.18); margin: 0 auto 16px;
}
.sheet h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.sheet-sub { font-size: 13.5px; color: var(--muted); margin-bottom: 18px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; height: 52px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 0 16px; font-size: 16px; outline: none;
}
.field input:focus { border-color: var(--gold); }
.err { color: var(--danger); font-size: 13.5px; margin-bottom: 12px; }
.primary {
  width: 100%; height: 52px; border-radius: 14px;
  background: var(--gold); color: #14100a;
  font-size: 16px; font-weight: 700;
}
.primary:disabled { opacity: .55; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; }
.ghost {
  width: 100%; height: 52px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line);
  font-size: 15.5px; font-weight: 600;
}
.ghost.danger { color: var(--danger); }

/* Profile */
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding-bottom: 6px; }
.profile-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 4px; }
.profile-tile .avatar {
  width: 68px; height: 68px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: #14100a;
  background: linear-gradient(135deg, var(--gold), #d18f2b);
}
.profile-tile:nth-child(3n+2) .avatar { background: linear-gradient(135deg, var(--petrol), #2a9d92); }
.profile-tile:nth-child(3n) .avatar { background: linear-gradient(135deg, #b48be8, #8b5fc0); }
.profile-tile span { font-size: 13.5px; color: var(--text); }

/* Toast */
.toast {
  position: fixed; left: 16px; right: 16px; z-index: 50;
  bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--card-hi); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast button { color: var(--gold); font-weight: 700; font-size: 14px; padding: 6px 4px; }

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(3, 1fr); max-width: 1100px; margin: 0 auto; }
  .shared-grid { grid-template-columns: repeat(3, 1fr); }
  .tabs, .live, .shared { max-width: 1100px; margin: 0 auto; }
  .sheet { max-width: 520px; left: 50%; transform: translateX(-50%); border-radius: 22px; bottom: 24px; }
  @keyframes up { from { transform: translate(-50%, 40px); opacity: .4; } to { transform: translate(-50%, 0); opacity: 1; } }
}
@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
  .shared-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Familie */
.fam-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.fam-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 12px;
}
.fam-row .avatar {
  width: 44px; height: 44px; border-radius: 13px; flex: 0 0 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #14100a;
  background: linear-gradient(135deg, var(--gold), #d18f2b);
}
.fam-row:nth-child(3n+2) .avatar { background: linear-gradient(135deg, var(--petrol), #2a9d92); }
.fam-row:nth-child(3n) .avatar { background: linear-gradient(135deg, #b48be8, #8b5fc0); }
.fam-row .fam-name { flex: 1; font-size: 15.5px; font-weight: 600; }
.fam-row .fam-act { display: flex; gap: 2px; }
.fam-row .fam-act button {
  min-width: 48px; height: 48px; border-radius: 12px;
  color: var(--muted); font-size: 13px; font-weight: 600; padding: 0 10px;
}
.fam-row .fam-act button:active { background: var(--card-hi); }
.fam-row .fam-act .del { color: var(--danger); }
.conseq { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; }
.conseq li { font-size: 14px; color: var(--text); margin-left: 18px; margin-bottom: 4px; }
.conseq li:last-child { margin-bottom: 0; }

.avatar{overflow:hidden;flex-shrink:0}.avatar img{width:100%;height:100%;object-fit:cover}.photo-preview{margin:12px 0}.photo-preview .avatar{width:80px;height:80px;font-size:30px}.card h3{overflow-wrap:anywhere}.sheet{max-height:90dvh;overflow-y:auto}
.photo-preview .avatar{display:flex;align-items:center;justify-content:center;border-radius:50%;background:var(--petrol)}


/* Gate (privater Katalog) */
.gate { padding: 56px 24px 40px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.gate svg { color: var(--gold); margin-bottom: 6px; }
.gate h2 { color: var(--text); font-size: 19px; }
.gate p { font-size: 14px; max-width: 320px; }
.gate .primary { width: auto; padding: 0 32px; margin-top: 8px; }
/* Familie: + und Menü */
.fam-head { display: flex; align-items: center; justify-content: space-between; }
.fam-head .addbtn { width: 40px; height: 40px; font-size: 26px; font-weight: 400; color: var(--gold); border: 1px solid var(--line); border-radius: 50%; margin-bottom: 6px; }
.fam-row { position: relative; }
.fam-row .menu-btn { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; color: var(--muted); line-height: 1; }
.fam-row .menu-btn:active { background: var(--card-hi); }
.fam-row .menu { position: absolute; right: 8px; top: auto; bottom: 48px; z-index: 5; background: var(--card-hi); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; min-width: 150px; box-shadow: 0 8px 24px rgba(0,0,0,.5); display: flex; flex-direction: column; }
.fam-row .menu button { text-align: left; padding: 13px 16px; font-size: 14.5px; font-weight: 600; color: var(--text); }
.fam-row .menu button:active { background: var(--card); }
.fam-row .menu .del { color: var(--danger); }
/* Foto-Picker */
.photo-pick { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.photo-pick .ghost { width: auto; height: 46px; padding: 0 18px; }
.photo-name { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#profPhotoRemove { width: auto; height: 42px; padding: 0 18px; font-size: 13.5px; }
/* kleine Geräte ab 320px */
@media (max-width: 340px) {
  .grid { padding: 12px 10px 8px; gap: 10px; }
  .card .body { padding: 10px 11px 12px; }
  .card h3 { font-size: 13.5px; }
  .card p { font-size: 12px; }
  .tabs, .live { padding-left: 10px; padding-right: 10px; }
  .top { padding-left: 12px; padding-right: 12px; }
  .sheet { padding-left: 16px; padding-right: 16px; }
}

/* Login-Gate: ganzer Screen, Bild + Karte */
.gate { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 24px; background: #07090d url('img/login.jpg') center/cover no-repeat; }
.gate[hidden] { display: none; }
.gate::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5,7,10,.50), rgba(5,7,10,.84)); }
.gate-card { position: relative; width: 100%; max-width: 380px; background: rgba(13,17,25,.78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid rgba(255,255,255,.09); border-radius: 20px; padding: 30px 26px 26px; box-shadow: 0 24px 60px rgba(0,0,0,.55); }
.gate-brand { margin: 0 0 6px; font-size: 30px; font-weight: 800; letter-spacing: .4px; text-align: center; }
.gate-sub { color: var(--muted); text-align: center; font-size: 14.5px; line-height: 1.5; margin: 0 0 20px; }
.gate .primary { width: 100%; min-height: 48px; }
