/* ================= BrickWorks — medium lavender & teal theme ================= */
:root {
  --lavender: #9370db;
  --lavender-deep: #7a55c7;
  --lavender-soft: #b9a1ec;
  --lavender-mist: #f3eefb;
  --lavender-far: #6d4bb8;
  --teal: #008080;
  --teal-deep: #005f5f;
  --teal-soft: #3db5b5;
  --teal-mist: #e6f5f5;
  --ink: #26203a;
  --ink-soft: #6b6480;
  --paper: #ffffff;
  --bg: #f6f4fa;
  --line: #e7e2f0;
  --field-bg: #fcfbfe;
  --shadow: 0 8px 30px rgba(60, 40, 110, 0.14);
  --danger: #d6455d;
  --ok: #2f9e6e;
  --photo-bg: #ffffff;
  --on-primary: #ffffff;
  --on-accent: #ffffff;
  --on-danger: #ffffff;
  --warn: #b26a00;
  --radius: 16px;
  --nav-h: 62px;
  --header-h: 58px;

  /* Semantic surface/text colors (light theme defaults) */
  --surface: var(--paper);
  --surface-2: #f2f0f7;
  --text: var(--ink);
  --text-soft: var(--ink-soft);
  --border: var(--line);
  --track: #e7e2f0;
  --danger-bg: #fdeef0;
  --danger-text: #a32340;
  --tag-used-bg: #fff1e6;
  --tag-used-text: #b26a00;
  --tag-new-bg: #e6f7ef;
  --tag-new-text: #1e7a50;
  color-scheme: light;
}

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
  --lavender: #a98be8;
  --lavender-deep: #c4a8f5;
  --lavender-soft: #7a5cb0;
  --lavender-mist: #2a2240;
  --lavender-far: #c9b3ff;
  --teal: #2bb8b8;
  --teal-deep: #5fd0d0;
  --teal-soft: #4fc4c4;
  --teal-mist: #143338;
  --ink: #eae6f5;
  --ink-soft: #a79fc4;
  --paper: #1c1830;
  --bg: #12101f;
  --line: #322c4a;
  --field-bg: #231e38;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --photo-bg: #ffffff;
  --on-primary: #1b1430;
  --on-accent: #10231f;
  --on-danger: #2a0d14;
  --warn: #f0b060;

  --surface: var(--paper);
  --surface-2: #231e38;
  --text: var(--ink);
  --text-soft: var(--ink-soft);
  --border: var(--line);
  --track: #3a3256;
  --danger-bg: #3a1e26;
  --danger-text: #ff8fa3;
  --tag-used-bg: #3a2a14;
  --tag-used-text: #f0b060;
  --tag-new-bg: #16352a;
  --tag-new-text: #5fd9a0;
  color-scheme: dark;
}

/* ---------- Settings: dark mode toggle ---------- */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.toggle-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.toggle-text strong { font-size: 15px; color: var(--text); }
.switch {
  flex: 0 0 auto;
  width: 50px; height: 30px; border-radius: 999px; border: none;
  background: var(--track);
  position: relative; padding: 0; transition: background .2s ease;
}
.switch .switch-knob {
  position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 2px 6px rgba(0,0,0,.25), 0 0 0 1px rgba(0,0,0,.12);
  transition: transform .2s ease;
}
.switch[aria-checked="true"] { background: linear-gradient(120deg, var(--teal), var(--teal-deep)); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(20px); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  touch-action: manipulation;
}
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 15px; color: var(--ink); }
[hidden] { display: none !important; }
.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }
.link { color: var(--teal-deep); font-weight: 600; text-decoration: none; }

/* ---------- header ---------- */
.app-header {
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 10px);
  padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding-left: 6px;
  padding-right: 8px;
  background: linear-gradient(120deg, var(--lavender) 0%, var(--lavender-deep) 55%, var(--lavender-far) 100%);
  color: var(--on-primary);
  box-shadow: 0 2px 14px rgba(90, 60, 150, 0.35);
  position: relative;
  z-index: 20;
}
body.fullscreen-active .app-header {
  height: var(--header-h);
  padding-top: 0;
}
.hdr-title { margin: 0; font-size: 19.5px; letter-spacing: .2px; text-align: center; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.hdr-title .brick-logo { width: 26px; height: 26px; border-radius: 6px; }
.hdr-title .brand-name { font-family: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif; font-weight: 500; letter-spacing: -0.02em; }
.hdr-title .brand-name strong { font-weight: 700; }
.sidebar-head .brand-name { font-family: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif; font-weight: 500; letter-spacing: -0.02em; font-size: 16px; }
.sidebar-head .brand-name strong { font-weight: 700; }

/* BrickWorks brick logo — shared with BrickWorksWebsite - studs centered with % so any size stays symmetric */
.brick-logo {
  width: 28px; height: 28px; border-radius: 7px;
  background:
    radial-gradient(circle at 28% 28%, var(--lavender) 3.8px, transparent 4.2px),
    radial-gradient(circle at 72% 28%, var(--lavender) 3.8px, transparent 4.2px),
    radial-gradient(circle at 28% 72%, var(--lavender) 3.8px, transparent 4.2px),
    radial-gradient(circle at 72% 72%, var(--teal) 3.8px, transparent 4.2px),
    var(--paper);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  flex: 0 0 auto;
}
.brick-logo--lavender {
  background:
    radial-gradient(circle at 28% 28%, var(--paper) 3.8px, transparent 4.2px),
    radial-gradient(circle at 72% 28%, var(--paper) 3.8px, transparent 4.2px),
    radial-gradient(circle at 28% 72%, var(--paper) 3.8px, transparent 4.2px),
    radial-gradient(circle at 72% 72%, var(--teal) 3.8px, transparent 4.2px),
    var(--lavender);
  box-shadow: 0 2px 8px rgba(60,40,110,0.22);
}
.brick-logo--sm { width: 22px; height: 22px; border-radius: 5px; }
.brick-logo--sm.brick-logo {
  background:
    radial-gradient(circle at 28% 28%, var(--lavender) 3px, transparent 3.3px),
    radial-gradient(circle at 72% 28%, var(--lavender) 3px, transparent 3.3px),
    radial-gradient(circle at 28% 72%, var(--lavender) 3px, transparent 3.3px),
    radial-gradient(circle at 72% 72%, var(--teal) 3px, transparent 3.3px),
    var(--paper);
}
.brick-logo--sm.brick-logo--lavender {
  background:
    radial-gradient(circle at 28% 28%, var(--paper) 3px, transparent 3.3px),
    radial-gradient(circle at 72% 28%, var(--paper) 3px, transparent 3.3px),
    radial-gradient(circle at 28% 72%, var(--paper) 3px, transparent 3.3px),
    radial-gradient(circle at 72% 72%, var(--teal) 3px, transparent 3.3px),
    var(--lavender);
}
.hdr-right { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.hdr-btn {
  width: 42px; height: 42px; border: none; background: transparent; color: var(--on-primary);
  display: grid; place-items: center; border-radius: 12px;
}
.hdr-btn svg { width: 22px; height: 22px; }
.hdr-btn.dark { color: var(--ink); font-size: 24px; }
/* Home shortcut next to the hamburger: slightly smaller glyph, same tap
   target, soft highlight while the Home tab is showing. */
#btn-goto-home svg { width: 19px; height: 19px; }
#btn-goto-home.active { background: rgba(255, 255, 255, .18); }
.hamburger { display: flex; flex-direction: column; gap: 5px; width: 20px; }
.hamburger i { display: block; height: 2px; background: var(--surface); border-radius: 2px; }
.api-status { display: flex; align-items: center; padding: 0 6px; }
.api-status .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--idle-on-primary); display: inline-block;
  box-shadow: 0 0 0 3px rgba(127,127,127,.18);
}
.api-status.ok .dot { background: var(--ok-on-primary); }
.api-status.bad .dot { background: var(--danger-on-primary); }

.sidebar-scrim {
  position: fixed; inset: 0; background: rgba(23,18,43,.45); z-index: 70;
}
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(82vw, 300px); z-index: 80;
  background: var(--surface); box-shadow: 8px 0 30px rgba(30,20,60,.22);
  transform: translateX(-105%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.sidebar.open { transform: translateX(0); }
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 14px 16px;
  background: var(--lavender-mist); color: var(--lavender-deep);
}
.sidebar-nav { display: flex; flex-direction: column; padding: 10px; overflow-y: auto; flex: 1; }
.sidebar-nav button {
  text-align: left; border: none; background: none; padding: 14px 12px;
  font-size: 16px; font-weight: 700; color: var(--ink); border-radius: 12px;
}
.sidebar-nav button:active, .sidebar-nav button.active { background: var(--lavender-mist); color: var(--lavender-deep); }

/* "API Keys Are Missing" prompt on Add Item, shown only when the BrickLink
 * API keys are missing. Lives in the left Price/Qty column and wraps to its
 * own line directly under those boxes (level with the -5/+5 pad row); the
 * red button fills the column (~half the screen). */
.restore-keys-block {
  flex: 1 1 100%;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
}
.restore-keys-block span {
  color: var(--danger-text); font-size: 13px; font-weight: 700;
}
.btn-restore-keys {
  width: 100%;
  background: var(--danger); color: var(--on-danger);
  padding: 11px 16px; font-size: 14px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn-restore-keys svg { width: 15px; height: 15px; }
.price-guide {
  margin-top: 8px; background: var(--teal-mist); border-radius: 10px; padding: 8px 10px; font-size: 12.5px;
}
.price-guide button {
  margin: 4px 4px 0 0; border: 1px solid var(--teal); background: var(--surface); color: var(--teal-deep);
  border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: 12px;
}
.page-title { margin: 4px 0 8px; font-size: 20px; }

/* ---------- settings sub-tabs ---------- */
.settings-tabs {
  display: flex; flex-wrap: wrap; gap: 7px; margin: 4px 0 14px;
  padding-bottom: 2px;
}
.settings-tab {
  flex: 0 0 auto; border: 1.5px solid var(--line); background: var(--surface);
  color: var(--ink-soft); border-radius: 999px; padding: 8px 17px;
  font-size: 13.5px; font-weight: 700; white-space: nowrap;
}
.settings-tab.active {
  background: linear-gradient(120deg, var(--lavender), var(--lavender-deep));
  color: var(--on-primary); border-color: transparent; box-shadow: 0 3px 10px rgba(122,85,199,.35);
}
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: fade .2s ease; }

