/* ==========================================================================
   KYNORA Scan — "Daylight Clean" theme + app shell (kyui1)
   Loaded LAST on every phone page. It re-points the tokens the older sheets
   already use (styles.css / returns.css / count.css / worker.css) to light
   values, then adds the shared header + bottom nav (kynora-shell.js) and the
   layout offsets the pages need around them. The camera stays dark.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f2f4f7;
  --bg-glow: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eef1f5;
  --text: #0f1a2e;
  --muted: #667085;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --accent: #14254a;
  --accent-soft: rgba(20, 37, 74, 0.08);
  --gold: #c98a2b;
  --gold-soft: rgba(201, 138, 43, 0.14);
  --success: #12a150;
  --success-soft: rgba(18, 161, 80, 0.1);
  --danger: #d92d20;
  --danger-soft: rgba(217, 45, 32, 0.08);
  --warn: #b7791f;
  --warn-soft: rgba(201, 138, 43, 0.12);
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.08);
  --ink: var(--text);
  --canvas: var(--bg);
  --card: var(--surface);
  --radius: 16px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 16px rgba(16, 24, 40, 0.06);
  --font: "Manrope", "IBM Plex Sans", system-ui, sans-serif;
  /* shell */
  --ky-head: 58px;
  --ky-tabs: 64px;
  --ky-top: calc(var(--ky-head) + var(--safe-top));
  --ky-nav: calc(var(--ky-tabs) + var(--safe-bottom));
  --nav-h: var(--ky-tabs);
}

html,
body,
#app {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  background: var(--bg);
}

button,
input,
select,
textarea {
  font-family: inherit;
}

/* ---------- base controls ---------- */
.card,
.rd-card,
.wk-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

input,
select,
textarea {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
}

input::placeholder,
textarea::placeholder {
  color: #98a2b3;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 37, 74, 0.12);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: none;
}

button {
  background: var(--accent);
  color: var(--on-accent, #fff);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

button.secondary,
.ghost-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.error,
.dock-error,
.rd-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(217, 45, 32, 0.25);
}

.brand-mark {
  background: #fff;
  box-shadow: 0 0 0 1px var(--line);
}

.login-shell .brand-logo,
.wk-login .brand-logo {
  background: #fff;
  box-shadow: var(--shadow);
}

/* ==========================================================================
   App shell: header, bottom nav, More sheet
   ========================================================================== */
.ky-top[hidden],
.ky-nav[hidden] {
  display: none !important;
}

.ky-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 70;
  height: var(--ky-top);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: var(--safe-top) calc(0.9rem + env(safe-area-inset-right)) 0 calc(0.9rem + env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  font-family: var(--font);
  color: var(--text);
}

.ky-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 0 0 1px var(--line);
  padding: 2px;
}

.ky-title {
  flex: 1;
  min-width: 0;
  display: grid;
  line-height: 1.15;
}

.ky-title b {
  font-size: 1.06rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.ky-title small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.ky-live {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.7rem;
  font-weight: 700;
}

.ky-live em {
  font-style: normal;
}

.ky-live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: ky-live 2s ease-out infinite;
}

.ky-live.is-off {
  background: var(--danger-soft);
  color: var(--danger);
}

.ky-live.is-off i {
  animation: none;
}

@keyframes ky-live {
  0% { box-shadow: 0 0 0 0 rgba(18, 161, 80, 0.45); }
  100% { box-shadow: 0 0 0 7px rgba(18, 161, 80, 0); }
}

.ky-avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  min-height: 0;
  padding: 0;
  margin: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  box-shadow: none;
}

.ky-avatar.lg {
  width: 44px;
  height: 44px;
  font-size: 0.95rem;
}

.ky-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  height: var(--ky-nav);
  display: grid;
  grid-template-columns: repeat(var(--ky-cols, 4), 1fr);
  padding: 0.35rem calc(0.6rem + env(safe-area-inset-right)) var(--safe-bottom) calc(0.6rem + env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  font-family: var(--font);
}

.ky-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0.2rem 0;
  background: transparent;
  border: 0;
  border-radius: 12px;
  box-shadow: none;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.ky-nav-item .ky-ic {
  width: 44px;
  height: 28px;
  padding: 3px 11px;
  border-radius: 999px;
  transition: background 0.18s ease;
}

.ky-nav-item.on {
  color: var(--accent);
}

.ky-nav-item.on .ky-ic {
  background: var(--accent-soft);
}

.ky-nav-item:active {
  transform: none;
}

