/* Drawer Finder — industrial workshop UI.
   One dominant field (warm wall/paper), one structural colour (cabinet blue),
   one signal colour (safety amber = "found / selected").
   Archivo carries the interface; IBM Plex Mono is reserved for data:
   drawer codes, quantities, positions, keys. */
:root {
  --wall: #ebe7df;
  --paper: #f6f3ec;
  --paper-2: #fbfaf7;
  --ink: #15181d;
  --ink-2: #3a3f47;
  --mute: #62666c;
  --line: #d9d3c7;
  --line-2: #e7e2d8;
  --blue: #1d5bd6;
  --blue-deep: #1543a3;
  --amber: #ffb000;
  --amber-deep: #b97f00;
  --amber-tint: #fff3d6;
  --low: #b93a0a;
  --live: #1f9d63;

  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --panel-w: 392px;
  --top-h: 60px;
  --r: 6px;
  --shadow-1: 0 1px 2px rgba(21, 24, 29, .1), 0 4px 12px -6px rgba(21, 24, 29, .28);
  --shadow-2: 0 2px 6px rgba(21, 24, 29, .08), 0 14px 32px -14px rgba(21, 24, 29, .45);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --sheet-ease: cubic-bezier(.22, .9, .24, 1);
  color-scheme: light;
  accent-color: var(--blue);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--wall);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  caret-color: var(--blue);
}
::selection { background: rgba(255, 176, 0, .42); color: var(--ink); }
* { scrollbar-width: thin; scrollbar-color: #c6bfb1 transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
[hidden] { display: none !important; }
.ico { width: 18px; height: 18px; flex: none; display: block; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  grid-template-rows: var(--top-h) minmax(0, 1fr);
  height: 100dvh;
}

/* ---------- header ---------- */
.top {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: calc(var(--panel-w) - 20px) minmax(240px, 640px) 1fr;
  align-items: center;
  gap: 20px;
  padding: 0 16px 0 20px;
  background: var(--ink);
  color: var(--paper);
  position: relative;
  z-index: 7;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-weight: 800; font-stretch: 125%; font-size: 17px; letter-spacing: -.01em; text-transform: uppercase; }
.brand-text small { font-size: 12px; font-weight: 500; color: #a9adb4; }

.search {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 8px 0 12px;
  background: var(--paper-2); color: var(--ink);
  border-radius: var(--r);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .12);
}
.search:focus-within { outline: 3px solid var(--amber); outline-offset: 0; }
.search .ico { color: var(--ink-2); }
.search input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  font-size: 15px;
}
.search input::placeholder { color: #6b6e73; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search-kbd {
  font: 600 12px/1 var(--mono); color: var(--ink-2);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  padding: 3px 6px; background: #fff;
}
.btn-head {
  justify-self: end;
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .22); border-radius: var(--r);
  background: transparent; color: var(--paper);
  font-weight: 600; font-size: 14px;
  transition: background-color .15s, border-color .15s;
}
.btn-head:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .4); }

