/* Warehouse — EBKaC labs public brand v3.1.
   Bone carries the background, Olive the brand, Clay the warmth, Signal appears once (the found-it marker). */
:root {
  --olive: #3A4A2E;
  --olive-deep: #2A3621;
  --sage: #94A581;
  --clay: #B85C3D;
  --signal: #FF5600;
  --moss: #4A7C59;
  --bone: #EFE7D2;
  --bone-warm: #E6DEC8;
  --ink: #1A1D17;

  --text: var(--ink);
  --muted: rgb(26 29 23 / .72);         /* Ink at 72%: captions and labels (66% is the floor) */
  --line: rgb(58 74 46 / .2);            /* Olive hairline */
  --field-line: rgb(58 74 46 / .62);     /* input outlines: 3:1 against Bone */
  --sage-tint: rgb(148 165 129 / .32);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 14px;
  --tabs-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 400 16px/1.5 var(--font-body);
  background: var(--bone-warm); color: var(--text);
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--olive); text-underline-offset: .18em; text-decoration-thickness: 1px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; margin: 0 0 .5rem; line-height: 1.15; letter-spacing: -.01em; color: var(--olive); font-optical-sizing: auto; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
h1 em, h2 em { font-style: italic; font-variation-settings: "WONK" 1, "SOFT" 50; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex: none; vertical-align: middle; }

:focus-visible { outline: 3px solid var(--clay); outline-offset: 2px; }
.topbar :focus-visible { outline-color: var(--sage); }   /* Clay is 2.8:1 on Olive-deep; Sage is 4.8:1 */

.skip { position: absolute; left: 12px; top: -60px; z-index: 30; background: var(--olive); color: var(--bone); padding: 10px 14px; border-radius: 10px; }
.skip:focus { top: 12px; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--olive-deep); color: var(--bone);
}
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; min-width: 0; }
.cradle { width: 32px; height: 32px; flex: none; }
.lockup { display: flex; flex-direction: column; line-height: 1.05; }
.lockup .product { font-family: var(--font-display); font-size: 1.3rem; font-weight: 500; letter-spacing: -.01em; }
.lockup .by { font-size: .75rem; color: var(--sage); letter-spacing: .01em; }
.lockup .by em { font-family: var(--font-display); font-style: italic; }
.hh-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 10px; border-radius: 10px;
  color: var(--bone); text-decoration: none; border: 1px solid rgb(239 231 210 / .55); font-size: .85rem; font-weight: 600;
  max-width: 40vw; min-width: 0;
}
.hh-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hh-btn:hover { background: rgb(239 231 210 / .12); }
.loc-picker { margin-left: auto; display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--sage); }
.loc-picker select {
  max-width: 48vw; background: transparent; color: var(--bone); border: 1px solid rgb(239 231 210 / .55);
  font-family: var(--font-mono); font-size: .85rem; min-height: 40px;
}
.loc-picker select option { color: var(--ink); background: var(--bone); }

/* Narrow phones: the shelf picker gets its own row under the brand and household. */
@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .hh-btn { margin-left: auto; }
  .loc-picker { flex-basis: 100%; margin-left: 0; }
  .loc-picker select { max-width: none; flex: 1; }
}
/* Signed out, no access, or no household yet: nothing to pick and nowhere to go. */
body.no-household .tabs, body.no-household .loc-picker, body.no-household .hh-btn { display: none; }
body.no-household { padding-bottom: 0; }
body.booting #view { visibility: hidden; }

main { padding: 20px 16px; max-width: 760px; margin: 0 auto; outline: none; }
main.wide { max-width: none; padding: 0; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--bone); border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; position: relative;
  color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 500;
}
.tabs a.active { color: var(--olive); font-weight: 700; }
.tabs a.active::after { content: ""; position: absolute; top: 6px; right: calc(50% - 18px); width: 6px; height: 6px; border-radius: 50%; background: var(--clay); }