.ky-ic {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

/* More sheet */
.ky-sheet[hidden] {
  display: none;
}

.ky-sheet {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: var(--font);
  color: var(--text);
}

.ky-sheet-back {
  position: absolute;
  inset: 0;
  background: rgba(15, 26, 46, 0.42);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ky-sheet-card {
  position: relative;
  width: min(520px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  padding: 0.6rem 1rem calc(1rem + var(--safe-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  box-shadow: 0 -10px 40px rgba(15, 26, 46, 0.18);
  transform: translateY(100%);
  transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ky-sheet.open .ky-sheet-back {
  opacity: 1;
}

.ky-sheet.open .ky-sheet-card {
  transform: none;
}

.ky-grab {
  display: block;
  width: 40px;
  height: 4px;
  margin: 0 auto 0.8rem;
  border-radius: 4px;
  background: var(--line-strong);
}

.ky-sheet-who {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.ky-sheet-who > div {
  flex: 1;
  min-width: 0;
  display: grid;
}

.ky-sheet-who b {
  font-size: 1rem;
  font-weight: 800;
}

.ky-sheet-who small {
  color: var(--muted);
  font-size: 0.75rem;
}

.ky-sheet-label {
  margin: 1rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ky-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.ky-tile {
  display: grid;
  justify-items: start;
  align-content: start;
  gap: 0.2rem;
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0.85rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  font-weight: 400;
}

.ky-tile b {
  margin-top: 0.35rem;
  font-size: 0.92rem;
  font-weight: 800;
}

.ky-tile small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
}

.ky-tile-ic {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.ky-tile-ic .ky-ic {
  width: 19px;
  height: 19px;
}

.ky-tile-ic.is-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.ky-tile-ic.is-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

/* Report a problem (More menu) */
.ky-rp { max-height: 92vh; overflow-y: auto; }
.ky-rp-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
.ky-rp-head b { font-size: 1.1rem; color: var(--text); }
.ky-rp-back { width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-size: 1.4rem; line-height: 1; padding: 0; margin: 0; }
.ky-rp-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ky-rp-chip { width: auto; margin: 0; display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.55rem 0.8rem; border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--text); font: 700 0.9rem var(--font); cursor: pointer; }
.ky-rp-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ky-rp-chip.is-stop.on { background: var(--danger); border-color: var(--danger); }
.ky-rp-chip .ky-ic { width: 18px; height: 18px; }
.ky-rp-text { width: 100%; box-sizing: border-box; margin: 0; border: 1px solid var(--line-strong); border-radius: 12px; padding: 0.7rem 0.8rem; font: 500 16px var(--font); background: var(--surface); color: var(--text); resize: vertical; }
.ky-rp-photo { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.6rem; }
.ky-rp-photo img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.ky-rp-send { width: 100%; margin: 0.8rem 0 0; border: 0; border-radius: 14px; padding: 0.9rem; background: var(--accent); color: #fff; font: 800 1rem var(--font); }
.ky-rp-send:disabled { opacity: 0.45; }
.ky-rp-hint { margin: 0.45rem 0 0; color: var(--muted); font-size: 0.8rem; }
.ky-rp-error { margin-top: 0.6rem; padding: 0.6rem 0.8rem; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-weight: 700; font-size: 0.86rem; }
.ky-rp-sent { display: grid; gap: 0.2rem; padding: 1rem; border-radius: 14px; background: var(--success-soft); border: 2px solid var(--success); }
.ky-rp-sent b { color: var(--success); font-size: 1.3rem; }
.ky-rp-sent span { color: var(--text); }
.ky-rp-row { padding: 0.65rem 0; border-top: 1px solid var(--line); }
.ky-rp-row-top { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; }
.ky-rp-row b { color: var(--text); font-size: 0.92rem; }
.ky-rp-row p { margin: 0.25rem 0 0; color: var(--text); font-size: 0.88rem; overflow-wrap: anywhere; }
.ky-rp-row small { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.76rem; }
.ky-rp-note { background: var(--info-soft); border-radius: 8px; padding: 0.35rem 0.5rem; }
.ky-rp-st { flex: none; font-size: 0.72rem; font-weight: 800; padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.ky-rp-st.st-seen { background: var(--info-soft); color: var(--info); }
.ky-rp-st.st-fixed { background: var(--success-soft); color: var(--success); }

.ky-help {
  margin-top: 0.7rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.85rem;
}

.ky-help ol {
  margin: 0.4rem 0;
  padding-left: 1.2rem;
}

.ky-help li {
  margin: 0.25rem 0;
}

.ky-help p {
  margin: 0;
  color: var(--muted);
}

.ky-sheet-close {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.9rem;
  padding: 0.8rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

/* ==========================================================================
   Page offsets: content sits between the header and the bottom nav
   ========================================================================== */
html.ky-on #app {
  height: auto;
  min-height: 100%;
  padding-top: var(--ky-head);
  padding-bottom: var(--ky-tabs);
}

/* The pages' own headers are replaced by the shell header. */
html.ky-on .pack-head,
html.ky-on .rd-head {
  display: none !important;
}

/* Worker: the shell header has the name; keep only the seller account chips. */
html.ky-on .wk-head {
  position: static;
  margin: 0 0 0.6rem;
  padding: 0;
  background: none;
  border: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html.ky-on .wk-head > :not(.wk-head-id),
html.ky-on .wk-head-id > b {
  display: none !important;
}

html.ky-on .shell.pack,
html.ky-on .rd .shell,
html.ky-on .wk .wk-shell {
  padding-bottom: calc(1.2rem + var(--safe-bottom));
}

html.ky-on .wk .wk-shell {
  padding-top: 0.8rem;
}

/* ==========================================================================
   Packing (index.html)
   ========================================================================== */

/* Section switch (Scan / Need list / Pending / Ready): a segmented control
   under the header instead of the old bottom tab bar. */
html.ky-on #floor-tabs {
  position: sticky;
  top: var(--ky-top);
  left: auto;
  right: auto;
  bottom: auto;
  z-index: 30;
  margin: 0 -0.9rem;
  padding: 0.55rem 0.9rem;
  background: var(--bg);
  border: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html.ky-on .floor-tabs,
html.ky-on .floor-tabs.four {
  max-width: 620px;
  gap: 0.2rem;
  padding: 0.22rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}

html.ky-on .floor-tab,
html.ky-on .floor-tabs.four .floor-tab,
html.ky-on .pack.scan-mode .floor-tab {
  flex-direction: row;
  justify-content: center;
  gap: 0.3rem;
  min-height: 38px;
  padding: 0.3rem 0.2rem;
  border-radius: 11px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

html.ky-on .floor-tab .tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

html.ky-on .floor-tab .tab-icon {
  display: none;
}

html.ky-on .floor-tab.on,
html.ky-on .floor-tabs.four .floor-tab.on,
html.ky-on .pack.scan-mode .floor-tab.on {
  background: var(--accent);
  color: #fff;
}

html.ky-on .floor-tab .count,
html.ky-on .floor-tabs.four .floor-tab .count {
  position: static;
  min-width: 0;
  padding: 0 0.35rem;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 17px;
  box-shadow: none;
}

html.ky-on .floor-tab.on .count {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Today stats as light tiles. */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.stat-num {
  font-family: var(--font);
  font-weight: 800;
}

.stat.is-warn .stat-num { color: var(--warn); }
.stat.is-info .stat-num { color: var(--info); }

html.ky-on .pack-stats {
  margin-top: 0.4rem;
}

/* Scan tab: the screen between header and nav; the camera fills it under the
   section switch and the order card floats on it. */
html.ky-on .shell.pack.scan-mode {
  top: var(--ky-top);
  bottom: var(--ky-nav);
  height: auto;
  max-height: none;
  padding: 0 0 0.6rem;
  background: var(--bg);
}

html.ky-on .pack.scan-mode > #floor-tabs {
  position: relative;
  top: 0;
  margin: 0;
  padding: 0.55rem calc(0.9rem + env(safe-area-inset-right)) 0.55rem calc(0.9rem + env(safe-area-inset-left));
}

html.ky-on .pack.scan-mode > #floor-tabs .floor-tabs {
  margin: 0 auto;
}

html.ky-on .pack.scan-mode > .pack-stats {
  display: none;
}

html.ky-on .pack.scan-mode .scan-stage {
  position: static;
}

html.ky-on .pack.scan-mode .scan-stage-cam,
html.ky-on .pack.has-order.scan-mode .scan-stage-cam,
html.ky-on .pack.scan-mode:not(.has-order) .scan-stage-cam:has(.reader-wrap.is-portrait-cam) {
  position: absolute;
  top: var(--cam-y, 56px);
  left: 0;
  right: 0;
  bottom: 0;
  inset-inline: 0;
  height: auto;
}

html.ky-on .pack.scan-mode .reader-wrap::before {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0) 16%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 30%);
}

/* Order card / step card: a white card on the camera. */
html.ky-on .pack.scan-mode .scan-dock {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html.ky-on .pack.scan-mode .scan-dock :is(.floor-stock, .size-swap, .pc-row, .dock-sku-list, .pc) {
  background-color: var(--surface-2);
}

html.ky-on .pack.has-order.scan-mode .scan-dock > .dock-skip {
  background: var(--surface);
  box-shadow: 0 -10px 18px rgba(255, 255, 255, 0.9);
}

/* Camera overlays stay dark glass with white text. */
.pack.scan-mode .cam-tip,
.pack.scan-mode .photo-badge,
.scan-reticle-hint {
  color: #fff;
}

html.ky-on .pack.scan-mode .cam-open-btn {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Light (torch / screen light) and Sound as big buttons on the camera. */
.cam-fabs {
  position: absolute;
  z-index: 6;
  top: calc(var(--cam-top, 0px) + 0.7rem);
  left: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.cam-fab {
  position: relative;
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0.6rem 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  background: rgba(8, 11, 18, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.cam-fab::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3h8l-1.5 5h-5z'/%3E%3Cpath d='M9.5 8h5v12a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1z'/%3E%3Cpath d='M12 12v3'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3h8l-1.5 5h-5z'/%3E%3Cpath d='M9.5 8h5v12a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1z'/%3E%3Cpath d='M12 12v3'/%3E%3C/svg%3E") center / contain no-repeat;
}

.cam-fab.torch-on {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff !important;
}

/* Landscape / iPad: the order column stops above the bottom nav. */
@media (orientation: landscape) and (min-width: 640px) {
  html.ky-on .pack.scan-mode #pack-panels,
  html.ky-on .pack.scan-mode:not(.has-order) #pack-panels {
    bottom: calc(var(--ky-nav) + 0.9rem);
  }
}

/* List tabs (Need / Pending / Ready): the page scrolls, so the section
   switch can stick under the header. */
html.ky-on .pack.list-mode {
  overflow: visible;
  overflow-x: clip;
}

html.ky-on .shell.pack.list-mode > #floor-tabs {
  margin: 0 -0.9rem;
}

@media (min-width: 700px) {
  html.ky-on .shell.pack.list-mode > #floor-tabs {
    margin: 0 -1.4rem;
    padding-left: 1.4rem;
    padding-right: 1.4rem;
  }
}

/* Staff without the packing job. */
.jobs-link {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

/* ==========================================================================
   Returns desk / Stock count (rd)
   ========================================================================== */
html.ky-on .rd .shell.rd-scan {
  top: var(--ky-top);
  bottom: var(--ky-nav);
  height: auto;
  padding-top: 0.6rem;
}

html.ky-on .rd-actionbar {
  bottom: var(--ky-nav);
  padding-bottom: 0.7rem;
}

html.ky-on .rd-queue,
html.ky-on .rd-vbar {
  bottom: calc(var(--ky-nav) + 0.6rem);
}

.rd-actionbar {
  background: rgba(255, 255, 255, 0.96);
}

.rd-link {
  background: var(--surface);
}

/* ==========================================================================
   Worker page
   ========================================================================== */
html.ky-on .wk-toast {
  bottom: calc(var(--ky-nav) + 0.8rem);
}

/* ==========================================================================
   Old dark-theme colour literals → Daylight tokens. The older sheets wrote
   some colours as literals tuned for a dark page (pale red / green text, dark
   ink on gold buttons, dark glass panels); these point them at the light
   tokens. Camera views are left alone (they stay dark).
   ========================================================================== */
:root .torch-btn.torch-on { color: #fff; }
:root .floor-tab.on .count { color: #fff; }
:root .offline-bar { color: var(--danger); }
:root .size-chip.on { color: #fff; }
:root .product-chip.on { color: #fff; }
:root .chip.on { color: #fff; }
:root .stock-pill.uncounted { color: var(--warn); }
:root .need-grid-row .short-tag.uncounted { color: var(--warn); }
:root .pack-confirm-yes { background: var(--accent); color: #fff; }
:root .swap-slot.is-oos .swap-slot-state { color: var(--danger); }
:root .swap-slot.is-approved .swap-slot-state { color: var(--success); }
:root .swap-slot-btn.is-primary { color: #fff; }
:root .swap-plan-btn { color: #fff; }
:root .swap-row-stock { color: var(--success); }
:root .swap-plan-go { color: #fff; }
:root .pc-head em { color: var(--danger); }
:root .pc-head em.is-ok { color: var(--success); }
:root .pc-row.is-oos .pc-sub { color: var(--danger); }
:root .pc-row.is-done .pc-sub { color: var(--success); }
:root .pc-row.is-approved .pc-sub { color: var(--success); }
:root .pc-btn.is-primary { color: #fff; }
:root .fl .fl-seg button.on { color: #fff; }
:root .fl-chip.on { color: #fff; }
:root .fl .fl-chip.on { color: #fff; }
:root .fl-send .fl-seg button.on { color: #fff; }
:root .fl-send-opt.is-primary { background: var(--accent); color: #fff; }
:root .worker-link { color: var(--info); }
:root .rd-ok { color: var(--success); }
:root .rd-ended .mark { color: var(--success); }
:root .rd-keypad-note { color: var(--danger); }
:root .rd-key.is-go { color: #fff; }
:root .rd-torch.is-on { color: #fff; }
:root .rd-torch-auto.is-on { color: var(--success); }
:root .rd-match-ret { color: var(--danger); }
:root .rd-why span { color: var(--danger); }
:root .rd-why em { color: var(--danger); }
:root .rd-actionbar { background: var(--surface); }
:root .rd-pc-parts button.on { color: #fff; }
:root .sc-tabs button.on { color: #fff; }
:root .sc-toast.is-dup { color: #fff; }
:root .sc-toast.is-ok { color: #fff; }
:root .sc-done .mark { color: var(--success); }
:root .rs-banner { color: var(--warn); }
:root .rs-wait { color: var(--warn); }
:root .rs-wait.is-off { color: var(--danger); }
:root .rs-sent { color: var(--success); }
:root .rs-row.is-warn em { color: var(--warn); }
:root .sc-plus { color: var(--success); }
:root .sc-summary .up b { color: var(--success); }
:root .sc-summary .down b { color: var(--danger); }
:root .sc-unlock { color: var(--success); }
:root .qr-done { color: var(--success); }
:root .qr-chip.on { color: #fff; }
:root .sc-confirm-list em.up { color: var(--success); }
:root .sc-confirm-list em.down { color: var(--danger); }
:root .wk-head { background: var(--surface); }
:root .wk-block { color: var(--danger); }
:root .wk-ok { color: var(--success); }

/* Camera screens of the returns desk / stock count keep the dark look: the
   old dark tokens apply inside them (glass controls, keypad, recording). */
.rd .shell.rd-scan,
.rd-capture {
  color-scheme: dark;
  --surface: #121826;
  --surface-2: #182135;
  --surface-3: #1f2a42;
  --text: #eef2f8;
  --muted: #8b95aa;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #d9a54a;
  --accent-soft: rgba(217, 165, 74, 0.14);
  --success: #2ecc71;
  --danger: #ff5a52;
  --warn: #f5b544;
  --info: #5aa9ff;
  --on-accent: #1a1305;
  color: var(--text);
}


/* ==========================================================================
   Packing workspace (kyui2): Scan | Orders, step card, order card, motions
   ========================================================================== */
html.ky-on .floor-tabs.two {
  grid-template-columns: 1fr 1fr;
}

.sound-fab::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9.5v5h3.5L12 18.5v-13L7.5 9.5z'/%3E%3Cpath d='M15.5 9a4 4 0 0 1 0 6M18 6.5a7.5 7.5 0 0 1 0 11'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9.5v5h3.5L12 18.5v-13L7.5 9.5z'/%3E%3Cpath d='M15.5 9a4 4 0 0 1 0 6M18 6.5a7.5 7.5 0 0 1 0 11'/%3E%3C/svg%3E");
}

/* ---------- Orders: Pending / Need list / Ready tiles ---------- */
html.ky-on .pack-stats {
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.15rem 0 0.4rem;
}

.ord-tile {
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0.7rem 0.4rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--text);
  font-weight: 400;
}

.ord-tile::before {
  display: none;
}

.ord-tile .stat-num {
  font-size: 1.45rem;
  color: var(--text) !important;
}

.ord-tile .stat-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.ord-tile.on {
  border: 2px solid var(--accent);
  padding: calc(0.7rem - 1px) calc(0.4rem - 1px);
  box-shadow: 0 4px 14px rgba(20, 37, 74, 0.12);
}

.ord-tile.on .stat-label {
  color: var(--accent);
}

.ord-today {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

.ord-today b {
  color: var(--success);
}

/* ---------- step card (no order yet) ---------- */
.dock-kicker {
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.step-card {
  display: grid;
  gap: 0.2rem;
}

.step-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

.step-sub {
  color: var(--muted);
  font-size: 0.86rem;
}

.step-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.step-meta span {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.step-meta b {
  color: var(--text);
}

/* ---------- L1: working… card shimmer ---------- */
.dock-load {
  display: grid;
  gap: 0.6rem;
}

.dock-load-cap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 800;
}

.dock-load-cap i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2.5px solid rgba(201, 138, 43, 0.25);
  border-top-color: var(--gold);
  animation: kySpin 0.8s linear infinite;
}

.dock-load .bone {
  display: block;
  height: 12px;
  border-radius: 7px;
  background: linear-gradient(90deg, #eef1f5 0%, #f8f9fb 50%, #eef1f5 100%) 0 0 / 200% 100%;
  animation: kyShim 1.2s linear infinite;
}

.dock-load .bone.tall {
  width: 100%;
  height: 40px;
  border-radius: 12px;
}

@keyframes kyShim { to { background-position: -200% 0; } }
@keyframes kySpin { to { transform: rotate(360deg); } }

/* ---------- P1: pieces progress ring ---------- */
.dock-product .pk-ring {
  order: 3;
}

.pk-ring {
  position: relative;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
}

.pk-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.pk-ring circle {
  fill: none;
  stroke-width: 5;
}

.pk-ring .trk {
  stroke: var(--surface-3);
}

.pk-ring .arc {
  stroke: var(--success);
  stroke-linecap: round;
  stroke-dasharray: var(--c);
  stroke-dashoffset: var(--off);
}

.pk-ring.just-moved .arc {
  animation: kyArc 0.7s cubic-bezier(0.3, 1.1, 0.4, 1);
}

.pk-ring b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1rem;
  font-weight: 800;
}

.pk-ring b small {
  display: none;
}

.pk-ring.just-moved b {
  animation: kyBump 0.4s ease 0.45s;
}

@keyframes kyArc { from { stroke-dashoffset: var(--from); } }
@keyframes kyBump { 40% { transform: scale(1.3); color: var(--success); } }

/* ---------- T3: piece rows, tick + gold "next" frame moves down ---------- */
.pk-list {
  list-style: none;
  display: grid;
  gap: 0.45rem;
  margin: 0.7rem 0 0;
  padding: 0;
}

.pk-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.pk-row.is-done {
  background: var(--success-soft);
  border-color: rgba(18, 161, 80, 0.3);
}

.pk-row.is-next::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 12px;
  box-shadow: 0 0 0 2px var(--gold);
  pointer-events: none;
}

.pk-row.just-next::after {
  animation: kyFrameIn 0.45s cubic-bezier(0.3, 1.3, 0.5, 1) 0.3s both;
}

.pk-row.just-done {
  animation: kyTint 0.6s ease 0.05s both;
}

.pk-thumb,
.pk-thumb-wrap .dock-photo {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  object-fit: cover;
}

.pk-thumb-wrap {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
}

.pk-thumb-empty {
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.pk-copy {
  flex: 1;
  min-width: 0;
  display: grid;
}

.pk-copy b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.86rem;
}

.pk-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.74rem;
}

.pk-st {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2.5px dashed var(--gold);
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
}

.pk-st.ok {
  border: 0;
  background: rgba(18, 161, 80, 0.16);
  color: var(--success);
}

.pk-st svg,
.ky-badge svg,
.k3-tick svg {
  width: 60%;
  height: 60%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pk-row.just-done .pk-st.ok {
  animation: kyPop 0.35s cubic-bezier(0.3, 1.7, 0.5, 1) both;
}

.pk-row.just-done .pk-st.ok path,
.ky-fx.fx-ok .ky-badge path,
.k3-tick path {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  animation: kyDraw 0.3s ease 0.2s forwards;
}

@keyframes kyFrameIn { from { transform: translateY(-58px); } }
@keyframes kyTint { from { background: var(--surface-2); border-color: var(--line); } }
@keyframes kyPop { 0% { opacity: 0; transform: scale(0.4); } 100% { opacity: 1; transform: scale(1); } }
@keyframes kyDraw { to { stroke-dashoffset: 0; } }

/* ---------- S1 / E1 / D1 on the camera ---------- */
.ky-fx {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.ky-fx:empty {
  display: none;
}

.ky-vig {
  position: absolute;
  inset: 0;
}

.ky-fx-area {
  position: absolute;
  top: var(--cam-top, 0px);
  bottom: var(--cam-bottom, 0px);
  left: 0;
  right: var(--cam-right, 0px);
  display: grid;
  place-items: center;
}

.ky-ring,
.ky-badge {
  grid-area: 1 / 1;
}

.ky-ring {
  width: min(58%, 250px);
  aspect-ratio: 1;
  border-radius: 22%;
  border: 3px solid var(--success);
  opacity: 0;
}

.ky-badge {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  opacity: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.ky-chip {
  position: absolute;
  left: 50%;
  bottom: calc(var(--cam-bottom, 0px) + 0.9rem);
  transform: translateX(calc(-50% - var(--cam-right, 0px) / 2));
  max-width: 86%;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--success);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  opacity: 0;
}

/* S1 — good scan */
.ky-fx.fx-ok .ky-ring { animation: kyRingOut 0.7s ease-out 0.05s; }
.ky-fx.fx-ok .ky-ring.r2 { display: none; }
.ky-fx.fx-ok .ky-badge { animation: kyPopHold 0.85s cubic-bezier(0.3, 1.7, 0.5, 1) 0.1s both; }
.ky-fx.fx-ok .ky-chip { animation: kyChip 0.85s cubic-bezier(0.2, 1.4, 0.4, 1) 0.1s both; }
.scan-reticle.fx-ok .scan-reticle-box i { border-color: #3dd68c; }
.scan-reticle.fx-ok .scan-reticle-box { animation: kyLock 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
.scan-reticle.fx-ok .scan-laser { opacity: 0; }

/* E1 — wrong scan */
.ky-fx.fx-wrong .ky-vig { animation: kyVig 1.2s ease-out both; }
.ky-fx.fx-wrong .ky-ring,
.ky-fx.fx-wrong .ky-badge { display: none; }
.ky-fx.fx-wrong .ky-chip { background: var(--danger); animation: kyChip 1.5s cubic-bezier(0.2, 1.4, 0.4, 1) 0.05s both; }
.scan-reticle.fx-wrong .scan-reticle-box { animation: kyShake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
.scan-reticle.fx-wrong .scan-reticle-box i { border-color: #ff5a5a; }
.scan-reticle.fx-wrong .scan-laser { opacity: 0; }

/* D1 — scanned twice */
.ky-fx.fx-twice .ky-ring { border-color: #f5b544; animation: kyDbl 0.8s ease-out both; }
.ky-fx.fx-twice .ky-ring.r2 { animation-delay: 0.12s; }
.ky-fx.fx-twice .ky-badge { background: #e8a33a; animation: kyPopHold 1.4s cubic-bezier(0.3, 1.7, 0.5, 1) both; }
.ky-fx.fx-twice .ky-chip { background: #b7791f; animation: kyChip 1.5s cubic-bezier(0.2, 1.6, 0.4, 1) both, kyWob 0.4s ease 0.35s; }
.scan-reticle.fx-twice .scan-reticle-box i { border-color: #f5b544; }
.scan-reticle.fx-twice .scan-laser { opacity: 0; }

@keyframes kyRingOut { 0% { opacity: 0.9; transform: scale(0.9); } 100% { opacity: 0; transform: scale(1.7); } }
@keyframes kyPopHold { 0% { opacity: 0; transform: scale(0.4); } 30% { opacity: 1; transform: scale(1); } 80% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0.9); } }
@keyframes kyChip { 0% { opacity: 0; margin-bottom: -20px; } 20% { opacity: 1; margin-bottom: 0; } 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes kyLock { 60% { transform: scale(0.92); } 100% { transform: scale(0.96); } }
@keyframes kyShake { 15%, 55% { translate: -9px 0; } 35%, 75% { translate: 9px 0; } 90% { translate: -3px 0; } }
@keyframes kyVig { 0% { box-shadow: inset 0 0 0 0 rgba(255, 93, 97, 0); } 25% { box-shadow: inset 0 0 70px 22px rgba(255, 70, 70, 0.6); } 100% { box-shadow: inset 0 0 0 0 rgba(255, 70, 70, 0); } }
@keyframes kyDbl { 0%, 50% { opacity: 0.95; transform: scale(0.95); } 25%, 75% { opacity: 0; transform: scale(1.3); } 100% { opacity: 0; transform: scale(1.4); } }
@keyframes kyWob { 30% { rotate: -3deg; } 60% { rotate: 3deg; } }

/* ---------- Wrong product sheet ---------- */
.ky-wrong[hidden] {
  display: none;
}

.ky-wrong {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding: 0 calc(0.6rem + env(safe-area-inset-right)) 0 calc(0.6rem + env(safe-area-inset-left));
}

.ky-wrong-card {
  width: min(560px, 100%);
  padding: 0.6rem 1rem 1rem;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
  text-align: center;
  color: var(--text);
}

.ky-wrong.open .ky-wrong-card {
  animation: kySheetUp 0.32s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

.ky-wrong-x {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 0.3rem;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 1.4rem;
  font-weight: 800;
}

.ky-wrong.open .ky-wrong-x {
  animation: kyXIn 0.4s cubic-bezier(0.3, 1.6, 0.5, 1) 0.1s both;
}

.ky-wrong h3 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
}

.ky-wrong p {
  margin: 0.25rem 0 0.8rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.ky-wrong-pair {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0.6rem;
}

.ky-wrong-box {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 0.6rem;
  border-radius: 14px;
  border: 2px solid var(--success);
}

.ky-wrong-box.is-got {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.ky-wrong-box small {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ky-wrong-box b {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  word-break: break-all;
}

.ky-wrong-box.is-got b {
  color: var(--danger);
}

.ky-wrong-photo,
.ky-wrong-photo-wrap .dock-photo {
  width: 64px;
  height: 64px;
  flex: none;
  border-radius: 12px;
  object-fit: cover;
}

.ky-wrong-none {
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}

.ky-wrong-again {
  width: 100%;
  margin-top: 0.8rem;
  padding: 0.85rem;
  font-size: 1rem;
}

@keyframes kySheetUp { from { transform: translateY(100%); } }
@keyframes kyXIn { 0% { transform: scale(0) rotate(-90deg); } 100% { transform: scale(1) rotate(0); } }

/* ---------- K3: packed — pieces drop, flaps fold, tape, tick ---------- */
.scan-flash-check.k3 {
  position: relative;
  width: 150px;
  height: 130px;
  border-radius: 0;
  background: none;
  box-shadow: none;
  font-size: 0;
  animation: none;
}

.scan-flash.has-ship .scan-flash-check.k3,
.scan-flash.has-sku .scan-flash-check.k3 {
  width: 120px;
  height: 104px;
}

.k3-box {
  width: 100%;
  height: 100%;
}

.k3-piece {
  transform: translateY(-70px);
  opacity: 0;
  animation: kyDropIn 0.35s cubic-bezier(0.5, 0, 0.6, 1.4) forwards;
}

.k3-piece.p2 {
  animation-delay: 0.1s;
}

.k3-flapL {
  transform-origin: 26px 52px;
  transform: rotate(-150deg);
  animation: kyFlap 0.25s ease-in-out 0.4s forwards;
}

.k3-flapR {
  transform-origin: 104px 52px;
  transform: rotate(150deg);
  animation: kyFlap 0.25s ease-in-out 0.5s forwards;
}

.k3-tape {
  stroke-dasharray: 80;
  stroke-dashoffset: 80;
  animation: kyDraw 0.25s ease 0.72s forwards;
}

.k3-tick {
  position: absolute;
  right: 4%;
  bottom: 2%;
  display: grid;
  place-items: center;
  width: 38%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  color: var(--success);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  opacity: 0;
  animation: kyPop 0.35s cubic-bezier(0.3, 1.8, 0.5, 1) 0.9s forwards;
}

.k3-tick path {
  animation-delay: 1.05s;
}

@keyframes kyDropIn { to { transform: translateY(0); opacity: 1; } }
@keyframes kyFlap { to { transform: rotate(0deg); } }

/* D1 on the full "Already collected" screen, E1 on "Not in your order" / cancelled. */
.scan-flash-already .scan-flash-check {
  animation: kyDblFlash 0.8s ease-out both;
}

.scan-flash-already .scan-flash-title {
  display: inline-block;
  animation: kyWob 0.4s ease 0.35s;
}

.scan-flash-missing .scan-flash-check,
.scan-flash-cancelled .scan-flash-check {
  animation: kyShake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.scan-flash-missing {
  box-shadow: inset 0 0 90px 26px rgba(120, 0, 0, 0.45);
}

@keyframes kyDblFlash {
  0%, 50% { box-shadow: 0 0 0 0 rgba(255, 213, 120, 0.9); }
  25%, 75% { box-shadow: 0 0 0 26px rgba(255, 213, 120, 0); }
  100% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.07); }
}

/* Less motion when the phone asks for it: end states only. */
@media (prefers-reduced-motion: reduce) {
  .ky-fx *,
  .pk-row,
  .pk-row::after,
  .pk-st,
  .pk-ring *,
  .k3-box *,
  .k3-tick,
  .ky-wrong-card,
  .scan-flash-check,
  .dock-load .bone {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
  }
}

/* The camera tip steps aside while a scan motion plays. */
.ky-fx.play ~ .cam-tip {
  opacity: 0;
}

html.ky-on .pack.scan-mode > #floor-tabs {
  background: var(--bg);
  border-top: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* ==========================================================================
   Returns · Stock · Worker in Daylight Clean (kyui3)
   ========================================================================== */

/* ---------- shared: headings, done marks, chips ---------- */
.rd-q {
  font-weight: 800;
  letter-spacing: -0.01em;
}

.rd-done,
.sc-done {
  border-radius: 20px;
}

.rd-done h2,
.sc-done h2 {
  font-weight: 800;
  letter-spacing: -0.01em;
}

/* Done: the mark pops in, a ring pushes out (same feel as S1). */
.rd-done .mark,
.sc-done .mark {
  position: relative;
  animation: kyPop 0.45s cubic-bezier(0.3, 1.7, 0.5, 1) both;
}

.rd-done .mark::after,
.sc-done .mark::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid currentColor;
  opacity: 0;
  animation: kyRingOut 0.9s ease-out 0.25s;
}

.rd-done h2,
.sc-done h2,
.rd-done > p,
.sc-done > .sc-done-row {
  animation: kyRise 0.35s ease 0.2s both;
}

@keyframes kyRise { from { opacity: 0; transform: translateY(8px); } }

.sc-done .mark {
  background: var(--success-soft);
  color: var(--success);
}

.rd-done.tone-iron .mark {
  background: var(--gold-soft);
  color: var(--gold);
}

.rd-big {
  min-height: 56px;
  border-radius: 16px;
  font-size: 1.05rem;
  font-weight: 800;
}

/* Screen on / Photo sound: light chips (dark glass stays on the camera). */
.rd-pref {
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
}

.rd-pref.on {
  background: var(--gold-soft);
  border-color: rgba(201, 138, 43, 0.4);
  color: #8a5a12;
}

/* ---------- Returns: scan screen ---------- */
html.ky-on .rd-scan .rd-type-btn {
  border: 0;
  background: #fff;
  color: #14254a;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.rd-cam.ky-shake .rd-scanfx {
  animation: kyShake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.rd-cam.ky-shake::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  animation: kyVig 1.1s ease-out both;
}

/* Keypad: a light sheet over the camera. */
.rd .shell.rd-scan .rd-keypad {
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eef1f5;
  --text: #0f1a2e;
  --muted: #667085;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --accent: #14254a;
  --on-accent: #fff;
  color-scheme: light;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
}

.rd-key {
  background: var(--surface-2);
  border-color: var(--line);
}

.rd .shell.rd-scan .rd-keypad .rd-key.is-go {
  color: #fff;
}

/* ---------- Returns: details ---------- */
.rd-hero-item {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.rd-why {
  background: var(--surface);
  border-color: var(--line);
}

.rd-go {
  background: var(--danger);
  box-shadow: 0 8px 22px rgba(217, 45, 32, 0.25);
}

.rd-ghost {
  background: var(--surface);
  border-color: var(--line-strong);
}

/* ---------- Returns: questions ---------- */
.rd-ans {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.rd-ans.tone-iron {
  background: var(--gold-soft);
  border-color: rgba(201, 138, 43, 0.45);
}

.rd-ans.tone-iron b {
  color: #8a5a12;
}

.rd-ans.tone-wash {
  background: rgba(37, 99, 235, 0.07);
  border-color: rgba(37, 99, 235, 0.35);
}

.rd-ans.tone-wash b {
  color: var(--info);
}

.rd-ans.is-picked {
  outline-color: var(--accent);
}

.rd-ans:active {
  transform: scale(0.98);
}

.rd-expect {
  background: var(--surface);
  border-color: rgba(201, 138, 43, 0.4);
}

.rd-expect-sku {
  color: var(--accent);
}

.rd-pc {
  background: var(--surface);
  border-color: var(--line);
}

.rd-wnote-btn {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}

/* ---------- Stock count ---------- */
.sc-tabs {
  background: var(--surface);
  border-color: var(--line);
}

.sc-tabs button.on {
  background: var(--accent);
  color: #fff;
}

.lk-card {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.lk-key {
  background: var(--surface-2);
  border-color: var(--line);
}

.lk-key:active {
  background: var(--accent);
  color: #fff;
}

.lk-dots i.on {
  background: var(--accent);
  border-color: var(--accent);
}

.lk-radar i {
  border-color: var(--gold);
}

.lk-note {
  background: var(--surface-2);
}

.lk-note.is-bad {
  color: var(--danger);
}

.lk-error {
  color: var(--danger);
}

.lk-spin {
  border-color: var(--line);
  border-top-color: var(--gold);
}

.qr-modes button {
  background: var(--surface);
  border-color: var(--line);
}

/* Count scans on the camera: the brackets frame (kyscan1) shows the result. */
.sc-toast {
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.sc-toast.is-ok {
  background: var(--success);
  color: #fff;
}

.sc-toast.is-dup {
  background: #b7791f;
  color: #fff;
  animation: kyWob 0.4s ease 0.1s;
}

.sc-toast.is-unknown,
.sc-toast.is-bad {
  background: var(--danger);
}

/* ---------- Worker ---------- */
.wk-tab {
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 700;
}

.wk-tab.on {
  background: var(--accent);
  color: #fff;
}

.wk-card {
  background: var(--surface);
  border-radius: 16px;
}

.wk-drop {
  background: var(--surface-2);
}

.wk-seg button {
  background: var(--surface);
}

.wk-seg button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.wk-acc {
  background: var(--accent-soft);
  color: var(--accent);
}

/* L1 shimmer while a page loads (worker, stock access check). */
.ky-load {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.8rem;
  padding: 1rem;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.ky-load .dock-load-cap {
  margin-bottom: 0.1rem;
}

@media (prefers-reduced-motion: reduce) {
  .rd-done .mark,
  .rd-done .mark::after,
  .sc-done .mark,
  .sc-done .mark::after,
  .rd-done h2,
  .sc-done h2,
  .rd-done > p,
  .sc-done > .sc-done-row,
  .rd-cam.ky-shake *,
  .sc-cam * {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
  }
}

/* ==========================================================================
   Scanner frame: breathing gold brackets + number tag (kyscan1)
   Packing (#scan-reticle .scan-reticle-box), Returns desk and Stock count
   (.rd-scanfx). kynora-scan.js adds .kys-frame and the state classes.
   ========================================================================== */
.kys-frame {
  overflow: visible !important;
  border-color: transparent !important;
}

.kys-frame::before,
.kys-frame :is(.scan-laser, .laser) {
  display: none !important;
}

.kys-frame > i:is(.c-tl, .c-tr, .c-bl, .c-br, .c) {
  display: block;
  position: absolute;
  width: 30px;
  height: 30px;
  border: 4px solid var(--gold) !important;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.55));
  animation: kysBreathe 1.4s ease-in-out infinite;
  transition: border-color 0.18s ease, transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.kys-frame > i:is(.c-tl, .tl) { top: 0; left: 0; border-right: 0 !important; border-bottom: 0 !important; border-top-left-radius: 12px; --dx: -4px; --dy: -4px; }
.kys-frame > i:is(.c-tr, .tr) { top: 0; right: 0; left: auto; border-left: 0 !important; border-bottom: 0 !important; border-top-right-radius: 12px; --dx: 4px; --dy: -4px; }
.kys-frame > i:is(.c-bl, .bl) { bottom: 0; left: 0; top: auto; border-right: 0 !important; border-top: 0 !important; border-bottom-left-radius: 12px; --dx: -4px; --dy: 4px; }
.kys-frame > i:is(.c-br, .br) { bottom: 0; right: 0; top: auto; left: auto; border-left: 0 !important; border-top: 0 !important; border-bottom-right-radius: 12px; --dx: 4px; --dy: 4px; }

@keyframes kysBreathe { 50% { transform: translate(var(--dx), var(--dy)); } }

/* A code is being checked: the corners hold still. */
.scan-reticle.is-checking .kys-frame > i,
.rd-cam.is-hit .kys-frame > i,
.kys-frame:is(.kys-ok, .kys-bad, .kys-twice) > i {
  animation: none;
}

/* Right code: corners snap tight and turn green, a quick green wash, the tag. */
.kys-frame.kys-ok > i {
  border-color: var(--success, #22c55e) !important;
  transform: translate(calc(var(--dx) * -2), calc(var(--dy) * -2));
}

.kys-frame.kys-ok::after {
  content: "" !important;
  display: block;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(34, 197, 94, 0.22);
  animation: kysFade 0.6s ease-out forwards !important;
}

@keyframes kysFade { from { opacity: 1; } to { opacity: 0; } }

/* Wrong kind of code: red corners, shake, a red cross, "Need this". */
.kys-frame.kys-bad > i {
  border-color: #ff4d4f !important;
}

.kys-frame.kys-bad {
  animation: kysShake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97) !important;
}

@keyframes kysShake { 15%, 55% { translate: -9px 0; } 35%, 75% { translate: 9px 0; } 90% { translate: -3px 0; } }

/* Scanned twice: amber corners blink twice. */
.kys-frame.kys-twice > i {
  border-color: #f5b544 !important;
  animation: kysBlink 0.8s ease-out both;
}

@keyframes kysBlink { 0%, 50% { opacity: 1; } 25%, 75% { opacity: 0.25; } }

.kys-tag {
  position: absolute;
  left: -2px;
  top: -32px;
  z-index: 3;
  padding: 4px 9px;
  border-radius: 7px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: calc(100% + 40px);
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(6px) scale(0.9);
  transform-origin: left bottom;
  pointer-events: none;
  transition: opacity 0.2s 0.12s, transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1) 0.12s;
}

.kys-frame.kys-ok .kys-tag { opacity: 1; transform: none; background: #22c55e; color: #04220f; }
.kys-frame.kys-bad .kys-tag { opacity: 1; transform: none; background: #ff4d4f; color: #fff; }
.kys-frame.kys-twice .kys-tag { opacity: 1; transform: none; background: #f5b544; color: #1a1204; }

.kys-x {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ff4d4f;
  color: #fff;
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
}

.kys-x svg {
  width: 60%;
  height: 60%;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 26;
  stroke-dashoffset: 26;
}

.kys-frame.kys-bad .kys-x { animation: kysPop 0.4s cubic-bezier(0.3, 1.7, 0.5, 1) 0.1s forwards; }
.kys-frame.kys-bad .kys-x svg { animation: kysDraw 0.3s ease 0.25s forwards; }

@keyframes kysPop { to { opacity: 1; transform: scale(1); } }
@keyframes kysDraw { to { stroke-dashoffset: 0; } }

.kys-ghost {
  position: absolute;
  right: -2px;
  bottom: -34px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s;
}

.kys-ghost:empty { display: none; }
.kys-ghost svg { width: 26px; height: 18px; }
.kys-frame.kys-bad .kys-ghost { opacity: 1; transform: none; }

/* Packing: the hint under the frame steps aside while a result shows. */
.scan-reticle:is(.fx-ok, .fx-wrong, .fx-twice) .scan-reticle-hint {
  opacity: 0;
}

/* Packing: the old ring / tick / cross over the code are replaced by the frame. */
.ky-fx .ky-ring,
.ky-fx .ky-badge {
  display: none !important;
}

.ky-fx.fx-ok .ky-chip {
  display: none;
}

/* Stock count: the piece QR gets a square frame. */
.sc-cam .rd-scanfx.kys-frame {
  inset: auto;
  left: 50%;
  top: 50%;
  height: 66%;
  width: auto;
  aspect-ratio: 1;
  max-width: 82%;
  transform: translate(-50%, -50%);
}

/* Returns desk: "No label? Scan piece QR" turns the frame square. */
.rd-scan .rd-cam.kys-qr .rd-scanfx.kys-frame {
  width: min(62vw, 300px);
  height: min(62vw, 300px);
}

.rd-piece-btn {
  width: 100%;
  min-height: 44px;
  margin-top: 0.45rem;
  border-radius: 14px;
  background: rgba(8, 11, 18, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: none;
}

.rd-piece-btn.on {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1204;
}

@media (prefers-reduced-motion: reduce) {
  .kys-frame,
  .kys-frame > i,
  .kys-frame .kys-x,
  .kys-frame .kys-x svg,
  .kys-frame::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Packing: Light / Sound sit above the frame, so the tag goes under it. */
.scan-reticle .kys-tag {
  top: auto;
  bottom: -34px;
  transform-origin: left top;
}

.scan-reticle .kys-frame.kys-bad .kys-tag {
  max-width: 62%;
}

/* ==========================================================================
   kyq1 — packing queue ticker, all-done screen, kept-for-orders swap rows
   ========================================================================== */
.pk-queue {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  top: 3.6rem; /* under the Light / Sound buttons, over the camera */
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  padding: 0.55rem 0.8rem;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.3;
}
.pk-queue[hidden] { display: none !important; }
.pk-queue-text { flex: 1; min-width: 0; }
.pk-queue-text b { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-weight: 600; }
.pk-queue-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--success); box-shadow: 0 0 0 3px rgba(18, 161, 80, 0.3); }
.pk-queue.is-wait .pk-queue-dot { background: var(--gold); box-shadow: 0 0 0 3px rgba(201, 138, 43, 0.35); }
.pk-queue.is-short { background: var(--danger); }
.pk-queue.is-short .pk-queue-dot { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35); }

.pk-done {
  position: fixed;
  inset: 0;
  z-index: 450;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: rgba(15, 26, 46, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.pk-done[hidden] { display: none !important; }
.pk-done.on { opacity: 1; }
.pk-done-card {
  width: min(100%, 380px);
  background: var(--surface);
  border-radius: 24px;
  padding: 1.6rem 1.2rem 1.2rem;
  text-align: center;
  box-shadow: 0 24px 60px rgba(15, 26, 46, 0.35);
}
.pk-done-count {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 4.6rem;
  line-height: 1;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pk-done-sub { color: var(--muted); font-weight: 600; margin-top: 0.2rem; }
.pk-done-stamp {
  display: inline-block;
  margin-top: 0.8rem;
  padding: 0.35rem 0.9rem;
  border: 3px solid var(--success);
  border-radius: 9px;
  color: var(--success);
  font-weight: 800;
  letter-spacing: 0.14em;
  transform: rotate(-6deg);
}
.pk-done.on .pk-done-stamp { animation: pk-stamp 0.42s 0.9s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
@keyframes pk-stamp { from { transform: rotate(-6deg) scale(2.4); opacity: 0; } }
.pk-done-text { color: var(--muted); margin: 1rem 0 0; font-size: 0.92rem; }
.pk-done-wait { margin: 0.6rem 0 0; padding: 0.5rem 0.7rem; border-radius: 10px; background: var(--gold-soft); color: var(--text); font-size: 0.85rem; font-weight: 600; }
.pk-done-ok { margin-top: 1rem; width: 100%; border-radius: 14px; padding: 0.85rem; background: var(--accent); color: #fff; font-weight: 800; border: 0; }
@media (prefers-reduced-motion: reduce) { .pk-done.on .pk-done-stamp { animation: none; } }

.swap-row.is-locked { background: var(--surface-3); border-style: dashed; }
.swap-row.is-locked .swap-row-stock { color: var(--danger); font-size: 1.1rem; }
.swap-row-why { white-space: normal !important; }
.swap-row-split { display: flex; height: 5px; border-radius: 5px; overflow: hidden; background: var(--success); margin-top: 0.2rem; max-width: 12rem; }
.swap-row-split i { display: block; height: 100%; }
.swap-row-split i.kept { background: var(--gold); }
.swap-row-split i.prom { background: var(--line-strong); }
.swap-kept { display: grid; gap: 0.55rem; padding: 0.4rem 0.1rem; }
.swap-kept b { font-size: 1rem; }
.swap-kept p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.swap-kept-list { display: grid; gap: 0.3rem; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.swap-kept-list div { display: flex; justify-content: space-between; gap: 0.5rem; font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 0.8rem; }
.swap-kept-list small { color: var(--muted); font-family: inherit; }
.swap-kept-back { border-radius: 12px; padding: 0.75rem; background: var(--accent); color: #fff; font-weight: 800; border: 0; }
.swap-kept-ask { border-radius: 12px; padding: 0.7rem; background: var(--surface); color: var(--text); font-weight: 700; border: 1px solid var(--line-strong); }
.swap-kept-note { color: var(--muted); font-size: 0.75rem; text-align: center; }

/* ---------- kyq2: copied sticker sheet ---------- */
.pk-copy { position: fixed; inset: 0; z-index: 460; display: grid; place-items: end center; padding: 1rem; background: rgba(15, 26, 46, 0.55); opacity: 0; transition: opacity 0.18s ease; }
.pk-copy[hidden] { display: none !important; }
.pk-copy.on { opacity: 1; }
.pk-copy-card { width: min(100%, 420px); background: var(--surface); border-radius: 22px; padding: 1.1rem; display: grid; gap: 0.6rem; border-top: 4px solid var(--danger); box-shadow: 0 24px 60px rgba(15, 26, 46, 0.35); margin-bottom: calc(var(--safe-bottom, 0px) + 0.4rem); }
.pk-copy-title { color: var(--danger); font-size: 1.1rem; }
.pk-copy-text { margin: 0; font-size: 0.92rem; line-height: 1.45; color: var(--text); }
.pk-copy .mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 0.86em; }
.pk-copy-main { border: 0; border-radius: 14px; padding: 0.9rem; background: var(--accent); color: #fff; font-weight: 800; font-size: 0.98rem; }
.pk-copy-alt, .pk-copy-close { border-radius: 12px; padding: 0.7rem; background: var(--surface); color: var(--text); font-weight: 700; border: 1px solid var(--line-strong); }
.pk-copy-close { border-color: var(--line); color: var(--muted); }
.pk-copy-list { display: grid; gap: 0.35rem; }
.pk-copy-list button { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; text-align: left; border-radius: 12px; padding: 0.65rem 0.8rem; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-weight: 700; }
.pk-copy-list small { color: var(--muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.pk-copy-err { margin: 0; color: var(--danger); font-weight: 700; font-size: 0.86rem; }
.pk-copy-note { margin: 0; color: var(--muted); font-size: 0.75rem; text-align: center; }
.pk-copy button[disabled] { opacity: 0.6; }
.fl-iron { color: var(--warn); font-weight: 700; }

/* ---------- kyq3: need list by design ---------- */
.fl-designs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
.fl-designs::-webkit-scrollbar { display: none; }
.fl-designs .fl-chip { white-space: nowrap; flex: none; }
.fl-design { border-top: 3px solid var(--accent); }
.fl-design-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; padding: 0.7rem 0.9rem; background: var(--surface-2); }
.fl-design-head b { font-size: 1rem; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-design-head span { color: var(--muted); font-size: 0.82rem; font-weight: 700; white-space: nowrap; }
.fl-color-head { display: flex; justify-content: space-between; padding: 0.35rem 0.9rem; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border-top: 1px solid var(--line); }
.fl-count-hint { margin: 0.4rem 0.2rem 0.2rem; font-size: 0.8rem; color: var(--muted); }
.fl-design .fl-meta { white-space: normal; overflow: visible; line-height: 1.35; }

/* Swap piece on top (rescan after a skip) */
.dock-product.is-swap { border: 2px solid var(--gold); border-radius: var(--radius); background: var(--gold-soft); padding: 0.5rem 0.6rem; }
.dock-kicker.is-swap { color: var(--gold); }
.dock-product.is-swap s { color: var(--muted); }

/* Swap tray: parcel aside under a number of the day */
.tray-chip { display: flex; align-items: center; gap: 0.55rem; width: 100%; margin-top: 0.6rem; padding: 0.55rem 0.7rem; border: 1.5px solid var(--gold); border-radius: 12px; background: var(--gold-soft); color: var(--text); font: inherit; font-size: 0.86rem; text-align: left; cursor: pointer; }
.tray-chip-n { display: grid; place-items: center; min-width: 1.9rem; height: 1.9rem; border-radius: 999px; background: #111; color: #fff; font-weight: 800; }
.tray-card { position: fixed; inset: 0; z-index: 4200; display: grid; place-items: center; padding: 1rem; background: rgba(15, 26, 46, 0.6); }
.tray-card[hidden] { display: none; }
.tray-card-box { width: min(420px, 100%); background: var(--surface); border-radius: 22px; padding: 1.2rem 1.1rem 1rem; display: grid; gap: 0.55rem; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3); }
.tray-card-kicker { color: var(--success); font-weight: 800; font-size: 0.9rem; }
.tray-card-no { justify-self: center; min-width: 7rem; padding: 0.2rem 1rem; border-radius: 18px; background: #111; color: #fff; font-size: 4.2rem; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tray-card-title { font-size: 1.15rem; font-weight: 800; color: var(--text); }
.tray-card-sub { font-size: 0.9rem; color: var(--muted); line-height: 1.4; }
.tray-card-meta { font-size: 0.8rem; color: var(--muted); font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.tray-card-go { margin-top: 0.3rem; border: 0; border-radius: 14px; padding: 0.95rem; background: var(--accent); color: #fff; font: inherit; font-weight: 800; font-size: 1.05rem; }
.tray-card-stay { border: 1px solid var(--line-strong); border-radius: 14px; padding: 0.7rem; background: var(--surface); color: var(--text); font: inherit; font-weight: 700; }
.tray-flash { position: fixed; left: 50%; top: calc(var(--ky-top) + 12px); z-index: 4300; transform: translate(-50%, -20px); opacity: 0; pointer-events: none; width: min(440px, calc(100% - 32px)); display: flex; align-items: center; gap: 0.8rem; padding: 0.75rem 0.9rem; border-radius: 16px; background: var(--surface); border: 2px solid var(--success); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2); transition: opacity 0.18s, transform 0.18s; }
.tray-flash.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.tray-flash.is-warn { border-color: var(--danger); }
.tray-flash-no { flex: none; padding: 0.1rem 0.6rem; border-radius: 12px; background: #111; color: #fff; font-size: 2rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.tray-flash-text { font-weight: 700; color: var(--text); font-size: 0.95rem; line-height: 1.35; }
.tray-flash.is-warn .tray-flash-text { color: var(--danger); }
.tray-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.2rem; border-top: 1px solid var(--line); }
.tray-row.is-done { opacity: 0.55; }
.tray-row-no { flex: none; min-width: 3rem; text-align: center; padding: 0.15rem 0.4rem; border-radius: 10px; background: #111; color: #fff; font-weight: 900; font-size: 1.25rem; }
.tray-row-main { flex: 1; min-width: 0; display: grid; gap: 0.1rem; }
.tray-row-main small { color: var(--muted); font-size: 0.78rem; }
.tray-row-state { flex: none; font-size: 0.78rem; font-weight: 800; color: var(--gold); }
.tray-row.is-done .tray-row-state { color: var(--success); }

/* Swap sheet (Option A): ordered piece, best pick, tabs, photo cards. Text never overlaps. */
.swap-sheet .sp-ph { position: relative; display: grid; place-items: center; overflow: hidden; background: var(--surface-3); color: var(--muted); }
.swap-sheet .sp-ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.swap-sheet .sp-ph em { font-style: normal; font-weight: 800; font-size: 0.7rem; text-align: center; padding: 0 4px; line-height: 1.2; overflow: hidden; max-height: 2.4em; }
.swap-sheet .sp-ordered { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem; border-radius: 14px; background: var(--surface-2); min-width: 0; }
.swap-sheet .sp-ordered-ph { flex: none; width: 46px; height: 56px; border-radius: 10px; }
.swap-sheet .sp-ordered-txt { display: grid; min-width: 0; flex: 1; }
.swap-sheet .sp-ordered-txt b, .swap-sheet .sp-ordered-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swap-sheet .sp-ordered-txt small { color: var(--muted); font-size: 0.76rem; }
.swap-sheet .sp-ordered-stock { flex: none; display: grid; text-align: center; font-weight: 900; font-size: 1.1rem; color: var(--success); line-height: 1.1; }
.swap-sheet .sp-ordered-stock.is-none { color: var(--danger); }
.swap-sheet .sp-ordered-stock small { font-size: 0.62rem; font-weight: 800; color: var(--muted); }
.swap-sheet .sp-tabs { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--surface-3); }
.swap-sheet .sp-tab { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 0.3rem; min-height: 38px; padding: 0 0.3rem; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 800 0.8rem var(--font); box-shadow: none; white-space: nowrap; overflow: hidden; }
.swap-sheet .sp-tab b { font-size: 0.7rem; padding: 1px 6px; border-radius: 99px; background: var(--surface); color: var(--text); }
.swap-sheet .sp-tab.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(15, 26, 46, 0.1); }
.swap-sheet .sp-tab.on b { background: var(--accent); color: #fff; }
.swap-sheet .sp-tab:disabled { opacity: 0.45; }
.swap-sheet .sp-best { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 0.7rem; padding: 0.6rem; border-radius: 18px; border: 2px solid var(--success); background: var(--success-soft); }
.swap-sheet .sp-best-ph { width: 112px; height: 140px; border-radius: 12px; }
.swap-sheet .sp-best-info { display: grid; align-content: start; gap: 0.35rem; min-width: 0; }
.swap-sheet .sp-best-k { font: 800 0.68rem/1 var(--font); letter-spacing: 0.08em; text-transform: uppercase; color: var(--success); }
.swap-sheet .sp-best-t { font-weight: 800; font-size: 1rem; line-height: 1.25; }
.swap-sheet .sp-best-go { margin-top: 0.15rem; min-height: 44px; border: 0; border-radius: 12px; background: var(--success); color: #fff; font: 800 0.95rem var(--font); box-shadow: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 0.6rem; }
.swap-sheet .sp-mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 0.7rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swap-sheet .sp-cs { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.swap-sheet .sp-cs span { max-width: 100%; padding: 1px 7px; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 800; font-size: 0.82rem; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swap-sheet .sp-free { font-weight: 800; font-size: 0.8rem; color: var(--success); white-space: nowrap; }
.swap-sheet .sp-kept { font-weight: 800; font-size: 0.74rem; color: var(--warn); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swap-sheet .sp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.5rem; }
.swap-sheet .sp-card { display: grid; grid-template-rows: 120px auto; min-width: 0; padding: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); color: var(--text); text-align: left; font: inherit; box-shadow: none; }
.swap-sheet .sp-card-ph { width: 100%; height: 120px; }
.swap-sheet .sp-card-in { display: grid; gap: 0.25rem; padding: 0.45rem 0.5rem 0.5rem; min-width: 0; }
.swap-sheet .sp-card-why { font-size: 0.74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swap-sheet .sp-card-ft { display: flex; align-items: center; justify-content: space-between; gap: 0.3rem; min-width: 0; }
.swap-sheet .sp-pick { flex: none; padding: 3px 10px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 800; font-size: 0.78rem; }
.swap-sheet .sp-card.is-locked { border-style: dashed; background: var(--surface-2); }
.swap-sheet .sp-card.is-locked .sp-card-ph { opacity: 0.6; }
.swap-sheet .sp-card:active { transform: scale(0.98); }
.swap-sheet #swap-chips[hidden] { display: none; }
.swap-sheet .swap-sheet-tools { grid-template-columns: minmax(0, 1fr); }
.swap-sheet .sp-tab { flex: 1 1 0; text-overflow: ellipsis; }
.swap-sheet .sp-tab b { flex: none; }
@media (max-width: 380px) { .swap-sheet .sp-tab { font-size: 0.74rem; gap: 0.2rem; } }
.swap-sheet .sp-tab { flex-direction: column; gap: 1px; min-height: 46px; line-height: 1.15; padding: 4px 2px; }
.swap-sheet .sp-tab b { font-size: 0.68rem; padding: 0 7px; }
@media (max-width: 380px) { .swap-sheet .sp-tab { font-size: 0.72rem; } }

/* Bags mode: a sealed ready bag of this SKU is on the rack (packing step card). */
.ready-bag-chip { display: grid; gap: 2px; margin-top: 0.5rem; padding: 0.55rem 0.75rem; border-radius: 12px; border: 2px solid var(--accent); background: var(--surface); }
.ready-bag-chip b { color: var(--text); font-size: 0.95rem; letter-spacing: 0.02em; }
.ready-bag-chip span { color: var(--muted); font-size: 0.8rem; }
.rb-take { grid-template-columns: 64px 1fr; align-items: center; gap: 0.7rem; padding: 0.6rem; border-width: 3px; }
.rb-photo { width: 64px; height: 80px; border-radius: 10px; object-fit: cover; background: var(--surface-3); display: block; }
.rb-body { display: grid; gap: 2px; min-width: 0; }
.rb-box { justify-self: start; background: var(--text); color: var(--surface) !important; border-radius: 7px; padding: 0.1rem 0.5rem; font-weight: 800; font-size: 0.85rem !important; letter-spacing: 0.04em; }
.ready-bag-chip .rb-what { font-size: 1.2rem; }
.ready-bag-chip .rb-do { color: var(--accent); font-size: 0.9rem; }
.ready-bag-chip .rb-or { font-size: 0.75rem; }

/* Live packing counter: ring pill on the camera (top right) and its sheet. */
.ky-counter { white-space: nowrap; position: absolute; z-index: 6; top: calc(var(--cam-top, 0px) + 0.7rem); right: 0.75rem; width: auto; min-height: 0; margin: 0; display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.75rem 0.3rem 0.35rem; border-radius: 999px; background: rgba(8, 11, 18, 0.62); border: 1px solid rgba(255, 255, 255, 0.18); color: #fff; font-size: 0.82rem; font-weight: 800; box-shadow: none; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.ky-counter span { font-weight: 600; opacity: 0.85; font-size: 0.76rem; }
.ky-counter.is-done { background: rgba(22, 128, 74, 0.85); border-color: rgba(255, 255, 255, 0.3); }
.ky-counter.bump { animation: ky-bump 0.45s ease-out; }
@keyframes ky-bump { 0% { transform: scale(1); } 35% { transform: scale(1.12); } 100% { transform: scale(1); } }
.kc-ring { flex: none; display: block; width: auto; height: auto; }
.kc-ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.25); stroke-width: 3; }
.kc-ring-fg { fill: none; stroke: #4ade80; stroke-width: 3; stroke-linecap: round; transition: stroke-dasharray 0.5s ease; }
.kc-late { color: #fca5a5; font-style: normal; font-weight: 800; }
.ky-counter-sheet { position: fixed; inset: 0; z-index: 80; background: rgba(8, 11, 18, 0.45); display: flex; align-items: flex-end; justify-content: center; }
.ky-counter-sheet .cs-card { width: 100%; max-width: 520px; background: var(--surface); color: var(--text); border-radius: 18px 18px 0 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px)); display: grid; gap: 0.8rem; animation: cs-up 0.2s ease-out; }
@keyframes cs-up { from { transform: translateY(30px); opacity: 0.5; } to { transform: none; opacity: 1; } }
.cs-head { display: flex; justify-content: space-between; align-items: center; }
.cs-seg { display: inline-flex; gap: 3px; background: var(--surface-3); padding: 3px; border-radius: 10px; }
.cs-seg button { width: auto; margin: 0; min-height: 0; border: 0; border-radius: 8px; padding: 0.4rem 0.9rem; background: transparent; color: var(--muted); font-weight: 800; font-size: 0.86rem; box-shadow: none; }
.cs-seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(15, 26, 46, 0.1); }
.cs-x { width: auto; margin: 0; min-height: 0; border: 0; background: transparent; color: var(--muted); font-size: 1.1rem; box-shadow: none; }
.cs-big { display: flex; gap: 0.9rem; align-items: center; }
.cs-big .kc-ring-bg { stroke: var(--surface-3); stroke-width: 5; }
.cs-big .kc-ring-fg { stroke: var(--success); stroke-width: 5; }
.cs-big b { display: block; font-size: 1.8rem; line-height: 1.1; }
.cs-big span { color: var(--muted); font-size: 0.9rem; }
.cs-done { margin: 0; color: var(--success); font-weight: 800; }
.cs-accs { display: grid; gap: 0.5rem; }
.cs-acc { display: grid; grid-template-columns: minmax(0, 7rem) 1fr auto; gap: 0.6rem; align-items: center; font-size: 0.86rem; }
.cs-acc b { border-left: 4px solid var(--acc, var(--accent)); padding-left: 0.45rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-acc .cs-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.cs-acc .cs-bar i { display: block; height: 100%; background: var(--acc, var(--accent)); transition: width 0.5s ease; }
.cs-acc.is-done span:last-child { color: var(--success); font-weight: 800; }
.cs-muted { margin: 0; color: var(--muted); font-size: 0.8rem; }
@media (prefers-reduced-motion: reduce) { .ky-counter.bump, .ky-counter-sheet .cs-card { animation: none; } }
/* The pill sits on the Light / Sound line, centred on the buttons; fitCounter() drops extras until it clears them. */
.ky-counter { top: calc(var(--cam-top, 0px) + 0.7rem); min-height: 0; box-sizing: border-box; height: var(--fab-h, 2.33rem); padding-top: 0; padding-bottom: 0; }
@media (max-width: 480px) {
  .cam-fabs { gap: 0.4rem; }
  .cam-fab { padding: 0.6rem 0.7rem; }
  .ky-counter { gap: 0.3rem; padding-left: 0.3rem; padding-right: 0.6rem; }
}
.ky-counter.fit-1 .kc-late small, .ky-counter.fit-2 .kc-late small, .ky-counter.fit-3 .kc-late small, .ky-counter.fit-stack .kc-late small { display: none; }
.ky-counter.fit-1 .kc-late::before, .ky-counter.fit-2 .kc-late::before, .ky-counter.fit-3 .kc-late::before, .ky-counter.fit-stack .kc-late::before { content: "+"; }
.ky-counter.fit-2 > span, .ky-counter.fit-3 > span, .ky-counter.fit-stack > span { display: none; }
.ky-counter.fit-3 .kc-eta, .ky-counter.fit-stack .kc-eta { display: none; }
.ky-counter.fit-stack { top: calc(var(--cam-top, 0px) + 0.7rem + 3.1rem); }
.ky-counter b, .cs-big b, .cs-num { font-variant-numeric: tabular-nums; }
/* Smart pill: finish time stays visible on phones; amber = past pickup, red = late orders; pulse = another phone packed. */
.ky-counter .kc-eta { font-style: normal; font-weight: 700; font-size: 0.76rem; opacity: 0.9; font-variant-numeric: tabular-nums; }
.ky-counter > .kc-late { font-size: 0.74rem; }
.ky-counter.tone-amber { background: rgba(146, 84, 0, 0.82); border-color: rgba(253, 211, 77, 0.6); }
.ky-counter.tone-red { background: rgba(153, 27, 27, 0.82); border-color: rgba(252, 165, 165, 0.6); }
.ky-counter.tone-red > .kc-late { color: #fff; }
.ky-counter.team-pulse { animation: ky-team 0.9s ease-out; }
@keyframes ky-team { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); } 100% { box-shadow: 0 0 0 12px rgba(74, 222, 128, 0); } }
.cs-pace { margin: 0; padding: 0.55rem 0.7rem; border-radius: 10px; font-size: 0.86rem; background: var(--surface-3); }
.cs-pace.ok { background: color-mix(in srgb, var(--success) 12%, var(--surface)); }
.cs-pace.amber { background: color-mix(in srgb, #d97706 16%, var(--surface)); }
.cs-pace.red { background: color-mix(in srgb, #dc2626 14%, var(--surface)); }
.cs-next { display: flex; gap: 0.6rem; align-items: center; font-size: 0.86rem; border: 1px solid var(--border, rgba(15, 26, 46, 0.12)); border-radius: 10px; padding: 0.5rem 0.6rem; }
.cs-box { flex: none; background: var(--text); color: var(--surface); font-weight: 900; border-radius: 6px; padding: 0.2rem 0.45rem; font-size: 0.8rem; }
.cs-late summary { cursor: pointer; font-weight: 800; color: #b91c1c; font-size: 0.86rem; }
.cs-late ul { list-style: none; margin: 0.4rem 0 0; padding: 0; display: grid; gap: 0.25rem; max-height: 9rem; overflow-y: auto; font-size: 0.8rem; }
.cs-late li { display: flex; justify-content: space-between; gap: 0.5rem; }
.cs-late li span { color: var(--muted); text-align: right; }
.cs-team { margin: 0; font-size: 0.82rem; color: var(--muted); }
.cs-team b { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .ky-counter.team-pulse { animation: none; } }
.cs-big > div { min-width: 0; }
.cs-num { white-space: nowrap; font-size: 0.82rem; color: var(--muted); }