/* ---------- Printer: Old / New sub-pills (Settings → Printer) ---------- */
.printer-subtabs {
  display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 14px;
}
.printer-subtab {
  flex: 0 0 auto; border: 1.5px solid var(--line); background: var(--surface);
  color: var(--ink-soft); border-radius: 999px; padding: 8px 17px;
  font-size: 13.5px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.printer-subtab.active {
  background: linear-gradient(120deg, var(--teal), var(--teal-deep));
  color: var(--on-accent); border-color: transparent;
  box-shadow: 0 3px 10px rgba(0,128,128,.30);
}
.printer-subpanel { display: none; }
.printer-subpanel.active { display: block; animation: fade .2s ease; }
.tag-old { margin: 2px 0 8px; font-weight: 700; color: var(--ink-soft); }
.tag-new { margin: 2px 0 8px; font-weight: 700; color: var(--teal-deep); }
.sub-head {
  margin: 14px 0 6px; font-size: 15px; font-weight: 800; color: var(--ink);
}
.printer-subpanel .card .sub-head:first-child { margin-top: 4px; }
.free-badge {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  padding: 1px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 800;
  letter-spacing: .04em; color: var(--on-primary);
  background: linear-gradient(120deg, var(--teal), var(--teal-deep));
}
.paid-badge {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  padding: 1px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 800;
  letter-spacing: .04em; color: var(--on-primary); background: var(--warn);
}
.print-os-panel { margin-top: 14px; padding-top: 4px; }
/* Four platform buttons (Windows / macOS / Android / iPhone) stay in one
 * horizontal row even on a phone — labels are short. */
.segmented.print-os-row {
  flex-wrap: nowrap;
}
.segmented.print-os-row button {
  flex: 1 1 0; min-width: 0; padding: 10px 2px; font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Comments table ---------- */
.comments-table-wrap {
  overflow-x: auto; margin: 2px 0 12px;
  border: 1.5px solid var(--line); border-radius: 12px;
}
.comments-table {
  width: 100%; border-collapse: collapse; table-layout: fixed;
  container-type: inline-size;
}
.comments-table th {
  text-align: left; font-size: 11.5px; font-weight: 800; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .4px; padding: 9px 10px;
  border-bottom: 1.5px solid var(--line); background: var(--field-bg);
  white-space: nowrap;
}
/* Comments 45% / Remarks 45% / Discount 10% of the table. */
.comments-table th.comments-col-comment { width: 45%; }
.comments-table th.comments-col-remarks { width: 45%; }
.comments-table th.comments-col-discount {
  width: 10%;
  text-align: right;
  white-space: normal;
  padding-left: 2px;
  padding-right: 6px;
}
.comments-table th.comments-del-col { width: 44px; }
.comments-table td {
  padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: middle;
}
.comments-table tbody tr:last-child td { border-bottom: none; }
.comments-table input {
  width: 100%; min-width: 90px; box-sizing: border-box;
  border: 1.5px solid transparent; border-radius: 9px; padding: 7px 8px;
  background: transparent; color: inherit; font-size: 13.5px; outline: none;
}
.comments-table input:hover { border-color: var(--line); background: var(--field-bg); }
.comments-table input:focus {
  border-color: var(--lavender); background: var(--surface);
  box-shadow: 0 0 0 3px rgba(147,112,219,.15);
}
/* Discount input is 10% of the table width, right-justified. */
.comments-table td.comments-col-discount {
  width: 10%; padding: 5px 4px; text-align: right;
}
.comments-table input[data-key="discount"] {
  width: 10cqi; max-width: 10cqi; min-width: 0;
  display: block; margin-left: auto; box-sizing: border-box;
  padding: 7px 4px; text-align: right; font-variant-numeric: tabular-nums;
}
@supports not (width: 1cqi) {
  .comments-table input[data-key="discount"] { width: 100%; max-width: 100%; }
}
/* While editing a Comments or Remarks cell, the box becomes a full-width
   edit bar across the screen — no more squinting into a narrow column. */
.comments-table input[data-key="comment"]:focus,
.comments-table input[data-key="remarks"]:focus {
  position: fixed; top: 12px; left: 12px; right: 12px; width: auto;
  z-index: 60; padding: 12px 14px; font-size: 15px;
  box-shadow: 0 8px 30px rgba(60,40,110,.3);
}
.comments-del-btn {
  border: 1.5px solid transparent; background: transparent; color: var(--danger-text);
  font-size: 16px; line-height: 1; padding: 6px 9px; border-radius: 8px; cursor: pointer;
}
.comments-del-btn:hover { background: var(--danger-bg); }

/* Remarks column On/Off switch (lives in the column header). */
.comments-remarks-inner {
  display: flex; align-items: center; justify-content: flex-start; gap: 6px;
}
.switch-mini { width: 38px; height: 22px; }
.switch-mini .switch-knob { top: 2px; left: 2px; width: 18px; height: 18px; }
.switch-mini[aria-checked="true"] .switch-knob { transform: translateX(16px); }
.comments-table.remarks-off td.comments-col-remarks { opacity: .45; }
.comments-table.remarks-off td.comments-col-remarks input { border-color: transparent; }

/* Add Item: Cost + Discount % + Discount2 % share one line; each discount
   field takes a quarter of the row, Cost gets the remaining half. When
   Settings → Listing Cost is 0 the Cost field is hidden and the two
   discount fields split the row. */
.row-discounts .field-discount { flex: 0 0 25%; }
.row-discounts.no-cost .field-discount { flex: 1 1 50%; }

/* Add Item: hamburger sits inside the Comments field row, at the far right. */
.ed-comments-row { display: flex; align-items: center; gap: 8px; }
.ed-comments-row input { flex: 1 1 auto; min-width: 0; }
.ed-remarks-menu-btn {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 11px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--field-bg); color: var(--ink-soft);
  display: grid; place-items: center; transition: transform .1s ease, border-color .15s ease;
}
.ed-remarks-menu-btn:active { transform: scale(.94); }
.ed-remarks-menu-btn svg { width: 20px; height: 20px; }

/* Add Item: saved-comments picker sheet (opened by the hamburger). */
#comments-pick-note { margin: 0 0 10px; }
.comments-pick-list { display: flex; flex-direction: column; gap: 8px; }
.comments-pick-row {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  border: 1.5px solid var(--line); border-radius: 11px; background: var(--surface);
  padding: 10px 12px; cursor: pointer; transition: transform .08s ease, border-color .12s ease;
}
.comments-pick-row:active { transform: scale(.985); border-color: var(--lavender); }
.comments-pick-main { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.comments-pick-sub { font-size: 12.5px; color: var(--ink-soft); }

/* Add Item: list-price → discounted-price note under the Price/Quantity
   boxes. It is a sibling of those fields inside .ed-pq-left (the left half
   of the row), so flex-basis 100% spans that half — 50% of the screen. */
.price-discount-label {
  flex: 0 0 100%;
  display: block;
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .4px;
}
.price-discount {
  flex: 0 0 100%;
  font-size: 12px; font-weight: 700; color: var(--teal-deep);
  background: var(--teal-mist); border-radius: 8px; padding: 5px 8px;
}

/* Add Item: "already in your store" lot-match notice */
.lotmatch {
  border: 1.5px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 9%, var(--surface));
  border-radius: 12px; padding: 11px 12px; margin: 4px 0 12px;
}
.lotmatch-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.lotmatch-head strong { font-size: 13.5px; color: var(--warn); }
.lotmatch-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 8px; }
.lotmatch-row {
  text-align: left; width: 100%; display: flex; flex-direction: column; gap: 3px;
  border: 1.5px solid var(--line); background: var(--field-bg);
  border-radius: 10px; padding: 9px 11px; cursor: pointer;
}
.lotmatch-row:hover { border-color: var(--teal-soft); }
.lotmatch-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lotmatch-cond {
  flex: 0 0 auto; font-size: 11px; font-weight: 800; padding: 1px 9px; border-radius: 999px;
  color: var(--on-primary);
}
.lotmatch-cond.cond-N { background: linear-gradient(120deg, var(--teal), var(--teal-deep)); }
.lotmatch-cond.cond-U { background: linear-gradient(120deg, var(--lavender), var(--lavender-deep)); }
.lotmatch-meta { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.lotmatch-notes {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; line-height: 1.35;
}
.lotmatch-remark {
  flex: 0 0 auto; font-size: 12.5px; font-weight: 700; color: var(--teal-deep);
}
.lotmatch-sub { flex: 1 1 auto; text-align: right; font-weight: 400; }
.lotmatch .btn-block { margin-top: 2px; }

/* Add Item: live Default-multiplier indicator next to the Price label.
   Plain text (not a pill) so it stays a quiet cue beside PRICE. */
.price-mult-badge {
  display: inline; margin-left: 6px; padding: 0;
  font-size: 11px; font-weight: 400; font-style: normal; line-height: inherit;
  vertical-align: baseline; letter-spacing: 0; text-transform: none;
  color: var(--ink-soft); background: none; border: none; border-radius: 0;
  cursor: pointer; font-family: inherit; appearance: none; -webkit-appearance: none;
}
.price-mult-badge[hidden] { display: none; }
/* Round 20: the Price label is a full-width row — "Price" hard left, the
   ×multiplier field hard right — so it lines up exactly with the edges of
   the price input below it. The multiplier is always visible (×1.00 too);
   its inline editor opens in the same right-hand slot. */
.field > label#ed-price-label {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.field > label#ed-price-label .price-mult-badge { margin-left: auto; }
/* Tiny inline editor that replaces ×#.## when the badge is tapped. */
.field > label .price-mult-edit {
  display: inline-block; width: 3.8em; margin-left: 6px; vertical-align: baseline;
  padding: 1px 4px; font-size: 11px; font-weight: 400;
  border: 1.5px solid var(--line); border-radius: 6px; background: var(--field-bg);
}

.home-hero {
  background: var(--surface); border-radius: var(--radius); padding: 28px 18px; text-align: center;
  box-shadow: var(--shadow);
}
.home-hero h2 { margin: 0 0 8px; }
.home-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.search-row { display: flex; gap: 8px; margin: 10px 0; }
.search-row input { flex: 1; border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 12px; }
.search-results { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.segmented.wrap { flex-wrap: wrap; }
.segmented.wrap button { min-width: 44%; }

.ed-thumb { padding: 0; cursor: zoom-in; }
.ed-name-link {
  display: block; border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 12px;
  background: var(--field-bg); color: var(--ink); font-size: 14.5px; font-weight: 400;
  line-height: 1.3; text-decoration: none; overflow-wrap: anywhere;
}
/* Add Item: Color (half width, left) shares a line with Used/New. */
.ed-color-cond-row { display: flex; align-items: flex-start; gap: 11px; }
.ed-color-cond-row .ed-color-field { flex: 0 0 50%; max-width: 50%; min-width: 0; }
.ed-color-cond-row .ed-cond-field { flex: 1 1 auto; min-width: 0; }
.ed-cond-field > label { text-align: center; } /* centred like the buttons below it */
.ed-color-field #ed-color-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Add Item: Print label button sits beside the Stockroom toggles, with a
   "Hold to Lock" caption above it. */
.ed-stock-row { align-items: flex-end; }
.ed-stock-row .ed-print-block {
  flex: 0 0 auto; margin-bottom: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.ed-print-hint {
  font-size: 10px; font-weight: 700; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .4px; white-space: nowrap;
}

.print-lock-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 11px;
  padding: 8px 12px; font-weight: 700; color: var(--ink);
}
.print-lock-btn svg { width: 20px; height: 20px; }
.print-lock-btn.locked { border-color: var(--teal); background: var(--teal-mist); color: var(--teal-deep); }

.photo-lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(10,8,20,.88);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(5px);
  cursor: pointer;
}
.photo-lightbox img {
  width: min(88vw, 400px);
  height: min(88vw, 400px);
  max-width: 92vw;
  max-height: 68dvh;
  object-fit: contain;
  border-radius: 20px;
  background: var(--photo-bg);
  padding: 24px;
  box-shadow: 0 16px 48px rgba(0,0,0,.65);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.photo-lightbox img:active {
  transform: scale(0.97);
}
.lb-close { display: none; }
.lb-caption {
  margin-top: 16px;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  max-width: 90vw;
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
  cursor: pointer;
}
.browse-item img, .result-item .thumb, .rev-thumb, .results-list .thumb, .ed-thumb {
  cursor: zoom-in;
}

#print-only { display: none; }
#print-only img { display: block; width: 1.18in; height: 0.5in; }
@media print {
  @page { size: 1.18in 0.5in; margin: 0; }
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 1.18in !important;
    height: 0.5in !important;
    background: #fff !important;
    overflow: hidden !important;
  }
  body.printing-label > *:not(#print-only) { display: none !important; }
  body.printing-label #print-only {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 1.18in;
    height: 0.5in;
    overflow: hidden;
    background: #fff;
  }
  body.printing-label #print-only img {
    display: block !important;
    width: 1.18in !important;
    height: 0.5in !important;
  }
}

