/* billys-bar/app/public/style.css — neutral graphite board, white light table,
   phone screens. Colour is semantic only: picked green, missing orange,
   comments blue. Daylight mode swaps the graphite for white. */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }  /* author CSS must never defeat the hidden attribute */

:root {
  --bg: #1c1c1e; --bg-subtle: #242426; --surface: #2a2a2d; --border: #3a3a3e;
  --text: #f5f5f7; --text-2: #a1a1a6;
  --bar-bg: rgba(28, 28, 30, 0.84);
  --seg-on: #48484d;
  --stack-1: #2f2f33; --stack-2: #4a4a4f; --stack-3: #28282b; --stack-4: #3e3e43;
  --accent: #0a84ff;          /* actions */
  --picked: #30d158;          /* semantic: a look has been chosen / an order is full */
  --warn: #ff9f0a;            /* semantic: people missing from the order */
  --comment: #0a84ff;
  --tile-w: 136px;
  --bars-h: 96px;             /* set from the real top bar height by app.js */
  /* overshoot-and-settle spring (linear() approximation) */
  --spring: linear(0, 0.218 2.1%, 0.693 6.4%, 0.914 9%, 1.027 11.4%, 1.08 13.7%,
    1.097 15.5%, 1.099 17.6%, 1.071 21.4%, 0.986 28.7%, 0.967 32.1%, 0.967 36.4%,
    1.001 47%, 1.007 52.8%, 0.998 71.7%, 1);
}
/* Daylight: for working outdoors on set (toggle in Filters on a phone). */
[data-theme="light"] {
  --bg: #ffffff; --bg-subtle: #f5f5f7; --surface: #f2f2f7; --border: #d2d2d7;
  --text: #1d1d1f; --text-2: #6e6e73;
  --bar-bg: rgba(255, 255, 255, 0.88);
  --seg-on: #ffffff;
  --stack-1: #ececf0; --stack-2: #c7c7cc; --stack-3: #f2f2f7; --stack-4: #d1d1d6;
  --warn: #c93400;
}

body {
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- login / error ---------- */
.screen { min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; padding: 24px; }
.screen h1 { font-size: 28px; font-weight: 700; text-align: center; letter-spacing: -0.01em; }
.screen h1 span { display: block; font-size: 15px; font-weight: 500; color: var(--text-2); letter-spacing: 0.12em; text-transform: uppercase; margin-top: 4px; }
#login-form { display: flex; flex-direction: column; gap: 10px; width: 260px; }
#login-form input { padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 16px; }
#login-form button, #error-retry { padding: 11px; border-radius: 10px; border: none; background: var(--accent); color: #fff; font-weight: 600; }
.error { color: #ff6961; text-align: center; }

/* ---------- top bar + category rail ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bar-bg);
  backdrop-filter: saturate(160%) blur(20px); -webkit-backdrop-filter: saturate(160%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.bar-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 20px 8px; }
.brand { display: flex; flex-direction: column; line-height: 1.15; margin-right: 8px; }
.brand strong { font-size: 15px; }
.brand span { font-size: 11px; color: var(--text-2); letter-spacing: 0.1em; text-transform: uppercase; }
#search, #topbar select {
  height: 30px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
}
#search { width: 190px; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.seg button { border: none; background: none; padding: 4px 10px; border-radius: 6px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.seg button.on { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
.spacer { flex: 1; }
#progress { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
#view-badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
#share-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; }
#share-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#share-btn:hover { border-color: var(--text-2); }
body.view-only #share-btn { display: none; }
#share-url { font-size: 13px !important; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; }
#refresh-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: 15px; }
#refresh-btn.spinning { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#notice-bar { margin: 12px 20px 0; padding: 8px 12px; border-radius: 8px; background: var(--bg-subtle); border: 1px solid var(--border); color: var(--text-2); font-size: 13px; }

#cat-rail { display: flex; gap: 6px; overflow-x: auto; padding: 0 20px 10px; scrollbar-width: none; }
#cat-rail::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; font-weight: 600;
}
.chip .n { color: var(--text); font-variant-numeric: tabular-nums; }
.chip.short .n { color: var(--warn); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.on .n { color: var(--bg); }

/* ---------- sections: one per category, headed by the order count ---------- */
#grid { padding-bottom: 60px; }
.cat-head {
  position: sticky; top: var(--bars-h); z-index: 6;
  display: flex; align-items: center; justify-content: space-between; gap: 10px 24px; flex-wrap: wrap;
  padding: 12px 24px 11px;
  background: var(--bar-bg);
  backdrop-filter: saturate(160%) blur(20px); -webkit-backdrop-filter: saturate(160%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.cat-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.cat-title h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; white-space: nowrap; }
.cat-n { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.cat-tallies { display: flex; gap: 8px 26px; flex-wrap: wrap; }

/* The signature: a breakdown-sheet headcount. Big cast/ordered numerals,
   then the day and what's missing. */
.tally { display: grid; grid-template-columns: auto auto; column-gap: 9px; align-items: center; }
.t-num {
  grid-column: 1; grid-row: 1 / span 2;
  font-size: 27px; line-height: 1; font-weight: 600; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.t-num b { font-weight: 700; }
.t-num i { font-style: normal; font-weight: 300; color: var(--text-2); margin: 0 1px; }
.t-day { grid-column: 2; font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-2); line-height: 1.2; }
.t-state { grid-column: 2; font-size: 12.5px; font-weight: 600; line-height: 1.25; white-space: nowrap; }
.tally.short .t-state { color: var(--warn); }
.tally.full .t-state { color: var(--picked); }
.tally.over .t-state { color: var(--text-2); }
.tally.none .t-state { grid-column: 1 / -1; color: var(--text-2); font-weight: 500; }
.t-sub { grid-column: 1 / -1; font-size: 11px; color: var(--text-2); margin-top: 3px; white-space: nowrap; }

.cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile-w), 1fr));
  gap: 22px 16px; padding: 20px 24px 34px;
}
.cat-empty { grid-column: 1 / -1; color: var(--text-2); font-size: 13px; padding: 14px 0; }
#empty { text-align: center; color: var(--text-2); padding: 60px; }
.link-btn { border: none; background: none; color: var(--accent); font-weight: 600; }