/* ---------- panel ---------- */
.panel {
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
  position: relative; z-index: 6;
}
.sheet-grip { display: none; }
.tabs { display: flex; gap: 24px; padding: 0 22px; border-bottom: 1px solid var(--line); flex: none; }
.tabs button {
  border: 0; background: none; padding: 15px 0 12px;
  font-weight: 600; font-size: 14px; color: var(--mute);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.panel-body { flex: 1; overflow: auto; padding: 4px 22px 48px; overscroll-behavior: contain; }

.sec {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 30px 0 4px; padding-top: 12px;
  border-top: 1px solid var(--ink);
  font-size: 12px; font-weight: 700; font-stretch: 115%; letter-spacing: .08em; text-transform: uppercase;
}
.sec .aside { font-size: 13px; font-weight: 500; font-stretch: 100%; letter-spacing: 0; text-transform: none; color: var(--mute); }
.sec button {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: none; padding: 0;
  font-size: 13px; font-weight: 600; font-stretch: 100%; letter-spacing: 0; text-transform: none; color: var(--blue);
}
.sec button .ico { width: 15px; height: 15px; }
.sec button:hover { text-decoration: underline; text-underline-offset: 3px; }

/* overview summary */
.summary { margin: 22px 0 0; font-size: 19px; line-height: 1.4; font-weight: 450; color: var(--ink-2); text-wrap: pretty; }
.summary b { color: var(--ink); font-weight: 750; font-variant-numeric: tabular-nums; }
.summary b.low { color: var(--low); }
.source { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--mute); }
.source i { width: 7px; height: 7px; border-radius: 50%; background: #9a9da2; flex: none; }
.source[data-state="live"] i { background: var(--live); box-shadow: 0 0 0 3px rgba(31, 157, 99, .16); }
.source[data-state="local"] i { background: var(--amber); box-shadow: 0 0 0 3px rgba(255, 176, 0, .2); }
.source button { border: 0; background: none; padding: 0; color: var(--blue); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.summary-link {
  display: inline; padding: 0; border: 0; background: none; text-align: left;
  font: inherit; color: inherit;
  text-decoration: underline; text-decoration-color: rgba(185, 58, 10, .3); text-decoration-thickness: 1.5px; text-underline-offset: 4px;
  transition: text-decoration-color .15s;
}
.summary-link:hover { text-decoration-color: var(--low); }

/* cabinet glyph: a to-scale drawing of the real cabinet (0.56 × 0.72 m) */
.cab-glyph {
  display: flex; flex-direction: column; gap: 3px; flex: none;
  width: 58px; aspect-ratio: 56 / 72; padding: 4px;
  background: var(--blue); border-radius: 4px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .22), 0 6px 14px -10px rgba(21, 24, 29, .6);
}
.g-up, .g-low { flex: 1; display: grid; gap: 1px; }
.g-up { grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(5, 1fr); }
.g-low { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding-top: 3px; border-top: 2px solid var(--blue-deep); }
.cab-glyph i, .cab-glyph button { display: block; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 1px; background: rgba(255, 255, 255, .26); }
.cab-glyph .f { background: #fff; }
.cab-glyph .hot { background: var(--amber); }
.cab-glyph .sel { background: var(--amber); box-shadow: 0 0 0 1.5px var(--ink); }

/* overview: one row per cabinet */
.cabs { display: grid; gap: 2px; margin: 0 -10px; }
.cab {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center;
  width: 100%; padding: 10px; text-align: left;
  border: 0; border-radius: 8px; background: none;
  transition: background-color .15s, box-shadow .15s;
}
.cab:hover { background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--line); }
.cab > .ico { width: 16px; height: 16px; color: #a19a8c; transition: color .15s, transform .2s var(--ease-out); }
.cab:hover > .ico { color: var(--ink); transform: translateX(2px); }
.cab-body { display: grid; gap: 2px; min-width: 0; }
.cab-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.cab-title b { font-weight: 800; font-stretch: 125%; font-size: 19px; line-height: 1; color: var(--blue); }
.cab-name { font-weight: 650; font-size: 15px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-bottom: 1px; }
.cab-name.unnamed { color: var(--mute); font-weight: 500; }
.cab-meta { margin: 0; font-size: 13px; color: var(--mute); font-variant-numeric: tabular-nums; }
.cab-peek { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* cabinet view */
.cabv-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; margin: 14px 0 4px; }
.cab-glyph.lg { width: 112px; padding: 6px; gap: 5px; border-radius: 6px; }
.cab-glyph.lg .g-up, .cab-glyph.lg .g-low { gap: 2px; }
.cab-glyph.lg .g-low { padding-top: 5px; border-top-width: 3px; }
.cab-glyph.lg button { border-radius: 2px; cursor: pointer; transition: background-color .12s, box-shadow .12s; }
.cab-glyph.lg button:hover { background: var(--amber); }
.cabv-text h2 { display: flex; align-items: center; gap: 10px; min-width: 0; margin: 0 0 6px; font-size: 17px; }
.cabv-letter { font-weight: 800; font-stretch: 125%; font-size: 30px; line-height: 1; color: var(--blue); }
.cabv-name { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; }
.cabv-text .cab-meta + .cab-meta { margin-top: 2px; }
.cab-rename {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 30px; border: 0; border-radius: 5px; background: none; color: var(--mute);
}
.cab-rename:hover { color: var(--ink); background: rgba(21, 24, 29, .06); }
.cab-rename .ico { width: 15px; height: 15px; }
.cab-name-input { width: 100%; min-width: 0; border: 1px solid var(--ink); border-radius: 4px; padding: 4px 8px; font-size: 15px; background: #fff; }

.drows { display: grid; margin: 4px -10px 0; }
.drow {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start;
  width: 100%; padding: 10px; text-align: left; border: 0; border-radius: var(--r); background: none;
  transition: background-color .12s, box-shadow .12s;
}
.drow + .drow { box-shadow: 0 -1px 0 var(--line-2); }
.drow:hover { background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--line); }
.drow:hover + .drow { box-shadow: none; }
.drow-items { display: grid; gap: 2px; min-width: 0; }
.drow-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.drow-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drow-more { font-size: 13px; color: var(--mute); }
.code-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag.empty { background: transparent; border-style: dashed; color: var(--mute); box-shadow: none; }
.tag.empty:hover { color: var(--ink); background: #fff; border-style: solid; }

/* list rows */
.row-item {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px;
  width: 100%; padding: 10px 0; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line-2);
}
button.row-item:hover .row-name { text-decoration: underline; text-underline-offset: 3px; }
.row-name { overflow-wrap: anywhere; }
.qty { font: 500 13px/1 var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.badge-low {
  display: inline-block; vertical-align: 1px; margin-left: 8px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; line-height: 1;
  color: var(--low); background: rgba(185, 58, 10, .09); border-radius: 3px; padding: 4px 5px 3px;
}
.more-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 6px 0;
  border: 0; background: none; color: var(--blue); font-size: 14px; font-weight: 600;
}
.more-btn .ico { width: 15px; height: 15px; transition: transform .2s var(--ease-out); }
.more-btn[aria-expanded="true"] .ico { transform: rotate(180deg); }
.more-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* drawer contents: name left (with stock badge), quantity in a fixed right column */
.items { display: grid; }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) 3.5em; gap: 12px; align-items: baseline;
  padding: 11px 0; border-bottom: 1px solid var(--line-2);
}
.item .qty { text-align: right; font-size: 14px; color: var(--ink); }
.item-name { overflow-wrap: anywhere; }

