:root {
  --bg: #111418;
  --surface: #1b2027;
  --text: #e8ecf1;
  --muted: #8b95a3;
  --accent: #4f9cf9;
  --ok: #3ecf8e;
  --warn: #f5a524;
  --bad: #f05252;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
}

.pill {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}
.pill.online { color: var(--ok); }
.header-right { display: flex; gap: 8px; align-items: center; }
a.pill.logout { color: var(--muted); text-decoration: none; }
/* Scanner | Sammlung: two big buttons at the bottom on phones (thumb reach), a segmented switch on top
   on wide screens. The active page is the filled button. */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(17, 20, 24, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid #2a313b;
}
.tabs a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid #2f3742;
  background: #1b2027;
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, transform 0.06s;
}
.tabs a:active { transform: scale(0.97); }
.tabs a span[aria-hidden] { font-size: 20px; line-height: 1; }
.tabs a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-sub { font-size: 12px; font-weight: 500; opacity: 0.8; }
.tab-sub:empty { display: none; }
body { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) {
  .tabs {
    position: sticky;
    top: 0;
    justify-content: center;
    padding: 8px 16px;
    margin-bottom: 12px;
    border-top: none;
    border-bottom: 1px solid #2a313b;
  }
  .tabs a { flex: 0 0 200px; min-height: 42px; font-size: 15px; border-radius: 10px; }
  .tabs a:not([aria-current="page"]):hover { background: #232a33; }
  body { padding-bottom: 0; }
}
/* Recognised cards: the whole row is a link into the collection */
.log li a { display: flex; justify-content: space-between; gap: 8px; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.log li a span:first-child::after { content: " ›"; color: var(--muted); }
.log li a:hover span:first-child, .log li a:active span:first-child { color: var(--accent); }

main { padding: 0 16px 24px; max-width: 640px; margin: 0 auto; }

.viewfinder {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 3 / 4;
}
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder .frame {
  position: absolute;
  inset: 8% 15%;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  pointer-events: none;
}

.result {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 14px 0;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
}
.result .bin {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
}
.result.unknown .bin { background: var(--warn); }
.result.empty .bin { background: #2a313b; color: var(--muted); }
.result .name { font-weight: 600; font-size: 17px; }
.result .meta { color: var(--muted); font-size: 13px; }

.watch-state {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.6);
  color: var(--muted);
}
.watch-state[data-state="bewegung"] { color: var(--warn); }
.watch-state[data-state="ruhig"] { color: var(--ok); }

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
}
.field[hidden], .controls[hidden] { display: none; }
.field input,
.field select {
  flex: 1;
  font: inherit;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

.controls { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.controls.sorter-only { grid-template-columns: 1fr 1fr; }
button {
  font: inherit;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
.controls button {
  min-height: 52px;
  padding: 0 10px;
  border: 1px solid #2f3742;
  border-radius: 12px;
  background: #232a33;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.06s, background 0.12s;
}
.controls button:active { transform: scale(0.97); }
button.primary, .controls button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.controls button.active { outline: 2px solid var(--warn); }
button:disabled { opacity: 0.5; }

.log { list-style: none; padding: 0; margin: 16px 0 0; font-size: 13px; }
.log li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #232a33;
}
.log li span:last-child { color: var(--muted); white-space: nowrap; }
.log li.undone { text-decoration: line-through; opacity: 0.5; }

/* ---------- scanner on phones: everything up to the buttons fits one screen ---------- */
.scan-pane { display: flex; flex-direction: column; }
@media (max-width: 699px) {
  body:not(.library) header { padding: 0 14px; height: 46px; }
  body:not(.library) main { padding: 0 12px 16px; }
  .scan-pane {
    /* screen minus header (46px) and bottom buttons (68px + home bar) */
    height: calc(100dvh - 46px - 68px - env(safe-area-inset-bottom));
    gap: 8px;
    padding-bottom: 8px;
  }
  .scan-pane .viewfinder { flex: 1 1 auto; min-height: 180px; aspect-ratio: auto; }
  .scan-pane .viewfinder .frame {
    inset: auto;
    top: 4%;
    bottom: 4%;
    left: 50%;
    transform: translateX(-50%);
    aspect-ratio: 63 / 88; /* card shaped whatever the space */
    max-width: 92%;
  }
  .scan-pane .result { margin: 0; padding: 8px 10px; gap: 10px; flex: none; }
  .scan-pane .result .bin { width: 44px; height: 44px; font-size: 22px; }
  .scan-pane .result .name { font-size: 16px; }
  .scan-pane .result .meta { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .scan-pane .field { margin: 0; flex: none; }
  .scan-pane .field input, .scan-pane .field select { padding: 8px 10px; font-size: 16px; }
  .scan-pane .controls { margin: 0; flex: none; }
  .tabs { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .tabs a { min-height: 50px; }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
}