.label-sheet { display: none !important; }

/* ---------- main / tabs ---------- */
main { flex: 1 1 auto; overflow: hidden; position: relative; }
.offline-banner {
  margin: 12px 14px 0;
  background: var(--danger-bg); color: var(--danger-text);
  border: 1.5px solid rgba(214,69,93,.4); border-radius: 12px;
  padding: 10px 12px; font-size: 12.5px; line-height: 1.45;
  position: absolute; top: 0; left: 0; right: 0; z-index: 15;
}
.offline-banner strong { display: block; margin-bottom: 2px; }
.tab { position: absolute; inset: 0; overflow-y: auto; padding: 14px 14px calc(var(--nav-h) + 18px); display: none; }
.tab.active { display: block; }

/* ---------- scan ---------- */
#tab-scan { padding: 0; overflow: hidden; }
#tab-scan.active { display: block; }
.mode-bar {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 7;
  display: flex; gap: 8px; justify-content: center; margin-bottom: 0;
}
.mode {
  border: 1.5px solid var(--lavender-soft);
  background: var(--surface); color: var(--lavender-deep);
  border-radius: 999px; padding: 7px 16px; font-size: 13.5px; font-weight: 600;
}
.mode.active { background: linear-gradient(120deg, var(--lavender), var(--lavender-deep)); color: var(--on-primary); border-color: transparent; box-shadow: 0 3px 10px rgba(122,85,199,.35); }

.viewfinder {
  position: absolute;
  inset: 0;
  border-radius: 0;
  overflow: hidden;
  background: #17122b;
  box-shadow: none;
  cursor: pointer;
}
#camera { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#photo-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #17122b; }

.corners .c { position: absolute; width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.85); z-index: 3; }
.c.tl { top: 12px; left: 12px; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.c.tr { top: 12px; right: 12px; border-left: 0; border-bottom: 0; border-top-right-radius: 8px; }
.c.bl { bottom: 12px; left: 12px; border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }
.c.br { bottom: 12px; right: 12px; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }

.vf-placeholder {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: #cdc6e6; text-align: center; padding: 24px; font-size: 14px;
}
.vf-placeholder svg { width: 44px; height: 44px; opacity: .8; }

.vf-scanning {
  position: absolute; inset: 0; z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(23, 18, 43, .82); color: #fff; backdrop-filter: blur(3px);
}
.vf-scanning p { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .3px; }
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.25); border-top-color: var(--teal-soft);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.camera-zoom-control {
  position: absolute; left: 12px; right: 12px; bottom: 10px; z-index: 5;
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 10px;
  background: rgba(255,255,255,.5); border: 1.5px solid rgba(255,255,255,.7);
  border-radius: 999px; padding: 8px 12px; box-shadow: 0 4px 12px rgba(10,8,30,.24);
  opacity: .5;
}
.camera-zoom-control span, .camera-zoom-control b {
  font-size: 12px; font-weight: 800; color: var(--lavender-deep);
}
.camera-zoom-control input { width: 100%; accent-color: var(--teal); }
.scan-controls {
  position: absolute; left: 50%; bottom: 58px; transform: translateX(-50%);
  z-index: 5; display: flex; align-items: center; justify-content: center; gap: 18px;
}
.ctl {
  width: 52px; height: 52px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.7); background: rgba(255,255,255,.5); color: var(--lavender-deep);
  display: grid; place-items: center; box-shadow: 0 4px 12px rgba(10,8,30,.24);
  opacity: .5;
}
.ctl.active { background: linear-gradient(120deg, var(--teal), var(--teal-deep)); color: var(--on-accent); border-color: transparent; opacity: .75; }
.ctl svg { width: 24px; height: 24px; }

/* ---------- review ---------- */
/* ---- BrickLink API usage counter (Settings → BrickLink) ---- */
.usage-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 2px 0 10px; }
#inv-stats { grid-template-columns: repeat(2, 1fr); }
.usage-cell { background: var(--surface); border-radius: 12px; padding: 10px 6px; text-align: center; box-shadow: 0 2px 10px rgba(60,40,110,.06); }
.usage-cell:nth-child(2) { background: linear-gradient(160deg, var(--surface) 0%, var(--teal-mist) 100%); }
.usage-num { display: block; font-size: 17px; font-weight: 800; color: var(--lavender-deep); }
.usage-cell:nth-child(2) .usage-num { color: var(--teal-deep); }
.usage-cell label { font-size: 11px; color: var(--ink-soft); }
.usage-bar { height: 8px; border-radius: 6px; background: var(--field-bg); overflow: hidden; margin: 2px 0 8px; }
.usage-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--teal-deep)); border-radius: 6px; transition: width .4s ease; }
.usage-bar i.warn { background: linear-gradient(90deg, var(--warn), var(--tag-used-text)); }
.usage-bar i.over { background: linear-gradient(90deg, var(--danger), var(--danger-text)); }

.summary-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.sum {
  background: var(--surface); border-radius: 14px; padding: 12px 6px; text-align: center;
  box-shadow: 0 3px 12px rgba(60,40,110,.07);
}
.sum:nth-child(2) { background: linear-gradient(160deg, var(--surface) 0%, var(--lavender-mist) 100%); }
.sum:nth-child(3) { background: linear-gradient(160deg, var(--surface) 0%, var(--teal-mist) 100%); }
.sum span { display: block; font-size: 17px; font-weight: 800; color: var(--lavender-deep); }
.sum:nth-child(3) span { color: var(--teal-deep); }
.sum label { font-size: 11px; color: var(--ink-soft); }

.review-list { display: flex; flex-direction: column; gap: 10px; }
.rev-card {
  background: var(--surface); border-radius: var(--radius); padding: 12px;
  display: flex; gap: 12px; align-items: center;
  box-shadow: 0 3px 12px rgba(60,40,110,.07);
  border-left: 4px solid var(--lavender);
  animation: pop .25s ease;
}
.rev-card.uploaded { border-left-color: var(--ok); opacity: .82; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.rev-thumb {
  width: 75px; height: 75px; flex: 0 0 auto; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); display: grid; place-items: center;
}
.rev-thumb img { width: 100%; height: 100%; object-fit: contain; background: var(--photo-bg); }
.thumb-fallback { font-size: 10px; font-weight: 700; color: var(--ink-soft); }
.rev-info { flex: 1 1 auto; min-width: 0; }
.rev-info h4 {
  margin: 0 0 3px; font-size: 14.5px; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rev-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag {
  font-size: 10.5px; font-weight: 700; padding: 2.5px 8px; border-radius: 999px;
  background: var(--lavender-mist); color: var(--lavender-deep);
}
.tag.type { background: var(--teal-mist); color: var(--teal-deep); }
.tag.cond-U { background: var(--tag-used-bg); color: var(--tag-used-text); }
.tag.cond-N { background: var(--tag-new-bg); color: var(--tag-new-text); }
.tag.ok { background: var(--tag-new-bg); color: var(--tag-new-text); }
.color-chip { display: inline-flex; align-items: center; gap: 5px; }
.color-chip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.12); }
.rev-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; }
.rev-bottom .price { font-weight: 700; color: var(--teal-deep); font-size: 13.5px; }
.rev-actions2 { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-soft); display: grid; place-items: center;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.danger { color: var(--danger); }

