/* Tinventory — dark, desktop-and-phone stylesheet.
   Type floor is 11px; serif is reserved for titles and big numbers. */
:root {
  color-scheme: dark;
  --accent: #aac3df;
  --accent-surface: #253449;
  --ink: #e3e9f1;
  --muted: #a0aec0;
  --faint: #8d9bb0;
  --page: #10151d;
  --surface: #1a2230;
  --surface-deep: #151c26;
  --surface-raised: #202b3a;
  --surface-hover: #29374a;
  --input: #131b26;
  --line: #303c4d;
  --copper: #d0ad81;
  --focus: #d6b78e;
  --success: #a4c9b0;
  --error: #ecb0a8;
  --error-surface: #36262d;
  --error-border: #68434d;
  --serif: Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --shadow: 0 8px 28px #00000024;
  --sidebar: 236px;
  --print-sheet-bar: 60px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
  scrollbar-color: #52647f var(--surface-deep);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: wait; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--accent); }
a img { border: 0; }
[hidden] { display: none !important; }
button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
::selection { background: #3b5878; color: var(--ink); }
select option { background: var(--input); color: var(--ink); }
input:-webkit-autofill { -webkit-text-fill-color: var(--ink); box-shadow: 0 0 0 1000px var(--input) inset; caret-color: var(--ink); }
input::placeholder { color: var(--faint); }

.skip-link { position: fixed; left: 20px; top: -100px; z-index: 99; padding: 12px; background: var(--surface-raised); }
.skip-link:focus { top: 12px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.6; }

/* ---------- Sign-in and administration ---------- */
.sign-in { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.sign-in-card { width: min(100%, 380px); text-align: center; }
.sign-in-brand { justify-content: center; margin-bottom: 28px; }
.sign-in-brand h1 { font-size: 40px; }
.sign-in-brand .brand-symbol { width: 48px; height: 52px; }
.sign-in-brand .brand-symbol svg { width: 35px; }
.sign-in-card .access-form { text-align: left; margin-top: 24px; }
.sign-in-card .access-form button { margin-top: 6px; }
#sign-in-status:empty { display: none; }
.google-sign-in { display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 9px 12px; border: 1px solid #747775; border-radius: 4px; color: #1f1f1f; background: #fff; font-family: 'Google Sans', Arial, sans-serif; font-size: 14px; line-height: 20px; font-weight: 500; text-decoration: none; }
.google-sign-in:hover { box-shadow: 0 1px 3px #0006; background: #f8faff; }
.google-sign-in svg { width: 20px; height: 20px; flex-shrink: 0; }
.access-form { display: grid; gap: 10px; }
.access-form label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.access-form input, .access-form select { width: 100%; min-width: 0; min-height: 38px; padding: 8px 10px; color: var(--ink); background: var(--input); border: 1px solid var(--line); border-radius: 6px; }
.account-menu { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.current-user { font-size: 12px; color: var(--ink); overflow-wrap: anywhere; min-width: 0; }
.account-menu .text-button { flex-shrink: 0; }
.account-google-link { text-align: left; margin-bottom: 10px; }
.account-google-email { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; margin-bottom: 10px; }
.google-link-dialog { width: min(440px, calc(100% - 32px)); max-height: calc(100svh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--surface); }
.google-link-dialog::backdrop { background: #070b14ad; backdrop-filter: blur(3px); }
.google-link-form { padding: 20px 26px 26px; gap: 16px; }
.google-link-form p { margin: 0; }
#google-link-status:empty { display: none; }
.admin-page { max-width: 1100px; }
.admin-intro { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.admin-intro p { margin: 0; }
.admin-section { margin: 24px 0; }
.admin-section h2 { margin-bottom: 14px; }
.admin-users { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.admin-user { padding: 18px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; grid-template-columns: 1fr 1fr; }
.admin-user-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; grid-column: 1 / -1; margin-bottom: 4px; }
.admin-user-heading strong { overflow-wrap: anywhere; min-width: 0; font-weight: 600; }
.admin-google-email { grid-column: 1 / -1; margin: 0 0 4px; overflow-wrap: anywhere; }
.admin-user > label:first-of-type { grid-column: 1 / -1; }
.admin-user-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.access-active { color: var(--success); }
.access-disabled { color: var(--error); background: var(--error-surface); }
.access-pending { color: var(--copper); }
.admin-add-user { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 16px 18px; }
.admin-add-user summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.admin-create-form { margin-top: 18px; grid-template-columns: minmax(160px, 2fr) 1fr 1fr auto; align-items: end; }
.admin-sessions { display: grid; gap: 10px; }
.admin-session { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 18px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; }
.admin-session > div { min-width: 0; }
.admin-session strong { overflow-wrap: anywhere; }
.admin-session dl { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 12px 0 0; }
.admin-session dt { color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.admin-session dd { margin: 0; font-size: 12px; }
@media (max-width: 1100px) {
  .admin-users { grid-template-columns: 1fr; }
  .admin-create-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  body.signed-out { padding-bottom: 0; }
  .admin-create-form > label:first-child, .admin-create-form > button { grid-column: 1 / -1; }
  .admin-session { align-items: flex-start; gap: 12px; padding: 14px; }
  .admin-session dl { display: grid; gap: 9px; }
  .admin-user { padding: 14px; }
  .sheet-foot .account-google-link, .sheet-foot .account-google-email { flex-basis: 100%; margin-bottom: 0; }
}

/* ---------- Sidebar ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); padding: 28px 18px 20px; background: var(--surface-deep); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; z-index: 3; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; font-family: var(--serif); font-size: 24px; letter-spacing: -.6px; font-weight: bold; white-space: nowrap; color: var(--ink); }
.brand small { display: block; font-family: system-ui, sans-serif; font-size: 11px; letter-spacing: .2px; font-weight: 400; margin-top: 4px; color: var(--muted); }
.brand-symbol { width: 36px; height: 40px; display: grid; place-items: center; background: var(--accent-surface); border-radius: 10px; color: var(--copper); flex-shrink: 0; }
.brand-symbol svg { width: 27px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.nav-label { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); margin: 30px 0 10px 12px; font-weight: 700; }
#navigation { display: grid; gap: 3px; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 8px 12px; text-decoration: none; border-radius: 7px; color: var(--muted); font-size: 13px; font-weight: 500; }
.nav-item:hover { background: var(--surface-hover); }
.nav-item.active { color: var(--accent); background: var(--accent-surface); }
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-item .count { margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums; opacity: .75; }
.sidebar-scan { margin-top: 18px; width: 100%; }
.sidebar-foot { margin-top: auto; color: var(--muted); font-size: 12px; padding: 16px 8px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.refresh-meta { font-size: 11px; color: var(--faint); }
.workspace { margin-left: var(--sidebar); }

/* ---------- Buttons ---------- */
.button { border: 1px solid transparent; border-radius: 6px; min-height: 38px; padding: 8px 15px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; text-decoration: none; line-height: 1.3; white-space: nowrap; transition: background .15s, transform .15s; }
.button:active { transform: translateY(1px); }
.button-primary { background: var(--accent); color: #122235; }
.button-primary:hover { background: #bed3eb; }
.button-outline { background: var(--surface); border-color: var(--line); }
.button-outline:hover { background: var(--surface-hover); }
.button-danger { background: #7e3c48; color: var(--ink); }
.button-subtle { background: var(--accent-surface); color: var(--accent); }
.button svg { width: 17px; height: 17px; }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0; border: 0; border-radius: 6px; background: transparent; font-size: 16px; color: var(--muted); }
.icon-button:hover { background: var(--surface-hover); color: var(--accent); }
.icon-button.active, .icon-button[aria-pressed="true"] { background: var(--surface-hover); box-shadow: 0 1px 4px #00000024; color: var(--accent); }
.text-button { border: 0; padding: 4px 0; background: transparent; font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.text-button:hover { color: var(--accent); }

/* ---------- Page heading and toolbar ---------- */
main { padding: 26px 36px 40px; max-width: 1760px; margin: auto; outline: none; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; min-height: 40px; }
h1 { font-family: var(--serif); font-size: 32px; line-height: 1.1; letter-spacing: -.8px; font-weight: 400; margin: 0; display: flex; align-items: center; gap: 12px; }
h2 { font-family: var(--serif); font-size: 21px; font-weight: 400; letter-spacing: -.3px; margin: 0; }
.count-pill { font-family: system-ui, sans-serif; font-size: 12px; letter-spacing: 0; font-weight: 500; background: var(--accent-surface); color: var(--muted); padding: 4px 8px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.page-actions { display: flex; align-items: center; gap: 8px; }
.view-toggle { padding: 3px; background: var(--surface-raised); display: flex; border-radius: 6px; }
.view-toggle .icon-button { width: 30px; height: 28px; }
.view-toggle svg { width: 15px; height: 15px; }
.eyebrow { font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; font-weight: 700; color: var(--muted); margin-bottom: 8px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 16px; }
.search-field { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 0 12px; min-height: 38px; flex: 1 1 260px; min-width: 200px; }
.search-field svg { width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 1.8; flex-shrink: 0; }
.search-field input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 13px; color: var(--ink); min-height: 36px; }
.search-field:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.search-field input:focus-visible { outline: none; }
.search-field kbd { font-family: inherit; color: var(--faint); font-size: 11px; border: 1px solid var(--line); padding: 1px 6px; border-radius: 3px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.filters label { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; color: var(--muted); white-space: nowrap; }
.filters select { border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-height: 34px; border-radius: 5px; padding: 6px 26px 6px 10px; font-size: 12px; max-width: 200px; }
.sort-group { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.sort-order { width: 30px; height: 30px; }
.sort-order svg { width: 15px; height: 15px; }
.sort-order.asc svg { transform: scaleY(-1); }
.mobile-nav, .mobile-filters, .sheet { display: none; }

/* ---------- Grid cards ---------- */
.record-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.record-card { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; box-shadow: 0 2px 6px #00000020; transition: box-shadow .2s, transform .2s; }
.record-card:hover { box-shadow: 0 6px 18px #00000040; transform: translateY(-1px); }
.record-card.cursor, .record-table tr.cursor td { outline: 2px solid var(--focus); outline-offset: -2px; }
.card-link { display: block; text-align: left; width: 100%; padding: 0; border: 0; background: none; color: inherit; }
.card-link:focus-visible { outline-offset: -3px; }
.card-image { height: 150px; position: relative; background: var(--surface-raised); overflow: hidden; display: grid; place-items: center; }
.card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.record-card:hover .card-image img { transform: scale(1.03); }
.image-empty { background: radial-gradient(ellipse at 50% 44%, #263449, #182230); color: var(--faint); }
.image-empty svg { width: 54px; height: 54px; fill: none; stroke: currentColor; stroke-width: .9; opacity: .65; }
.image-empty small { position: absolute; bottom: 14px; text-transform: uppercase; letter-spacing: 1.2px; font-size: 11px; color: var(--muted); }
.card-image .badge { position: absolute; left: 9px; top: 9px; background: #18222fee; box-shadow: 0 1px 4px #00000024; }
.card-image .group-count { position: absolute; right: 9px; top: 9px; }
.group-count { font-family: var(--mono); font-size: 12px; font-weight: 600; background: #18222fee; color: var(--copper); border: 1px solid var(--line); border-radius: 5px; padding: 3px 7px; line-height: 1; white-space: nowrap; }
.badge { font-size: 11px; line-height: 1; letter-spacing: .4px; display: inline-flex; gap: 4px; align-items: center; border-radius: 4px; padding: 5px 7px; font-weight: 600; white-space: nowrap; color: var(--muted); background: var(--accent-surface); }
.badge-open { color: #e2c595; background: #3c3020 !important; }
.badge-sealed { color: #b4d5c0; }
.badge-gone { color: #bac3cf; background: #2c3440 !important; }
.badge-expected { color: #bdd3f0; background: #28394f !important; }
.badge-desired { color: #d9c0e0; background: #3b2d43 !important; }
.card-content { padding: 12px 13px 10px; min-width: 0; }
.card-maker { font-size: 11px; text-transform: uppercase; letter-spacing: .9px; color: var(--muted); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-title { font-family: var(--serif); font-size: 17px; line-height: 1.2; font-weight: 400; letter-spacing: -.2px; margin: 4px 0 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 20px; }
.card-title .group-count { font-size: 11px; vertical-align: middle; margin-left: 4px; }
.card-family { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 14px; }
.card-foot { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); min-height: 22px; }
.asset-tag { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .3px; }
.card-age { color: var(--copper); }
.group-members { grid-column: 1 / -1; display: grid; gap: 6px; padding: 4px 0 8px 12px; border-left: 2px solid var(--line); margin-left: 6px; }

/* ---------- Compact list (phone, and group members everywhere) ---------- */
.record-list { display: grid; grid-template-columns: 1fr; gap: 6px; }
.record-list .record-card, .group-members .record-card { border-radius: 7px; }
.record-list .card-link, .group-members .card-link { display: flex; align-items: center; }
.record-list .card-image, .group-members .card-image { height: 72px; width: 84px; flex-shrink: 0; }
.record-list .card-image .badge, .group-members .card-image .badge { left: 5px; top: 5px; padding: 4px 5px; font-size: 10px; }
.record-list .card-image .group-count, .group-members .card-image .group-count { right: 5px; top: 5px; font-size: 11px; padding: 3px 5px; }
.record-list .image-empty svg, .group-members .image-empty svg { width: 30px; height: 30px; }
.record-list .image-empty small, .group-members .image-empty small { display: none; }
.record-list .card-content, .group-members .card-content { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(130px, .7fr); grid-template-rows: auto auto; align-items: center; column-gap: 16px; width: 100%; padding: 10px 14px; }
.record-list .card-maker, .group-members .card-maker { grid-column: 1; grid-row: 1; }
.record-list .card-title, .group-members .card-title { grid-column: 1; grid-row: 2; margin: 3px 0 0; font-size: 17px; min-height: auto; }
.record-list .card-family, .group-members .card-family { grid-column: 2; grid-row: 1 / 3; }
.record-list .card-foot, .group-members .card-foot { grid-column: 3; grid-row: 1 / 3; border: 0; margin: 0; padding: 0; }

/* ---------- Table (desktop list view) ---------- */
.record-table-wrap { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: clip; }
.record-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.record-table th { position: sticky; top: 0; z-index: 1; background: var(--surface-deep); text-align: left; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); padding: 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.record-table th > span, .record-table th > button { display: block; width: 100%; padding: 9px 10px; text-align: left; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; background: none; border: 0; }
.record-table th > button:hover { color: var(--accent); background: var(--surface-hover); }
.record-table th[aria-sort] > button { color: var(--accent); }
.record-table th[aria-sort] > button::after { content: ' ↑'; }
.record-table th[aria-sort="descending"] > button::after { content: ' ↓'; }
.record-table th.num, .record-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.record-table th.num > button { text-align: right; }
.record-table td { padding: 5px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-table tbody tr:last-child td { border-bottom: 0; }
.record-table tr[data-open], .record-table tr[data-toggle-group] { cursor: pointer; }
.record-table tr[data-open]:hover td, .record-table tr[data-toggle-group]:hover td { background: var(--surface-hover); }
.record-table .thumb-cell { width: 44px; padding: 4px 4px 4px 8px; }
.record-table .thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; display: block; background: var(--surface-raised); }
.record-table .thumb.image-empty { display: grid; place-items: center; }
.record-table .thumb.image-empty svg { width: 20px; height: 20px; }
.record-table .title-cell { font-weight: 500; }
.record-table .title-cell small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.record-table .asset-tag { font-size: 12px; color: var(--ink); }
.record-table tr.member-row td { background: #161e2a; }
.record-table tr.member-row td:first-child { padding-left: 26px; }
.record-table .chevron { display: inline-block; width: 14px; color: var(--faint); transition: transform .15s; }
.record-table tr[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.record-table .muted-cell { color: var(--muted); }

/* ---------- Status, load more ---------- */
.collection-status:empty { display: none; }
.collection-status { padding: 44px 24px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 13px; margin-bottom: 16px; line-height: 1.7; }
.collection-status strong { display: block; font-family: var(--serif); font-size: 24px; font-weight: 400; color: var(--accent); margin-bottom: 8px; }
.collection-status.error { background: var(--error-surface); border-color: var(--error-border); color: var(--error); }
.load-more-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 0 10px; }
.load-more-wrap > span { font-size: 12px; color: var(--faint); }
#load-sentinel, #labels-sentinel { width: 100%; height: 1px; }

/* ---------- Labels ---------- */
.labels-toolbar .search-field { max-width: 640px; }
.labels-sort { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.labels-sort select { min-height: 38px; max-width: 100%; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); padding: 6px 8px; }
/* Wraps within the toolbar so a narrow column (beside the print sheet dock, or a 320px phone) never pushes buttons out of it. */
.labels-toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; max-width: 100%; }
#labels-sync { min-width: 94px; }
#labels-sync:disabled { cursor: default; }
.labels-collector { color: var(--faint); font-size: 12px; margin: 0 0 6px; line-height: 1.5; }
.labels-schedule { color: var(--faint); font-size: 12px; margin: 0 0 22px; line-height: 1.5; }
.labels-sync-message { color: var(--error); font-size: 12px; line-height: 1.5; margin: -12px 0 22px; overflow-wrap: anywhere; }
.labels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 24px; align-items: start; }
.label-tile { position: relative; display: block; aspect-ratio: 1; min-width: 0; border-radius: 50%; background: var(--surface-raised); box-shadow: 0 3px 16px #00000035; transition: transform .18s, box-shadow .18s; }
.label-tile:hover { transform: translateY(-3px); box-shadow: 0 7px 24px #00000055; }
.label-tile img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: contain; }
.label-tile:focus-visible { outline-offset: 5px; }
h1.label-heading { font-size: clamp(26px, 3vw, 34px); line-height: 1.2; overflow-wrap: anywhere; }
.label-back { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; margin: 0 0 24px; text-decoration: none; }
.label-back:hover { text-decoration: underline; }
.label-back svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.label-detail-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(250px, 1fr); align-items: start; gap: 40px; max-width: 1100px; }
.label-artwork { min-width: 0; }
.label-artwork a { display: block; }
.label-artwork img { display: block; width: 100%; max-height: 70vh; object-fit: contain; }
.label-information { padding: 24px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.label-information h2 { font-size: 25px; }
.label-description { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); line-height: 1.7; margin: 18px 0; }
.label-fields { margin: 24px 0; display: grid; gap: 18px; }
.label-fields dt { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.label-fields dd { margin: 0; line-height: 1.5; overflow-wrap: anywhere; }
.label-topics { margin: 0 0 24px; }
.label-topics h3 { font-size: 12px; font-weight: 400; color: var(--muted); margin: 0 0 8px; }
.label-topics ul { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.label-topics li { padding: 4px 8px; border-radius: 5px; background: var(--surface-raised); font-size: 12px; overflow-wrap: anywhere; }
.label-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Print sheet ---------- */
/* Picking labels onto an Avery round sheet: gallery select mode, a desktop dock, and a phone bar plus bottom sheet. */
#labels-print-sheet[aria-pressed="true"] { background: var(--accent-surface); border-color: #52647f; color: var(--accent); }
.labels-grid.selecting .label-tile { cursor: copy; }
.labels-grid.selecting .label-tile:hover { box-shadow: 0 0 0 3px var(--accent), 0 7px 24px #00000055; }
.label-tile.on-print-sheet { box-shadow: 0 0 0 3px var(--copper), 0 3px 16px #00000035; }
.print-sheet-badge { position: absolute; top: 3%; right: 3%; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; display: grid; place-items: center; background: var(--copper); color: #20160b; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; box-shadow: 0 2px 8px #00000066; pointer-events: none; }
/* The exact complement of the JS phone query (max-width: 760px), so fractional widths get one layout or the other. */
@media (width > 760px) {
  .labels-page.has-print-sheet { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
  /* The dock comes first in the DOM for keyboard order; explicit placement keeps it on the right. */
  .has-print-sheet > .print-sheet-dock { grid-column: 2; grid-row: 1; }
  .has-print-sheet > #labels-browser, .has-print-sheet > #label-detail { grid-column: 1; grid-row: 1; min-width: 0; }
}
.print-sheet-dock { position: sticky; top: 20px; max-height: calc(100dvh - 40px); overflow: auto; overscroll-behavior: contain; padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow); }
.print-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.print-sheet-head h2 { font-size: 21px; }
.print-sheet-summary { margin: 5px 0 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.print-sheet-done { min-height: 32px; padding: 5px 12px; }
.print-sheet-field { display: grid; gap: 6px; margin-bottom: 14px; font-size: 12px; color: var(--muted); }
.print-sheet-field select { width: 100%; min-height: 38px; border: 1px solid var(--line); border-radius: 5px; background: var(--input); color: var(--ink); padding: 6px 8px; font-size: 13px; }
.print-sheet-status { margin: 8px 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.print-sheet-status.error { color: var(--error); overflow-wrap: anywhere; }
/* The preview is a to-scale sheet of paper, so it stays light in the dark UI. */
.print-sheet-paper { position: relative; width: 100%; aspect-ratio: 8.5 / 11; background: #f7f6f2; border-radius: 2px; box-shadow: 0 1px 2px #00000080, 0 10px 30px #00000059; color: #4d5663; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.print-sheet-spot { position: absolute; aspect-ratio: 1; border-radius: 50%; }
.print-sheet-spot-button { display: grid; place-items: center; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.print-sheet-paper button:focus-visible { outline-color: #1f5f9e; }
.print-sheet-spot.is-open .print-sheet-spot-button { border: 1.5px dashed #a3abb6; background: #fff; }
.print-sheet-spot.is-open .print-sheet-spot-button:hover { border-color: #5d7899; color: #2c4a6e; }
.print-sheet-spot.is-used .print-sheet-spot-button { border: 1px solid #c6cbd2; background: repeating-linear-gradient(-45deg, #dcdfe4 0 5px, #eef0f2 5px 10px); color: #5e6773; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; }
/* Only filled spots claim touch gestures, so the bottom sheet still scrolls from anywhere else. */
.print-sheet-spot.is-filled { touch-action: none; }
.print-sheet-spot.is-filled .print-sheet-spot-button { position: relative; cursor: grab; box-shadow: 0 0 0 1px #0000001f; }
.print-sheet-spot img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
/* The ID tag in spot-diameter percentages, as the PDF draws it: 25 modules wide (21 + 2·2 quiet), each 13.5/21 % of the
   diameter, 29.9 tall with the ID line, rounded 1.5 modules, its bottom 6 % above the cut circle's bottom. */
.print-sheet-tag { position: absolute; left: 50%; bottom: 6%; display: none; width: 16.071%; aspect-ratio: 25 / 29.9; translate: -50% 0; border-radius: 6% / 5%; background: #fff; color: #000; box-shadow: .4px 1px 2px #00000059, 0 0 1px #00000033; pointer-events: none; }
.print-sheet-paper.with-codes .print-sheet-tag { display: block; }
/* Spots are buttons, so the outline-icon stroke from `button svg` must not reach the modules. */
.print-sheet-tag svg { display: block; width: 100%; height: 100%; fill: currentColor; stroke: none; }
.print-sheet-tag rect { fill: #9aa1aa; }
.print-sheet-remove { position: absolute; top: 0; right: 0; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: #152031ed; color: var(--ink); font-size: 12px; box-shadow: 0 1px 4px #00000040; opacity: 0; transition: opacity .15s; }
.print-sheet-spot:hover .print-sheet-remove, .print-sheet-spot:focus-within .print-sheet-remove { opacity: 1; }
@media (hover: none) { .print-sheet-remove { opacity: 1; } }
.print-sheet-spot.dragging { z-index: 2; transform: translate(var(--drag-x, 0), var(--drag-y, 0)); }
.print-sheet-spot.dragging .print-sheet-spot-button { cursor: grabbing; transform: scale(1.06); box-shadow: 0 12px 28px #00000066; }
.print-sheet-spot.dragging .print-sheet-remove { display: none; }
.print-sheet-paper.no-drop .print-sheet-spot.dragging .print-sheet-spot-button { cursor: no-drop; }
.print-sheet-spot.drop-target .print-sheet-spot-button { outline: 3px solid #2f6db0; outline-offset: 2px; }
.print-sheet-spot.no-drop .print-sheet-spot-button { outline: 3px solid #b6454f; outline-offset: 2px; cursor: no-drop; }
/* A label picked for moving by tap or keyboard; the ring is a shadow so the focus outline stays distinct. */
.print-sheet-spot.is-moving { z-index: 1; }
.print-sheet-spot.is-moving .print-sheet-spot-button { transform: scale(1.06); box-shadow: 0 0 0 3px #f7f6f2, 0 0 0 6px #2f6db0, 0 8px 20px #00000059; }
.print-sheet-paper:has(.is-moving) .print-sheet-spot.is-open .print-sheet-spot-button { border-color: #2f6db0; color: #2c4a6e; }
.print-sheet-hint { margin: 10px 0 12px; font-size: 11px; line-height: 1.5; color: var(--faint); text-align: center; }
.print-sheet-bleed, .print-sheet-codes { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 2px 8px; font-size: 12px; line-height: 1.4; color: var(--muted); cursor: pointer; }
.print-sheet-bleed input, .print-sheet-codes input { margin: 1px 0 0; accent-color: var(--accent); }
.print-sheet-codes { margin-top: 10px; }
.print-sheet-codes small { grid-column: 2; font-size: 11px; color: var(--faint); }
.print-sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.print-sheet-actions .button { flex: 1 1 auto; }
.print-sheet-actions .button-primary { flex-basis: 100%; }
.print-sheet-dock [aria-disabled="true"], .print-sheet-dialog [aria-disabled="true"], .print-sheet-bar [aria-disabled="true"] { cursor: wait; opacity: .6; }
.print-sheet-recent { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); }
.print-sheet-recent > summary { padding: 4px 0; font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.print-sheet-recent-list { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.print-sheet-recent-item { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 6px 10px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-raised); }
.print-sheet-mini { position: relative; grid-row: span 2; align-self: start; width: 40px; aspect-ratio: 8.5 / 11; border-radius: 1px; background: #f2f1ec; }
.print-sheet-mini-spot { position: absolute; aspect-ratio: 1; overflow: hidden; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 1px #b8bec7; }
.print-sheet-mini-spot.is-used { background: #cfd3d9; box-shadow: none; }
.print-sheet-mini-spot.is-missing { background: var(--error); box-shadow: none; }
.print-sheet-mini-spot img { display: block; width: 100%; height: 100%; object-fit: cover; }
.print-sheet-recent-text { display: grid; gap: 3px; min-width: 0; }
.print-sheet-recent-text strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.print-sheet-recent-text small { font-size: 11px; line-height: 1.4; color: var(--muted); }
.print-sheet-recent-text .print-sheet-missing { color: var(--error); }
.print-sheet-recent-text .print-sheet-recent-ids { font-variant-numeric: tabular-nums; }
.print-sheet-recent-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.print-sheet-recent-actions button { padding: 4px 0; border: 0; background: none; font-size: 12px; font-weight: 600; color: var(--accent); }
.print-sheet-recent-actions button:hover { text-decoration: underline; text-underline-offset: 3px; }
.print-sheet-recent-actions button:disabled { cursor: not-allowed; opacity: .45; text-decoration: none; }
.print-sheet-more { width: 100%; margin-top: 10px; }
/* Phone: a bar above the tab bar (whose height is 61px plus the bottom inset) opens the editor as a bottom sheet. */
.print-sheet-bar { position: fixed; left: 0; right: 0; bottom: calc(61px + max(6px, env(safe-area-inset-bottom))); z-index: 5; height: var(--print-sheet-bar); display: flex; align-items: center; gap: 10px; padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: #1d2736f7; backdrop-filter: blur(12px); }
.print-sheet-bar-open { display: flex; flex: 1; align-items: center; gap: 12px; min-width: 0; height: 100%; padding: 0; border: 0; background: none; text-align: left; }
.print-sheet-dots { display: grid; gap: 3px; flex-shrink: 0; }
.print-sheet-dots i { width: 9px; height: 9px; border: 1px dashed var(--faint); border-radius: 50%; }
.print-sheet-dots i.is-filled { border: 0; background: var(--copper); }
.print-sheet-dots i.is-used { border: 0; background: var(--line); }
.print-sheet-bar-text { display: grid; gap: 2px; min-width: 0; }
.print-sheet-bar-text strong { font-size: 13px; }
.print-sheet-bar-text small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.print-sheet-bar .button { flex-shrink: 0; min-height: 40px; padding: 8px 14px; }
.print-sheet-dialog { position: fixed; inset: auto 0 0 0; width: 100%; max-width: 100%; max-height: calc(100dvh - 24px); margin: 0; padding: 0; border: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; background: var(--surface); color: var(--ink); overflow: auto; overscroll-behavior: contain; box-shadow: 0 -16px 60px #00000070; }
.print-sheet-dialog::backdrop { background: #070b14ad; backdrop-filter: blur(3px); }
.print-sheet-dialog-content { padding: 0 16px max(18px, env(safe-area-inset-bottom)); }
.print-sheet-dialog .print-sheet-head { position: sticky; top: 0; z-index: 3; margin: 0 -16px 14px; padding: 22px 16px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.print-sheet-dialog .print-sheet-head::before { content: ''; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line); }
.print-sheet-dialog .print-sheet-paper { max-width: 400px; margin: 0 auto; }
.print-sheet-dialog .print-sheet-field select { font-size: 16px; }
.print-sheet-dialog .print-sheet-actions, .print-sheet-dialog .print-sheet-bleed, .print-sheet-dialog .print-sheet-codes, .print-sheet-dialog .print-sheet-hint { max-width: 400px; margin-left: auto; margin-right: auto; }
@media (760px < width <= 1250px) {
  .has-print-sheet .label-detail-layout { grid-template-columns: 1fr; gap: 24px; }
  .has-print-sheet .label-artwork { max-width: 480px; }
}
@media (760px < width <= 980px) {
  .labels-page.has-print-sheet { grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; }
}
@media (max-width: 760px) {
  body.print-sheet-active .labels-page { padding-bottom: calc(92px + var(--print-sheet-bar)); }
  body.print-sheet-active #toast { bottom: calc(85px + var(--print-sheet-bar) + env(safe-area-inset-bottom)); }
}

/* ---------- Cellar ---------- */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 18px 0; margin-bottom: 22px; box-shadow: var(--shadow); }
.stat { padding: 0 22px; border-right: 1px solid var(--line); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat-label { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 11px; font-weight: 500; margin-bottom: 8px; white-space: nowrap; }
.stat-label svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 1.6; fill: none; flex-shrink: 0; }
.stat-number { font-family: var(--serif); font-size: 28px; line-height: 1; letter-spacing: -.6px; white-space: nowrap; }
.stat-number small { font-family: system-ui, sans-serif; font-size: 12px; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.stat-meta { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.cellar-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.cellar-column { display: grid; gap: 18px; min-width: 0; }
.panel { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 16px 18px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { font-size: 19px; }
.panel-head a { font-size: 12px; white-space: nowrap; }
.panel .record-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.panel .card-image { height: 118px; }
.panel .card-title { font-size: 16px; }
.panel .card-content { padding: 9px 10px 8px; }
.panel .card-foot { margin-top: 7px; padding-top: 6px; }
.attention-list, .bar-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.attention-list a { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; background: var(--surface-raised); text-decoration: none; color: var(--ink); font-size: 13px; }
.attention-list a:hover { background: var(--surface-hover); }
.attention-list .zero { color: var(--faint); }
.attention-list strong { font-family: var(--mono); font-weight: 600; font-size: 13px; color: var(--copper); }
.attention-list .zero strong { color: var(--faint); }
.bar-list li { display: grid; grid-template-columns: minmax(80px, 1fr) minmax(0, 2fr) 42px; align-items: center; gap: 10px; font-size: 12px; }
.bar-list a { color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-list a:hover { color: var(--accent); }
.bar-list .bar { height: 10px; border-radius: 3px; background: var(--surface-raised); overflow: hidden; }
.bar-list .bar i { display: block; height: 100%; background: var(--accent); opacity: .75; border-radius: 3px; }
.bar-list .n { text-align: right; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.cellar-scan { min-height: 52px; font-size: 15px; gap: 12px; margin-bottom: 18px; display: none; }
#cellar-status { margin-top: 0; }

/* ---------- Dialogs ---------- */
.record-dialog, .scan-dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(960px, calc(100vw - 40px)); max-height: calc(100dvh - 60px); background: var(--surface); color: var(--ink); box-shadow: 0 30px 100px #00000080; }
.record-dialog[open] { display: flex; flex-direction: column; }
.record-dialog::backdrop, .scan-dialog::backdrop, .sheet::backdrop { background: #070b14ad; backdrop-filter: blur(3px); }
.dialog-content, .record-form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 26px 18px; border-bottom: 1px solid var(--line); background: var(--surface-deep); flex-shrink: 0; }
.dialog-header h2 { font-size: 26px; line-height: 1.15; overflow-wrap: anywhere; }
.dialog-header .eyebrow { margin-bottom: 6px; }
.dialog-header .header-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.dialog-subtitle { font-size: 12px; color: var(--muted); margin-top: 7px; line-height: 1.5; }
.back-button { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 600; max-width: 100%; }
.back-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.close-dialog { background: var(--surface-hover); color: var(--muted); border: 1px solid var(--line); width: 32px; height: 32px; font-size: 14px; }
.dialog-body { overflow: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.detail-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
.detail-visual { padding: 22px; border-right: 1px solid var(--line); background: var(--surface-deep); position: sticky; top: 0; max-height: calc(100dvh - 60px - 150px); overflow: auto; }
.detail-main-photo { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 8px; background: var(--surface-raised); display: block; }
.detail-main-placeholder { width: 100%; aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; }
.detail-main-placeholder svg { width: 70px; height: 70px; stroke-width: 1.1; }
.gallery-thumbs { display: flex; gap: 6px; margin-top: 10px; overflow: auto; padding-bottom: 4px; }
.gallery-thumbs button { padding: 0; border: 2px solid transparent; background: transparent; border-radius: 5px; flex-shrink: 0; }
.gallery-thumbs button.selected { border-color: var(--accent); }
.gallery-thumbs img { display: block; width: 48px; height: 48px; object-fit: cover; border-radius: 3px; }
.photo-caption { font-size: 11px; line-height: 1.6; color: var(--muted); margin: 10px 0 0; }
.detail-summary { display: grid; gap: 9px; margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.detail-summary > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.detail-summary strong { font-size: 13px; color: var(--ink); font-weight: 500; text-align: right; }
.detail-content { padding: 20px 26px 24px; min-width: 0; }
.detail-section-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px; margin: 22px 0 12px; }
.detail-section-title:first-child { margin-top: 0; }
.detail-fields { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.detail-field.long { grid-column: 1 / -1; }
.detail-field dt { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.detail-field dd { margin: 0; font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-field dd a { color: var(--accent); text-underline-offset: 3px; }
.detail-field .value-empty { color: var(--faint); }
.reference-link { background: none; border: 0; padding: 0; font-size: inherit; color: var(--accent); text-align: left; text-decoration: underline; text-underline-offset: 3px; line-height: inherit; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { background: var(--accent-surface); padding: 4px 7px; border-radius: 4px; font-size: 12px; color: var(--muted); }
.related-records { display: grid; gap: 6px; }
.related-link { border: 1px solid var(--line); border-radius: 6px; background: var(--surface-raised); padding: 9px 12px; text-align: left; display: flex; align-items: center; gap: 10px; min-width: 0; }
.related-link:hover { background: var(--surface-hover); }
.related-link > span { flex: 1; min-width: 0; }
.related-link strong { display: block; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.related-link small { display: block; color: var(--muted); margin-top: 3px; font-size: 11px; }
.related-link > img { width: 34px; height: 34px; object-fit: cover; border-radius: 4px; }
.related-link > em { font-size: 17px; font-style: normal; color: var(--muted); }
.detail-id { font-size: 11px; font-family: var(--mono); color: var(--faint); overflow-wrap: anywhere; margin-top: 22px; line-height: 1.7; }
.dialog-footer { padding: 13px 26px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); background: var(--surface-deep); flex-shrink: 0; }
.dialog-footer .button-group { display: flex; gap: 8px; align-items: center; }
.pager { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pager .icon-button { width: 30px; height: 30px; }
.pager .icon-button svg { width: 15px; height: 15px; }
.pager .icon-button:disabled { cursor: default; opacity: .3; }
.muted-cell { color: var(--muted); }
.stars { letter-spacing: 1px; color: var(--copper); }
.delete-button { color: var(--error); font-size: 12px; font-weight: 500; text-decoration: none; }

/* ---------- Forms ---------- */
.form-content { padding: 20px 26px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.form-field { display: block; min-width: 0; }
.form-field.full-width { grid-column: 1 / -1; }
fieldset.form-field { border: 0; padding: 0; margin: 0; }
.field-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 7px; color: var(--muted); }
.required-mark { font-weight: 400; color: var(--copper); margin-left: 4px; }
.form-field input:not([type=checkbox]):not([type=file]), .form-field select, .form-field textarea, .scan-manual input { width: 100%; border: 1px solid var(--line); border-radius: 5px; background: var(--input); color: var(--ink); padding: 9px 11px; min-height: 40px; font-size: 13px; }
.form-field textarea { resize: vertical; min-height: 92px; line-height: 1.6; }
.form-field .field-help { display: block; color: var(--faint); font-size: 11px; line-height: 1.5; margin-top: 6px; }
.checkboxes { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 0; }
.checkbox-option { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); padding: 7px 9px; border-radius: 5px; font-size: 12px; color: var(--muted); background: var(--surface-raised); cursor: pointer; }
.checkbox-option:has(input:checked) { background: var(--accent-surface); color: var(--accent); border-color: #52647f; }
.checkbox-option input { accent-color: var(--accent); margin: 0; }
.form-error { font-size: 13px; color: var(--error); line-height: 1.5; padding: 12px 15px; background: var(--error-surface); border: 1px solid var(--error-border); border-radius: 5px; margin: 0 0 18px; }
.form-error:empty { display: none; }
.image-field-gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.image-field-item { position: relative; width: 88px; height: 88px; }
.image-field-item > a > img { width: 100%; height: 100%; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }
.image-field-item > button { position: absolute; top: 4px; right: 4px; border: 0; background: #152031ed; border-radius: 50%; width: 24px; height: 24px; font-size: 11px; color: var(--ink); box-shadow: 0 1px 4px #00000024; }
.upload-label { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; border: 1px dashed #52647f; border-radius: 7px; padding: 10px 15px; font-size: 12px; color: var(--muted); background: var(--surface-raised); margin-top: 10px; min-height: 40px; }
.upload-label input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-label:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.upload-status { font-size: 12px; margin-top: 8px; line-height: 1.6; color: var(--muted); }
.upload-status.error { color: var(--error); }
.form-metadata { font-size: 12px; color: var(--faint); margin: 0 0 18px; }
.field-input-action { display: flex; gap: 8px; align-items: stretch; }
.field-input-action > input { min-width: 0; flex: 1; }
.asset-scan-button { flex-shrink: 0; min-height: 40px; }

/* Reference picker: a searchable combobox with recents and inline create. */
.picker { position: relative; }
.picker-row { display: flex; gap: 6px; align-items: stretch; }
.picker-row > input { flex: 1; min-width: 0; }
.picker-clear { flex-shrink: 0; width: 40px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-raised); color: var(--muted); font-size: 14px; }
.picker-clear:hover { color: var(--accent); background: var(--surface-hover); }
.picker-menu { margin-top: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-raised); max-height: 260px; overflow: auto; display: grid; box-shadow: var(--shadow); }
.picker-group { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); padding: 8px 12px 4px; font-weight: 700; }
.picker-option { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 12px; border: 0; background: none; text-align: left; font-size: 13px; color: var(--ink); min-height: 38px; }
.picker-option:hover, .picker-option.active { background: var(--surface-hover); }
.picker-option img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.picker-option > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-option small { display: block; color: var(--muted); font-size: 11px; }
.picker-option.picker-new { color: var(--accent); font-weight: 600; border-top: 1px solid var(--line); }
.picker-empty { padding: 10px 12px; font-size: 12px; color: var(--muted); }
.picker-selected { font-size: 11px; color: var(--success); margin-top: 6px; display: block; }

/* ---------- Scanner ---------- */
.scan-dialog { width: min(660px, calc(100vw - 40px)); }
.scan-body { padding: 18px 26px 24px; }
.scan-body > .muted { margin: 0 0 14px; }
.camera-preview { position: relative; border-radius: 9px; overflow: hidden; background: #0b111b; aspect-ratio: 4 / 3; }
.camera-preview video { width: 100%; height: 100%; object-fit: cover; }
.camera-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; padding: 30px; }
.scan-guide { position: absolute; inset: 21% 24%; z-index: 1; pointer-events: none; }
.scan-guide i { position: absolute; width: 23px; height: 23px; border: 2px solid #d7e3f2; }
.scan-guide i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 5px; }
.scan-guide i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 5px; }
.scan-guide i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 5px; }
.scan-guide i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 5px; }
.scan-controls { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.scan-controls .button { font-size: 12px; padding: 8px 12px; min-height: 36px; }
.photo-button { position: relative; cursor: pointer; }
.photo-button:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.photo-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
#scan-status { font-size: 12px; line-height: 1.7; color: var(--muted); min-height: 20px; }
#scan-status[data-state=error] { color: var(--error); }
#scan-status[data-state=success] { color: var(--success); }
#scan-results { display: grid; gap: 6px; }
#scan-results .scan-value { font-family: var(--mono); font-size: 16px; overflow-wrap: anywhere; margin: 6px 0 10px; background: var(--surface-hover); padding: 12px; border-radius: 6px; }
.scan-manual { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.scan-manual label { font-size: 12px; color: var(--muted); }
.scan-manual form { display: flex; gap: 8px; margin-top: 8px; }
.scanner-types { font-size: 11px; color: var(--faint); text-align: center; letter-spacing: .3px; margin: 20px 0 0; }

/* ---------- Toast ---------- */
#toast { position: fixed; inset: auto; margin: 0; border: 0; left: calc(50% + var(--sidebar) / 2); bottom: 25px; transform: translateX(-50%); max-width: calc(100vw - 40px); padding: 12px 20px; border-radius: 7px; background: var(--accent); color: #122235; font-size: 13px; box-shadow: 0 6px 25px #00000040; z-index: 50; line-height: 1.5; }
#toast.error { background: var(--error-surface); color: var(--error); border: 1px solid var(--error-border); }

/* ---------- Responsive ---------- */
@media (min-width: 1650px) {
  .record-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
  .panel .record-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 1250px) {
  :root { --sidebar: 212px; }
  .sidebar { padding: 26px 14px 18px; }
  .brand { font-size: 22px; gap: 8px; }
  main { padding: 22px 26px 36px; }
  .record-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .panel .record-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters select { max-width: 170px; }
  .stat { padding: 0 16px; }
  .stat-number { font-size: 25px; }
}
@media (max-width: 980px) {
  :root { --sidebar: 184px; }
  .sidebar { padding: 22px 10px 16px; }
  .brand { font-size: 20px; gap: 7px; }
  .brand small { font-size: 10px; }
  .brand-symbol { width: 31px; height: 36px; }
  .brand-symbol svg { width: 24px; }
  .nav-item { font-size: 12px; padding: 8px 10px; }
  main { padding: 20px 20px 32px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0; overflow: hidden; }
  .stat { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .stat:nth-child(3n) { border-right: 0; }
  .stat:nth-child(n+4) { border-bottom: 0; }
  .cellar-grid { grid-template-columns: 1fr; }
  .record-grid { gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .record-list .card-content, .group-members .card-content { grid-template-columns: minmax(0, 1.5fr) 110px; column-gap: 12px; }
  .record-list .card-family, .group-members .card-family { display: none; }
  .record-list .card-foot, .group-members .card-foot { grid-column: 2; }
  .detail-layout { grid-template-columns: 260px minmax(0, 1fr); }
  .detail-visual { padding: 18px; }
  .detail-content { padding: 20px; }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .workspace { margin-left: 0; }
  main { padding: 22px 18px 0; }
  .page-heading { margin-bottom: 14px; flex-wrap: wrap; }
  .page-actions { margin-left: auto; }
  h1 { font-size: 30px; }
  .page-heading .button { padding: 8px 12px; min-height: 36px; font-size: 12px; }
  .cellar-scan { display: inline-flex; width: 100%; }
  .stats { margin-bottom: 18px; border-radius: 8px; }
  .stat-label svg { display: none; }
  .stat-number { font-size: 24px; }
  .panel .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-image { height: 170px; }
  .filters select { max-width: none; }
  .mobile-nav { position: fixed; inset: auto 0 0 0; padding: 6px max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); background: #151c26f7; backdrop-filter: blur(12px); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; z-index: 5; }
  .mobile-nav .nav-item { min-width: 0; display: flex; flex-direction: column; gap: 4px; border-radius: 8px; min-height: 54px; padding: 7px 2px 5px; font-size: 11px; font-weight: 500; line-height: 1.2; letter-spacing: 0; color: var(--muted); justify-content: center; border: 0; background: transparent; }
  .mobile-nav .nav-item > span:not(.count) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
  .mobile-nav .nav-item.active { color: var(--accent); background: var(--accent-surface); }
  .mobile-nav .nav-item svg { width: 20px; height: 20px; }
  .mobile-nav .nav-item .count { display: none; }
  .mobile-nav .nav-scan { color: #122235; background: var(--accent); }
  .mobile-nav .nav-scan:hover { background: #bed3eb; }
  .collection-section, .cellar-page, .labels-page { padding-bottom: 92px; }
  .labels-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 20px; }
  .label-detail-layout { grid-template-columns: 1fr; gap: 24px; }
  .label-artwork { max-width: 480px; width: 100%; margin: 0 auto; }
  .label-artwork img { max-height: 55vh; }
  .label-information { padding: 20px; }
  .sheet { position: fixed; inset: auto 0 0 0; width: 100%; max-width: 100%; margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; padding: 10px 16px max(18px, env(safe-area-inset-bottom)); background: var(--surface); color: var(--ink); }
  .sheet[open] { display: block; }
  .sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
  .sheet h2 { font-size: 20px; margin-bottom: 10px; }
  #more-navigation { display: grid; gap: 4px; }
  #more-navigation .nav-item { min-height: 48px; font-size: 14px; }
  .sheet-foot { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
  .sheet-foot .account-menu { flex: 0 0 100%; margin-bottom: 0; }
  #toast { left: 50%; bottom: calc(85px + env(safe-area-inset-bottom)); font-size: 12px; }
  .record-dialog, .scan-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 30px); border-radius: 10px; }
  .dialog-header { padding: 18px 20px 16px; }
  .dialog-header h2 { font-size: 24px; }
  .detail-layout { grid-template-columns: 230px minmax(0, 1fr); }
  .detail-visual { padding: 18px; max-height: none; position: static; }
  .detail-content { padding: 20px; }
  .dialog-footer { padding: 12px 20px; }
  .form-content { padding: 20px; }
  .scan-body { padding: 18px 20px; }
}
@media (max-width: 520px) {
  main { padding: 20px 16px 0; }
  .page-heading { gap: 10px; }
  h1 { font-size: 28px; gap: 8px; }
  .count-pill { font-size: 11px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .stat:nth-child(3n) { border-right: 1px solid var(--line); }
  .stat:nth-child(2n) { border-right: 0; }
  .stat:nth-child(n+4) { border-bottom: 1px solid var(--line); }
  .stat:last-child { border-bottom: 0; border-right: 0; grid-column: 1 / -1; }
  .stat-label svg { display: block; width: 11px; height: 11px; }
  .stat-number { font-size: 26px; }
  .record-grid { gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .labels-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .labels-toolbar .search-field { min-width: 0; flex-basis: 100%; }
  .labels-sort { width: 100%; }
  .labels-sort select { flex: 1; font-size: 16px; }
  .labels-toolbar-actions { width: 100%; justify-content: flex-end; }
  .labels-toolbar .button { padding: 8px 10px; font-size: 12px; }
  .card-image { height: 150px; }
  .card-content { padding: 10px 11px 9px; }
  .card-title { font-size: 16px; }
  .search-field { min-height: 40px; padding: 0 11px; gap: 8px; flex-basis: 200px; }
  .search-field kbd { display: none; }
  .mobile-filters { display: flex; padding: 8px 12px; font-size: 12px; min-height: 40px; }
  .toolbar { gap: 8px; }
  .filters { display: none; width: 100%; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 7px; padding: 12px; gap: 10px; }
  .filters.visible { display: grid; grid-template-columns: 1fr 1fr; }
  .filters label { display: block; }
  .filters label > span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
  .filters label select { width: 100%; max-width: none; font-size: 16px; padding: 8px; }
  .filters .sort-order { justify-self: start; align-self: end; }
  .filters .text-button { justify-self: start; align-self: end; font-size: 12px; }
  .search-field input { font-size: 16px; }
  .search-field input::placeholder { font-size: 13px; }
  .record-list .card-image, .group-members .card-image { height: 76px; width: 80px; }
  .record-list .card-content, .group-members .card-content { padding: 10px 12px; grid-template-columns: minmax(0, 1fr); gap: 0; }
  .record-list .card-title, .group-members .card-title { font-size: 16px; }
  .record-list .card-foot, .group-members .card-foot { grid-column: 1; grid-row: 3; justify-content: flex-start; gap: 12px; margin-top: 5px; font-size: 11px; }
  .group-members { padding-left: 8px; margin-left: 4px; }
  .record-dialog, .scan-dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .dialog-header { padding: 18px 18px 14px; }
  .detail-layout { display: block; }
  .detail-visual { padding: 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .detail-main-photo, .detail-main-placeholder { max-height: 260px; aspect-ratio: auto; min-height: 180px; object-fit: contain; }
  .detail-main-placeholder { height: 180px; }
  .gallery-thumbs { justify-content: center; }
  .detail-summary { grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; padding-top: 14px; }
  .detail-summary > div { display: block; }
  .detail-summary strong { display: block; text-align: left; margin-top: 4px; }
  .photo-caption { text-align: center; }
  .detail-content { padding: 20px 18px; }
  .dialog-footer { padding: 12px 18px max(12px, env(safe-area-inset-bottom)); min-height: 66px; flex-wrap: wrap; }
  .dialog-footer .button { font-size: 12px; min-height: 38px; padding: 9px 12px; }
  .form-content { padding: 20px 18px; }
  .form-grid { grid-template-columns: 1fr; gap: 18px; }
  .form-field.full-width { grid-column: auto; }
  .form-field input:not([type=checkbox]):not([type=file]), .form-field select, .form-field textarea, .scan-manual input { font-size: 16px; }
  .image-field-item > button { width: 32px; height: 32px; font-size: 12px; }
  .scan-body { padding: 18px; }
  .scan-controls { gap: 6px; }
  .camera-preview { aspect-ratio: 1; }
  .scan-manual input { min-width: 0; }
  .collection-status { padding: 32px 14px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