/* ---------- surfaces ---------- */
.card { background: var(--bone); border-radius: var(--radius); border: 1px solid var(--line); padding: 16px; margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.between { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.eyebrow { font-family: var(--font-mono); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ---------- controls ---------- */
button, .btn {
  font: 500 1rem/1.2 var(--font-body); border: 1px solid var(--field-line); background: transparent; color: var(--ink);
  border-radius: 10px; padding: 9px 14px; min-height: 44px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover, .btn:hover { background: var(--sage-tint); }
button:active { transform: translateY(1px); }
button.primary, .btn.primary { background: var(--olive); color: var(--bone); border-color: var(--olive); font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: var(--olive-deep); }
button.danger { border-color: var(--clay); }
button.danger .icon { color: var(--clay); }
button.ghost { border-color: transparent; }
button.sm, .btn.sm { min-height: 36px; padding: 6px 11px; font-size: .9rem; }
button:disabled { color: var(--muted); border-color: var(--line); cursor: default; }
input, select, textarea {
  font: 400 1rem/1.3 var(--font-body); color: var(--ink); background: var(--bone); border: 1px solid var(--field-line);
  border-radius: 10px; padding: 9px 11px; min-height: 44px; width: 100%;
}
input::placeholder { color: var(--muted); }
textarea { min-height: 72px; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--olive); flex: none; margin: 0; }
label.check { display: flex; gap: 10px; align-items: flex-start; }
label.check input { margin-top: 2px; }
label.field { display: block; font-size: .875rem; color: var(--muted); font-weight: 500; }
label.field > input, label.field > select, label.field > textarea, label.field > .row { margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 440px) { .grid2 { grid-template-columns: 1fr; } }

.segmented { display: flex; border: 1px solid var(--field-line); border-radius: 12px; overflow: hidden; background: var(--bone); }
.segmented button { flex: 1; border: 0; border-radius: 0; font-weight: 600; }
.segmented button + button { border-left: 1px solid var(--field-line); }
.segmented button[aria-pressed=true] { background: var(--olive); color: var(--bone); }

#reader { width: 100%; border-radius: var(--radius); overflow: hidden; background: var(--ink); }
.scan-box.off #reader { display: none; }

/* ---------- data ---------- */
.code, .kbd { font-family: var(--font-mono); font-weight: 500; letter-spacing: .02em; }
.kbd { font-size: .85em; background: var(--sage-tint); padding: 1px 6px; border-radius: 5px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: 500 .8rem/1.3 var(--font-mono); padding: 3px 9px; border-radius: 999px; background: var(--sage-tint);
  color: var(--ink); border: 0; min-height: 26px; display: inline-flex; align-items: center; text-decoration: none;
}
button.chip { cursor: pointer; }
.chip.here { background: var(--olive); color: var(--bone); }
.chip.none { background: transparent; border: 1px dashed var(--field-line); color: var(--muted); font-family: var(--font-body); }
.badge {
  font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--bone); color: var(--ink); font-weight: 600;
  border: 1.5px solid var(--clay); display: inline-flex; align-items: center; gap: 5px; vertical-align: middle;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--clay); }

.qty { font-family: var(--font-display); font-size: 2.1rem; font-weight: 500; color: var(--olive); line-height: 1.1; letter-spacing: -.02em; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.actions button { padding: 8px 4px; }
.thumb { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; background: var(--bone-warm); flex: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); padding: 12px 0; }
.list > li:last-child { border-bottom: 0; }
.list > li.undone { color: var(--muted); text-decoration: line-through; }
.list a.rowlink { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }

table.simple { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.simple td, table.simple th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.simple td.num { text-align: right; white-space: nowrap; }

/* ---------- toasts & dialog ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 12px + env(safe-area-inset-bottom)); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 520px); pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: var(--bone); border-radius: 12px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; animation: rise .18s ease-out; }
.toast > .icon { color: var(--moss); }
.toast.error > .icon { color: var(--clay); }
.toast button { min-height: 34px; padding: 4px 12px; color: var(--bone); border-color: rgb(239 231 210 / .6); }
.toast button:hover { background: rgb(239 231 210 / .12); }
.toast :focus-visible { outline-color: var(--sage); }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } }

dialog#modal { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(94vw, 560px); background: var(--bone); color: var(--ink); }
dialog#modal::backdrop { background: rgb(26 29 23 / .45); }
#modal-body { padding: 18px; max-height: 85vh; overflow: auto; }

/* ---------- 3D room ---------- */
.room-wrap { position: relative; height: 60vh; min-height: 320px; background: var(--bone-warm); }   /* exact height set by viewRoom */
.room-wrap canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.room-ui { position: absolute; z-index: 2; inset: 10px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.room-ui > * { pointer-events: auto; }
.room-panel { background: var(--bone); border-radius: var(--radius); padding: 10px 12px; border: 1px solid var(--line); max-width: 520px; flex: 0 1 auto; min-height: 0; overflow: auto; }
.room-tools { margin-top: auto; align-self: flex-end; flex: none; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
.room-tools button { background: var(--bone); }
.room-tools button:hover { background: var(--bone-warm); }
.marker-label { font: 500 12px/1 var(--font-mono); padding: 4px 7px; border-radius: 6px; background: var(--ink); color: var(--bone); white-space: nowrap; transform: translateY(-20px); pointer-events: none; }
.marker-label.dim { background: var(--sage); color: var(--ink); }
.marker-label.hot { background: var(--signal); color: var(--ink); font-size: 14px; padding: 6px 9px; }
.marker-label.warm { background: var(--bone); color: var(--ink); box-shadow: inset 0 0 0 2px var(--clay); font-size: 14px; padding: 6px 9px; }  /* Clay can't sit behind small text */
.marker-label.zone { font: 500 18px/1 var(--font-display); background: var(--olive); color: var(--bone); }
.room-loading { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 600; color: var(--muted); }

.room-switch { padding: 10px 16px; background: var(--bone); border-bottom: 1px solid var(--line); }
.room-switch select { max-width: 420px; }

/* ---------- sign-in & household ---------- */
.auth-wrap { max-width: 460px; margin: 8px auto; }
.form-msg { margin: 0; font-size: .9rem; font-weight: 500; }
.form-msg.error { color: var(--ink); border-left: 3px solid var(--clay); padding: 2px 0 2px 10px; }
.form-msg.ok { color: var(--ink); border-left: 3px solid var(--moss); padding: 2px 0 2px 10px; }
input.otp { font-family: var(--font-mono); font-size: 1.5rem; letter-spacing: .3em; max-width: 220px; }
.invite-link { border: 1.5px dashed var(--olive); border-radius: 12px; padding: 12px; background: var(--bone-warm); }
.invite-link input { font-family: var(--font-mono); font-size: .85rem; }
.who { font-weight: 600; color: var(--ink); }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.signoff { text-align: center; font-family: var(--font-display); color: var(--olive); margin: 28px 0 8px; }
.signoff em { font-style: italic; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