.empty-state { text-align: center; padding: 46px 22px; color: var(--ink-soft); }
.empty-icon {
  width: 76px; height: 76px; margin: 0 auto 16px; border-radius: 24px;
  background: linear-gradient(140deg, var(--lavender-mist), var(--surface));
  border: 1.5px dashed var(--lavender-soft);
  display: grid; place-items: center; color: var(--lavender);
}
.empty-icon svg { width: 36px; height: 36px; }
.empty-state h3 { margin: 0 0 6px; color: var(--ink); font-size: 17px; }
.empty-state p { margin: 0 0 18px; font-size: 13.5px; line-height: 1.5; }

.review-actions { display: flex; gap: 10px; margin-top: 16px; margin-bottom: 16px; }
.review-actions .btn { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  border: none; border-radius: 12px; padding: 11px 16px;
  font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  text-decoration: none; transition: transform .1s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: linear-gradient(120deg, var(--teal), var(--teal-deep)); color: var(--on-accent); box-shadow: 0 4px 14px rgba(0,128,128,.35); }
.btn-outline { background: var(--surface); color: var(--lavender-deep); border: 1.5px solid var(--lavender-soft); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1.5px dashed var(--line); }
.btn-block { width: 100%; margin-top: 14px; padding: 14px; font-size: 15px; }
#ed-price-guide { display: none !important; }
#sheet-editor #ed-save { margin-top: 8px; margin-bottom: 8px; }

/* ---------- upload tab ---------- */
.card {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 3px 12px rgba(60,40,110,.07); margin-bottom: 14px;
}
.card h2 { margin: 0 0 8px; font-size: 16px; display: flex; align-items: center; gap: 9px; }
.chip {
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto;
  display: inline-grid; place-items: center; font-size: 12.5px; font-weight: 800;
}
.chip-lavender { background: linear-gradient(135deg, var(--lavender), var(--lavender-deep)); color: var(--on-primary); }
.chip-teal { background: linear-gradient(135deg, var(--teal), var(--teal-deep)); color: var(--on-accent); }
.card .muted { margin: 0 0 12px; font-size: 13px; line-height: 1.5; }
.field { margin-bottom: 11px; }
.field > label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }
.field input, .field select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 11px;
  padding: 10px 12px; background: var(--field-bg); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--lavender); background: var(--surface); box-shadow: 0 0 0 3px rgba(147,112,219,.15); }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 120px; }
/* Upload → Manual upload: three actions share one screen-width row. */
.xml-actions {
  flex-wrap: nowrap;
  gap: 6px;
  align-items: stretch;
}
.xml-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 4px;
  font-size: 11.5px;
  line-height: 1.15;
  white-space: normal;
  text-align: center;
}
.xml-actions .btn .btn-label { display: block; text-align: center; overflow-wrap: anywhere; }
/* Let button labels wrap to a second line so they always fit the button
   (e.g. "Download comments" / "Upload comments" on narrow phones). */
.btn .btn-label { line-height: 1.2; white-space: normal; }
.btn-row .btn .btn-label { text-align: center; }
.status-box { margin-top: 12px; border-radius: 12px; padding: 11px 13px; font-size: 13px; line-height: 1.45; }
.status-box.ok, .status-box.good { background: var(--teal-mist); color: var(--teal-deep); }
.status-box.bad { background: var(--danger-bg); color: var(--danger-text); }
.status-box.working { background: var(--lavender-mist); color: var(--lavender-deep); }
.printer-ip-row { margin: 0; }
.printer-ip-row .btn { flex: 0 0 auto; min-width: 0; white-space: nowrap; }
.printer-found { margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; }
.printer-found-label { margin: 2px 0 2px; font-size: 12.5px; }
.printer-hit {
  width: 100%; text-align: left; border: 1.5px solid var(--line);
  background: var(--surface); border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  color: var(--ink);
}
.printer-hit:hover, .printer-hit:active { border-color: var(--teal); background: var(--teal-mist); }
.printer-hit.sel { border-color: var(--teal); background: var(--teal-mist); box-shadow: 0 0 0 3px rgba(0,128,128,.18); }
.printer-hit .ph-model { font-weight: 800; font-size: 14px; }
.printer-hit .ph-ip { font-weight: 700; font-size: 13.5px; color: var(--teal-deep); font-variant-numeric: tabular-nums; }
.printer-hit .ph-roll { font-weight: 600; font-size: 12.5px; color: var(--ink-soft); }
.printer-hit .err { color: var(--danger); font-weight: 600; font-size: 12.5px; }
.status-box ul { margin: 8px 0 0; padding-left: 18px; }
.xml-preview {
  background: #17122b; color: #d9d2f0; border-radius: 12px; padding: 12px;
  font-size: 11.5px; overflow-x: auto; white-space: pre; margin-top: 12px; max-height: 220px; overflow-y: auto;
}
.teal-card { background: linear-gradient(150deg, var(--surface) 30%, var(--teal-mist) 100%); }
.how { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.65; color: var(--ink-soft); }
.how strong { color: var(--teal-deep); }

/* restore-keys prompt (Upload tab) */
.restore-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  background: var(--lavender-mist); border: 1.5px solid var(--lavender-soft);
  border-radius: 12px; padding: 12px 14px; margin: 0 0 12px;
}
.restore-banner strong { display: block; font-size: 14px; color: var(--lavender-deep); margin-bottom: 2px; }
.restore-banner .btn { flex: 0 0 auto; }

/* ---------- bottom nav ---------- */
body.scan-active .bottom-nav { display: none; }
body.scan-active .toast { bottom: calc(22px + env(safe-area-inset-bottom)); }
.bottom-nav {
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  flex: 0 0 auto;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 18px rgba(60,40,110,.08);
  position: relative; z-index: 20;
}
.bottom-nav .nav {
  flex: 1; border: none; background: none; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 700; position: relative;
}
.bottom-nav .nav svg { width: 23px; height: 23px; }
.bottom-nav .nav.active { color: var(--lavender-deep); }
.bottom-nav .nav.active::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 34px; height: 3.5px; border-radius: 0 0 6px 6px;
  background: linear-gradient(90deg, var(--lavender), var(--lavender-deep));
}
.badge {
  position: absolute; top: 6px; left: calc(50% + 8px);
  min-width: 17px; height: 17px; border-radius: 999px; padding: 0 5px;
  background: var(--teal); color: var(--on-accent); font-size: 10px; font-weight: 800;
  display: grid; place-items: center;
}

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; background: rgba(23,18,43,.5); z-index: 40; backdrop-filter: blur(2px); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface); border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 40px rgba(30,20,60,.3);
  max-height: 86dvh; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .28s cubic-bezier(.32,.72,.35,1);
  max-width: 520px; margin: 0 auto;
}
.sheet.open { transform: translateY(0); }
.sheet-head {
  padding: 14px 18px 10px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.sheet-head h3 { margin: 0; font-size: 16.5px; }
.sheet-head .close {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--lavender-mist); color: var(--lavender-deep); font-size: 20px; line-height: 1;
}
.sheet-body { padding: 14px 18px 24px; overflow-y: auto; }

/* results */
.result-item {
  width: 100%; display: flex; gap: 12px; align-items: center; text-align: left;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px;
  padding: 10px 12px; margin-bottom: 10px;
  transition: border-color .15s ease, background .15s ease;
}
.result-item:hover, .result-item:active { border-color: var(--lavender); background: var(--lavender-mist); }
.result-item .thumb {
  width: 56px; height: 56px; flex: 0 0 auto; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); display: grid; place-items: center;
}
.result-item .thumb img { width: 100%; height: 100%; object-fit: contain; background: var(--photo-bg); }
.result-info { flex: 1; min-width: 0; }
.result-info .name { font-weight: 700; font-size: 14px; margin: 0 0 4px; line-height: 1.3; }
.score-bar { height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; margin-top: 6px; }
.score-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--teal), var(--teal-soft)); }
.result-item .ext { color: var(--teal-deep); flex: 0 0 auto; }
.result-item .ext svg { width: 19px; height: 19px; }
.results-empty { text-align: center; color: var(--ink-soft); padding: 30px 10px; font-size: 14px; line-height: 1.5; }

/* editor */
/* Add Item is a full-screen workspace rather than a short bottom sheet. */
#sheet-editor {
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
}
.ed-top { display: flex; gap: 12px; margin-bottom: 12px; }
.ed-thumb {
  width: 95px; height: 95px; flex: 0 0 auto; border-radius: 14px; overflow: hidden;
  background: var(--surface-2); display: grid; place-items: center; border: 1.5px solid var(--line);
}
.ed-thumb img { width: 100%; height: 100%; object-fit: contain; background: var(--photo-bg); }
.ed-fields { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.ed-fields input, .ed-fields select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 12px;
  background: var(--field-bg); outline: none; font-size: 14.5px;
}
.ed-fields input:focus, .ed-fields select:focus { border-color: var(--lavender); background: var(--surface); }
.row2 { display: flex; gap: 9px; }
.row2 input { flex: 1.4; }
/* Add Item: Part ID (item no.) — 20% larger than normal inputs + bold. */
#ed-no { font-size: 18px; font-weight: 700; }
.row2 select { flex: 1; }
.row3 { display: flex; gap: 11px; }
.row3 .field { flex: 1; }

