:root {
  --bg: #101418;
  --panel: #1a2027;
  --line: #2c3540;
  --text: #e8edf2;
  --muted: #94a3b3;
  --accent: #4da3ff;
  --good: #3ecf8e;
  --warn: #f5b942;
  --bad: #ff6b6b;
  --tabs: 56px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }
button, .file-button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }
a.button { display: inline-block; text-decoration: none; border-radius: 8px; padding: 8px 12px; justify-self: start; }
a.button:not(.primary) { background: var(--panel); border: 1px solid var(--line); color: var(--text); }
a.button.primary { background: var(--accent); color: #06121f; font-weight: 600; }
.ebay-link { align-self: center; color: var(--accent); }
#ebay-form { display: grid; gap: 12px; }
.toolbar { gap: 8px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
button.danger { color: var(--bad); }
button.link { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 8px 0; }
input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
}
input[type="checkbox"] { width: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.muted { color: var(--muted); }
.error { color: var(--bad); margin: 6px 0 0; min-height: 1em; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login form { width: min(340px, 100%); display: grid; gap: 10px; }
.login h1 { margin: 0 0 8px; font-size: 22px; }

/* shell */
#app { height: 100%; }
.view { height: calc(100% - var(--tabs) - env(safe-area-inset-bottom)); overflow-y: auto; }
.tabs {
  position: fixed; inset: auto 0 0 0;
  height: calc(var(--tabs) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--panel); border-top: 1px solid var(--line);
}
.tabs button { border: none; border-radius: 0; background: none; color: var(--muted); }
.tabs button.active { color: var(--accent); font-weight: 600; }

/* capture */
.capture { display: flex; flex-direction: column; overflow: hidden; background: #000; }
.set-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg); color: var(--muted); font-size: 13px; }
.set-bar select { font-size: 15px; color: var(--text); }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.guide {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  /* A standard card is 2.5 x 3.5 in. Sized to fit both the width and the height of the stage. */
  aspect-ratio: 5 / 7;
  width: min(80%, calc((100dvh - var(--tabs) - 240px) * 5 / 7));
  border: 3px solid #fff;
  border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.guide.back { border-color: var(--warn); }
.guide span {
  position: absolute; top: -34px; left: 50%; transform: translateX(-50%);
  font-weight: 700; letter-spacing: 0.12em;
}
.guide.back span { color: var(--warn); }
.camera-message {
  position: absolute; inset: auto 16px 16px 16px; margin: 0;
  background: rgba(0, 0, 0, 0.8); padding: 10px 12px; border-radius: 8px; text-align: center;
}
.capture-bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 12px; padding: 12px 16px 4px; background: var(--bg);
}
.capture-side { display: flex; align-items: center; gap: 8px; min-height: 64px; }
.capture-side.right { justify-content: flex-end; }
.thumb { height: 64px; border-radius: 4px; border: 1px solid var(--line); }
.shutter {
  width: 72px; height: 72px; border-radius: 50%;
  background: #fff; border: 5px solid var(--bg); outline: 3px solid #fff; padding: 0;
}
.shutter:active { transform: scale(0.94); }
.capture-status { margin: 0; padding: 4px 16px 10px; min-height: 2.2em; text-align: center; color: var(--muted); background: var(--bg); }

/* review */
.toolbar {
  position: sticky; top: 0; z-index: 1;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.filters { display: flex; gap: 6px; }
.filters button.active { border-color: var(--accent); color: var(--accent); }
.cards { display: grid; gap: 12px; padding: 12px 16px 24px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 430px), 1fr)); }
.empty { text-align: center; padding: 40px 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: #000; }
.photo img { display: block; width: 100%; height: 220px; object-fit: contain; }
.body { padding: 12px; }
.status-row { display: flex; gap: 8px; align-items: baseline; margin-bottom: 10px; }
.badge { flex: none; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line); }
.badge[data-kind="high"], .badge[data-kind="approved"] { background: var(--good); color: #05251a; }
.badge[data-kind="medium"] { background: var(--warn); color: #2b1f00; }
.badge[data-kind="low"], .badge[data-kind="error"] { background: var(--bad); color: #2b0606; }
.notes { color: var(--muted); font-size: 13px; }
.guide-line { margin: -4px 0 10px; font-size: 13px; color: var(--muted); }
.guide-line[data-matched="true"] { color: var(--good); }
.guide-line:empty { display: none; }
.busy { padding: 24px 0; text-align: center; color: var(--muted); }
.details { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.details label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.details label > * { font-size: 15px; color: var(--text); }
.details .count { font-size: 12px; color: var(--muted); justify-self: end; margin-top: -18px; }
.details .wide { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 14px; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
.shipping { margin: 0; font-weight: 600; }
.shipping[data-method="envelope"] { color: var(--good); }
.shipping[data-method="tracked"] { color: var(--accent); }
.shipping[data-method="none"] { color: var(--muted); font-weight: 400; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* settings */
#view-settings { padding: 16px; }
.settings { display: grid; gap: 12px; max-width: 420px; }
.settings h2 { margin: 0; font-size: 18px; }
.settings p { margin: 0; }
.settings + .settings { margin-top: 28px; max-width: 720px; }
.guide-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; }
.guide-item summary { cursor: pointer; font-weight: 600; }
.guide-item textarea { margin-top: 8px; font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; }
.settings label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
