*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--font-size-m);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Bausteine ---------- */

.btn {
  min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-s);
  padding: 0 18px;
  border-radius: var(--radius-m);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.btn--primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--block { width: 100%; }
.btn svg { flex-shrink: 0; }

.icon-btn {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-m); border: 1px solid transparent; background: transparent;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--font-size-s); font-weight: 600; }
.input, .select {
  min-height: 48px; width: 100%;
  padding: 0 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-m);
  background: var(--color-surface);
}
.input:focus, .select:focus, .btn:focus-visible, .chip:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--color-accent); outline-offset: 2px;
}

.chip {
  min-height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 18px;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  font-size: 14px;
}
.chip[aria-pressed="true"] { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
.chip--dashed { border-style: dashed; background: transparent; }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-s); }

.tag { padding: 3px 10px; border-radius: 12px; background: var(--color-muted-bg); font-size: 12px; color: var(--color-text-soft); }
.tag--outline { background: transparent; border: 1px solid var(--color-border-strong); }

.badge { padding: 4px 8px; border-radius: var(--radius-s); font-size: 12px; font-weight: 600; background: var(--color-surface); }
.badge--dark { background: var(--color-text); color: var(--color-surface); font-weight: 500; }
.badge--warn { background: var(--color-warning-bg); border: 1px solid var(--color-warning-border); color: var(--color-warning); }

.label-caps { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand__logo {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--radius-m); border: 2px dashed var(--color-text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--color-text-muted);
}
.brand__name { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.brand__claim { font-size: 12px; color: var(--color-text-muted); }

/* ---------- Vorschaubild ---------- */

.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--color-placeholder); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb__empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: var(--color-text-muted);
  background: linear-gradient(135deg, var(--color-placeholder), var(--color-muted-bg));
}
.thumb__tl { position: absolute; top: 10px; left: 10px; }
.thumb__tr { position: absolute; top: 10px; right: 10px; }
.thumb__br { position: absolute; bottom: 10px; right: 10px; }

/* ---------- Login & Startfrage ---------- */

.center-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-l);
  padding: var(--space-xl) var(--space-m);
}
.card {
  width: 100%; max-width: 420px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-l); padding: 28px;
  display: flex; flex-direction: column; gap: 18px;
}
.card h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.hint { font-size: 14px; color: var(--color-text-muted); margin: 0; }
.hint--box { padding: 10px 12px; border-radius: var(--radius-m); background: var(--color-muted-bg); color: var(--color-text-soft); }
.code-input { letter-spacing: .5em; font-size: 22px; text-align: center; font-weight: 600; }
.error { color: var(--color-warning); font-size: 14px; margin: 0; }

.onboarding { width: 100%; max-width: 860px; display: flex; flex-direction: column; gap: var(--space-l); text-align: center; }
.onboarding h1 { margin: 0; font-size: clamp(26px, 4vw, 34px); letter-spacing: -.02em; }
.option-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; text-align: left; }
.option {
  min-height: 110px; display: flex; align-items: center; gap: 16px; padding: 20px;
  border-radius: var(--radius-l); border: 2px solid var(--color-border); background: var(--color-surface);
}
.option[aria-checked="true"] { border-color: var(--color-accent); }
.option__icon { width: 48px; height: 48px; flex-shrink: 0; border-radius: 12px; background: var(--color-muted-bg); display: flex; align-items: center; justify-content: center; }
.option__title { display: block; font-size: 17px; font-weight: 600; }
.option__text { display: block; font-size: 14px; color: var(--color-text-muted); }

/* ---------- App-Layout ---------- */

.layout { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: 250px; flex-shrink: 0;
  padding: 24px 18px;
  background: var(--color-surface); border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
}
.sidebar__section { display: flex; flex-direction: column; gap: 10px; }
.nav-item {
  min-height: 44px; width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 12px; border: 0; border-radius: var(--radius-m);
  background: transparent; text-align: left;
}
.nav-item[aria-pressed="true"] { background: var(--color-muted-bg); font-weight: 600; }
.nav-item__meta { font-size: 12px; color: var(--color-text-muted); font-weight: 400; }
.sidebar__footer { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  min-height: 72px; padding: 12px 28px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
}
.topbar__brand { display: none; }
.search {
  flex: 1 1 220px; min-width: 0; height: 44px;
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-m); background: var(--color-surface);
}
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; }
.sort { height: 44px; padding: 0 10px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-m); background: var(--color-surface); }

.content { padding: 22px 28px 40px; display: flex; flex-direction: column; gap: 20px; }

