:root {
  --bg: #0b0d12;
  --bg-2: #10131a;
  --card: #151922;
  --card-2: #1b202b;
  --line: #262c39;
  --line-2: #323a4a;
  --text: #eef1f6;
  --muted: #8d97a8;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --error: #f87171;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 15px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 92, 255, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 211, 238, 0.09), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

a { color: #a99bff; text-decoration: none; }
a:hover { color: #c9c0ff; }

/* Kopfleiste */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px max(20px, env(safe-area-inset-left));
  background: rgba(11, 13, 18, 0.78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text) !important;
  white-space: nowrap;
}
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(124, 92, 255, 0.5);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 7px;
  border-left: 9px solid #fff;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}
.mainnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.mainnav a:hover { color: var(--text); background: var(--card-2); }
.mainnav a.active { color: var(--text); background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.logout { margin: 0; }

main { max-width: 1320px; margin: 0 auto; padding: 28px max(20px, env(safe-area-inset-left)) 60px; }

h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.4px; margin: 0 0 20px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
h2 a { color: var(--text); }
.small { font-size: 13px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.grid > .card { margin-bottom: 0; }
.card.narrow { max-width: 400px; margin: 10vh auto; box-shadow: var(--shadow); }
.login { padding: 30px 28px; }
.login-brand { font-size: 20px; margin-bottom: 4px; }
.login p { margin-top: 0; margin-bottom: 22px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > input { flex: 1 1 180px; }
.row.spread { justify-content: space-between; align-items: center; }
.inline { display: inline; }

label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }

fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: flex; gap: 18px; flex-wrap: wrap; }
legend { color: var(--muted); font-size: 13px; padding: 0 4px; }

input, select, textarea {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--text);
  padding: 9px 12px;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25);
}
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent), #5b7cff);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s, transform 0.05s;
}
button:hover, .button:hover { filter: brightness(1.12); color: #fff; }
button:active, .button:active { transform: translateY(1px); }
button.secondary, .button.secondary { background: var(--card-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
button.danger { background: transparent; color: var(--error); box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.6); }
button.link { background: none; color: var(--text); padding: 0; }
button.ghost { background: transparent; color: var(--muted); padding: 7px 12px; }
button.ghost:hover { color: var(--text); background: var(--card-2); }
button:disabled { opacity: 0.5; cursor: default; filter: none; }

table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
td.actions { white-space: nowrap; text-align: right; }
td.actions form, td.actions .button { margin-left: 4px; }
tr.disabled td { opacity: 0.5; }

code { font-size: 13px; color: var(--muted); word-break: break-all; }
.flash code { color: var(--text); }

.muted { color: var(--muted); }
.ok { color: var(--ok); }
.error { color: var(--error); }
.badge { font-size: 11px; background: var(--line-2); border-radius: 6px; padding: 2px 7px; }
.pill { font-size: 11px; border-radius: 999px; padding: 2px 8px; background: var(--line); color: var(--muted); margin-left: 4px; }
.pill-ok { background: rgba(52, 211, 153, 0.15); color: var(--ok); }
.pill-error { background: rgba(248, 113, 113, 0.15); color: var(--error); }

.status { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-on { color: var(--ok); }
.status-on::before { box-shadow: 0 0 10px var(--ok); }
.status-off { color: var(--muted); }

.flash { border-radius: 12px; padding: 11px 16px; margin-bottom: 18px; }
.flash-ok { background: rgba(52, 211, 153, 0.1); border: 1px solid rgba(52, 211, 153, 0.5); }
.flash-error { background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.5); }

ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 3px 0; }

/* Übersicht */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 26px; }
.stat {
  display: flex;
  flex-direction: column;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(124, 92, 255, 0.16), rgba(34, 211, 238, 0.05) 70%), var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.stat:hover { border-color: var(--line-2); transform: translateY(-2px); color: var(--text); }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 13px; }

.shelf { margin-bottom: 28px; }
.shelf-head { display: flex; justify-content: space-between; align-items: baseline; }
.shelf-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 140px;
  gap: 14px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scroll-snap-type: x proximity;
}
.shelf-item { display: flex; flex-direction: column; gap: 3px; color: var(--text); scroll-snap-align: start; min-width: 0; }
.shelf-item:hover { color: var(--text); }
.shelf-item:hover .poster { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5); }
.shelf-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 6px; }

/* Bibliothek */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.tabs a {
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: #fff; background: linear-gradient(135deg, var(--accent), #5b7cff); border-color: transparent; }
.tabs .count { font-size: 12px; opacity: 0.75; margin-left: 4px; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 20px; }
.toolbar input[type="search"] { flex: 1 1 260px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 22px 16px;
}
.tiles .empty { grid-column: 1 / -1; }

.poster {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(145deg, #252b3a, #161a24);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tiles-square .poster { aspect-ratio: 1 / 1; }
.poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.poster-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  overflow: hidden;
}
.tile:hover .poster { transform: translateY(-4px); box-shadow: 0 16px 34px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(124, 92, 255, 0.5); }

.seen-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ok);
  color: #06281c;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: rgba(0, 0, 0, 0.55);
}
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.tile.seen .progress span { background: var(--ok); }

.tile-body { padding: 10px 2px 0; min-width: 0; }
.tile-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta { margin: 4px 0 0; font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.tile-links { margin: 4px 0 0; font-size: 12px; display: flex; gap: 10px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 30px; }

/* Filme */
.small-button { margin-top: 8px; padding: 5px 12px; font-size: 13px; }
.tile-title a { color: var(--text); }
.status-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(11, 13, 18, 0.82);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.status-badge.static { position: static; display: inline-block; }
.status-wanted { color: var(--accent-2); }
.status-sent { color: #c9c0ff; }
.status-done { color: var(--ok); }
.status-failed { color: var(--error); }

.movie-head { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 16px; }
.movie-poster { width: 180px; flex: 0 0 180px; }
.movie-info { flex: 1; min-width: 0; }
.movie-info h1 { margin-bottom: 4px; }
.movie-info p { margin: 0 0 10px; }
.movie-info .row { margin-bottom: 10px; }

table.releases td { vertical-align: top; }
.release-title { font-weight: 600; word-break: break-word; }
.release-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 4px; }
.release-tags .pill { margin-left: 0; }
td.score { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
ul.reasons { list-style: none; margin: 0; padding: 0; font-size: 12px; min-width: 200px; }
ul.reasons li { padding: 1px 0; white-space: nowrap; }
details.card summary { cursor: pointer; }
details.card summary h2 { display: inline; }

@media (max-width: 720px) {
  body { font-size: 14px; }
  .topbar { flex-wrap: wrap; gap: 6px 12px; padding: 10px 14px 6px; }
  .mainnav { order: 3; flex-basis: 100%; margin: 0 -4px; }
  .logout { margin-left: auto; }
  main { padding: 20px 14px 48px; }
  h1 { font-size: 23px; }
  .card { padding: 14px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 16px 10px; }
  .tile-title { font-size: 13px; }
  .tile-links { display: none; }
  .seen-badge { width: 22px; height: 22px; font-size: 12px; top: 6px; right: 6px; }
  .shelf-row { grid-auto-columns: 112px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
  .stat-value { font-size: 22px; }
  .toolbar select, .toolbar button { flex: 1 1 auto; }
  .movie-head { gap: 14px; }
  .movie-poster { width: 104px; flex-basis: 104px; }
  ul.reasons li { white-space: normal; }
}