/* Add Item: Price Each + Quantity take the left half of the page (each box is
 * half the old width, pushed left). The 2x4 quantity pad takes the right half;
 * its 4 rows are taller than the inputs, so everything from "Add to Review
 * List" down shifts down to make room. */
.ed-pq-row { display: flex; gap: 11px; align-items: flex-start; }
.ed-pq-left { flex: 1 1 50%; min-width: 0; display: flex; gap: 9px; flex-wrap: wrap; }
.ed-pq-left .field { flex: 1; min-width: 0; }
.ed-qty-pad {
  flex: 1 1 50%; min-width: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding-top: 19px; /* line the first row up with the Quantity input, under its label */
}
.ed-qty-pad-btn {
  border: 1.5px solid var(--line); border-radius: 11px;
  background: var(--field-bg); color: var(--ink);
  font-size: 16px; font-weight: 800; line-height: 1;
  padding: 12px 0; width: 100%;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: transform .06s ease, background .12s ease, border-color .12s ease;
}
.ed-qty-pad-btn.minus { color: var(--lavender-deep); }
.ed-qty-pad-btn.plus { color: var(--teal-deep); }
.ed-qty-pad-btn:active { transform: scale(.96); }
.ed-qty-pad-btn.minus:active { background: var(--lavender-mist); border-color: var(--lavender-soft); }
.ed-qty-pad-btn.plus:active { background: var(--teal-mist); border-color: var(--teal-soft); }

.color-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--line); border-radius: 11px; padding: 9px 12px;
  background: var(--field-bg); font-size: 14.5px; color: var(--ink);
}
.color-btn svg { margin-left: auto; width: 17px; height: 17px; color: var(--ink-soft); }
.swatch { width: 22px; height: 22px; border-radius: 7px; border: 1px solid rgba(0,0,0,.14); flex: 0 0 auto; }
.detected-tag {
  margin-left: 8px; font-size: 10px; font-weight: 700; color: var(--teal-deep);
  background: var(--teal-mist); padding: 2px 8px; border-radius: 999px;
  text-transform: none; letter-spacing: 0;
}
.stepper { display: flex; align-items: stretch; border: 1.5px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--field-bg); }
.stepper button { width: 40px; border: none; background: none; font-size: 19px; color: var(--lavender-deep); font-weight: 700; }
.stepper input { border: none; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; text-align: center; width: 100%; min-width: 0; background: var(--surface); font-weight: 700; }
.segmented { display: flex; border: 1.5px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--field-bg); }
.segmented button { flex: 1; border: none; background: none; padding: 10px; font-size: 13.5px; font-weight: 700; color: var(--ink-soft); }
.segmented button.active { background: linear-gradient(120deg, var(--lavender), var(--lavender-deep)); color: var(--on-primary); }
#ed-condition.segmented button.active { background: linear-gradient(120deg, var(--teal), var(--teal-deep)); }
/* Compact, infrequently changed editor selectors. */
#ed-condition.compact-toggle {
  width: max-content;
  border-radius: 9px;
  margin-left: auto;
  margin-right: auto; /* centre the Used/New buttons in their half of the row */
}
#ed-condition.compact-toggle button {
  flex: 0 0 auto;
  min-width: 52px;
  height: 40px; /* + 3px container border = the Color button's height */
  padding: 0 12px;
  font-size: 12.5px;
}
#ed-stock.stock-toggles {
  display: flex;
  gap: 6px;
  border: none;
  overflow: visible;
  background: transparent;
}
#ed-stock.stock-toggles button {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 800;
}

/* color picker */
.color-known-info {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 0 10px; padding: 9px 11px; border-radius: 12px;
  background: var(--lavender-mist); border: 1.5px solid var(--lavender-soft);
  color: var(--lavender-deep); font-size: 12.5px; line-height: 1.35;
}
.color-known-info strong { display: block; font-size: 13px; color: var(--lavender-deep); }
.color-known-info span { color: var(--ink-soft); }
.color-known-info button {
  flex: 0 0 auto; border: none; background: var(--surface); color: var(--teal-deep);
  border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 800;
}
.color-known-info.warn { background: var(--danger-bg); border-color: rgba(214,69,93,.35); color: var(--danger-text); }
.color-known-info.warn strong, .color-known-info.warn span { color: var(--danger-text); }
.fam-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.fam-row button {
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-soft);
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 6px 12px;
}
.fam-row button.active { background: var(--teal); border-color: var(--teal); color: var(--on-accent); }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 9px; }
.color-picker-empty {
  grid-column: 1 / -1; text-align: center; color: var(--ink-soft);
  padding: 22px 8px; font-size: 13px;
}
.color-cell {
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
  padding: 7px; display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: pointer;
}
.color-cell:hover { border-color: var(--lavender-deep); }
.color-cell.sel { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,128,128,.18); }
.color-cell .sw { width: 100%; height: 30px; border-radius: 8px; border: 1px solid rgba(0,0,0,.12); box-shadow: inset 0 -3px 7px rgba(0,0,0,.14); }
.color-cell .nm { font-size: 10px; font-weight: 700; text-align: center; line-height: 1.15; color: var(--ink); }

/* --- 1x2 brick-plate swatches (Browse Catalog > By Color + Add Item picker)
   The flat .sw chip becomes a top-down 1x2 LEGO plate: a 2:1 slab in the
   part color with two embossed studs, each stamped with the BW logo. */
#browse-body .color-cell,
#color-grid .color-cell { container-type: inline-size; }
#browse-body .color-cell .sw,
#color-grid .color-cell .sw {
  position: relative; height: auto; aspect-ratio: 2 / 1; border-radius: 6px;
  border-color: rgba(0,0,0,.22);
  box-shadow:
    0 1px 2px rgba(0,0,0,.16),
    inset 0 2px 2px rgba(255,255,255,.28),
    inset 0 -3px 5px rgba(0,0,0,.18);
}
#browse-body .color-cell .sw::before,
#browse-body .color-cell .sw::after,
#color-grid .color-cell .sw::before,
#color-grid .color-cell .sw::after {
  content: "BW";
  position: absolute; top: 50%; width: 30%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background-color: inherit; /* picks up the swatch's own color */
  box-shadow:
    0 1px 2px rgba(0,0,0,.30),
    inset 0 0 0 1px rgba(0,0,0,.07),
    inset 0 2px 2px rgba(255,255,255,.32),
    inset 0 -2px 3px rgba(0,0,0,.20);
  font-size: 11.5px; font-weight: 800; line-height: 1; letter-spacing: -0.03em;
  /* molded stamp: lettering matches the plate color (inherited from the
     .sw inline color), relief kept visible by shadow below + highlight above */
  color: inherit;
  text-shadow: 0 1px 1px rgba(0,0,0,.45), 0 -1px 1px rgba(255,255,255,.22);
  user-select: none; pointer-events: none;
}
#browse-body .color-cell .sw::before,
#color-grid .color-cell .sw::before { left: 25%; }
#browse-body .color-cell .sw::after,
#color-grid .color-cell .sw::after  { left: 75%; }
@supports (width: 1cqw) {
  /* scale the BW stamp with the cell width (container = .color-cell) */
  #browse-body .color-cell .sw::before,
  #browse-body .color-cell .sw::after,
  #color-grid .color-cell .sw::before,
  #color-grid .color-cell .sw::after { font-size: 12.65cqw; }
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 26px); transform: translateX(-50%);
  background: var(--text); color: var(--surface); padding: 11px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; z-index: 90; box-shadow: var(--shadow);
  max-width: 86vw; text-align: center;
  animation: toast-in .25s ease;
}
:root[data-theme="dark"] .toast { border: 1px solid var(--line); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

.confirm-card {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--surface); border-radius: 18px; padding: 20px; z-index: 60;
  box-shadow: 0 18px 50px rgba(20, 10, 50, .4); width: min(86vw, 340px);
  animation: pop .18s ease;
}
.confirm-card p { margin: 0 0 16px; font-size: 14.5px; line-height: 1.5; font-weight: 600; }
.confirm-card .btn-row .btn { flex: 1; min-width: 0; }

@media (min-width: 560px) {
  main, .app-header, .bottom-nav { max-width: 560px; margin-left: auto; margin-right: auto; width: 100%; }
}

