:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #1d1f23;
  --muted: #6b6f76;
  --line: #ddd8cc;
  --accent: #2f5d50;
  --aktiv: #2e7d4f;
  --ruhend: #b7791f;
  --archiviert: #8a8f98;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --surface: #202328;
    --ink: #eceae4;
    --muted: #9aa0a8;
    --line: #2e3238;
    --accent: #7fc0a8;
    --aktiv: #5cc58a;
    --ruhend: #e0a646;
    --archiviert: #8a8f98;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
[hidden] { display: none !important; }
button, input, a.icon-btn { font: inherit; color: inherit; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(340px, 100%); background: var(--surface); border-radius: 16px; padding: 28px 24px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
}
.login-icon { align-self: center; border-radius: 16px; }
.login-card h1 { margin: 4px 0 8px; font-size: 22px; text-align: center; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input {
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 16px;
}
.login-card button {
  margin-top: 6px; padding: 11px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600;
}
@media (prefers-color-scheme: dark) { .login-card button { color: #10201b; } }
.error { color: #c0392b; min-height: 1.2em; margin: 0; font-size: 14px; }

/* Bars */
.bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.bar h1 { margin: 0; font-size: 19px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: transparent; font-size: 20px; cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.counter { font-size: 13px; color: var(--muted); min-width: 3.2em; text-align: center; font-variant-numeric: tabular-nums; }
.notice { margin: 10px 16px 0; padding: 8px 12px; border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 13px; }

/* Grid */
.grid {
  list-style: none; margin: 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 24px);
  display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 22px; } }
.tile {
  display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer; border: 0; padding: 0; text-align: left; width: 100%;
  transition: transform .15s ease;
}
.tile:active { transform: scale(.98); }
.tile.archiviert { opacity: .6; }
.thumb { aspect-ratio: 210 / 297; background: #fff; border-bottom: 1px solid var(--line); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.thumb.missing { display: grid; place-items: center; color: #9aa0a8; font-size: 12px; }
.tile-body { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 4px; }
.tile-title { font-weight: 600; font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.aktiv { color: var(--aktiv); }
.badge.ruhend { color: var(--ruhend); }
.badge.archiviert { color: var(--archiviert); }
.empty { text-align: center; color: var(--muted); margin-top: 60px; }

/* Detail */
.detail { min-height: 100vh; }
.detail-title { flex: 1; min-width: 0; }
.detail-title h1 { font-size: 16px; }
.meta { margin: 1px 0 0; font-size: 12px; color: var(--muted); display: flex; gap: 10px; }
.stage { padding: 16px 0 calc(env(safe-area-inset-bottom) + 24px); overflow-x: hidden; }
.frame-box { margin: 0 auto; position: relative; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
#frame { border: 0; display: block; width: 794px; height: 1123px; transform-origin: 0 0; background: #fff; }
@media (max-width: 830px) { .stage { padding-top: 0; } .frame-box { box-shadow: none; } }
@media (max-width: 520px) { .bar-actions .counter { display: none; } }
.slide-left { animation: slide-left .22s ease; }
.slide-right { animation: slide-right .22s ease; }
@keyframes slide-left { from { transform: translateX(40px); opacity: 0; } }
@keyframes slide-right { from { transform: translateX(-40px); opacity: 0; } }