/* ---------- tiles ---------- */
.tile { position: relative; cursor: pointer; outline: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.tile-img {
  position: relative; aspect-ratio: 1 / 2.1; border-radius: 8px; overflow: hidden;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.tile-img img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; display: block; }
/* several looks, none picked yet: prints peeking out behind the top one */
.tile.stack .tile-img {
  overflow: visible;
  box-shadow: 4px -4px 0 -1px var(--stack-1), 4px -4px 0 0 var(--stack-2), 8px -8px 0 -2px var(--stack-3), 8px -8px 0 -1px var(--stack-4);
}
.tile.stack .tile-img img { border-radius: 8px; }
.tile.picked .tile-img { outline: 2px solid var(--picked); outline-offset: 2px; }
.tile:focus-visible .tile-img { outline: 2px solid var(--accent); outline-offset: 3px; }
/* booked by casting, no fitting photo yet */
.tile.empty .tile-img { display: grid; place-items: center; background: var(--bg-subtle); border: 1px dashed var(--border); box-shadow: none; }
.ph { font-size: 22px; font-weight: 600; letter-spacing: 0.04em; color: var(--text-2); }
.tile.empty .meta { color: var(--warn); }
.tile.lifted { opacity: 0.3; }
.check {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--picked); color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.tile-cap { display: flex; flex-direction: column; padding: 7px 2px 0; }
.tile-cap .nm { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-cap .meta { font-size: 11.5px; color: var(--text-2); display: flex; gap: 8px; align-items: center; }
.cm { display: inline-flex; align-items: center; gap: 3px; color: var(--comment); }
.ico { width: 12px; height: 12px; fill: currentColor; flex: none; }

/* ---------- drag to another category (desktop) ---------- */
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }
#ghost {
  position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none;
  display: flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 13px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
}
#ghost img, #ghost .ph { width: 28px; height: 46px; border-radius: 6px; object-fit: cover; object-position: 50% 0; display: grid; place-items: center; font-size: 12px; background: var(--bg-subtle); }
#dock {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60;
  width: max-content; max-width: calc(100vw - 32px); padding: 10px 12px 12px; border-radius: 16px;
  background: var(--bar-bg); border: 1px solid var(--border);
  backdrop-filter: saturate(160%) blur(24px); -webkit-backdrop-filter: saturate(160%) blur(24px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}