.hero {
  display: flex; gap: 24px; padding: 18px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-l);
}
.hero__thumb { width: min(380px, 42%); flex-shrink: 0; border-radius: var(--radius-m); }
.hero__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.hero__title { margin: 0; font-size: clamp(20px, 2.4vw, 26px); line-height: 1.2; letter-spacing: -.01em; }
.hero__actions { margin-top: auto; display: flex; gap: 12px; flex-wrap: wrap; }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.list-head h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.segmented { display: flex; padding: 4px; border-radius: 12px; background: var(--color-placeholder); }
.segmented button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; font-size: 14px; }
.segmented button[aria-pressed="true"] { background: var(--color-surface); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.item {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-m);
  overflow: hidden; display: flex; flex-direction: column;
}
.item--done { opacity: .72; }
.item__body { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.item__title { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.35; word-break: break-word; }
.item__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 6px; border-top: 1px solid var(--color-muted-bg); }
.check { min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 4px; border: 0; background: transparent; font-size: 13px; }
.check__box {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--color-text-muted);
  display: flex; align-items: center; justify-content: center; background: var(--color-surface);
}
.check[aria-pressed="true"] .check__box { background: var(--color-accent); border-color: var(--color-accent); }
.open-link { min-height: 44px; display: flex; align-items: center; gap: 6px; padding: 0 4px; font-size: 13px; font-weight: 600; text-decoration: none; }

.empty {
  min-height: 240px; border: 2px dashed var(--color-border-strong); border-radius: var(--radius-l);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; padding: 32px;
}

/* ---------- Dialoge ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(20, 20, 19, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.dialog {
  width: 100%; max-width: 640px;
  background: var(--color-surface); border-radius: 18px; padding: 26px;
  display: flex; flex-direction: column; gap: 20px;
}
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog__head h2 { margin: 0; font-size: 22px; }
.dialog__foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--color-muted-bg); }
.dialog__foot .grow { margin-right: auto; }
.preview { display: flex; gap: 16px; padding: 14px; border-radius: 14px; background: var(--color-bg); }
.preview .thumb { width: 200px; flex-shrink: 0; border-radius: 8px; }
.preview__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; }
.row > .input { flex: 1; min-width: 0; }
.member { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.avatar { width: 36px; height: 36px; border-radius: 18px; background: var(--color-muted-bg); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.member__name { flex: 1; }
.share-box { display: flex; gap: 18px; padding: 16px; border-radius: 14px; background: var(--color-bg); align-items: center; }
.qr { width: 112px; height: 112px; flex-shrink: 0; border: 2px dashed var(--color-text-muted); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--color-text-muted); background: var(--color-surface); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--color-border-strong); border-top-color: var(--color-accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  padding: 12px 18px; border-radius: var(--radius-m);
  background: var(--color-text); color: var(--color-surface); font-weight: 600;
}

/* ---------- Nur-Ansehen (Oma & Babysitter) ---------- */

.viewer-top {
  min-height: 84px; padding: 14px 32px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
}
.viewer-top h1 { margin: 0; font-size: 20px; }
.kid-switch { margin-left: auto; display: flex; padding: 4px; border-radius: 14px; background: var(--color-placeholder); }
.kid-switch button { min-height: 52px; min-width: 110px; padding: 0 20px; border: 0; border-radius: 11px; background: transparent; font-size: 18px; }
.kid-switch button[aria-pressed="true"] { background: var(--color-surface); font-weight: 700; }
.viewer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px; }
.tile { display: flex; flex-direction: column; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-l); overflow: hidden; text-decoration: none; }
.tile__play {
  position: absolute; top: 50%; left: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border-radius: 32px; background: var(--color-accent); display: flex; align-items: center; justify-content: center;
}
.tile__body { padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 18px; font-weight: 600; }

/* ---------- Responsiv ---------- */

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .main { display: contents; }
  .topbar { order: 0; }
  .sidebar { order: 1; }
  .content { order: 2; }
  .sidebar {
    width: auto; height: auto; position: static;
    border-right: 0; border-bottom: 1px solid var(--color-border);
    padding: 16px; gap: 16px;
  }
  .sidebar .brand, .sidebar__footer { display: none; }
  .sidebar__lists { flex-direction: row; flex-wrap: wrap; }
  .sidebar__lists .nav-item { width: auto; }
  .topbar { padding: 12px 16px; }
  .topbar__brand { display: flex; width: 100%; justify-content: space-between; }
  .content { padding: 18px 16px 32px; }
  .hero { flex-direction: column; }
  .hero__thumb { width: 100%; }
  .preview { flex-direction: column; }
  .preview .thumb { width: 100%; }
  .viewer-top { padding: 14px 16px; }
  .kid-switch { margin-left: 0; }
}