.tag {
  display: inline-block;
  font: 600 12.5px/1 var(--mono);
  background: #fff; color: var(--ink);
  border: 1px solid #cfc9bd; border-radius: 3px;
  padding: 5px 6px 4px; min-width: 40px; text-align: center;
  box-shadow: 0 1px 0 rgba(21, 24, 29, .1);
  white-space: nowrap;
}
.tag.hot { background: var(--amber); border-color: var(--amber-deep); }
button.tag { cursor: pointer; transition: border-color .15s; }
button.tag:hover { border-color: var(--ink); }

mark { background: rgba(255, 176, 0, .38); color: inherit; border-radius: 2px; padding: 0 1px; }

/* search results */
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 20px 0 6px; }
.results-head b { font-weight: 800; font-stretch: 118%; font-size: 21px; letter-spacing: -.01em; }
.results-head span { font-size: 13px; color: var(--mute); font-variant-numeric: tabular-nums; }
.hits { display: grid; margin: 8px -10px 0; }
.hit {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start;
  width: 100%; text-align: left;
  padding: 12px 10px; border: 0; border-radius: var(--r); background: none;
  transition: background-color .12s, box-shadow .12s;
}
.hit + .hit { box-shadow: 0 -1px 0 var(--line-2); }
.hit:hover, .hit.active { background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--line); }
.hit:hover + .hit, .hit.active + .hit { box-shadow: none; }
.hit-items { display: grid; gap: 3px; min-width: 0; }
.hit-items div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.hit-sub { font: 500 12px/1.3 var(--mono); color: var(--mute); margin-top: 5px; }
.drawer-jump {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  margin-top: 12px; padding: 12px; border: 1px solid var(--amber-deep); border-radius: var(--r);
  background: var(--amber-tint); box-shadow: var(--shadow-1);
}
.drawer-jump b { font-size: 15px; }
.drawer-jump .pos { font: 500 12px/1.3 var(--mono); color: var(--ink-2); }
.empty { padding: 24px 0 8px; color: var(--mute); }
.empty b { display: block; font-weight: 800; font-stretch: 112%; font-size: 19px; color: var(--ink); margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  border: 1px solid var(--line); background: var(--paper-2); border-radius: 99px;
  padding: 6px 12px; font-size: 14px; color: var(--ink);
  transition: border-color .15s;
}
.chip:hover { border-color: var(--ink); }

