/* Where's My Stuff?: laid out like Men's Scope's Attire (slate tokens, pill pages, cards, photo tiles, sheets). */
:root {
  --bg: #f4f6f8; --panel: #ffffff; --panel-2: #eef1f4;
  --ink: #1f2933; --muted: #64748b; --line: #e2e8f0;
  --accent: #3a6ea5; --accent-ink: #ffffff; --accent-soft: #e7eef7; --err: #c4513f;
  --r: 12px; --r-sm: 9px; --btn-r: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05); --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --panel: #171b21; --panel-2: #1e242c; --ink: #e6eaef; --muted: #8b95a1; --line: #2a313a; --accent: #6ea8fe; --accent-ink: #0f1216; --accent-soft: #1e2a3b; --err: #f08a78; --shadow: 0 1px 3px rgba(0, 0, 0, .4); --shadow-lg: 0 10px 28px rgba(0, 0, 0, .5); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; padding-bottom: env(safe-area-inset-bottom); }
h1, h2, h3 { margin: 0; letter-spacing: -.2px; }
img { display: block; max-width: 100%; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

/* Buttons and fields */
:where(button, .button, label.file) { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: var(--btn-r); padding: 11px 18px; font-weight: 700; cursor: pointer; text-decoration: none; line-height: 1.25; white-space: nowrap; }
.primary { background: var(--accent); color: var(--accent-ink); }
.quiet { background: var(--panel); color: var(--ink); border: 1.5px solid var(--line); font-weight: 600; }
.quiet:hover { border-color: var(--accent); color: var(--accent); }
.danger { background: transparent; color: var(--err); border: 1.5px solid color-mix(in oklab, var(--err) 45%, transparent); font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
.small { padding: 7px 13px; font-size: 13.5px; }
.big { padding: 15px 28px; font-size: 16px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-weight: 600; }
.icon-button { background: transparent; color: var(--muted); width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 22px; font-weight: 400; flex: none; }
.icon-button:hover { background: var(--panel-2); color: var(--ink); }
input, select { width: 100%; min-width: 0; padding: 11px 13px; border-radius: var(--r-sm); border: 1.5px solid var(--line); background: var(--panel); color: var(--ink); font-size: 16px; }
input:focus, select:focus { border-color: var(--accent); outline: none; }
input[type=checkbox] { width: 20px; height: 20px; padding: 0; accent-color: var(--accent); flex: none; }
select { -webkit-appearance: none; appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 19px) 52%, calc(100% - 14px) 52%; background-size: 5px 5px; background-repeat: no-repeat; text-overflow: ellipsis; }
.field { display: grid; gap: 7px; margin: 0 0 16px; font-weight: 700; font-size: 14px; }
.field input, .field select { font-weight: 500; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.pair.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.with-button { display: flex; gap: 10px; align-items: center; }
.with-button > select, .with-button > input { flex: 1; }
.with-button > button { flex: none; }

/* Header and pages */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); background: color-mix(in oklab, var(--bg) 92%, transparent); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand h1 { font-size: 19px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mark { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.mark.big { width: 64px; height: 64px; border-radius: 16px; }
.scan-btn { padding: 9px 16px; }
main { max-width: 1120px; margin: 0 auto; padding: 18px 16px 40px; }
.pages { display: flex; gap: 4px; background: var(--panel-2); padding: 4px; border-radius: 999px; margin: 0 0 18px; overflow-x: auto; scrollbar-width: none; }
.pages::-webkit-scrollbar { display: none; }
.page { flex: 1; text-align: center; white-space: nowrap; padding: 10px 14px; border-radius: 999px; font-weight: 700; font-size: 14.5px; color: var(--muted); text-decoration: none; }
.page[aria-current="page"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }

/* Cards */
.card { background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); padding: 22px; margin: 0 0 16px; min-width: 0; }
.card h2 { font-size: 22px; font-weight: 800; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px 20px; flex-wrap: wrap; }
.head > div:first-child { flex: 1 1 280px; min-width: 0; }
.head-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.sub { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 6px 0 0; }
.sub.center { text-align: center; margin: 0 0 14px; }
.is-err { color: var(--err); font-weight: 600; }
.label { display: block; color: var(--muted); font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; margin: 22px 0 10px; }
.card > .label:first-child, .label-row .label { margin-top: 0; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.label-row .label { margin-bottom: 0; }
.empty { text-align: center; padding: 34px 22px; }
.empty p { color: var(--muted); line-height: 1.6; margin: 0 auto 16px; max-width: 460px; }
.count { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.actions.end { justify-content: flex-end; }
.grow { flex: 1; }

/* Chips and tiles */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.chip { background: var(--panel); color: var(--ink); border: 1.5px solid var(--line); padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; }
.chip small { color: var(--muted); font-weight: 700; margin-left: 2px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.on small { color: inherit; opacity: .8; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; align-items: stretch; gap: 5px; text-align: left; background: var(--panel); color: var(--ink); border-radius: var(--r); box-shadow: var(--shadow); padding: 10px 10px 14px; font-weight: 400; white-space: normal; min-width: 0; border: 1px solid transparent; }
.tile:hover { box-shadow: var(--shadow-lg); }
.grid.small .tile { border-color: var(--line); box-shadow: none; }
.ph { position: relative; display: block; aspect-ratio: 1; border-radius: var(--r-sm); background: var(--panel-2); overflow: hidden; margin-bottom: 4px; }
.ph img { width: 100%; height: 100%; object-fit: contain; }
.ph-qr { position: absolute; inset: 10% 18% 24%; }
.ph-qr .qr { width: 100%; height: 100%; border-radius: 4px; }
.badge { position: absolute; top: 8px; right: 8px; background: var(--panel); color: var(--ink); font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 999px; box-shadow: var(--shadow); }
.badge.is-out { top: auto; bottom: 8px; left: 8px; right: auto; background: var(--err); color: #fff; }
.badge.code { top: auto; bottom: 8px; left: 8px; right: auto; font-family: ui-monospace, Menlo, monospace; letter-spacing: .04em; }
.tile .title { font-size: 14.5px; line-height: 1.3; padding: 0 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile small { color: var(--muted); font-size: 12.5px; line-height: 1.35; padding: 0 4px; }
.tile .desc { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .where { color: var(--accent); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Find */
.search { display: flex; gap: 10px; margin: 0 0 16px; position: sticky; top: calc(70px + env(safe-area-inset-top)); z-index: 5; }
.search input { font-size: 17px; padding: 14px 16px; border-radius: var(--r); box-shadow: var(--shadow); }
.search button { min-width: 72px; }
.answer { background: var(--accent-soft); border-radius: var(--r); padding: 16px 18px; margin: 0 0 16px; display: grid; gap: 12px; justify-items: start; }
.answer p { margin: 0; font-size: 16px; line-height: 1.5; }

/* Sheets */
dialog { border: 0; padding: 0; background: var(--panel); color: var(--ink); border-radius: 20px; width: min(520px, calc(100% - 24px)); max-height: calc(100dvh - 24px); box-shadow: var(--shadow-lg); }
dialog.is-wide { width: min(780px, calc(100% - 24px)); }
dialog::backdrop { background: rgba(15, 23, 42, .4); backdrop-filter: blur(2px); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 22px 0 24px; }
.dialog-header h2 { font-size: 22px; font-weight: 800; margin-top: 3px; overflow-wrap: anywhere; }
.eyebrow { font-size: 11px; letter-spacing: .16em; color: var(--accent); font-weight: 800; margin: 0; }
.dialog-body { padding: 16px 24px 24px; max-height: calc(100dvh - 110px); overflow-y: auto; }
.dialog-body > .sub:first-child { margin: 0 0 16px; }
.split { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 14px; }
.side { display: grid; gap: 12px; }
.attachment { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; }
.attachment img { width: 64px; height: 64px; object-fit: contain; border-radius: var(--r-sm); background: var(--panel-2); border: 1.5px solid var(--line); }
.where-big { font-size: 16px; font-weight: 700; margin: 0; }
.where-big .is-out { color: var(--err); }
.scene { width: 100%; max-height: 46vh; object-fit: contain; border-radius: var(--r-sm); background: var(--panel-2); }
.scene-wrap { position: relative; border-radius: var(--r-sm); overflow: hidden; }
.scene-wrap .scene { max-height: none; border-radius: 0; }
.outline { position: absolute; border: 3px solid var(--accent); border-radius: 8px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); animation: pulse 1.6s ease-in-out 2; }
@keyframes pulse { 50% { border-color: #fff; } }
.box-top { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.box-info { flex: 1 1 260px; display: grid; gap: 4px; min-width: 0; }
.box-info .head-actions { margin-top: 12px; }
.label-card { flex: none; width: 132px; display: grid; justify-items: center; gap: 6px; background: #fff; color: #000; border: 1.5px dashed #c8c8c8; border-radius: var(--r); padding: 12px; }
.label-card .qr { width: 100%; height: auto; }
.label-card.as-image { width: min(100%, 320px); padding: 6px; }
.label-card.as-image img { width: 100%; }
.code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; letter-spacing: .06em; font-size: 15px; }
details.edit { border: 1.5px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-top: 22px; }
details.edit summary { cursor: pointer; font-weight: 700; }
details.edit[open] summary { margin-bottom: 16px; }
details.edit .actions { margin-top: 4px; }
.keys { list-style: none; padding: 0; margin: 8px 0 14px; display: grid; gap: 8px; }
.secret code { word-break: break-all; background: var(--accent-soft); padding: 4px 6px; border-radius: 6px; display: inline-block; margin-top: 6px; }

/* Add */
.step .with-button { margin-bottom: 4px; }
#new-box { margin-top: 14px; }
.pick { display: flex; flex-wrap: wrap; gap: 10px; }
.scan { padding: 16px 18px; }
.scan-head { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.scan-head > span { flex: 1; min-width: 0; }
.scan-head img, .ph-mini { width: 60px; height: 60px; object-fit: cover; border-radius: var(--r-sm); background: var(--panel-2); flex: none; }
.found { display: grid; grid-template-columns: 22px 84px minmax(0, 1fr); gap: 14px; align-items: start; padding: 14px 0 0; margin-top: 14px; border-top: 1px solid var(--line); }
.found > input[type=checkbox] { margin-top: 32px; }
.found.off { opacity: .45; }
.found img { width: 84px; height: 84px; object-fit: contain; background: var(--panel-2); border-radius: var(--r-sm); }
.found-fields { display: grid; gap: 8px; min-width: 0; }
.found-fields input, .found-fields select { padding: 9px 12px; font-size: 15px; }
.found-fields input[data-name] { font-weight: 700; }
.found-row { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px; }
.savebar { position: sticky; bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; justify-content: center; padding: 10px 0 0; z-index: 4; }
.savebar button { box-shadow: var(--shadow-lg); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* Labels */
.picklist { display: grid; gap: 8px; margin: 0 0 20px; }
.pickrow { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm); cursor: pointer; }
.pickrow span { flex: 1; display: grid; min-width: 0; }
.pickrow strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pickrow small { color: var(--muted); text-transform: capitalize; }
.pickrow code { font-weight: 700; color: var(--muted); }
.sheet-preview { padding: 14px; }
.sheet-preview img { width: 100%; max-width: 620px; margin: 0 auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.sheet-preview figcaption { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; color: var(--muted); font-size: 14px; }

/* Scanner */
.scan-view { position: relative; aspect-ratio: 1; max-height: 56vh; margin: 0 auto 16px; border-radius: var(--r); background: #000; overflow: hidden; display: grid; place-items: center; }
.scan-view video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .3); pointer-events: none; }
.scan-msg { position: relative; z-index: 1; margin: 0 20px; color: #fff; text-align: center; font-size: 14px; line-height: 1.5; background: rgba(0, 0, 0, .55); padding: 10px 14px; border-radius: var(--r-sm); }
.scan-type { display: flex; gap: 10px; margin-top: 12px; }
.scan-view.no-camera { aspect-ratio: auto; min-height: 140px; }
.scan-view.no-camera .scan-frame { display: none; }
.scan-type input:not(:placeholder-shown) { text-transform: uppercase; }
.scan-type input { font-family: ui-monospace, Menlo, monospace; letter-spacing: .06em; }

/* Status, lock, spinner */
.status { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 60; margin: 0; padding: 11px 18px; border-radius: 999px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); font-size: 14px; text-align: center; }
.status[data-kind="error"] { background: var(--err); color: #fff; border-radius: var(--r); }
.locked { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--bg); padding: 16px; }
.locked .card { text-align: center; display: grid; gap: 14px; justify-items: center; max-width: 380px; padding: 34px 28px; }
.locked p { color: var(--muted); margin: 0; line-height: 1.55; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; flex: none; }
.primary .spin { border-color: rgba(255, 255, 255, .4); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(1turn); } }

/* Phones */
@media (max-width: 720px) {
  .top { padding-left: 16px; padding-right: 12px; }
  .brand h1 { font-size: 17px; }
  main { padding: 14px 16px 32px; }
  .card { padding: 18px; }
  .head-actions { width: 100%; }
  .head-actions > * { flex: 1; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .grid.small { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search { top: calc(62px + env(safe-area-inset-top)); }
  dialog, dialog.is-wide { width: 100%; max-width: 100%; max-height: calc(100dvh - 10px - env(safe-area-inset-top)); margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .dialog-header { padding: 18px 16px 0 18px; }
  .dialog-body { padding: 14px 18px calc(24px + env(safe-area-inset-bottom)); max-height: calc(100dvh - 100px - env(safe-area-inset-top)); }
  .split { grid-template-columns: 1fr; gap: 16px; }
  .pair.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pair.three .field:first-child { grid-column: 1 / -1; }
  .box-top { gap: 16px; }
  .label-card { width: 112px; }
  .found { grid-template-columns: 22px 72px minmax(0, 1fr); gap: 12px; }
  .found img { width: 72px; height: 72px; }
  .found-row { grid-template-columns: 72px minmax(0, 1fr); }
}
@media (max-width: 340px) { .brand h1 { display: none; } }
.dialog-body .tile .where { display: none; }