/* ---------- camera Color Lock ---------- */
.hdr-left { display: flex; align-items: center; min-width: 0; }
.color-lock-control { position: relative; }
.color-lock-btn {
  position: relative; width: 34px; height: 34px; padding: 4px; border-radius: 8px;
  border: 1.5px solid currentColor; background: rgba(127,127,127,.20);
  box-shadow: 0 2px 7px rgba(31,18,65,.2); color: var(--on-primary);
  touch-action: none; overflow: hidden;
}
.color-lock-swatch {
  display: block; width: 100%; height: 100%; border-radius: 4px;
  border: 1px solid rgba(0,0,0,.22); box-shadow: inset 0 -3px 5px rgba(0,0,0,.14);
}
.color-lock-badge {
  position: absolute; right: -1px; bottom: -1px; width: 15px; height: 15px;
  display: grid; place-items: center; border-radius: 5px 0 7px 0;
  background: rgba(31,26,52,.82); color: #fff;
}
.color-lock-badge svg { width: 10px; height: 10px; }
.color-lock-btn .lock-closed { display: none; }
.color-lock-btn.locked { border-color: var(--ok-on-primary); box-shadow: 0 0 0 2px rgba(127,127,127,.28); }
.color-lock-btn.locked .color-lock-badge { background: var(--teal); }
.color-lock-btn.locked .lock-open { display: none; }
.color-lock-btn.locked .lock-closed { display: block; }
.color-lock-btn::after {
  content: ''; position: absolute; inset: 0; border-radius: 7px; pointer-events: none;
  background: rgba(94,240,180,.72); opacity: 0; transform: scaleX(0); transform-origin: left;
  mix-blend-mode: screen;
}
.color-lock-btn.holding::after { opacity: .75; animation: color-lock-hold 2s linear forwards; }
@keyframes color-lock-hold { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.color-lock-menu {
  position: absolute; top: 43px; left: -42px; width: min(88vw, 330px);
  max-height: min(64dvh, 520px); overflow: hidden; z-index: 65;
  display: flex; flex-direction: column; padding: 12px;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 14px 38px rgba(25,15,55,.32);
}
.color-lock-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.color-lock-heading > span:first-child { display: flex; flex-direction: column; }
.color-lock-heading strong { font-size: 15px; }
.color-lock-heading small { color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.color-lock-current { font-size: 12px; font-weight: 800; color: var(--teal-deep); text-align: right; }
.color-lock-menu p { margin: 7px 0 9px; color: var(--ink-soft); font-size: 11.5px; line-height: 1.35; }
#color-lock-search {
  width: 100%; flex: 0 0 auto; border: 1.5px solid var(--line); border-radius: 9px;
  padding: 8px 10px; margin-bottom: 8px; background: var(--field-bg); outline: none;
}
#color-lock-search:focus { border-color: var(--lavender); }
.color-lock-list { overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 3px; }
.color-lock-option {
  width: 100%; min-height: 38px; display: grid; grid-template-columns: 28px 1fr auto;
  align-items: center; gap: 9px; padding: 5px 7px; border: 1px solid transparent;
  border-radius: 9px; background: transparent; color: var(--ink); text-align: left;
}
.color-lock-option:hover, .color-lock-option:active { background: var(--lavender-mist); }
.color-lock-option.selected { border-color: var(--teal); background: var(--teal-mist); }
.color-lock-option .sw { width: 28px; height: 28px; border-radius: 6px; border: 1px solid rgba(0,0,0,.16); }
.color-lock-option .nm { font-size: 12.5px; font-weight: 700; }
.color-lock-option .cid { color: var(--ink-soft); font-size: 10.5px; }
.color-lock-empty { padding: 18px 8px; text-align: center; color: var(--ink-soft); font-size: 12px; }
.detected-tag.color-locked { color: var(--teal-deep); background: var(--teal-mist); }

/* ---- catalog browse (BrickWorksDB1) ---- */
.browse-cat{display:flex;align-items:center;width:100%;padding:13px 12px;background:transparent;border:0;border-bottom:1px solid var(--line);font-size:22.5px;cursor:pointer;text-align:left;color:inherit}
.browse-cat .bc-name{font-size:22.5px;line-height:1.3}
.browse-cat .bc-count{display:none}
.browse-item{display:flex;align-items:center;gap:14px;padding:10px 12px;border-bottom:1px solid var(--line)}
.browse-item img{width:66px;height:66px;object-fit:contain;background:var(--photo-bg);border:1px solid var(--line);border-radius:10px;flex:none}
.browse-item img.broken{opacity:.25;background:var(--surface-2)}
.browse-item .bi-main{flex:1;min-width:0}
.browse-item .bi-no{font-weight:600;font-size:21px;line-height:1.25}
.browse-item .bi-name{font-size:19.5px;color:var(--text-soft, #6b6386);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.3}
.browse-item .btn{padding:8px 16px;font-size:15px;flex:none}
#browse-crumbs a{color:var(--lavender-deep);text-decoration:none;font-weight:600}
#btn-browse-more{margin:12px auto;display:block}

/* ---- thumbnail color cascade settings ---- */
.thumb-pref-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.thumb-pref-row { display: flex; flex-direction: column; gap: 4px; }
.pref-rank { font-size: 11.5px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.5px; }
.pref-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 10px 14px; cursor: pointer;
}
.pref-card:hover { border-color: var(--lavender-soft); }
.pref-card.static { background: var(--surface-2); border-style: dashed; cursor: default; }
.pref-swatch {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid rgba(0,0,0,.15); flex: none;
}
.pref-swatch.auto-swatch {
  display: grid; place-items: center; background: var(--lavender-mist);
  color: var(--lavender-deep); border-color: var(--lavender-soft);
}
.pref-swatch.auto-swatch svg { width: 18px; height: 18px; }
.pref-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pref-name { font-size: 15px; }
.pref-id { font-size: 12px; }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 8px; }

/* UPC Scan */
.upc-finder {
  position: relative;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  margin: 8px 0 12px;
}
.upc-finder video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.upc-finder-hint {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 8px 12px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 13px;
}
#upc-set-card { margin: 10px 0; }
#upc-options .toggle-row { margin-top: 10px; }
/* Part-out: two fields per row at 50% (qty | condition, multiplier | sale). */
.upc-split-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}
.upc-split-row > .field {
  flex: 1 1 50%;
  min-width: 0;
}
.upc-mult-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.upc-mult-row input {
  flex: 1 1 auto;
  min-width: 0;
}
.upc-mult-row .switch { flex: 0 0 auto; }
#upc-mult:disabled,
#upc-sale:disabled { opacity: .45; }

/* ================= Theme picker =============================================
   Tiles render a miniature of the app chrome painted in each theme's own
   DERIVED tokens, so the preview shows the contrast decisions the engine made
   rather than the raw base16 input.
   Note: all preview colours arrive as inline styles from theme-store.js — they
   must NOT use var(), or every tile would render in the active theme. */
.theme-slot-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 7px;
}
.theme-slot-head label { margin: 0; }
.segmented.theme-slot-switch { flex: 0 0 auto; width: 132px; }
.segmented.theme-slot-switch button { padding: 6px 10px; font-size: 12px; }

.theme-tiles {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 9px; margin-bottom: 11px;
}
.theme-tile {
  display: flex; flex-direction: column; gap: 6px; padding: 6px 6px 7px;
  border: 2px solid var(--line); border-radius: 13px; background: var(--surface);
  text-align: center; transition: border-color .15s ease, transform .1s ease;
}
.theme-tile:hover { border-color: var(--lavender-soft); }
.theme-tile:active { transform: scale(.97); }
.theme-tile.selected { border-color: var(--lavender); box-shadow: 0 0 0 3px var(--lavender-mist); }
.tt-name {
  font-size: 11.5px; font-weight: 700; color: var(--text); line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 2.5em;
}

/* the miniature */
.tp {
  display: block; border-radius: 8px; overflow: hidden; height: 54px;
  position: relative; border: 1px solid rgba(127,127,127,.28);
}
.tp-bar { display: block; height: 13px; }
.tp-card {
  display: block; margin: 5px; padding: 5px; border-radius: 5px;
  border: 1px solid; text-align: left;
}
.tp-line { display: block; height: 3px; border-radius: 2px; margin-bottom: 3px; }
.tp-line.short { width: 62%; }
.tp-dots { display: flex; gap: 3px; margin-top: 4px; }
.tp-dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }

.theme-count { opacity: .7; font-weight: 600; }

/* browse-all sheet */
.theme-sheet-tools {
  padding: 10px 18px 12px; display: flex; flex-direction: column; gap: 9px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
#theme-search {
  width: 100%; border: 1.5px solid var(--line); border-radius: 11px;
  padding: 10px 12px; background: var(--field-bg); color: var(--text);
  outline: none; font-size: 15px;
}
#theme-search:focus { border-color: var(--lavender); }
.theme-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 9px;
}
.theme-attrib { margin: 14px 0 0; line-height: 1.5; }


/* ================= Home screen layouts (Settings → Home) =================
   9 selectable layouts render into #home-layout. Tiles are buttons with
   data-action attributes; app.js maps them to the real features. The
   Settings → Home panel reuses .home-pick / .pv mini-wireframe styles below. */

.home-root { animation: fade .25s ease; }

/* Shared welcome line at the top of every home layout. Layout names stay
   hidden — the Home page greets the user instead. */
.home-welcome { display: flex; align-items: center; gap: 12px; margin: 4px 2px 14px; }
.hw-badge {
  width: 46px; height: 46px; flex: 0 0 auto; border-radius: 15px;
  background: linear-gradient(140deg, var(--lavender), var(--teal));
  color: var(--on-primary); display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(122,85,199,.35);
}
.hw-badge svg { width: 24px; height: 24px; }
.hw-txt { min-width: 0; }
.hw-txt h2 {
  margin: 0; font-size: 19px; font-weight: 800;
  background: linear-gradient(120deg, var(--lavender-deep), var(--teal-deep));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hw-txt p { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); line-height: 1.4; }
.lay-zen .home-welcome { justify-content: center; text-align: center; }

/* shared stat chips */
.home-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.hstat {
  background: var(--surface); border-radius: 14px; padding: 11px 6px; text-align: center;
  box-shadow: 0 3px 12px rgba(60,40,110,.07);
}
.hstat b { display: block; font-size: 16px; font-weight: 800; color: var(--lavender-deep); }
.hstat span { font-size: 11px; color: var(--ink-soft); }
.home-strip .hstat:nth-child(2),
.dash-stats .hstat:nth-child(3),
.dash-stats .hstat:nth-child(4) { background: linear-gradient(160deg, var(--surface) 0%, var(--lavender-mist) 100%); }
.home-strip .hstat:nth-child(3),
.dash-stats .hstat:nth-child(2) { background: linear-gradient(160deg, var(--surface) 0%, var(--teal-mist) 100%); }
.dash-stats .hstat:nth-child(2) b,
.home-strip .hstat:nth-child(3) b { color: var(--teal-deep); }

/* ---------- 1 · Classic Welcome ---------- */
.home-hero-classic { position: relative; overflow: hidden; text-align: center; }
.home-hero-classic::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 5px;
  background: linear-gradient(90deg, var(--lavender), var(--teal), var(--lavender));
}
.home-hero-classic p { margin: 0; }
.home-chip-row { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; align-items: center; margin-top: 14px; }
.home-chip-row + .home-chip-row { margin-top: 8px; }
.home-chip-label { margin-right: 2px; }
.home-chip {
  border: 1.5px solid var(--line); background: var(--field-bg); color: var(--ink-soft);
  border-radius: 999px; padding: 7px 13px; font-size: 12.5px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
  transition: transform .1s ease, border-color .15s ease, color .15s ease, background .15s ease;
}
.home-chip:active { transform: scale(.95); border-color: var(--lavender); color: var(--lavender-deep); }
.home-chip svg { width: 14px; height: 14px; }
.home-chip.on {
  background: linear-gradient(120deg, var(--lavender), var(--lavender-deep));
  color: var(--on-primary); border-color: transparent; box-shadow: 0 3px 10px rgba(122,85,199,.35);
}