/* drawer detail */
.back {
  display: inline-flex; align-items: center; gap: 4px; margin: 16px 0 0 -4px;
  border: 0; background: none; padding: 4px;
  font-size: 13.5px; font-weight: 600; color: var(--mute); border-radius: 4px;
}
.back .ico { width: 16px; height: 16px; }
.back:hover { color: var(--ink); }
.detail-head { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; margin: 14px 0 4px; }
.sticker {
  display: inline-block;
  font: 600 44px/1 var(--mono); letter-spacing: -.02em;
  background: #fff; color: #111;
  border: 1px solid #d8d2c6; border-radius: 2px;
  padding: 12px 16px 10px;
  transform: rotate(-1.6deg);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08), 0 10px 22px -12px rgba(0, 0, 0, .45);
}
.detail-head h2 { margin: 0; font-weight: 750; font-stretch: 112%; font-size: 19px; line-height: 1.2; text-wrap: balance; }
.detail-head p { margin: 0; }
.detail-sub { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-top: 2px !important; }
.detail-type { font-size: 14px; color: var(--ink-2); margin-top: 6px !important; }
.detail-pos { font: 500 12.5px/1.45 var(--mono); color: var(--mute); margin-top: 1px !important; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.toolbar { display: flex; gap: 8px; margin-top: 18px; }
.btn.grow { flex: 1; }
.btn.icon { width: 40px; min-width: 40px; padding: 0; flex: none; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 0;
  border: 0; background: none; color: var(--blue); font-size: 13.5px; font-weight: 600;
}
.link-btn .ico { width: 15px; height: 15px; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--paper-2); color: var(--ink);
  font-size: 13.5px; font-weight: 600;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--ink); box-shadow: var(--shadow-1); }
.btn .ico { width: 16px; height: 16px; }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { background: #2b3038; }
.btn[aria-expanded="true"] { border-color: var(--ink); background: #fff; }
.spacer { flex: 1; }

.qr-card {
  display: grid; grid-template-columns: 112px 1fr; gap: 16px; align-items: center;
  margin-top: 14px; padding: 14px; background: #fff; border: 1px dashed #b9b2a3; border-radius: var(--r);
}
.qr-card svg { width: 112px; height: 112px; display: block; }
.qr-card p { margin: 0 0 10px; font-size: 14px; color: var(--ink-2); }
.qr-card code { font-family: var(--mono); font-size: 12.5px; }

.compass-wrap { display: flex; gap: 18px; align-items: center; margin-top: 12px; }
.compass { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 6px; align-items: center; }
.compass .tag { min-width: 46px; }
.compass .here { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.compass .none { visibility: hidden; }
.compass-wrap p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--mute); }
kbd.k { font: 600 11px/1 var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 2px 5px; background: #fff; color: var(--ink-2); }

.edit-rows { display: grid; gap: 6px; margin-top: 10px; }
.edit-row { display: grid; grid-template-columns: 1fr 72px 38px; gap: 6px; }
.edit-row input { width: 100%; min-height: 38px; border: 1px solid var(--line); border-radius: 5px; padding: 7px 9px; background: #fff; font-size: 14px; }
.edit-row input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 2px var(--amber); }
.edit-row input[type="number"] { font-family: var(--mono); }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border: 1px solid transparent; border-radius: 5px; background: none; color: var(--mute);
  transition: color .15s, background-color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--ink); background: rgba(21, 24, 29, .06); }
.edit-row .icon-btn { border-color: var(--line); background: var(--paper-2); }
.edit-row .icon-btn:hover { color: var(--low); border-color: var(--low); }
.note { font-size: 13px; color: var(--mute); margin-top: 10px; }