.dock-hint { font-size: 12px; color: var(--text-2); margin: 0 4px 8px; }
.dock-row { display: flex; gap: 8px; flex-wrap: wrap; }
.drop {
  min-width: 112px; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--stack-2);
  background: var(--surface); display: flex; flex-direction: column; gap: 2px; font-size: 13px; font-weight: 600;
}
.drop em { font-style: normal; font-size: 11.5px; color: var(--warn); }
.drop.here { opacity: 0.45; }
.drop.new span { color: var(--accent); }
.drop.over { border: 1px solid var(--accent); background: rgba(10, 132, 255, 0.16); }
section.cat.over .cat-grid { outline: 2px dashed var(--accent); outline-offset: -8px; border-radius: 14px; background: rgba(10, 132, 255, 0.06); }

/* ---------- hover fan ---------- */
#fan { position: fixed; z-index: 50; }
.fan-card {
  position: absolute; margin: 0; border-radius: 10px; overflow: hidden; cursor: zoom-in;
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
  transform: var(--from); transform-origin: 50% 50%;
  transition: transform 420ms var(--spring) var(--d);
}
#fan.open .fan-card { transform: var(--to); }
.fan-card img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; display: block; }
.fan-card figcaption:not(:empty) {
  position: absolute; left: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: rgba(0, 0, 0, 0.62); color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.fan-card.sel { box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 3px var(--picked); }
@media (prefers-reduced-motion: reduce) { .fan-card { transition: none; } }

/* ---------- light table (desktop) ---------- */
#lighttable {
  width: min(96vw, 1900px); height: 93vh; max-width: none; max-height: none; margin: auto;
  border: none; border-radius: 16px; padding: 0; overflow: hidden;
  background: #ffffff; color: #1d1d1f;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}
#lighttable[open] { display: grid; grid-template-rows: auto 1fr auto; }
#lighttable::backdrop { background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(6px); }
.lt-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #e5e5ea; }
.lt-title { flex: 1; min-width: 0; }
.lt-title h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.lt-title p { font-size: 13px; color: #6e6e73; }
.lt-title #lt-check.warn { color: #b25000; }
.lt-head button { width: 34px; height: 34px; border-radius: 50%; border: none; background: #f2f2f7; font-size: 18px; color: #1d1d1f; flex: none; }
.lt-head button:disabled { opacity: 0.3; }
.lt-nav { font-size: 22px !important; line-height: 1; }
.lt-cat { display: flex; flex-direction: column; gap: 3px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #6e6e73; }
.lt-cat input {
  width: 230px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid #d2d2d7; background: #fff;
  font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; color: #1d1d1f;
}
.lt-cat input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.lt-cat input[readonly] { background: #f2f2f7; }

#lt-surface {
  --cap-h: 150px; --img-h: 500px;
  display: flex; gap: 20px; align-items: flex-start; justify-content: safe center;
  overflow: auto; padding: 18px 22px; min-height: 0;
  background: #f5f5f7;
}
.lt-card { flex: none; width: calc(var(--img-h) * var(--ar)); margin: 0; }
.lt-img {
  position: relative; height: var(--img-h); width: 100%; cursor: zoom-in;
  border-radius: 6px; overflow: hidden; background: #e5e5ea;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 6px 18px rgba(0, 0, 0, 0.08);
}
#lt-surface.zoomed .lt-img { cursor: zoom-out; }
#lt-surface.zoomed figcaption { display: none; }
.lt-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lt-num {
  position: absolute; top: 8px; left: 8px; min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 12px; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.62); color: #fff; font-size: 13px; font-weight: 700;
}
.lt-card.selected .lt-img { outline: 3px solid var(--picked); outline-offset: 3px; }
.lt-card figcaption { height: var(--cap-h); overflow-y: auto; padding-top: 10px; font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
.lt-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.lt-date { color: #6e6e73; font-variant-numeric: tabular-nums; }
.lt-select {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; border: 1px solid #d2d2d7; background: #fff;
  font-size: 13px; font-weight: 600; color: #1d1d1f;
}
.lt-select kbd { font: 11px ui-monospace, SFMono-Regular, monospace; color: #8e8e93; }
.lt-select[aria-pressed="true"] { background: var(--picked); border-color: var(--picked); color: #fff; }
.lt-select[aria-pressed="true"] kbd { color: rgba(255, 255, 255, 0.8); }
.lt-sel-ro { font-size: 13px; font-weight: 600; color: #248a3d; }
.lt-tags { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: #e8e8ed; color: #3a3a3c; }
.lt-comments { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.lt-comments li { display: flex; gap: 6px; align-items: flex-start; padding: 5px 8px; border-radius: 8px; background: #eef5ff; color: #1d1d1f; }
.lt-comments .ico { fill: var(--comment); margin-top: 2px; }
.lt-note { width: 100%; min-height: 34px; border: 1px solid #d2d2d7; border-radius: 6px; padding: 5px 7px; font-size: 12px; resize: vertical; background: #fff; }
.lt-note:focus, #lt-notes:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.lt-note-ro { padding: 5px 8px; border-radius: 6px; background: #f2f2f7; white-space: pre-wrap; }
.lt-empty { margin: auto; max-width: 440px; text-align: center; color: #6e6e73; font-size: 14px; }
.lt-empty-h { font-size: 17px; font-weight: 600; color: #1d1d1f; margin-bottom: 6px; }

/* zoomed: a second pair of arrows steps through the looks */
.lt-look-nav {
  position: absolute; top: 50%; z-index: 3; width: 52px; height: 52px; margin-top: -26px; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.08); background: rgba(255, 255, 255, 0.92); color: #1d1d1f;
  font-size: 30px; line-height: 1; display: grid; place-items: center; padding-bottom: 3px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.lt-look-nav.prev { left: 22px; }
.lt-look-nav.next { right: 22px; }
.lt-look-nav:hover:not(:disabled) { background: #fff; }
.lt-look-nav:disabled { opacity: 0.35; }
#lt-look-pos {
  position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 3;
  padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: rgba(0, 0, 0, 0.66); color: #fff; pointer-events: none;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

.lt-foot { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 14px; align-items: center; padding: 10px 22px 12px; border-top: 1px solid #e5e5ea; }
.lt-foot label { font-size: 13px; font-weight: 600; }
#lt-notes { width: 100%; border: 1px solid #d2d2d7; border-radius: 8px; padding: 7px 9px; font-size: 13px; resize: vertical; background: #fff; }
#lt-notes[readonly] { background: #f2f2f7; resize: none; }
.lt-foot.empty-ro label, .lt-foot.empty-ro #lt-notes { visibility: hidden; }
.lt-hint { font-size: 11.5px; color: #8e8e93; white-space: nowrap; }
.lt-hint kbd { font: 11px ui-monospace, SFMono-Regular, monospace; padding: 0 4px; border: 1px solid #d2d2d7; border-radius: 4px; background: #fff; }
body.view-only .lt-hint { visibility: hidden; }

/* ---------- toast / pending ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  max-width: min(560px, calc(100vw - 32px)); white-space: pre-wrap;
  padding: 9px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
#pending-badge {
  position: fixed; right: 16px; bottom: 16px; z-index: 100;
  padding: 5px 11px; border-radius: 999px; font-size: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}

/* ================= phone ================= */
.phone { display: none; }
.icon-btn { position: relative; display: grid; place-items: center; color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* Touch: a long press is an app gesture, never a text selection. iOS otherwise
   grabs the nearest selectable text (a header, a caption) even when the
   pressed tile itself is unselectable, and offers "Copy" on long-pressed images. */
@media (hover: none) and (pointer: coarse) {
  #screen-board, #dock, #fan, #sheet, #zoomer, .ps-head, #ps-cat, #ps-pager, #ps-strip, .ps-foot {
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  }
  #screen-board input, #sheet input, #sheet textarea { -webkit-user-select: text; user-select: text; }
}

@media (max-width: 700px) {
  .desk { display: none !important; }
  input, select, textarea { font-size: 16px !important; }   /* below 16px iOS zooms the page on focus */

  #topbar { padding-top: env(safe-area-inset-top); }
  .bar-row { flex-wrap: nowrap; gap: 8px; padding: 8px 14px 8px; }
  .brand strong { font-size: 17px; }
  #search { display: none; }
  body.searching #search { display: block; flex: 1; min-width: 0; width: auto; height: 38px; border-radius: 10px; }
  body.searching .brand, body.searching #progress { display: none; }
  #progress { font-size: 12.5px; }
  #refresh-btn { width: 36px; height: 36px; border-radius: 10px; }
  #share-btn { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: 10px; }
  #share-btn span { display: none; }
  #share-btn svg { width: 19px; height: 19px; }
  body.searching #share-btn { display: none; }
  #cat-rail { padding: 0 14px 10px; }
  #notice-bar { margin: 10px 12px 0; }

  .cat-head { padding: 10px 14px; gap: 6px 14px; }
  .cat-title h2 { font-size: 17px; }
  .t-num { font-size: 22px; }
  .cat-tallies { gap: 6px 18px; }
  .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 8px; padding: 12px 12px 26px; }
  .tile-cap .nm { font-size: 12.5px; }
  #grid { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

  #bottombar {
    display: flex; align-items: center; gap: 8px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: var(--bar-bg); border-top: 1px solid var(--border);
    backdrop-filter: saturate(160%) blur(20px); -webkit-backdrop-filter: saturate(160%) blur(20px);
  }
  #bottombar .icon-btn { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
  #m-day { flex: 1; min-width: 0; height: 44px; border-radius: 12px; }
  #m-day button { flex: 1; font-size: 13.5px; font-weight: 600; border-radius: 9px; padding: 0 4px; }
  #toast, #pending-badge { bottom: calc(76px + env(safe-area-inset-bottom)); }
  #pending-badge { right: 12px; }
}

/* ---------- person screen (phone) ---------- */
#person {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border: none; padding: 0;
  background: #f5f5f7; color: #1d1d1f; overflow: hidden; touch-action: manipulation;
}
#person[open] { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto auto; }
#person::backdrop { background: #000; }
.ps-head { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 8px) 12px 4px; background: #fff; }
.ps-title { flex: 1; min-width: 0; }
.ps-title h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ps-sub { font-size: 13px; color: #6e6e73; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-round {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: none; background: #ececf0; color: #1d1d1f;
  display: grid; place-items: center; font-size: 24px; line-height: 1;
}
.ps-round svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ps-round:disabled { opacity: 0.3; }
.ps-zoom { background: #ececf0; border-color: transparent; border-radius: 10px; }
.ps-zoom button { min-width: 34px; height: 30px; color: #3a3a3c; font-weight: 700; border-radius: 8px; }
.ps-zoom button.on { background: #fff; color: #1d1d1f; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); }
.ps-zoom svg { width: 14px; height: 14px; fill: currentColor; vertical-align: -2px; }
.ps-cat {
  justify-self: start; margin: 4px 12px 8px; display: inline-flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 6px 0 13px; border-radius: 999px; border: 1px solid #d2d2d7; background: #fff;
  font-size: 14px; font-weight: 600; color: #1d1d1f; max-width: calc(100vw - 24px);
}
.ps-cat .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-cat .chev { font-size: 13px; color: #fff; background: var(--accent); border-radius: 999px; padding: 3px 10px; }
.ps-cat:disabled { padding-right: 13px; }

#ps-pager {
  position: relative; display: flex; gap: 12px; align-items: center;
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  /* half a screen of room at each end so even the first and last look can sit centred */
  padding: 6px 50vw 10px; scrollbar-width: none; touch-action: pan-x pan-y; overscroll-behavior: contain;
}
#ps-pager::-webkit-scrollbar { display: none; }
.ps-slide {
  position: relative; flex: none; margin: 0; height: 100%; aspect-ratio: var(--ar); max-width: 88vw;
  scroll-snap-align: center; border-radius: 10px; overflow: hidden; background: #e5e5ea;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.1);
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
.ps-slide img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.ps-slide.sel { outline: 3px solid var(--picked); outline-offset: 3px; }
#person[data-zoom="2"] #ps-pager { padding: 6px 12px 10px; scroll-padding-inline: 12px; }
#person[data-zoom="2"] .ps-slide { height: auto; width: calc(50vw - 18px); max-height: 100%; scroll-snap-align: start; }
#person[data-zoom="all"] #ps-pager {
  flex-wrap: wrap; align-items: flex-start; align-content: flex-start; overflow-x: hidden; overflow-y: auto;
  scroll-snap-type: none; padding: 8px 12px 14px; gap: 10px; touch-action: pan-y;
}
#person[data-zoom="all"] .ps-slide { height: auto; width: calc((100vw - 44px) / 3); }
#person:not([data-zoom="1"]) #ps-details { display: none; }
#person.no-looks #ps-pager { justify-content: center; }
.ps-empty { margin: auto; max-width: 300px; text-align: center; color: #6e6e73; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ps-empty .ph { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: #e5e5ea; font-size: 26px; color: #6e6e73; }

#ps-details {
  display: flex; flex-direction: column; gap: 9px; max-height: 32dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 12px 14px; background: #fff; border-top: 1px solid #e5e5ea; font-size: 14px;
}
#ps-details:empty { display: none; }
.pd-row { display: flex; gap: 8px; }
.pill {
  flex: 1; height: 46px; border-radius: 12px; border: 1.5px solid #d2d2d7; background: #fff;
  color: #1d1d1f; font-size: 16px; font-weight: 700;
}
.pill.on { background: var(--picked); border-color: var(--picked); color: #fff; }
.pill.ro { display: grid; place-items: center; }
.pd-notebtn { flex: none; height: 46px; padding: 0 18px; border-radius: 12px; border: 1.5px solid #d2d2d7; background: #fff; font-size: 15px; font-weight: 600; color: #1d1d1f; }
#ps-details .tag { font-size: 12px; padding: 2px 9px; }
#ps-details .lt-date { font-size: 13px; }
#ps-details .lt-comments li { font-size: 14px; padding: 7px 10px; }
#ps-details .lt-comments li.extra { display: none; }
#ps-details.all-comments .lt-comments li.extra { display: flex; }
#ps-details.all-comments .pd-more { display: none; }
.pd-more { align-self: flex-start; border: none; background: none; color: var(--accent); font-weight: 600; padding: 2px 0; }
.pd-note { padding: 8px 10px; border-radius: 10px; background: #f2f2f7; white-space: pre-wrap; }

#ps-strip { display: flex; gap: 7px; overflow-x: auto; padding: 9px 12px; background: #fff; border-top: 1px solid #e5e5ea; scrollbar-width: none; }
#ps-strip::-webkit-scrollbar { display: none; }
#ps-strip:empty { display: none; }
#ps-strip button { position: relative; flex: none; width: 42px; height: 64px; padding: 0; border: none; border-radius: 7px; overflow: hidden; background: #e5e5ea; }
#ps-strip img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; display: block; }
#ps-strip span { position: absolute; left: 3px; bottom: 3px; padding: 0 4px; border-radius: 4px; font-size: 10px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, 0.62); }
#ps-strip .sel::after { content: ""; position: absolute; inset: 0; border: 3px solid var(--picked); border-radius: 7px; }
#ps-strip .cur { outline: 2px solid #1d1d1f; outline-offset: 2px; }
.ps-foot { display: flex; gap: 10px; align-items: center; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #e5e5ea; }
.ps-notes {
  flex: 1; min-width: 0; height: 46px; display: flex; flex-direction: column; justify-content: center;
  padding: 0 14px; border-radius: 12px; border: 1px solid #d2d2d7; background: #fff; color: #1d1d1f; text-align: left;
}
.ps-notes b { font-size: 13.5px; }
.ps-notes span { font-size: 13px; color: #6e6e73; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- zoom (phone) ---------- */
#zoomer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border: none; padding: 0; background: #000; color: #fff; overflow: hidden; }
#zoomer::backdrop { background: #000; }
#zm-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
#zm-img { width: 100%; height: 100%; object-fit: contain; display: block; transform-origin: 0 0; will-change: transform; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#zm-close { position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: 12px; background: rgba(255, 255, 255, 0.16); color: #fff; font-size: 17px; }
.zm-foot {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 12px;
  padding: 18px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  pointer-events: none;
}
.zm-foot > * { pointer-events: auto; }
#zm-num { flex: 1; font-size: 15px; font-weight: 600; }
#zm-select { flex: none; width: 150px; background: rgba(255, 255, 255, 0.16); border-color: transparent; color: #fff; }
#zm-select.on { background: var(--picked); }

/* ---------- sheets (bottom on a phone, centred on a desktop) ---------- */
#sheet {
  width: 100%; max-width: 560px; max-height: 88dvh; margin: auto auto 0; border: none;
  border-radius: 18px 18px 0 0; padding: 6px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--bg-subtle); color: var(--text); overflow-y: auto; overscroll-behavior: contain;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35); transition: transform 200ms ease;
}
#sheet::backdrop { background: rgba(0, 0, 0, 0.45); }
#sheet.on-light {
  --bg-subtle: #ffffff; --surface: #f2f2f7; --border: #d2d2d7; --text: #1d1d1f; --text-2: #6e6e73;
  --stack-2: #c7c7cc; --seg-on: #ffffff; --warn: #c93400;
}
#sheet.top { margin: 0 auto auto; border-radius: 0 0 18px 18px; padding: calc(env(safe-area-inset-top) + 12px) 16px 14px; }
#sheet.top .grabber { display: none; }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--stack-2); margin: 4px auto 12px; }
@media (min-width: 701px) {
  #sheet, #sheet.top { margin: auto; border-radius: 16px; padding: 18px 20px 20px; max-width: 460px; }
  #sheet .grabber { display: none; }
}
.sh-head { margin-bottom: 14px; }
.sh-head h3 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.sh-head p { margin-top: 2px; color: var(--text-2); font-size: 13.5px; }
.sh-muted { color: var(--text-2); margin-bottom: 14px; }
.sh-strip { display: flex; gap: 8px; overflow-x: auto; padding: 3px 3px 8px; margin: 0 -3px 12px; scrollbar-width: none; }
.sh-strip::-webkit-scrollbar { display: none; }
.sh-strip button { position: relative; flex: none; width: 96px; aspect-ratio: 1 / 1.65; padding: 0; border: none; border-radius: 10px; overflow: hidden; background: var(--surface); }
.sh-strip img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; display: block; }
.sh-strip span { position: absolute; left: 5px; bottom: 5px; padding: 0 6px; border-radius: 5px; font-size: 11px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, 0.62); }
.sh-strip .sel { outline: 3px solid var(--picked); outline-offset: 2px; }
.sh-actions { display: flex; flex-direction: column; gap: 8px; }
.sh-btn { height: 50px; padding: 0 18px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 16px; font-weight: 600; }
.sh-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.sh-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.sh-list button {
  width: 100%; min-height: 58px; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "nm tick" "tl tick";
  align-items: center; padding: 8px 14px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: left;
}
.sh-list .nm { grid-area: nm; font-size: 16px; font-weight: 600; }
.sh-list .tl { grid-area: tl; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: pre; }
.sh-list .tl:empty { display: none; }
.sh-list .tl em { font-style: normal; font-weight: 600; color: var(--warn); }
.sh-list .tick { grid-area: tick; color: var(--accent); font-size: 18px; font-weight: 700; }
.sh-list .cur { border-color: var(--accent); }
.sh-new { display: flex; gap: 8px; }
.sh-new input { flex: 1; min-width: 0; height: 50px; padding: 0 13px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 16px; }
.sh-sec { margin-bottom: 16px; }
.sh-lbl { margin-bottom: 7px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
.sh-seg { display: flex; flex-wrap: wrap; width: 100%; border-radius: 11px; }
.sh-seg button { flex: 1 0 auto; padding: 9px 10px; font-size: 14.5px; font-weight: 600; border-radius: 9px; }
.sh-sec select { width: 100%; height: 46px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
.sh-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sh-toggle small { display: block; color: var(--text-2); font-size: 13px; }
.sh-toggle input { width: 26px; height: 26px; accent-color: var(--picked); }
.cmp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.cmp-head img, .cmp-head .ph { flex: none; width: 44px; height: 68px; border-radius: 8px; object-fit: cover; object-position: 50% 0; display: grid; place-items: center; background: var(--surface); font-size: 15px; }
.cmp-head div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cmp-head span { color: var(--text-2); font-size: 13.5px; }
.cmp-head .sh-btn { height: 40px; }
#cmp-text { width: 100%; min-height: 140px; padding: 11px 13px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface); color: var(--text); resize: vertical; }
#ps-pager:focus, #sheet-body:focus, #zm-stage:focus { outline: none; }