/* ---------- 2 · Command Grid ---------- */
.home-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.htile-big {
  border: none; border-radius: 18px; padding: 18px 14px; text-align: left;
  display: flex; flex-direction: column; gap: 6px; min-height: 118px;
  color: var(--on-primary); box-shadow: 0 6px 18px rgba(60,40,110,.18);
  transition: transform .12s ease, box-shadow .15s ease;
}
.htile-big:active { transform: scale(.965); }
.t-g1 { background: linear-gradient(135deg, var(--lavender), var(--lavender-deep)); }
.t-g2 { background: linear-gradient(135deg, var(--teal), var(--teal-deep)); color: var(--on-accent); }
.t-g3 { background: linear-gradient(135deg, #e0a44c, #b26a00); }
.htile-ico {
  width: 38px; height: 38px; border-radius: 12px; background: rgba(255,255,255,.18);
  display: grid; place-items: center;
}
.htile-ico svg { width: 21px; height: 21px; }
.htile-name { font-size: 15.5px; font-weight: 800; }
.htile-sub { font-size: 11.5px; opacity: .88; line-height: 1.3; }

/* ---------- 3 · Speed Dial ---------- */
.dial { position: relative; width: 300px; max-width: 100%; height: 300px; margin: 4px auto 10px; }
.dial-ring {
  position: absolute; inset: 0; display: grid;
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  grid-template-areas: "d1 d2 d3" "d4 . d5" "d6 d7 d8";
}
.dial-btn {
  border: none; background: var(--surface); color: var(--ink-soft);
  border-radius: 18px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; box-shadow: 0 4px 14px rgba(60,40,110,.10);
  font-size: 10.5px; font-weight: 700;
}
.dial-btn:nth-child(1) { grid-area: d1; } .dial-btn:nth-child(2) { grid-area: d2; }
.dial-btn:nth-child(3) { grid-area: d3; } .dial-btn:nth-child(4) { grid-area: d4; }
.dial-btn:nth-child(5) { grid-area: d5; } .dial-btn:nth-child(6) { grid-area: d6; }
.dial-btn:nth-child(7) { grid-area: d7; } .dial-btn:nth-child(8) { grid-area: d8; }
.dial-btn svg { width: 20px; height: 20px; color: var(--lavender-deep); }
.dial-btn:nth-child(even) svg { color: var(--teal-deep); }
.dial-btn:active { transform: scale(.94); }
.dial-main {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 118px; height: 118px; border-radius: 50%; border: none; z-index: 2;
  background: linear-gradient(140deg, var(--teal), var(--teal-deep)); color: var(--on-accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  box-shadow: 0 10px 28px rgba(0,128,128,.45);
}
.dial-main-ico {
  width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.16);
  display: grid; place-items: center;
}
.dial-main-ico svg { width: 24px; height: 24px; }
.dial-main-label { font-size: 13px; font-weight: 800; }
.dial-pulse {
  position: absolute; inset: -8px; border-radius: 50%; border: 2px solid var(--teal);
  opacity: .5; animation: dialPulse 2.2s ease-out infinite;
}
@keyframes dialPulse {
  0% { transform: scale(.9); opacity: .55; }
  70%, 100% { transform: scale(1.18); opacity: 0; }
}
.dial-status { text-align: center; margin: 0 0 6px; }

/* ---------- 4 · Seller Dashboard ---------- */
.dash-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.home-card {
  background: var(--surface); border-radius: var(--radius); padding: 14px;
  box-shadow: 0 3px 12px rgba(60,40,110,.07); margin-bottom: 12px;
}
.home-card h3 { margin: 0 0 10px; font-size: 14.5px; }
.check-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: none; background: transparent; padding: 9px 2px; border-bottom: 1px solid var(--line);
}
.check-row:last-child { border-bottom: none; }
.check-ico {
  width: 30px; height: 30px; flex: 0 0 auto; border-radius: 10px;
  display: grid; place-items: center; background: var(--surface-2); color: var(--ink-soft);
}
.check-ico svg { width: 15px; height: 15px; }
.check-ico.ok { background: var(--tag-new-bg); color: var(--tag-new-text); }
.check-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.check-txt b { font-size: 13.5px; }
.check-row > .muted svg { width: 16px; height: 16px; }
.recent-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: none; background: transparent; padding: 8px 2px; border-bottom: 1px solid var(--line);
}
.recent-row:last-child { border-bottom: none; }
.recent-thumb {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: 9px; overflow: hidden;
  background: var(--surface-2); display: grid; place-items: center;
}
.recent-thumb img { width: 100%; height: 100%; object-fit: contain; background: var(--photo-bg); }
.recent-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.recent-txt b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-price { font-size: 12.5px; font-weight: 800; color: var(--teal-deep); white-space: nowrap; }
.home-row { display: flex; gap: 8px; flex-wrap: wrap; }
.home-row .btn { flex: 1; }

/* ---------- 5 · Deck of Cards ---------- */
.deck {
  display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 4px 14px 12px; margin: 0 -14px; scrollbar-width: none;
}
.deck::-webkit-scrollbar { display: none; }
.deck-card {
  scroll-snap-align: center; flex: 0 0 72%; border: none; border-radius: 20px;
  padding: 18px 16px; text-align: left; display: flex; flex-direction: column; gap: 7px;
  color: var(--on-primary); box-shadow: 0 8px 22px rgba(60,40,110,.22); min-height: 172px;
}
.d-c1 { background: linear-gradient(140deg, var(--lavender), var(--lavender-deep)); }
.d-c2 { background: linear-gradient(140deg, var(--teal), var(--teal-deep)); color: var(--on-accent); }
.d-c3 { background: linear-gradient(140deg, #e0a44c, #b26a00); }
.deck-top { display: flex; justify-content: space-between; align-items: center; }
.deck-top > svg { width: 26px; height: 26px; }
.deck-arrow {
  width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.2);
  display: grid; place-items: center;
}
.deck-arrow svg { width: 16px; height: 16px; }
.deck-name { font-size: 19px; font-weight: 800; }
.deck-sub { font-size: 12.5px; opacity: .9; line-height: 1.35; }
.deck-stat {
  margin-top: auto; font-size: 12px; font-weight: 800; background: rgba(255,255,255,.16);
  border-radius: 999px; padding: 6px 12px; align-self: flex-start;
}
.home-hint { text-align: center; margin: 2px 0 0; }

/* ---------- 6 · Menu Rail ---------- */
.rail { display: flex; flex-direction: column; gap: 8px; }
.rail-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: none; background: var(--surface); border-radius: 16px; padding: 12px 14px;
  box-shadow: 0 3px 12px rgba(60,40,110,.07); transition: transform .1s ease;
}
.rail-row:active { transform: scale(.985); }
.rail-ico {
  width: 42px; height: 42px; flex: 0 0 auto; border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--lavender-mist), var(--surface));
  color: var(--lavender-deep); border: 1.5px solid var(--lavender-soft);
}
.rail-row:nth-child(even) .rail-ico {
  background: linear-gradient(140deg, var(--teal-mist), var(--surface));
  color: var(--teal-deep); border-color: var(--teal-soft);
}
.rail-ico svg { width: 21px; height: 21px; }
.rail-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rail-txt b { font-size: 14.5px; }
.rail-chev svg { width: 17px; height: 17px; }

/* ---------- 7 · The Pipeline ---------- */
.flow-progress { height: 8px; border-radius: 6px; background: var(--field-bg); overflow: hidden; margin: 4px 0 8px; }
.flow-progress i {
  display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--lavender), var(--teal)); transition: width .4s ease;
}
.flow-pct { margin: 0 0 12px; }
.flow { display: flex; flex-direction: column; }
.flow-step {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  border: none; background: var(--surface); border-radius: 18px; padding: 14px;
  box-shadow: 0 4px 14px rgba(60,40,110,.08); transition: transform .1s ease;
}
.flow-step:active { transform: scale(.98); }
.flow-n {
  width: 28px; height: 28px; flex: 0 0 auto; border-radius: 50%;
  background: linear-gradient(135deg, var(--lavender), var(--lavender-deep));
  color: var(--on-primary); font-size: 13px; font-weight: 800; display: grid; place-items: center;
}
.flow-step:nth-of-type(odd) .flow-n { background: linear-gradient(135deg, var(--teal), var(--teal-deep)); color: var(--on-accent); }
.flow-ico {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: 12px;
  background: var(--surface-2); display: grid; place-items: center; color: var(--lavender-deep);
}
.flow-ico svg { width: 20px; height: 20px; }
.flow-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.flow-txt b { font-size: 14.5px; }
.flow-stat {
  font-size: 11px; font-weight: 800; color: var(--teal-deep); background: var(--teal-mist);
  border-radius: 999px; padding: 5px 10px; white-space: nowrap;
}
.flow-chev svg { width: 16px; height: 16px; }
.flow-arrow { text-align: center; color: var(--lavender-soft); padding: 2px 0; }
.flow-arrow svg { width: 15px; height: 15px; }

