/* pic-choice PWA – phone first, same palette as the desktop UI
   (local/lrcull/static/index.html). No framework, no build step. */

:root {
  --bg: #161616; --panel: #1f1f1f; --line: #2c2c2c; --fg: #e6e6e6; --muted: #8a8a8a;
  --accent: #f5c518; --pick: #3ddc84; --reject: #ff5c5c; --warn: #ff9f43;
  --red: #e5484d; --yellow: #f5d90a; --green: #46a758; --blue: #3e8ef7; --purple: #8e4ec6;
  --head: 52px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }   /* our display rules must not beat it */

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  overscroll-behavior-y: none;
}

body { display: flex; flex-direction: column; }

/* ── header ─────────────────────────────────────────────────────── */
header {
  display: flex; align-items: center; gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
header .titles { flex: 1; min-width: 0; }
header h1 { margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header p { margin: 0; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; overflow: hidden; }
.sub-chip { flex: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; color: var(--muted); white-space: nowrap; }
.sub-chip.link { color: var(--fg); border-bottom: 1px dotted var(--line); cursor: pointer; }
.sub-chip.ok { color: var(--pick); }
.sub-chip.bad { color: var(--reject); }
button.icon {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center;
  background: #2a2a2a; color: var(--fg); border: 1px solid var(--line);
  border-radius: 8px; font-size: 20px; line-height: 1; cursor: pointer;
}
#sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pick); }
#sync-dot.pending { background: var(--accent); }
#sync-dot.offline { background: var(--reject); }

main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
main.deck-view { overflow: hidden; }

.pad { padding: 12px 12px calc(24px + env(safe-area-inset-bottom)); }
.empty { color: var(--muted); text-align: center; padding: 40px 20px; }
.empty b { color: var(--fg); display: block; margin-bottom: 6px; }

/* ── project list ───────────────────────────────────────────────── */
.project {
  display: block; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin-bottom: 10px; color: inherit; font: inherit; cursor: pointer;
}
.project[disabled] { opacity: .55; }
.project b { display: block; font-size: 16px; margin-bottom: 2px; }
.project .meta { color: var(--muted); font-size: 12px; }
.bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: #2a2a2a; margin-top: 10px; }
.bar i { display: block; height: 100%; }
.bar .b-pick { background: var(--pick); }
.bar .b-tisch { background: #3a3a3a; }
.bar .b-weg { background: var(--reject); opacity: .55; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend .k::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: baseline; }
.legend .k-pick::before { background: var(--pick); }
.legend .k-tisch::before { background: #3a3a3a; }
.legend .k-weg::before { background: var(--reject); }

/* ── basket tiles (FR-05 at phone width) ────────────────────────── */
.day { color: var(--muted); font-size: 12px; padding: 14px 2px 6px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--warn);
  border-radius: 10px; padding: 8px; cursor: pointer; text-align: left; color: inherit; font: inherit;
}
.tile.done { border-top-color: var(--pick); }
.tile.empty-basket { border-top-color: var(--line); opacity: .6; }
.tile .hd { display: flex; align-items: baseline; gap: 6px; font-size: 12px; margin-bottom: 6px; }
.tile .hd b { font-size: 13px; }
.tile .pl { color: var(--accent); font-weight: 600; }
.tile .tag { margin-left: auto; color: var(--muted); }
.tile .tag.ok { color: var(--pick); }
.tile .tag.warn { color: var(--warn); }
.mos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.mos .cell { position: relative; aspect-ratio: 1; border-radius: 3px; overflow: hidden; background: #202020; }
.mos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mos .cell.pick { box-shadow: inset 0 0 0 2px var(--pick); }
.mos .cell .cnt { position: absolute; right: 2px; bottom: 1px; font-size: 10px; background: #000a; padding: 0 3px; border-radius: 3px; }
.mos .more { display: grid; place-items: center; aspect-ratio: 1; background: #202020; border-radius: 3px; color: var(--muted); font-size: 12px; }
.tile .ft { color: var(--muted); font-size: 11px; margin-top: 6px; }

/* ── deck ───────────────────────────────────────────────────────── */
#deck { position: relative; height: 100%; display: flex; flex-direction: column; }
.deck-cards { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cards { position: relative; flex: 1; min-height: 0; margin: 10px 10px 0; }
.card {
  position: absolute; inset: 0; border-radius: 14px; overflow: hidden;
  background: #0d0d0d; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  touch-action: none; will-change: transform;
}
.card.behind { transform: scale(.94) translateY(10px); filter: brightness(.6); pointer-events: none; }
.card img { width: 100%; height: 100%; object-fit: contain; display: block; will-change: transform; }
.card.zoomed { touch-action: none; }
.card.zoomed .caption, .card.zoomed .badges { opacity: .25; }
.card .nothumb { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }
.card .badges { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge { background: #000a; border: 1px solid #ffffff22; border-radius: 6px; padding: 2px 7px; font-size: 11px; color: var(--fg); }
.badge.lab-red { border-color: var(--red); color: var(--red); }
.badge.lab-blue { border-color: var(--blue); color: var(--blue); }
.badge.stack { border-color: var(--accent); color: var(--accent); }
.card .caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px; font-size: 12px; color: #ddd; background: linear-gradient(transparent, #000c); display: flex; gap: 10px; }
.card .caption span:last-child { margin-left: auto; color: var(--muted); }

/* the zone tint bleeding in as the swipe passes the threshold */
.card .wash { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.card .wash.up { background: linear-gradient(270deg, #3ddc8455, transparent 60%); }
.card .wash.down { background: linear-gradient(90deg, #ff5c5c55, transparent 60%); }
.card .stamp {
  position: absolute; top: 18%; font-size: 26px; font-weight: 700; letter-spacing: .06em;
  padding: 6px 14px; border: 3px solid currentColor; border-radius: 10px; opacity: 0; pointer-events: none;
}
.card .stamp.up { right: 16px; color: var(--pick); transform: rotate(-12deg); }
.card .stamp.down { left: 16px; color: var(--reject); transform: rotate(12deg); }

/* the card's current rung */
.badge.zone-pick { border-color: var(--pick); color: var(--pick); }
.badge.zone-reject { border-color: var(--reject); color: var(--reject); }
.badge.zone-tisch { border-color: #555; color: var(--muted); }

.deck-actions {
  display: flex; gap: 8px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
}
.deck-actions button {
  flex: 1; padding: 12px 4px; border-radius: 10px; border: 1px solid var(--line);
  background: #2a2a2a; color: var(--fg); font: inherit; font-size: 14px; cursor: pointer;
}
.deck-actions .a-up { border-color: #2f6b4a; color: var(--pick); }
.deck-actions .a-down { border-color: #6b2f2f; color: var(--reject); }
.deck-actions .a-browse { color: var(--muted); flex: 0 1 22%; }
.deck-actions button[disabled] { opacity: .4; }

/* end-of-basket card */
.done-card { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; }
.done-card .big { font-size: 40px; margin-bottom: 8px; }
.done-card p { color: var(--muted); margin: 4px 0 16px; }
.done-card button { padding: 12px 18px; border-radius: 10px; border: 1px solid var(--line); background: #2a2a2a; color: var(--fg); font: inherit; cursor: pointer; }
.done-card button.primary { border-color: #2f6b4a; color: var(--pick); }

/* ── login ──────────────────────────────────────────────────────── */
#login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 50; padding: 20px; }
#login[hidden] { display: none; }
#login form { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; }
#login h2 { margin: 0 0 8px; font-size: 20px; }
#login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
#login input {
  background: #141414; color: var(--fg); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px; font: inherit;
}
#login button { padding: 12px; border-radius: 8px; border: 1px solid var(--line); background: #2a2a2a; color: var(--fg); font: inherit; cursor: pointer; }
#login-error { color: var(--reject); font-size: 13px; min-height: 1.2em; margin: 0; }

/* ── status sheet + toast ───────────────────────────────────────── */
#sheet { position: fixed; inset: 0; background: #000a; z-index: 40; display: flex; align-items: flex-end; }
#sheet .body {
  width: 100%; background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 14px 14px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
}
#sheet h3 { margin: 0 0 10px; font-size: 15px; }
#sheet dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 14px; font-size: 13px; }
#sheet dt { color: var(--muted); }
#sheet dd { margin: 0; }
#sheet .row { display: flex; gap: 8px; }
#sheet button { flex: 1; padding: 11px; border-radius: 8px; border: 1px solid var(--line); background: #2a2a2a; color: var(--fg); font: inherit; cursor: pointer; }

#toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #333; color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 13px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 90vw; text-align: center;
}
#toast.on { opacity: 1; }

/* ── zone overview (Auswahl / Weg) ──────────────────────────────── */
.hint { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.grid .cell {
  position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 4px;
  overflow: hidden; background: #202020; cursor: pointer;
}
.grid .cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .cell.zone-pick { box-shadow: inset 0 0 0 2px var(--pick); }
.grid .cell.zone-reject { box-shadow: inset 0 0 0 2px var(--reject); opacity: .8; }
.grid .cell .time {
  position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; color: #ddd;
  background: linear-gradient(transparent, #000c); padding: 8px 4px 2px;
}

/* ── fullscreen viewer (the same deck in an overlay) ────────────── */
#viewer {
  position: fixed; inset: 0; z-index: 45; background: #000;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.viewer-cards { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#viewer .card { background: #000; border-color: #222; }
.viewer-close {
  position: absolute; top: calc(8px + env(safe-area-inset-top)); right: 10px; z-index: 2;
  width: 38px; height: 38px; border-radius: 19px; border: 1px solid var(--line);
  background: #000a; color: var(--fg); font-size: 18px; cursor: pointer;
}