/* A–Z */
.az-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 20px; }
.az-head p { margin: 0; font-size: 15px; color: var(--ink-2); }
.az-head b { font-weight: 750; color: var(--ink); font-variant-numeric: tabular-nums; }
.az-rail { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0 6px; }
.az-rail button {
  min-width: 30px; height: 30px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 5px; background: var(--paper-2); color: var(--ink);
  font-size: 13px; font-weight: 700; font-stretch: 112%;
  transition: border-color .15s, background-color .15s, color .15s;
}
.az-rail button:hover { border-color: var(--ink); }
.az-letter {
  position: sticky; top: -4px; z-index: 1;
  background: var(--paper);
  font-weight: 800; font-stretch: 125%; font-size: 17px; color: var(--blue);
  padding: 16px 0 4px; border-bottom: 1px solid var(--line);
  scroll-margin-top: 4px;
}
.tab-count { margin-left: 4px; font-size: 12px; font-weight: 600; color: var(--mute); font-variant-numeric: tabular-nums; }

/* ---------- stage ---------- */
.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--wall); }
#wall { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hud { position: absolute; z-index: 3; display: flex; gap: 10px; align-items: center; }
.hud-tl { left: 18px; top: 16px; }
.hud-tr { right: 18px; top: 16px; }
.hud-bl { left: 18px; bottom: 18px; }
.hud-br { right: 18px; bottom: 18px; flex-direction: column; align-items: flex-end; gap: 8px; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-1);
}
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: transparent; color: var(--ink-2);
  padding: 6px 11px; border-radius: 5px; font-size: 13.5px; font-weight: 600;
  transition: background-color .15s, color .15s;
}
.seg button .ico { width: 16px; height: 16px; }
.seg button:hover:not([aria-pressed="true"]) { background: rgba(21, 24, 29, .06); color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.jump { display: flex; gap: 6px; }
.jump button {
  width: 40px; height: 40px; display: grid; place-items: center; padding: 0;
  background: var(--paper-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-1);
  font-weight: 800; font-stretch: 125%; font-size: 16px;
  transition: border-color .15s, background-color .15s, color .15s;
}
.jump button:hover { border-color: var(--ink); }
.jump button[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }

.toggle {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 13px;
  background: var(--paper-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-1);
  font-size: 13.5px; font-weight: 600;
  transition: border-color .15s, background-color .15s, color .15s;
}
.toggle .ico { color: var(--blue); }
.toggle:hover { border-color: var(--ink); }
.toggle[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.toggle[aria-pressed="true"] .ico { color: #8db4ff; }
.legend {
  display: flex; gap: 10px; padding: 7px 10px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-1);
  font-size: 12.5px; color: var(--ink-2);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }

.lit {
  display: inline-flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 6px 0 13px;
  background: var(--amber); color: var(--ink);
  border: 1px solid var(--amber-deep); border-radius: 8px; box-shadow: var(--shadow-1);
  font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.lit i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); animation: pulse 1.6s ease-in-out infinite; }
.lit .icon-btn { width: 28px; height: 28px; color: var(--ink); }
.lit .icon-btn:hover { background: rgba(0, 0, 0, .1); }
.lit .icon-btn .ico { width: 15px; height: 15px; }
.lit :focus-visible { outline-color: var(--ink); }
@keyframes pulse { 50% { opacity: .3; } }

.hint {
  position: absolute; left: 50%; top: 20px; transform: translateX(-50%); margin: 0; z-index: 2;
  font-size: 13px; color: var(--ink-2);
  background: rgba(251, 250, 247, .9); padding: 7px 13px; border-radius: 99px; border: 1px solid var(--line);
  transition: opacity .6s var(--ease-out), transform .6s var(--ease-out); white-space: nowrap;
}
.hint.gone { opacity: 0; transform: translate(-50%, -8px); pointer-events: none; }

.tip {
  position: fixed; z-index: 30; pointer-events: none;
  min-width: 170px; max-width: 280px;
  background: var(--ink); color: var(--paper);
  border-radius: var(--r); padding: 10px 12px;
  box-shadow: var(--shadow-2);
  font-size: 13.5px;
}
.tip .tag { margin-bottom: 8px; }
.tip ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; }
.tip li { display: flex; justify-content: space-between; gap: 12px; }
.tip li span:last-child { font-family: var(--mono); font-size: 12.5px; color: #c1c5cb; }
.tip .tip-empty { color: #b3b7bd; }
.tip .tip-foot { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--amber); }

.loading {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 4;
  background: var(--wall); transition: opacity .7s var(--ease-out); pointer-events: none;
  font-size: 14px; font-weight: 600; color: var(--mute);
}
.loading.done { opacity: 0; }

/* ---------- flat map ---------- */
.map {
  position: absolute; inset: 0; overflow: auto; z-index: 1;
  padding: 76px max(24px, calc((100% - 1260px) / 2)) 96px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px;
  align-content: start;
  background:
    radial-gradient(circle at 1px 1px, rgba(21, 24, 29, .08) 1px, transparent 0) 0 0 / 18px 18px,
    var(--wall);
}
.mcab {
  background: var(--blue); border-radius: 8px; padding: 8px 8px 10px;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .18), 0 18px 30px -22px rgba(0, 0, 0, .6);
}
.mcab header { display: flex; align-items: baseline; gap: 8px; color: #fff; padding: 2px 4px 8px; min-width: 0; }
.mcab header b { font-weight: 800; font-stretch: 125%; font-size: 22px; line-height: 1; }
.mcab header span { font-size: 13px; font-weight: 600; color: #dbe6ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcab header span.unnamed { font-weight: 500; color: #aec6fa; }
.mgrid { display: grid; gap: 3px; }
.mgrid.small { grid-template-columns: repeat(6, 1fr); }
.mgrid.large { grid-template-columns: repeat(3, 1fr); margin-top: 7px; padding-top: 7px; border-top: 3px solid var(--blue-deep); }
.cell {
  position: relative; height: 36px; padding: 0;
  background: rgba(240, 245, 248, .92); border: 1px solid rgba(255, 255, 255, .7); border-radius: 3px;
  display: grid; place-items: center;
  font: 600 11px/1 var(--mono); color: var(--ink);
  transition: background-color .15s, color .15s;
}
.mgrid.large .cell { height: 58px; font-size: 12px; }
.cell.tilt { transform: perspective(80px) rotateX(9deg); transform-origin: bottom; }
.cell::after { content: ""; position: absolute; left: 5px; right: 5px; bottom: 3px; height: 3px; border-radius: 2px; }
.cell.f::after { background: var(--blue); }
.cell:hover { background: #fff; }
.map.heat .cell[data-heat="0"] { background: #c9c3b6; }
.map.heat .cell[data-heat="1"] { background: #d6e4ff; }
.map.heat .cell[data-heat="2"] { background: #96baff; }
.map.heat .cell[data-heat="3"] { background: #4f8cff; color: #fff; }
.map.searching .cell:not(.hot):not(.sel) { background: rgba(255, 255, 255, .22); border-color: transparent; color: rgba(255, 255, 255, .78); }
.map.searching .cell:not(.hot):not(.sel).f::after { background: rgba(255, 255, 255, .55); }
.cell.hot { background: var(--amber) !important; color: var(--ink) !important; border-color: var(--amber-deep); }
.cell.sel { outline: 3px solid var(--ink); outline-offset: 1px; z-index: 1; background: var(--amber) !important; color: var(--ink) !important; }

/* ---------- dialog / toast / print ---------- */
.scan { border: 1px solid var(--line); border-radius: 10px; padding: 0; width: min(440px, 94vw); background: var(--paper); box-shadow: var(--shadow-2); }
.scan::backdrop { background: rgba(21, 24, 29, .55); }
.scan-inner { padding: 16px; display: grid; gap: 12px; }
.scan-inner header { display: flex; justify-content: space-between; align-items: center; }
.scan-inner h2 { margin: 0; font-weight: 800; font-stretch: 118%; font-size: 18px; }
.scan-view { position: relative; aspect-ratio: 4 / 3; background: var(--ink); border-radius: var(--r); overflow: hidden; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 22%; border: 2px solid var(--amber); border-radius: 8px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .25); }
.scan-msg { margin: 0; font-size: 14px; color: var(--mute); }
.scan-row { display: flex; gap: 8px; }
.scan-row input { flex: 1; min-width: 0; min-height: 38px; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; background: #fff; font-size: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 40;
  transform: translate(-50%, 140%); opacity: 0;
  background: var(--ink); color: var(--paper);
  padding: 11px 16px; border-radius: var(--r); box-shadow: var(--shadow-2);
  font-size: 14px;
  transition: transform .35s var(--ease-out), opacity .35s var(--ease-out);
  max-width: min(520px, 92vw);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.print-sheet { display: none; }
@media print {
  body { overflow: visible; background: #fff; }
  body > *:not(.print-sheet) { display: none !important; }
  .print-sheet { display: grid; place-items: center; padding-top: 30mm; }
  .print-label { border: 1px dashed #999; padding: 8mm; text-align: center; font-family: var(--mono); }
  .print-label svg { width: 50mm; height: 50mm; }
  .print-label b { display: block; font-size: 28pt; margin-top: 4mm; }
  .print-label small { display: block; font-size: 10pt; color: #444; font-family: var(--sans); }
}

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  :root { --panel-w: 340px; }
  .top { grid-template-columns: calc(var(--panel-w) - 20px) minmax(200px, 1fr) auto; }
}

/* ---------- phone: full-screen wall + bottom sheet ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .top {
    grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  }
  .brand-text, .search-kbd, .btn-head span { display: none; }
  .brand-mark { width: 32px; height: 32px; }
  .search { height: 44px; }
  .search input { font-size: 16px; }
  .btn-head { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .stage { grid-row: 2; }

  .panel {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: var(--sheet-h, 172px);
    border-right: 0; border-radius: 16px 16px 0 0;
    box-shadow: 0 -1px 0 var(--line), 0 -14px 34px -16px rgba(21, 24, 29, .5);
    transition: height .4s var(--sheet-ease);
  }
  .app.dragging .panel { transition: none; }
  .sheet-grip {
    display: grid; place-items: center; flex: none;
    width: 100%; height: 24px; padding: 0; border: 0; background: none;
    touch-action: none; cursor: grab;
  }
  .sheet-grip i { width: 40px; height: 4px; border-radius: 2px; background: #bdb6a8; }
  .tabs { padding: 0 18px; gap: 22px; touch-action: none; }
  .tabs button { padding: 8px 0 11px; min-height: 40px; }
  .panel-body { padding: 0 18px calc(28px + env(safe-area-inset-bottom)); }
  .app[data-sheet="peek"] .panel-body { overflow: hidden; }
  .summary { margin-top: 14px; font-size: 17px; }
  .detail-head { margin-top: 10px; }
  .sticker { font-size: 38px; padding: 10px 14px 8px; }
  .btn { min-height: 44px; }
  .btn.icon { width: 44px; min-width: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .az-rail button { min-width: 38px; height: 38px; }
  .cab-glyph.lg { width: 96px; }
  .edit-row { grid-template-columns: 1fr 72px 44px; }
  .edit-row input { min-height: 44px; font-size: 16px; }
  .row-item, .hit { min-height: 44px; }

  .hud-tl { left: 10px; top: 10px; }
  .hud-tr { right: 10px; top: 10px; }
  .hud-bl, .hud-br {
    bottom: calc(var(--sheet-h, 172px) + 12px);
    transition: bottom .4s var(--sheet-ease), opacity .2s;
  }
  .hud-bl { left: 10px; }
  .hud-br { right: 10px; }
  .app.dragging .hud-bl, .app.dragging .hud-br { transition: opacity .2s; }
  .app[data-sheet="full"] .hud-bl, .app[data-sheet="full"] .hud-br { opacity: 0; pointer-events: none; }
  .jump button, .toggle { width: 44px; height: 44px; }
  .toggle { padding: 0; justify-content: center; }
  .toggle span, .lit-q { display: none; }
  .seg button { padding: 8px 11px; min-height: 40px; }
  .lit { height: 44px; }
  .hint { display: none; }
  .legend { font-size: 12px; }

  .map {
    display: flex; overflow: auto; gap: 12px;
    scroll-snap-type: x mandatory; scroll-padding: 0 7vw;
    padding: 68px 7vw calc(var(--sheet-h, 172px) + 78px);
    align-items: flex-start; justify-content: flex-start;
  }
  .mcab { flex: 0 0 86vw; max-width: 380px; scroll-snap-align: center; }
  .cell { height: 44px; font-size: 12px; }
  .mgrid.large .cell { height: 62px; }

  .toast { bottom: calc(var(--sheet-h, 172px) + 72px); }
}

@media (hover: none) {
  .tip { display: none; }
}

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