/* ---------- 8 · Zen Minimal ---------- */
.zen { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 10px; }
.zen > p.muted { margin: 0 0 18px; }
.home-search {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 6px 8px 6px 12px; box-shadow: 0 4px 16px rgba(60,40,110,.10);
}
.home-search:focus-within {
  border-color: var(--lavender);
  box-shadow: 0 0 0 3px rgba(147,112,219,.15), 0 4px 16px rgba(60,40,110,.10);
}
.zen-lens { color: var(--ink-soft); display: grid; place-items: center; }
.zen-lens svg { width: 19px; height: 19px; }
.home-search-input { flex: 1; min-width: 0; border: none; background: transparent; padding: 9px 4px; font-size: 15px; outline: none; color: var(--ink); }
.zen-go { padding: 10px 18px; }
.zen-links { display: flex; flex-direction: column; gap: 14px; margin-top: 26px; }
.zen-links button {
  border: none; background: transparent; color: var(--teal-deep); font-size: 15.5px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 9px; padding: 4px 8px;
}
.zen-links svg { width: 19px; height: 19px; }
.zen-chips { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: 26px; }
.zen-chip {
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 5px 11px;
  background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.zen-chip.ok { background: var(--tag-new-bg); color: var(--tag-new-text); border-color: transparent; }

/* ---------- 9 · Bento Box ---------- */
.bento {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  grid-template-areas: "main rev" "main up" "m1 m2" "m3 m4" "m5 m6";
}
.bento-main {
  grid-area: main; position: relative; border: none; border-radius: 20px;
  background: linear-gradient(150deg, var(--lavender), var(--teal)); color: var(--on-primary);
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 20px 16px; text-align: left; box-shadow: 0 8px 22px rgba(60,40,110,.3);
}
.bento-ico {
  width: 40px; height: 40px; border-radius: 13px; background: rgba(255,255,255,.2);
  display: grid; place-items: center;
}
.bento-ico svg { width: 22px; height: 22px; }
.bento-main b { font-size: 18px; font-weight: 800; }
.bento-go {
  position: absolute; right: 14px; bottom: 14px; width: 32px; height: 32px;
  border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center;
}
.bento-go svg { width: 16px; height: 16px; }
.bento-tile {
  border: none; border-radius: 18px; background: var(--surface); color: var(--ink);
  box-shadow: 0 4px 14px rgba(60,40,110,.08); display: flex; flex-direction: column;
  align-items: flex-start; gap: 5px; padding: 14px; text-align: left;
}
.bt1 { grid-area: rev; } .bt2 { grid-area: up; }
.bento-tile .bento-ico { background: var(--lavender-mist); color: var(--lavender-deep); }
.bt2 .bento-ico { background: var(--teal-mist); color: var(--teal-deep); }
.bento-tile b { font-size: 14.5px; }
.bento-stat { font-size: 12px; font-weight: 800; color: var(--teal-deep); }
.bento-mini {
  border: none; border-radius: 16px; background: var(--surface); color: var(--ink);
  box-shadow: 0 3px 10px rgba(60,40,110,.07); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px; padding: 12px 6px;
}
.bento-mini svg { width: 19px; height: 19px; color: var(--lavender-deep); }
.bm2 svg, .bm4 svg, .bm6 svg { color: var(--teal-deep); }
.bento-mini b { font-size: 12px; }
.bento-mini span { font-size: 10.5px; font-weight: 800; color: var(--ink-soft); }
.bm1 { grid-area: m1; } .bm2 { grid-area: m2; } .bm3 { grid-area: m3; }
.bm4 { grid-area: m4; } .bm5 { grid-area: m5; } .bm6 { grid-area: m6; }
.bento > button:active { transform: scale(.97); }
.bento > button { transition: transform .1s ease; }

/* ---------- Settings → Home picker (9 preview panels) ---------- */
.home-pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.home-pick {
  position: relative; border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 16px; padding: 10px 10px 12px; display: flex; flex-direction: column;
  gap: 7px; text-align: left; transition: border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.home-pick:active { transform: scale(.97); }
.home-pick.active {
  border-color: var(--lavender);
  box-shadow: 0 0 0 3px rgba(147,112,219,.18), 0 6px 18px rgba(60,40,110,.12);
}
.home-pick-name { font-size: 13.5px; font-weight: 800; color: var(--ink); }
.home-pick-sub { font-size: 11.5px; color: var(--ink-soft); line-height: 1.35; }
.home-pick-check {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--teal-deep)); color: var(--on-accent);
  display: none; place-items: center;
}
.home-pick-check svg { width: 12px; height: 12px; }
.home-pick.active .home-pick-check { display: grid; }

/* Mini wireframes inside each pick panel. */
.pv {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px; height: 96px; overflow: hidden;
}
.pv .p { display: block; border-radius: 5px; background: var(--surface-2); }
.pv .p.a { background: linear-gradient(135deg, var(--lavender), var(--lavender-deep)); }
.pv .p.b { background: linear-gradient(135deg, var(--teal), var(--teal-deep)); }
.pv .p.w { height: 22px; }
.pv .p.s { flex: 1; }
.pv .p.h { flex: 1; }
.pv .p.pill { height: 9px; width: 52%; border-radius: 999px; align-self: center; }
.pv .p.line { height: 6px; width: 86%; align-self: center; border-radius: 999px; }
.pv .p.input { height: 14px; border-radius: 7px; }
.pv .p.arrow { height: 5px; width: 8px; margin: 0 auto; background: var(--lavender-soft); border-radius: 2px; }

.pv-classic { align-items: center; justify-content: center; }
.pv-classic .p.w { width: 80%; height: 26px; margin-bottom: 2px; }
.pv-classic .p.pill { margin-top: 2px; }

.pv-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; }
.pv-grid .p { height: auto; }

.pv-dial { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 3px; }
.pv-dial .dot { width: 12px; height: 12px; border-radius: 50%; place-self: center; }
.pv-dial .dot:nth-child(odd) { background: var(--lavender-soft); }
.pv-dial .dot:nth-child(even) { background: var(--teal-soft); }
.pv-dial .center {
  grid-area: 2 / 2; width: 26px; height: 26px; border-radius: 50%; place-self: center;
  background: linear-gradient(140deg, var(--teal), var(--teal-deep));
}

.pv-dash { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto; gap: 4px; }
.pv-dash .p.s { height: 18px; }
.pv-dash .p.line { width: 100%; height: 7px; }

.pv-deck { flex-direction: row; align-items: stretch; gap: 5px; padding: 10px; }
.pv-deck .card { width: 58%; border-radius: 8px; }
.pv-deck .card:nth-child(2), .pv-deck .card:nth-child(3) { margin-left: -42px; }

.pv-rail { justify-content: center; gap: 6px; }
.pv-rail .row { display: flex; align-items: center; gap: 5px; height: 12px; width: 100%; }
.pv-rail .row::before {
  content: ''; width: 12px; height: 12px; border-radius: 4px;
  background: var(--lavender-soft); flex: 0 0 auto;
}
.pv-rail .row:nth-child(even)::before { background: var(--teal-soft); }
.pv-rail .row::after { content: ''; flex: 1; height: 5px; border-radius: 999px; background: var(--surface-2); }

.pv-flow { justify-content: center; }
.pv-flow .p.w { height: 17px; }

.pv-zen { align-items: center; justify-content: center; gap: 6px; }
.pv-zen .p.input { width: 88%; }
.pv-zen .p.pill { margin-top: 2px; }
.pv-zen .p.pill:nth-of-type(2) { width: 60%; }
.pv-zen .p.pill:nth-of-type(3) { width: 44%; }

.pv-bento { display: grid; grid-template-columns: 1.4fr 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 5px; }
.pv-bento .p.h { grid-row: 1 / 3; grid-column: 1; }
.pv-bento .p.s { height: auto; }

.set-values {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.35;
}
.set-values b { font-weight: 700; }
.set-values .sv-note {
  margin: 6px 0 0;
  font-size: 11px;
  opacity: .75;
}

/* ==========================================================================
   Default theme — white text only on dark backgrounds (user preview request)
   The theme-engine now returns white for --on-primary/--on-accent when the
   primary/accent is dark and white still meets AA_UI (3:1). This extra block
   makes the intent explicit for the default light theme: any component whose
   background is a dark gradient keeps white text, while light surfaces keep
   dark text. Scoped to light so dark themes still pick the most legible pole.
   ========================================================================== */
:root[data-theme="light"] .app-header,
:root:not([data-theme]) .app-header,
:root[data-theme="light"] .bento-main,
:root:not([data-theme]) .bento-main,
:root[data-theme="light"] .htile-big,
:root:not([data-theme]) .htile-big,
:root[data-theme="light"] .deck-card,
:root:not([data-theme]) .deck-card,
:root[data-theme="light"] .mode.active,
:root:not([data-theme]) .mode.active,
:root[data-theme="light"] .settings-tab.active,
:root:not([data-theme]) .settings-tab.active,
:root[data-theme="light"] .printer-subtab.active,
:root:not([data-theme]) .printer-subtab.active,
:root[data-theme="light"] .home-chip.on,
:root:not([data-theme]) .home-chip.on,
:root[data-theme="light"] .flow-n,
:root:not([data-theme]) .flow-n,
:root[data-theme="light"] .dial-main,
:root:not([data-theme]) .dial-main,
:root[data-theme="light"] .btn-primary,
:root:not([data-theme]) .btn-primary,
:root[data-theme="light"] .chip-lavender,
:root:not([data-theme]) .chip-lavender,
:root[data-theme="light"] .chip-teal,
:root:not([data-theme]) .chip-teal {
  color: #ffffff;
}
/* Sub-elements that inherit but were sometimes overridden */
:root[data-theme="light"] .app-header .hdr-title,
:root:not([data-theme]) .app-header .hdr-title,
:root[data-theme="light"] .app-header .hdr-btn,
:root:not([data-theme]) .app-header .hdr-btn,
:root[data-theme="light"] .bento-main b,
:root:not([data-theme]) .bento-main b,
:root[data-theme="light"] .htile-big .htile-name,
:root:not([data-theme]) .htile-big .htile-name,
:root[data-theme="light"] .htile-big .htile-sub,
:root:not([data-theme]) .htile-big .htile-sub,
:root[data-theme="light"] .deck-card .deck-name,
:root:not([data-theme]) .deck-card .deck-name,
:root[data-theme="light"] .deck-card .deck-sub,
:root:not([data-theme]) .deck-card .deck-sub,
:root[data-theme="light"] .deck-card .deck-stat,
:root:not([data-theme]) .deck-card .deck-stat,
:root[data-theme="light"] .bento-main .bento-go,
:root:not([data-theme]) .bento-main .bento-go {
  color: #ffffff;
}
