@font-face {
  font-family: "Inter";
  src: url("/frontend/assets/fonts/inter/Inter-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

.item-photo-manager { display:grid; grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:12px; }
.managed-photo { border:1px solid var(--line); border-radius:14px; padding:8px; background:var(--panel); }
.managed-photo.main { border-color:var(--accent); }
.managed-photo img { width:100%; aspect-ratio:1; object-fit:cover; border-radius:10px; }
.managed-photo .actions { margin-top:8px; }
.access-existing, .category-list > div, .category-add { display:flex; align-items:center; gap:8px; }
.access-existing { justify-content:space-between; padding:10px 0; border-bottom:1px solid var(--line); }
.access-existing span { display:grid; gap:3px; }
.category-manager { border-top:1px solid var(--line); padding-top:16px; }
.category-add input, .category-list input { flex:1; min-width:0; }
.category-list { display:grid; gap:8px; margin-top:10px; }
.data-actions { flex-wrap:wrap; }
@font-face {
  font-family: "JetBrains Mono";
  src: url("/frontend/assets/fonts/jetbrains-mono/JetBrainsMono-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
}
@font-face {
  font-family: "Lora";
  src: url("/frontend/assets/fonts/lora/Lora-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --bg: #F0EEE6;
  --surface: #FBFAF7;
  --sunken: #F5F3EC;
  --sunken-2: #EFEDE4;
  --border: #E5E1D6;
  --input: #D8D3C4;
  --text: #1C1B1A;
  --muted: #5F5A50;
  --faint: #6B6557;
  --accent: #CC785C;
  --accent-soft: #F4E5DD;
  --ok: #2F8A52;
  --ok-soft: #E7F3EC;
  --danger: #B5503B;
  --dark: #26241F;
  --shadow: 0 18px 42px -30px rgba(28, 27, 26, .5);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #22201C;
  --surface: #2B2925;
  --sunken: #323029;
  --sunken-2: #383530;
  --border: #403C35;
  --input: #4E493F;
  --text: #EDE9E0;
  --muted: #B0A99B;
  --faint: #857E70;
  --accent: #D88A6E;
  --accent-soft: #3A2C25;
  --ok: #7FA98A;
  --ok-soft: #2A3A2F;
  --danger: #D87862;
  --dark: #11100E;
  --shadow: 0 18px 42px -30px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background: var(--bg);
}
body {
  margin: 0;
  min-width: 320px;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}
body:has(.home-hero) { min-height: 100vh; }
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .62; }
img { max-width: 100%; display: block; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.skip-link {
  position: fixed;
  left: 16px;
  top: 10px;
  z-index: 100;
  transform: translateY(-140%);
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--dark);
  color: var(--surface);
  font-weight: 800;
}
.skip-link:focus-visible { transform: translateY(0); }

.app-shell { min-height: 100dvh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 62px;
  padding: 0 clamp(16px, 4vw, 40px);
  background: rgba(251, 250, 247, .94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .bottom-bar {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}
html[data-theme="dark"] .brand svg rect { stroke: var(--text); }
html[data-theme="dark"] .condition-used { background: #263746; color: #9FC1DF; }
html[data-theme="dark"] .condition-damaged,
html[data-theme="dark"] .condition-needs_repair { background: #442A24; color: #F0A084; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: Lora, Georgia, serif;
  font-size: 18px;
  font-weight: 500;
}
.brand svg { width: 28px; height: 28px; flex: 0 0 auto; }
.nav { display: flex; gap: 4px; }
.nav button {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}
.nav button.active { background: var(--accent-soft); color: var(--accent); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--input);
  background: var(--sunken);
  color: var(--muted);
  font-weight: 500;
}

.main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3.6vw, 32px) clamp(16px, 4vw, 40px) 32px;
}
.stack { display: flex; flex-direction: column; gap: 16px; }
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 12px 0 4px;
  text-align: center;
}
.home-hero { padding-top: 20px; }
.page-hero {
  padding-top: 10px;
  gap: 10px;
}
.page-hero p { font-size: 14px; }
.page-search { width: min(780px, 100%); }
h1, h2, h3 {
  margin: 0;
  font-weight: 500;
  letter-spacing: 0;
}
h1, h2 { font-family: Lora, Georgia, serif; }
h3 { font-family: inherit; font-weight: 500; }
h1 { font-size: clamp(30px, 3.6vw, 38px); line-height: 1.08; }
h2 { font-size: 26px; line-height: 1.15; }
h3 { font-size: 18px; line-height: 1.2; }
p { margin: 0; color: var(--muted); line-height: 1.55; }

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--input);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { border-color: var(--accent); background: var(--accent); color: var(--surface); }
.btn-danger { border-color: #E8CFC7; color: var(--danger); }
.btn-icon { width: 44px; padding: 0; }
.btn-icon svg {
  width: 19px;
  height: 19px;
}
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.active-filters button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.active-filters span { color: var(--accent); }

.search-box {
  position: relative;
  width: min(720px, 100%);
}
.search-wrap {
  position: relative;
  width: min(720px, 100%);
}
.search-wrap .search-box { width: 100%; }
.search-input, .field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--input);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.search-input {
  height: 50px;
  padding: 0 18px;
  box-shadow: 0 14px 34px -22px rgba(28, 27, 26, .28);
  font-size: 15px;
}
.search-input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, .16);
}
.search-results {
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.floating-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 15;
  width: 100%;
  max-height: min(430px, calc(100vh - 220px));
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.quick-searches {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--faint);
}
.quick-searches::before {
  content: "Недавно искали:";
  align-self: center;
  font-size: 13px;
}
.quick-searches button {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  background: var(--sunken-2);
  color: var(--muted);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; color: var(--muted); }
.stats strong { color: var(--text); }
.stats .warn { color: var(--accent); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.link-btn {
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  padding: 4px 0;
}
.section-narrow { max-width: 720px; }
.screen-head { align-items: center; }
.muted { color: var(--faint); }
.accent { color: var(--accent); }
.mono { font-family: "JetBrains Mono", monospace; }

.places-strip, .recent-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.home-places .places-strip { justify-content: center; }
.centered-strip { justify-content: center; }
.recent-wrap {
  position: relative;
  overflow: hidden;
}
.recent-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.mobile-recent-grid {
  display: none;
}
.recent-card {
  flex: 0 0 calc((100% - 24px) / 3);
  min-width: 0;
  max-width: none;
}
.scroll-btn {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 38px;
  height: 38px;
  transform: translateY(-50%);
  border: 1px solid var(--input);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  box-shadow: var(--shadow);
}
.scroll-btn.left { left: -10px; }
.scroll-btn.right { right: -10px; }
.home-places .section-head { width: 100%; }
.place-card {
  min-width: 190px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  text-align: left;
}
.place-card img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  padding: 4px;
  border-radius: 10px;
  background: var(--sunken);
}
.place-card strong, .item-row strong, .item-card strong { color: var(--text); font-weight: 500; }
.place-card small, .item-row small { color: var(--faint); }
.chev { margin-left: auto; color: var(--input); font-size: 24px; }

.item-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
}
.item-row.selected,
.item-card.selected,
.items-table-row.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 58%, var(--surface));
}
.select-dot {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--input);
  border-radius: 8px;
  background: var(--surface);
  color: var(--surface);
  font-size: 13px;
  font-weight: 600;
}
.select-dot.on { border-color: var(--accent); background: var(--accent); }
.card-dot { position: absolute; top: 8px; right: 8px; z-index: 2; }
.thumb {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: repeating-linear-gradient(45deg, #F0EEE6 0 8px, #E9E6DB 8px 16px);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.icon-thumb { background: var(--sunken); padding: 8px; }
.icon-thumb img { object-fit: contain; }
.letter-thumb {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: var(--sunken);
  color: var(--accent);
  font-weight: 500;
  text-transform: uppercase;
}
.item-placeholder {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 72% 26%, color-mix(in srgb, var(--accent-soft) 70%, transparent) 0 14%, transparent 15%),
    linear-gradient(145deg, color-mix(in srgb, var(--surface) 88%, #fff), var(--sunken-2));
}
.item-placeholder::before {
  content: "";
  width: 50%;
  max-width: 64px;
  aspect-ratio: 1.18;
  border: 2px solid color-mix(in srgb, var(--muted) 28%, transparent);
  border-radius: 13px;
  background:
    linear-gradient(180deg, transparent 0 30%, color-mix(in srgb, var(--muted) 9%, transparent) 31% 100%),
    color-mix(in srgb, var(--surface) 70%, transparent);
  box-shadow:
    0 10px 22px -16px rgba(28, 27, 26, .45),
    12px 12px 0 -7px color-mix(in srgb, var(--muted) 14%, transparent);
}
.item-placeholder::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  transform: translateY(-22px);
}
.item-main { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.item-name {
  display: -webkit-box;
  min-height: 2.6em;
  overflow: hidden;
  line-height: 1.3;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.path { color: var(--muted); font-weight: 400; line-height: 1.35; }
.path strong { color: var(--accent); font-weight: 500; }
.path-muted { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--sunken-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}
.chip.inv { border-radius: 7px; color: var(--text); font-family: "JetBrains Mono", monospace; font-weight: 500; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.condition-new { background: var(--ok-soft); color: var(--ok); }
.condition-used { background: #E7EEF5; color: #426B8E; }
.condition-damaged,
.condition-needs_repair { background: #F7E0D9; color: var(--danger); }
.condition-unknown { border: 1px solid var(--border); background: var(--sunken); color: var(--muted); }

.home-item-card {
  width: 100%;
  min-height: 164px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.home-item-card > .item-name {
  width: 100%;
  min-height: 0;
  text-align: center;
  -webkit-line-clamp: 2;
}
.home-item-mid {
  min-width: 0;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.home-item-mid .thumb {
  width: 58px;
  height: 58px;
}
.home-item-mid .path {
  display: -webkit-box;
  overflow: hidden;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.home-item-mid .path strong { font-size: 11px; }
.home-item-bottom {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.home-item-bottom .chip.inv {
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-item-bottom .chips { align-content: start; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.items-search-row .search-input {
  width: 100%;
  height: 52px;
  border-radius: 16px;
  box-shadow: 0 14px 34px -22px rgba(28, 27, 26, .28);
}
.items-toolbar {
  display: grid;
  grid-template-columns: minmax(130px, .8fr) minmax(130px, .8fr) minmax(220px, 1.4fr) auto auto auto;
  align-items: center;
}
.collection-controls {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.page-search-line {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 10px;
}
.page-search-line.with-inline-action {
  max-width: 760px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin: 0 auto;
}
.page-search-line.with-inline-action .page-search {
  width: 100%;
}
.page-search-line.with-inline-action .actions {
  margin: 0;
}
.compact-add {
  white-space: nowrap;
}
.collection-controls .sort-select { min-width: 190px; }
.collection-items {
  flex-wrap: nowrap;
  align-items: flex-start;
}
.collection-items .place-filter-select { flex: 1 1 210px; }
.collection-boxes .bulk-wrap,
.collection-kits .bulk-wrap { margin-left: auto; }
.sort-menu,
.filter-menu {
  position: relative;
  flex: 0 0 auto;
}
.filter-menu { display: none; }
.sort-menu summary,
.filter-menu summary {
  list-style: none;
  cursor: pointer;
}
.sort-menu summary::-webkit-details-marker,
.filter-menu summary::-webkit-details-marker { display: none; }
.sort-menu summary span:last-child {
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sort-popover,
.filter-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 14;
  min-width: 190px;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.filter-popover {
  min-width: min(320px, calc(100vw - 32px));
  gap: 10px;
}
.filter-popover label {
  display: grid;
  gap: 5px;
}
.filter-popover label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.sort-popover button {
  min-height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  text-align: left;
  font-weight: 400;
}
.sort-popover button.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.bulk-wrap {
  position: relative;
  display: inline-flex;
}
.bulk-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 12;
  min-width: 210px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.bulk-menu strong {
  padding: 2px 4px;
  color: var(--muted);
  font-size: 12px;
}
.bulk-menu .btn {
  justify-content: flex-start;
  min-height: 32px;
}
.action-more-menu {
  position: relative;
}
.action-more-menu summary {
  list-style: none;
  cursor: pointer;
}
.action-more-menu summary::-webkit-details-marker { display: none; }
.action-more-menu > div {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 16;
  min-width: 210px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.action-more-menu > div .btn {
  width: 100%;
  justify-content: flex-start;
}
.advanced-settings {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--sunken);
}
.advanced-settings > summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  list-style: none;
  cursor: pointer;
  font-weight: 700;
}
.advanced-settings > summary::after {
  content: "⌄";
  margin-left: auto;
  color: var(--muted);
}
.advanced-settings[open] > summary::after { transform: rotate(180deg); }
.advanced-settings > summary::-webkit-details-marker { display: none; }
.advanced-settings-body {
  display: grid;
  gap: 14px;
  padding: 0 14px 14px;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.pager span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.toolbar .search-input { height: 46px; box-shadow: none; font-size: 15px; }
.toolbar .search-box { flex: 1; min-width: 240px; }
.filter-select {
  min-height: 38px;
  border: 1px solid var(--input);
  border-radius: 11px;
  appearance: none;
  background: linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 14px center / 6px 6px no-repeat, linear-gradient(135deg, var(--muted) 50%, transparent 50%) right 9px center / 6px 6px no-repeat, var(--surface);
  color: var(--muted);
  padding: 0 30px 0 12px;
  font-size: 13px;
  font-weight: 400;
}
.place-filter-select { min-width: 0; }
.compact-control {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 11px;
  font-size: 13px;
}
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--sunken);
}
.segmented button {
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0 9px;
  font-size: 13px;
  font-weight: 500;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 8px 18px -16px rgba(28, 27, 26, .35); }
.chip-btn {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 500;
}
.chip-btn.active { border-color: var(--accent-soft); background: var(--accent-soft); color: var(--accent); }

.grid { display: grid; gap: 12px; }
.items-grid { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
.boxes-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kits-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.item-card, .box-card, .kit-card, .panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.item-card {
  position: relative;
  overflow: hidden;
  text-align: left;
  padding: 0;
}
.item-photo {
  position: relative;
  height: 118px;
  background: repeating-linear-gradient(45deg, #F0EEE6 0 8px, #E9E6DB 8px 16px);
}
.item-photo img { width: 100%; height: 100%; object-fit: cover; }
.qr-photo {
  display: grid;
  place-items: center;
  background: var(--sunken);
}
.qr-photo img {
  width: 78px;
  height: 78px;
  object-fit: contain;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.kit-photo .item-placeholder::before {
  width: 50px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 10px color-mix(in srgb, var(--muted) 12%, transparent);
}
.photo-inv {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 4px 7px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(8px);
}
.kit-count-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 4px 7px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  backdrop-filter: blur(8px);
}
.kit-count-badge.inline {
  position: static;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  backdrop-filter: none;
  background: var(--sunken);
}
.item-card-body { display: flex; flex-direction: column; gap: 5px; padding: 10px 12px 12px; }
.item-card-body .item-name {
  font-weight: 500;
}
.mobile-card-more {
  display: none;
}
.mobile-item-home-layout {
  display: none;
}
.mobile-home-item-layout {
  display: none;
}
.item-card .path {
  display: -webkit-box;
  overflow: hidden;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.28;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.item-card .path strong { font-size: 11px; }
.kit-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.kit-item-card .item-card-body {
  min-height: 172px;
  padding: 14px;
}
.kit-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 24px;
}
.kit-preview span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 7px;
  border-radius: 8px;
  background: var(--sunken);
  color: var(--muted);
  font-size: 11px;
}
.kit-item-card .card-actions {
  gap: 6px;
  margin-top: 4px;
}
.kit-item-card .card-actions .btn {
  flex: 1 1 auto;
  min-width: 0;
}
.kit-item-card {
  cursor: pointer;
}
.kit-detail-items .item-card {
  min-height: 100%;
}
.items-table {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.items-table-head, .items-table-row {
  display: grid;
  grid-template-columns: 92px minmax(180px, 1.3fr) minmax(220px, 1.6fr) 90px 130px minmax(120px, .8fr);
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
}
.bulk-bar {
  position: sticky;
  top: 74px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.bulk-bar strong { margin-right: auto; }
.items-table-row .select-dot { margin-left: -4px; }
.items-table-row:has(.select-dot) {
  grid-template-columns: 28px 92px minmax(180px, 1.3fr) minmax(220px, 1.6fr) 90px 130px minmax(120px, .8fr);
}
.items-table-head.bulk-head {
  grid-template-columns: 28px 92px minmax(180px, 1.3fr) minmax(220px, 1.6fr) 90px 130px minmax(120px, .8fr);
}
.items-table-head {
  color: var(--faint);
  background: var(--sunken);
  font-size: 12px;
  font-weight: 800;
}
.items-table-head button {
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
}
.items-table-head button.active { color: var(--text); }
.items-table-row {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
}
.items-table-row:hover { background: var(--sunken); }
.boxes-table .items-table-head,
.boxes-table .items-table-row {
  grid-template-columns: 120px minmax(180px, 1.2fr) minmax(220px, 1.5fr) 90px;
}
.boxes-table .items-table-head.bulk-head,
.boxes-table .items-table-row:has(.select-dot) {
  grid-template-columns: 28px 120px minmax(180px, 1.2fr) minmax(220px, 1.5fr) 90px;
}
.kits-table .items-table-head,
.kits-table .items-table-row {
  grid-template-columns: minmax(180px, 1.2fr) minmax(240px, 1.6fr) 80px 90px;
}
.kits-table .items-table-head.bulk-head,
.kits-table .items-table-row:has(.select-dot) {
  grid-template-columns: 28px minmax(180px, 1.2fr) minmax(240px, 1.6fr) 80px 90px;
}

.places-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding-top: 24px;
  padding-bottom: 20px;
}
.places-layout > .stack { gap: 12px; }
.panel { padding: 18px; }
.places-panel {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 116px);
  min-height: 0;
}
.compact-search { width: 100%; }
.compact-search .search-input { height: 44px; box-shadow: none; font-size: 14px; padding-right: 14px; }
.tree {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}
.tree-group { display: flex; flex-direction: column; gap: 4px; }
.tree-node {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
}
.tree-node strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-node .muted { margin-left: auto; }
.tree-caret {
  width: 18px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--muted);
}
.place-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 2px 0 4px;
  text-align: center;
}
.place-actions {
  justify-content: center;
  gap: 8px;
}
.tree-node.active { background: var(--accent-soft); color: var(--accent); }
.map {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 2.6 / 1;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: repeating-linear-gradient(45deg, #E9E6DB 0 12px, #E2DECF 12px 24px);
}
.map img { width: 100%; height: 100%; object-fit: cover; }
.map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}
.zone {
  position: absolute;
  border: 2.5px solid var(--zone);
  border-radius: 10px;
  background: color-mix(in srgb, var(--zone) 16%, transparent);
  color: #fff;
}
.map.draw { cursor: crosshair; }
.map.draw .zone {
  cursor: move;
  touch-action: none;
}
.zone-resize-handle {
  position: absolute;
  right: -11px;
  bottom: -11px;
  z-index: 2;
  width: 24px;
  height: 24px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--zone);
  box-shadow: 0 3px 12px rgba(28, 27, 26, .35);
  cursor: nwse-resize;
  touch-action: none;
}
.zone.resizing { box-shadow: 0 0 0 4px color-mix(in srgb, var(--zone) 28%, transparent); }
.zone.moving {
  z-index: 3;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--zone) 28%, transparent), 0 8px 24px rgba(28, 27, 26, .28);
}
.drawrect {
  position: absolute;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  pointer-events: none;
}
.map-hint { font-size: 12.5px; }
.zone span {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: calc(100% - 8px);
  transform: translate(-50%, -50%) rotate(calc(-1 * var(--zone-rotation, 0deg)));
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--zone);
  color: inherit;
  font-size: 11.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.place-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.place-chips button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 12px;
  white-space: nowrap;
  font-weight: 800;
}

.box-card, .kit-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.box-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.qr-fake {
  width: 44px;
  height: 44px;
  border: 4px solid var(--surface);
  outline: 1px solid var(--border);
  border-radius: 6px;
  background: conic-gradient(var(--text) 25%, var(--surface) 0 50%, var(--text) 0 75%, var(--surface) 0) 0 0 / 9px 9px;
}
.qr-mini {
  width: 48px;
  height: 48px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.label-preview {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border: 1px solid var(--input);
  border-radius: 8px;
  background: #fff;
}
.label-preview img { width: 88px; height: 88px; }
.qr-large {
  width: 132px;
  height: 132px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.box-summary {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 18px;
  align-items: start;
}
.qr-camera {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 180px;
  border: 1px dashed var(--input);
  border-radius: 18px;
  background: var(--sunken);
  text-align: center;
}
.qr-camera span { font-size: 44px; color: var(--accent); }
.qr-camera small { color: var(--muted); }
.profile-page {
  display: grid;
  gap: 16px;
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}
.profile-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 20px;
}
.profile-avatar {
  width: 72px;
  height: 72px;
  font-size: 22px;
}
.profile-title {
  min-width: 0;
}
.profile-title h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
}
.profile-title p {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-panel {
  min-width: 0;
  padding: 18px;
}
.profile-stats {
  justify-content: flex-start;
}
.profile-stats button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}
.profile-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.profile-metrics button {
  min-height: 76px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--sunken);
  color: var(--text);
  text-align: left;
  padding: 12px;
}
.profile-metrics strong { display: block; font-size: 24px; }
.profile-metrics span { color: var(--muted); font-size: 12px; }
.data-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.data-checks span {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}
.data-checks .ok { background: var(--ok-soft); color: var(--ok); }
.data-checks .warn { background: var(--accent-soft); color: var(--accent); }
.profile-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.quick-action-grid {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.mobile-home-links {
  display: none;
}
.home-changes {
  display: none;
}
.settings-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--sunken);
  color: var(--text);
  text-align: left;
}
.profile-action-grid .settings-card {
  min-height: 86px;
  cursor: pointer;
}
.settings-card strong {
  font-weight: 600;
}
.settings-card span {
  color: var(--muted);
  font-size: 13px;
}
.settings-card h3 {
  font-size: 16px;
}
.settings-card p {
  font-size: 13px;
}
.check-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.check-list label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.check-list input {
  width: auto;
  min-height: auto;
}
.label-settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, .8fr);
  gap: 16px;
  align-items: start;
}
.label-preview-wrap {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed var(--input);
  border-radius: 12px;
  background: var(--sunken);
  padding: 16px;
}
.label-preview-box {
  width: min(100%, 280px);
  aspect-ratio: var(--label-ratio);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #1C1B1A;
  box-shadow: 0 12px 28px -24px rgba(28, 27, 26, .45);
}
.label-qr {
  width: 54px;
  height: 54px;
  border-color: #fff;
}
.label-preview-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.label-preview-text strong,
.label-preview-text span,
.label-preview-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.access-list {
  display: grid;
  gap: 8px;
}
.access-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(150px, .8fr) auto;
  gap: 8px;
}
.access-row select {
  min-width: 0;
}
.number-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--sunken);
}
.number-preview span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.number-preview strong {
  font-family: "JetBrains Mono", monospace;
  font-size: 18px;
}
.training-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.training-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--sunken);
}
.training-photo {
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 28%, transparent), transparent),
    repeating-linear-gradient(45deg, var(--sunken-2) 0 10px, var(--surface) 10px 20px);
}
.training-photo img {
  width: 72%;
  max-height: 92%;
  object-fit: contain;
}
.training-photo.qr-example span {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  color: #111;
  box-shadow: var(--shadow);
}
.training-photo.qr-example svg {
  width: 100%;
  height: 100%;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.auth-logo svg { width: 64px; height: 64px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { color: var(--muted); font-size: 13px; font-weight: 700; }
.field input, .field select, .field textarea { min-height: 46px; padding: 0 14px; }
.field textarea { min-height: 84px; padding: 12px 14px; resize: vertical; }
.field-error {
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 800;
}
.location-picker { display: grid; gap: 8px; }
.location-current {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--accent);
  border-radius: 13px;
  background: var(--accent-soft);
}
.location-current span { color: var(--muted); font-size: 11px; font-weight: 700; }
.location-current strong { font-size: 14px; line-height: 1.35; }
.location-recent { display: grid; gap: 7px; }
.location-recent > span { color: var(--faint); font-size: 12px; font-weight: 800; }
.location-recent > div { display: flex; flex-wrap: wrap; gap: 7px; }
.location-recent button {
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 20px -18px rgba(28, 27, 26, .55);
}
.location-recent button:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.location-all { border-radius: 13px; }
.location-all > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 13px;
  border: 1px solid var(--accent);
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  list-style: none;
  cursor: pointer;
  font-weight: 800;
}
.location-all > summary:hover { background: color-mix(in srgb, var(--accent-soft) 72%, var(--accent) 8%); }
.location-all > summary::after { content: "⌄"; margin-left: auto; transition: transform .18s ease; }
.location-all[open] > summary::after { transform: rotate(180deg); }
.location-all > summary::-webkit-details-marker { display: none; }
.location-all-body { display: grid; gap: 8px; padding-top: 8px; }
.location-picker-search { height: 42px; box-shadow: none; font-size: 14px; }
.location-options {
  max-height: 184px;
  overflow: auto;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--sunken);
}
.location-options button {
  min-height: 36px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.location-tree-group { display: grid; gap: 2px; }
.location-tree-node strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.location-options button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.location-options button:disabled {
  border-color: var(--border);
  background: color-mix(in srgb, var(--sunken-2) 80%, var(--surface));
}
.location-options span,
.location-more { color: var(--muted); font-size: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 12px; }
.error { color: var(--danger); font-size: 13px; font-weight: 600; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(28, 27, 26, .45);
}
.dialog {
  width: min(880px, 100%);
  max-height: min(860px, calc(100vh - 48px));
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 26px 80px -36px rgba(28, 27, 26, .65);
}
.dialog-actions {
  position: sticky;
  bottom: -20px;
  z-index: 2;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 12px;
  padding-bottom: 2px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 0%, transparent), var(--surface) 28%);
}
.dialog-actions .btn-primary { min-width: 190px; }
.dialog-head { display: flex; align-items: center; gap: 12px; }
.dialog-head .btn { margin-left: auto; }
.move-dialog { width: min(620px, 100%); gap: 18px; }
.move-dialog .dialog-head > div { min-width: 0; }
.move-dialog .dialog-head h2 { margin: 0; }
.move-dialog .dialog-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.move-item-summary {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--sunken);
}
.move-item-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
}
.move-item-summary > div { min-width: 0; display: grid; gap: 3px; }
.move-item-summary span { color: var(--muted); font-size: 11px; font-weight: 800; }
.move-item-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.move-item-summary small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.move-destination { gap: 9px; }
.move-dialog textarea { min-height: 72px; }
.sheet-main { display: grid; grid-template-columns: 220px 1fr; gap: 18px; }
.sheet-photo {
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: repeating-linear-gradient(45deg, #F0EEE6 0 8px, #E9E6DB 8px 16px);
}
.sheet-photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-openable { cursor: zoom-in; }
.managed-photo-open {
  width: 100%;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.managed-photo-open img { display: block; width: 100%; }
.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 64px 20px 24px;
  background: rgba(10, 10, 10, .92);
}
.photo-viewer[hidden] { display: none; }
.photo-viewer img {
  max-width: 100%;
  max-height: calc(100dvh - 88px);
  object-fit: contain;
  border-radius: 12px;
  cursor: zoom-in;
  transition: transform .18s ease;
}
.photo-viewer.zoomed { overflow: auto; place-items: start center; }
.photo-viewer.zoomed img { max-height: none; transform: scale(1.7); transform-origin: top center; cursor: zoom-out; }
.photo-viewer-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 16px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 30px;
}
.photo-viewer-nav {
  position: absolute;
  top: 50%;
  width: 48px;
  height: 64px;
  border: 0;
  border-radius: 14px;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 38px;
}
.photo-viewer-prev { left: 16px; }
.photo-viewer-next { right: 16px; }
.photo-viewer-count {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 13px;
}
.quick-item-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-condition {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 5px 4px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--sunken);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.quick-condition select {
  min-height: 28px;
  max-width: 150px;
  border: 0;
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  padding: 0 25px 0 8px;
}
.quality-groups { display: grid; gap: 18px; }
.quality-groups > section { display: grid; gap: 10px; }
.profile-quality-card { width: 100%; }
.profile-ai-card { gap: 4px; }
.subscription-current { gap: 8px; }
.subscription-current .chip { align-self: flex-start; }
.subscription-current b { font-size: 20px; color: var(--ink); }
.session-list { display: grid; gap: 10px; }
.session-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.session-card > div { display: grid; gap: 3px; }
.connection-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 8px 16px;
  background: #7a4a20;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
body.photo-viewer-open { overflow: hidden; }
.sheet-photo.no-photo {
  background: var(--sunken);
  border: 1px dashed var(--input);
}
.photo-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}
.photo-placeholder::before {
  content: "▧";
  display: block;
  margin-bottom: 6px;
  font-size: 22px;
  color: var(--muted);
  text-align: center;
}
.item-dialog { width: min(920px, 100%); }
.path-box {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--sunken);
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.history { display: flex; flex-direction: column; gap: 8px; }
.history-row { display: grid; grid-template-columns: 82px 1fr; gap: 12px; color: var(--muted); font-size: 13px; }
.details-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.details-grid div {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--sunken);
}
.details-grid span { color: var(--faint); font-size: 12px; font-weight: 800; }
.details-grid strong { font-size: 14px; overflow-wrap: anywhere; }
.add-dialog { width: min(700px, 100%); }
.mobile-head-action { display: none; }
.add-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
  align-items: stretch;
}
.photo-drop {
  min-height: 156px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 1px dashed var(--input);
  border-radius: 16px;
  background: var(--sunken);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}
.photo-drop span { color: var(--accent); font-size: 30px; line-height: 1; }
.photo-drop small { color: var(--faint); }
.photo-source-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.photo-source-button:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.photo-preview-list { width: 100%; display: grid; gap: 8px; }
.photo-preview-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
}
.photo-preview-thumb { width: 48px; height: 48px; position: relative; display: grid; place-items: center; overflow: hidden; border-radius: 9px; background: var(--sunken); }
.photo-preview-thumb img { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; }
.photo-preview-thumb b { color: var(--faint); font-size: 10px; }
.photo-preview-row > span:last-child { min-width: 0; display: grid; gap: 3px; }
.photo-preview-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.photo-preview-row small { color: var(--muted); font-size: 11px; }
.photo-preview-row progress { width: 100%; height: 6px; accent-color: var(--accent); }
.photo-upload-summary { width: 100%; color: var(--accent); font-size: 12px; font-weight: 800; }
.add-step {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.step-num {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  font-weight: 800;
}
.extra-fields {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--sunken);
}
.extra-fields summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
}
.extra-fields[open] { display: flex; flex-direction: column; gap: 12px; }
.pick-list {
  max-height: 280px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--sunken);
}
.pick-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
}
.pick-list label:hover { background: var(--surface); }
.pick-list input { width: auto; min-height: auto; }
.pick-list span { display: flex; flex-direction: column; gap: 2px; }
.pick-list small { color: var(--muted); }
.kit-pick-list {
  gap: 10px;
  padding: 10px;
}
.kit-place-group {
  display: grid;
  gap: 4px;
}
.kit-place-group summary {
  position: sticky;
  top: -10px;
  z-index: 1;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 7px 4px 6px;
  background: var(--sunken);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  list-style: none;
}
.kit-place-group summary::-webkit-details-marker { display: none; }
.kit-place-group summary strong {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.kit-place-group summary small {
  color: var(--muted);
  white-space: nowrap;
}
.kit-place-group:not([open]) summary .tree-caret { transform: rotate(-90deg); }
.kit-place-children {
  display: grid;
  gap: 4px;
}
.kit-place-group + .kit-place-group {
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button {
  width: 30px;
  height: 30px;
  border: 2px solid var(--surface);
  border-radius: 8px;
  box-shadow: 0 0 0 1px var(--border);
}
.swatches button.active { box-shadow: 0 0 0 2px var(--text); }

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  background: rgba(251, 250, 247, .96);
  border-top: 1px solid var(--border);
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  backdrop-filter: blur(14px);
}
.mobile-search-label {
  display: grid;
  gap: 4px;
  padding-bottom: 7px;
}
.mobile-search-label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.bottom-search {
  height: 46px;
  width: 100%;
  padding: 0 18px;
  border: 1px solid var(--input);
  border-radius: 14px;
  background: var(--sunken);
  color: var(--text);
}
.mobile-search-results {
  max-height: 42vh;
  overflow: auto;
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.mobile-search-results button {
  min-height: 50px;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: var(--sunken);
  color: var(--text);
  text-align: left;
}
.mobile-search-results span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mobile-fab,
.mobile-add-menu {
  display: none;
}
.mobile-control-label { display: none; }
.tabbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: center; }
.tabbar button {
  min-height: 48px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 700;
}
.tabbar button div {
  font-size: 17px;
  line-height: 1;
}
.tabbar button span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tabbar button.active { color: var(--accent); }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  max-width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--dark);
  color: var(--surface);
  font-weight: 700;
  white-space: pre-line;
  box-shadow: var(--shadow);
}
.empty {
  padding: 28px;
  border: 1px dashed var(--input);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}
.simple-empty {
  background: var(--surface);
}
.choice-dialog { width: min(520px, 100%); }
.choice-grid {
  display: grid;
  gap: 10px;
}
.choice-card {
  min-height: 76px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.choice-card strong { font-weight: 500; }
.choice-card span {
  color: var(--muted);
  font-size: 13px;
}
.choice-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.empty-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.compact-empty {
  padding: 18px;
  background: var(--surface);
}
.label-summary { color: var(--muted); font-weight: 700; }
.list-stack {
  display: grid;
  gap: 10px;
}
.kit-detail-dialog,
.archive-dialog {
  width: min(760px, 100%);
}
.kit-detail-items {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.archive-list {
  display: grid;
  gap: 8px;
  max-height: min(58vh, 560px);
  overflow: auto;
  padding-right: 2px;
}
.archive-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.archive-thumb {
  display: grid;
  place-items: center;
  width: 58px;
  height: 48px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--sunken);
}
.archive-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.archive-info {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.archive-info strong,
.archive-info small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.archive-info strong { font-weight: 500; }
.archive-info small { color: var(--muted); }
.archive-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 1120px) {
  .items-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .items-toolbar { grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) minmax(190px, 1.4fr) auto auto auto; }
  .boxes-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kits-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .places-layout { grid-template-columns: 300px minmax(0, 1fr); }
  .items-table-head, .items-table-row { grid-template-columns: 86px minmax(160px, 1.2fr) minmax(180px, 1.3fr) 80px 110px; }
  .items-table-row:has(.select-dot),
  .items-table-head.bulk-head { grid-template-columns: 28px 86px minmax(160px, 1.2fr) minmax(180px, 1.3fr) 80px 110px; }
  .items-table-head span:last-child, .items-table-row span:last-child { display: none; }
}

@media (max-width: 767px) {
  html,
  body {
    max-width: 100vw;
    overscroll-behavior: none;
    touch-action: pan-y;
  }
  body { font-size: 17px; }
  .photo-viewer { padding-inline: 8px; }
  .photo-viewer-nav {
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
    font-size: 30px;
  }
  .photo-viewer-prev { left: 12px; }
  .photo-viewer-next { right: 12px; }
  .quality-dialog { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .app-shell {
    width: 100%;
    max-width: 100vw;
    overflow-x: clip;
    padding-bottom: 164px;
  }
  .topbar { height: 62px; padding: 0 16px; }
  .nav, .top-actions .hide-mobile, .top-actions [data-open-add] { display: none; }
  .top-actions { gap: 8px; }
  .main {
    width: 100%;
    max-width: 100vw;
    overflow-x: clip;
    padding: 24px 16px 26px;
  }
  h1 { font-size: 36px; }
  h2 { font-size: 31px; }
  .btn { min-height: 50px; font-size: 17px; }
  .btn-icon { width: 50px; }
  .search-input, .field input, .field select, .field textarea { min-height: 50px; font-size: 17px; }
  .home-hero {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0 2px;
    text-align: center;
  }
  .home-hero h1 {
    display: none;
  }
  .home-hero .search-wrap,
  .home-hero .search-box,
  .home-hero .search-results,
  .home-hero .quick-searches { display: none; }
  .hero { align-items: stretch; text-align: left; padding-top: 6px; }
  .home-hero .stats {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 10px 14px;
  }
  .home-hero .stats span {
    min-height: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    text-align: center;
    font-size: 14px;
    white-space: nowrap;
  }
  .home-hero .stats strong {
    display: inline;
    font-size: 19px;
    line-height: 1;
  }
  .stats { justify-content: center; gap: 8px 14px; font-size: 14px; }
  .mobile-home-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .mobile-home-links button {
    min-width: 0;
    min-height: 66px;
    display: grid;
    gap: 2px;
    place-items: center;
    padding: 9px 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
  }
  .mobile-home-links strong {
    max-width: 100%;
    overflow: hidden;
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-home-links span {
    color: var(--muted);
    font-size: 17px;
    font-weight: 700;
  }
  .centered-strip { justify-content: flex-start; }
  .home-places,
  .home-places + section { gap: 10px; }
  body:has(.home-hero) .empty-action .btn[data-open-add] {
    display: none;
  }
  .quick-action-grid {
    display: none;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .home-changes {
    display: none;
  }
  .quick-action-grid .settings-card {
    min-height: 58px;
    gap: 4px;
  }
  .place-card { min-width: 132px; flex-direction: column; align-items: flex-start; padding: 10px; }
  .place-card .chev { display: none; }
  .place-card img { width: 44px; height: 44px; }
  .recent-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .recent-wrap {
    display: none;
  }
  .mobile-recent-grid {
    display: grid;
  }
  .recent-card { min-width: 0; max-width: none; }
  .home-item-card {
    min-height: 218px;
    padding: 14px;
  }
  .home-item-card .thumb {
    width: 100%;
    height: 74px;
  }
  .page-search-line.with-inline-action {
    max-width: none;
    grid-template-columns: 1fr;
    justify-items: stretch;
  }
  .page-search-line.with-inline-action .actions,
  .page-search-line.with-inline-action .actions .btn {
    width: 100%;
  }
  .page-hero .page-search-line,
  .page-hero .page-search,
  .page-hero .compact-add {
    display: none;
  }
  .page-hero {
    align-items: center;
    text-align: center;
  }
  .page-hero h1 { font-size: 34px; }
  .items-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .items-grid .item-card:not(.kit-item-card) {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 8px;
    aspect-ratio: 1 / 1;
    min-height: 0;
    padding: 12px;
  }
  .items-grid .item-card:not(.kit-item-card) > .item-photo,
  .items-grid .item-card:not(.kit-item-card) > .item-card-body {
    display: none;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout {
    min-width: 0;
    height: 100%;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 8px;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout > .item-name {
    width: 100%;
    min-height: 0;
    padding: 0 22px;
    overflow: hidden;
    font-size: 14.5px;
    line-height: 1.2;
    text-align: center;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .items-grid .item-card:not(.kit-item-card) .home-item-mid {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
  }
  .items-grid .item-card:not(.kit-item-card) .home-item-mid .thumb {
    width: 58px;
    height: 58px;
  }
  .items-grid .item-card:not(.kit-item-card) .home-item-bottom {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
  }
  .items-grid .item-card:not(.kit-item-card) .item-photo {
    grid-column: 1;
    grid-row: 2;
    width: 58px;
    height: 58px;
    min-height: 0;
    overflow: hidden;
    border-radius: 13px;
  }
  .items-grid .item-card:not(.kit-item-card) .photo-inv {
    display: none;
  }
  .items-grid .item-card:not(.kit-item-card) .item-card-body {
    display: contents;
    padding: 0;
  }
  .items-grid .item-card:not(.kit-item-card) .item-card-body .item-name {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 0;
    padding: 0 22px;
    font-size: 14.5px;
    line-height: 1.2;
    text-align: center;
    -webkit-line-clamp: 2;
  }
  .mobile-card-more {
    position: absolute;
    top: 10px;
    right: 12px;
    display: block;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
  }
  .items-grid .item-card:not(.kit-item-card) .path {
    grid-column: 1;
    grid-row: 2;
    align-self: center;
    margin-left: 68px;
    font-size: 12.5px;
    -webkit-line-clamp: 3;
  }
  .items-grid .item-card:not(.kit-item-card) .chips {
    grid-column: 1;
    grid-row: 3;
    align-self: end;
    gap: 4px;
  }
  .items-grid .item-card:not(.kit-item-card) .chip {
    min-height: 24px;
    padding: 0 7px;
    font-size: 11px;
  }
  .item-photo { height: 112px; }
  .boxes-grid, .kits-grid { grid-template-columns: 1fr; }
  .kit-item-card {
    display: block;
  }
  .kit-item-card .item-card-body {
    min-height: auto;
    gap: 10px;
    padding: 14px;
  }
  .kit-card-head {
    align-items: center;
  }
  .kit-preview {
    min-height: auto;
  }
  .kit-item-card .card-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .places-layout { display: flex; flex-direction: column; }
  .places-panel { position: static; max-height: none; }
  .tree { max-height: 44vh; }
  .panel { width: 100%; padding: 14px; }
  .toolbar .search-box { display: none; }
  .collection-items {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    padding-bottom: 0;
    overflow: visible;
  }
  .collection-items > .filter-select,
  .collection-items > .place-filter-select {
    display: none;
  }
  .collection-items > .filter-menu {
    display: block;
  }
  .collection-items .sort-menu {
    grid-column: 1;
  }
  .collection-items .filter-menu {
    grid-column: 2;
  }
  .collection-items .bulk-wrap {
    grid-column: 3;
    justify-self: end;
  }
  .collection-items .segmented {
    grid-column: 4;
  }
  .collection-items .sort-menu summary,
  .collection-items .filter-menu summary {
    width: 44px;
    padding: 0;
  }
  .collection-items .sort-menu summary span:last-child,
  .collection-items .filter-menu summary span:last-child {
    display: none;
  }
  .collection-items .bulk-wrap .btn {
    width: 44px;
    padding: 0;
    overflow: hidden;
    color: transparent;
  }
  .collection-items .bulk-wrap .btn::before {
    content: "☑";
    color: var(--text);
    font-size: 17px;
  }
  .collection-controls {
    justify-content: space-between;
    width: 100%;
    padding: 4px 0;
  }
  .collection-boxes .bulk-wrap,
  .collection-kits .bulk-wrap { margin-left: 0; }
  .collection-boxes,
  .collection-kits {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 6px;
    width: 100%;
  }
  .collection-boxes .sort-select,
  .collection-kits .sort-select {
    min-width: 0;
    width: 100%;
  }
  .collection-boxes .bulk-wrap,
  .collection-kits .bulk-wrap {
    justify-self: end;
  }
  .collection-boxes .bulk-wrap .btn,
  .collection-kits .bulk-wrap .btn {
    width: 44px;
    padding: 0;
  }
  .items-toolbar {
    grid-template-columns: repeat(6, max-content);
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .bulk-bar {
    top: 66px;
    align-items: stretch;
    flex-direction: column;
  }
  .bulk-bar strong { margin-right: 0; }
  .bulk-bar .btn { width: 100%; }
  .filter-select { min-width: 154px; min-height: 44px; }
  .place-filter-select { min-width: 190px; }
  .chip-btn { min-height: 40px; padding: 0 14px; }
  .screen-head { flex-direction: column; align-items: stretch; }
  .screen-head .actions { justify-content: space-between; }
  .items-table {
    display: grid;
    gap: 10px;
    overflow: visible;
    border: 0;
    background: transparent;
  }
  .items-table-head { display: none; }
  .items-table-row,
  .items-table-row:has(.select-dot) {
    min-width: 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 7px 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
  }
  .items-table-row .select-dot { grid-row: 1 / 4; margin: 0; }
  .items-table-row .chip.inv { grid-column: 1; grid-row: 1; }
  .items-table-row strong { grid-column: 2 / 4; grid-row: 1; font-size: 16px; }
  .items-table-row .path { grid-column: 1 / 4; grid-row: 2; font-size: 12px; }
  .items-table-row span:nth-last-child(3) { grid-column: 1; grid-row: 3; }
  .items-table-row .condition { grid-column: 2; grid-row: 3; justify-self: start; }
  .items-table-row span:last-child { grid-column: 3; grid-row: 3; font-size: 12px; color: var(--muted); }
  .map { aspect-ratio: 16 / 9; }
  .box-summary, .add-grid, .row3 { grid-template-columns: 1fr; }
  .profile-page { gap: 12px; }
  .profile-hero {
    grid-template-columns: 60px minmax(0, 1fr) 50px;
    align-items: center;
    padding: 16px;
  }
  .profile-hero .btn {
    width: 50px;
    grid-column: 3;
    grid-row: 1;
  }
  .profile-avatar {
    width: 60px;
    height: 60px;
    font-size: 18px;
  }
  .profile-title {
    grid-column: 2;
    grid-row: 1;
  }
  .profile-title h1 { font-size: 28px; }
  .profile-panel { padding: 14px; }
  .profile-stats {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .profile-stats button { flex: 0 0 auto; }
  .profile-action-grid,
  .label-settings-layout,
  .training-grid,
  .row2 {
    grid-template-columns: 1fr;
  }
  .access-row {
    grid-template-columns: 1fr;
  }
  .qr-large { width: 112px; height: 112px; }
  .bottom-bar {
    display: flex;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  }
  .mobile-search-label {
    padding-bottom: 6px;
  }
  .mobile-search-label span {
    display: none;
  }
  .bottom-search {
    height: 52px;
    font-size: 17px;
  }
  .tabbar button {
    min-height: 54px;
    font-size: 12.5px;
  }
  .tabbar button div {
    font-size: 19px;
  }
  .mobile-fab {
    position: fixed;
    right: 18px;
    bottom: calc(126px + env(safe-area-inset-bottom));
    z-index: 34;
    width: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: var(--surface);
    padding: 0 0 4px;
    font-size: 38px;
    line-height: .8;
    box-shadow: 0 14px 26px -12px rgba(28, 27, 26, .48);
  }
  .card-dot {
    top: 9px;
    left: 9px;
    right: auto;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    font-size: 14px;
    line-height: 1;
  }
  .mobile-add-menu {
    position: fixed;
    right: 18px;
    bottom: calc(188px + env(safe-area-inset-bottom));
    z-index: 33;
    width: min(260px, calc(100vw - 36px));
    display: grid;
    gap: 7px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .mobile-add-menu button {
    min-height: 54px;
    display: grid;
    gap: 2px;
    padding: 9px 11px;
    border: 0;
    border-radius: 12px;
    background: var(--sunken);
    color: var(--text);
    text-align: left;
  }
  .mobile-add-menu span {
    color: var(--muted);
    font-size: 12px;
  }
  .overlay { align-items: stretch; padding: 0; }
  .dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    padding: 14px 18px max(14px, env(safe-area-inset-bottom));
  }
  .item-dialog {
    padding: 0 0 max(14px, env(safe-area-inset-bottom));
    gap: 0;
  }
  .item-dialog .dialog-head {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 16px;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    backdrop-filter: blur(12px);
  }
  .sheet-main {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 0 16px 14px;
  }
  .sheet-photo {
    width: calc(100% + 32px);
    min-height: 230px;
    margin: 0 -16px;
    border-radius: 0 0 22px 22px;
  }
  .item-dialog h2 { font-size: 30px; }
  .item-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .item-modal-actions .btn:first-child {
    grid-column: 1 / -1;
  }
  .details-grid { grid-template-columns: 1fr 1fr; }
  .item-dialog > .details-grid,
  .item-dialog > .stack {
    margin: 0 16px 14px;
  }
  .add-step { grid-template-columns: 32px 1fr; padding: 12px; }
  .row2 { grid-template-columns: 1fr; }
  .row3 { grid-template-columns: 1fr; }
  .dialog-actions {
    bottom: max(-14px, calc(-1 * env(safe-area-inset-bottom)));
    margin: 0 -18px;
    padding: 12px 18px max(14px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
  }
  .dialog-actions .btn,
  .dialog-actions .btn-primary { width: 100%; min-width: 0; }
  .archive-row { grid-template-columns: 52px minmax(0, 1fr); }
  .archive-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }
  .archive-actions .btn { flex: 1; }
  .location-picker-search { height: 44px; }
  .location-options { max-height: 34dvh; }
  .add-dialog { padding: 14px 16px max(14px, env(safe-area-inset-bottom)); }
  .mobile-add-dialog {
    gap: 16px;
    overflow-x: hidden;
    padding-bottom: max(96px, env(safe-area-inset-bottom));
  }
  .mobile-form-dialog { padding: 14px 16px max(14px, env(safe-area-inset-bottom)); }
  .mobile-form-dialog .dialog-head,
  .add-dialog .dialog-head {
    position: sticky;
    top: -14px;
    z-index: 3;
    margin: -14px -16px 0;
    padding: 12px 16px;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    backdrop-filter: blur(12px);
  }
  .mobile-form-dialog .dialog-actions {
    position: sticky;
    bottom: max(-14px, calc(-1 * env(safe-area-inset-bottom)));
    margin: auto -16px max(-14px, calc(-1 * env(safe-area-inset-bottom)));
    padding: 12px 16px max(14px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    backdrop-filter: blur(12px);
  }
  .mobile-form-dialog .dialog-actions .btn-primary {
    width: 100%;
  }
  .move-dialog { gap: 14px; background: var(--sunken); }
  .move-dialog .dialog-head { border-bottom: 1px solid var(--border); }
  .move-dialog .move-item-summary,
  .move-dialog > .field {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
  }
  .move-dialog .dialog-actions { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); }
  .move-dialog .dialog-actions .btn { width: auto; }
  .box-create-dialog .location-options,
  .kit-dialog .kit-pick-list {
    max-height: 46dvh;
  }
  .add-dialog-head {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .add-dialog-head h2 {
    justify-self: center;
    font-size: 18px;
  }
  .mobile-head-action {
    display: inline-flex;
    min-height: 40px;
    padding: 0 12px;
  }
  .desktop-close {
    display: none;
  }
  .photo-drop {
    min-height: 150px;
    grid-template-columns: 1fr;
    place-items: center;
    gap: 8px;
    border-radius: 18px;
    text-align: center;
    padding: 18px;
    background: var(--sunken);
  }
  .photo-drop span {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--accent-soft);
    font-size: 34px;
  }
  .photo-drop strong { font-size: 17px; }
  .photo-source-button { width: 100%; min-height: 48px; padding: 9px 10px; font-size: 14px; }
  .mobile-add-dialog textarea[name="notes"] { scroll-margin-block: 112px; }
  .extra-fields summary {
    min-height: 46px;
    display: flex;
    align-items: center;
    font-size: 15px;
    font-weight: 700;
  }
  .history-row { grid-template-columns: 66px 1fr; }
  .section-head { align-items: flex-start; }
  .section-narrow { max-width: none; }

  /* Mobile audit fixes */
  .items-grid .item-card:not(.kit-item-card) > .item-photo,
  .items-grid .item-card:not(.kit-item-card) > .item-card-body {
    display: none !important;
  }
  .items-grid .item-card:not(.kit-item-card) {
    display: block;
    overflow: hidden;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout {
    grid-template-rows: 35px minmax(0, 1fr) auto;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout > .item-name {
    min-height: 35px;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout .home-item-mid .path {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    margin: 0;
    align-self: center;
    font-size: 12px;
    line-height: 1.25;
    text-align: left;
    -webkit-line-clamp: 3;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout .home-item-bottom .chips {
    display: flex;
    flex-wrap: nowrap;
    min-width: 0;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout .home-item-bottom {
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout .home-item-bottom .chip {
    min-width: 0;
    min-height: 22px;
    padding: 0 4px;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .profile-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
    padding: 0;
  }
  .profile-stats button {
    min-width: 0;
    min-height: 44px;
    padding: 6px 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--sunken);
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
  }
  .profile-stats button strong { display: block; font-size: 16px; }
  .bottom-bar.search-active .mobile-fab { display: none; }
  .mobile-search-results-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    padding: 0 4px 4px;
    background: var(--surface);
  }
  .mobile-search-results-head button {
    width: 40px;
    min-height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    font-size: 24px;
    text-align: center;
  }
  .link-btn { min-height: 44px; padding: 0 8px; }
  .tree-node { min-height: 44px; }
  .mobile-control-label { display: inline; }
  .collection-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .collection-items .sort-menu,
  .collection-items .filter-menu,
  .collection-items .bulk-wrap,
  .collection-items .segmented {
    grid-column: auto;
    width: 100%;
  }
  .collection-items .sort-menu summary,
  .collection-items .filter-menu summary,
  .collection-items .bulk-wrap .btn,
  .collection-items .segmented { width: 100%; }
  .collection-items .sort-menu summary span:last-child,
  .collection-items .filter-menu summary span:last-child { display: inline; }
  .collection-items .bulk-wrap .btn {
    color: var(--text);
    gap: 6px;
    padding: 0 10px;
  }
  .collection-items .bulk-wrap .btn::before { content: none; }
  .collection-items .segmented button {
    gap: 4px;
    padding: 0 7px;
    font-size: 12px;
  }
  .places-add-button,
  .place-content-add { gap: 6px; padding: 0 12px; }
  .mobile-add-dialog { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .mobile-add-dialog > .dialog-actions { display: none; }

  .add-dialog-head {
    grid-template-columns: 96px minmax(0, 1fr) 96px;
    gap: 8px;
  }
  .add-dialog-head .mobile-head-action {
    width: 96px;
    min-height: 44px;
    justify-content: center;
    padding: 0 8px;
  }
  .add-dialog-head .mobile-head-action:first-child {
    justify-self: start;
    margin-left: 0;
  }
  .add-dialog-head .mobile-head-action:nth-of-type(2) { justify-self: end; }

  .collection-items {
    grid-template-columns: 44px 44px minmax(0, 1fr) auto;
    gap: 6px;
  }
  .collection-items .sort-menu,
  .collection-items .filter-menu,
  .collection-items .bulk-wrap,
  .collection-items .segmented { width: auto; }
  .collection-items .sort-menu summary,
  .collection-items .filter-menu summary {
    width: 44px;
    padding: 0;
  }
  .collection-items .sort-menu summary span:last-child,
  .collection-items .filter-menu summary span:last-child,
  .collection-items .bulk-wrap .mobile-control-label,
  .collection-items .segmented .mobile-control-label { display: none; }
  .collection-items .bulk-wrap {
    justify-self: end;
  }
  .collection-items .bulk-wrap .btn {
    width: 44px;
    padding: 0;
  }
  .collection-items .segmented button {
    min-width: 34px;
    padding: 0 8px;
  }
  .items-grid .item-card:not(.kit-item-card) {
    min-height: 218px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 8px;
    aspect-ratio: auto;
    overflow: visible;
    padding: 14px;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout {
    display: contents;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout > .item-name {
    min-height: 0;
    padding: 0 22px;
    font-size: 14.5px;
    text-align: center;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout .home-item-mid {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout .home-item-mid .thumb {
    width: 58px;
    height: 58px;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout .home-item-mid .path {
    grid-column: 2;
    grid-row: 1;
    font-size: 11px;
    -webkit-line-clamp: 3;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout .home-item-bottom {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout .home-item-bottom .chips {
    display: flex;
    flex-wrap: wrap;
    grid-column: 2;
    grid-row: auto;
  }
  .items-grid .item-card:not(.kit-item-card) .mobile-item-home-layout .home-item-bottom .chip {
    min-height: 24px;
    padding: 0 7px;
    font-size: 11px;
  }
  .add-dialog-head { position: relative; }
  .add-dialog-head h2 {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
  }
  .add-dialog-head .mobile-head-action { position: relative; z-index: 1; }
  .collection-items .bulk-menu {
    right: 0;
    left: auto;
    width: min(250px, calc(100vw - 32px));
    min-width: 0;
  }
  .collection-items .bulk-menu .btn {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    white-space: normal;
  }

  .home-places .places-strip {
    width: 100%;
    justify-content: flex-start;
    scroll-padding-inline: 0;
  }

  .collection-boxes,
  .collection-kits {
    grid-template-columns: minmax(0, 1fr) 44px 84px;
  }
  .collection-boxes .bulk-wrap .mobile-control-label,
  .collection-kits .bulk-wrap .mobile-control-label,
  .collection-boxes .segmented .mobile-control-label,
  .collection-kits .segmented .mobile-control-label {
    display: none;
  }
  .collection-boxes .bulk-wrap .btn,
  .collection-kits .bulk-wrap .btn {
    width: 44px;
    padding: 0;
  }
  .collection-boxes .segmented,
  .collection-kits .segmented {
    width: 84px;
  }
  .collection-boxes .segmented button,
  .collection-kits .segmented button {
    min-width: 34px;
    padding: 0 7px;
  }

  .home-item-bottom .chips {
    min-width: 0;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .home-item-bottom .chips .chip {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .home-item-bottom .chips .chip:last-child {
    flex: 1 1 auto;
  }

  /* Keep inventory cards visually consistent with the desktop card layout. */
  .items-grid .item-card:not(.kit-item-card) {
    display: block;
    min-height: 0;
    aspect-ratio: auto;
    overflow: hidden;
    padding: 0;
  }
  .items-grid .item-card:not(.kit-item-card) > .mobile-item-home-layout {
    display: none !important;
  }
  .items-grid .item-card:not(.kit-item-card) > .item-photo {
    display: block !important;
    width: 100%;
    height: 112px;
    border-radius: 0;
  }
  .items-grid .item-card:not(.kit-item-card) > .item-photo .photo-inv {
    display: block;
  }
  .items-grid .item-card:not(.kit-item-card) > .item-card-body {
    display: flex !important;
    min-height: 96px;
    padding: 10px 12px 12px;
  }
  .items-grid .item-card:not(.kit-item-card) > .item-card-body .item-name {
    min-height: 2.6em;
    padding: 0;
    text-align: left;
  }
  .items-grid .item-card:not(.kit-item-card) > .item-card-body .path {
    margin: 0;
  }
  .items-grid .item-card:not(.kit-item-card) > .item-card-body .mobile-card-more {
    display: none;
  }

  .mobile-recent-grid .home-item-card {
    display: block;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    text-align: left;
  }
  .mobile-recent-grid .home-item-card > .item-name,
  .mobile-recent-grid .home-item-card > .home-item-mid,
  .mobile-recent-grid .home-item-card > .home-item-bottom {
    display: none;
  }
  .mobile-recent-grid .home-item-card > .mobile-home-item-layout {
    display: block;
  }
  .mobile-recent-grid .mobile-home-item-layout > .item-photo {
    display: block;
    width: 100%;
    height: 112px;
    border-radius: 0;
  }
  .mobile-recent-grid .mobile-home-item-layout > .item-card-body {
    display: flex;
    min-height: 96px;
    padding: 10px 12px 12px;
  }
  .mobile-recent-grid .mobile-home-item-layout .item-name {
    min-height: 2.6em;
    padding: 0;
    font-size: 14.5px;
    line-height: 1.2;
    text-align: left;
  }
  .mobile-recent-grid .mobile-home-item-layout .path {
    display: -webkit-box;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.28;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .mobile-recent-grid .mobile-home-item-layout .path strong {
    font-size: 11px;
  }

  /* Mobile usability pass: stable cards, clearer controls and a denser add flow. */
  .items-grid .item-card:not(.kit-item-card) {
    height: 252px;
  }
  .items-grid .item-card:not(.kit-item-card) > .item-card-body {
    height: 140px;
    min-height: 140px;
    justify-content: space-between;
  }
  .items-grid .item-card:not(.kit-item-card) > .item-card-body .item-name,
  .items-grid .item-card:not(.kit-item-card) > .item-card-body .path {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .items-grid .item-card:not(.kit-item-card) > .item-card-body .chips {
    min-height: 24px;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .items-grid .item-card:not(.kit-item-card) > .item-card-body .chip {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .items-table-row .path {
    display: -webkit-box;
    overflow: hidden;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .collection-items .sort-popover,
  .collection-items .filter-popover,
  .collection-items .bulk-menu {
    max-height: min(56dvh, 430px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .collection-items .sort-popover button,
  .collection-items .bulk-menu .btn {
    min-height: 44px;
  }
  .card-dot,
  .items-table-row .select-dot {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }
  .home-places .places-strip {
    padding-right: 22px;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 24px), transparent 100%);
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 24px), transparent 100%);
  }
  .home-places .place-card {
    scroll-snap-align: start;
  }
  .mobile-search-label {
    padding-right: 64px;
  }
  .bottom-search {
    height: 48px;
    padding: 0 14px;
    font-size: 16px;
  }
  .mobile-fab {
    right: 16px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: 54px;
    height: 54px;
    padding-bottom: 3px;
    font-size: 34px;
  }
  .mobile-add-menu {
    right: 14px;
    bottom: calc(136px + env(safe-area-inset-bottom));
  }
  .mobile-add-dialog {
    gap: 14px;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
  .mobile-add-dialog .photo-drop {
    min-height: 132px;
  }
  .mobile-add-dialog .location-options {
    max-height: 220px;
  }
  .mobile-add-dialog > .row3 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
  }
  .mobile-add-dialog > .row3 .field:last-child {
    grid-column: 1 / -1;
  }
  .mobile-add-dialog .extra-fields {
    border-top: 1px solid var(--border);
  }
  .mobile-add-dialog .extra-fields:not([open]) {
    margin-bottom: 6px;
  }
  .add-dialog-head .mobile-head-action:first-child:focus-visible,
  .add-dialog-head .mobile-head-action:first-child:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: none;
  }
  .mobile-recent-grid .home-item-card {
    height: 252px;
  }
  .mobile-recent-grid .mobile-home-item-layout > .item-photo {
    height: 112px;
  }
  .mobile-recent-grid .mobile-home-item-layout > .item-card-body {
    height: 140px;
    min-height: 140px;
    justify-content: space-between;
  }
  .mobile-recent-grid .mobile-home-item-layout .item-name,
  .mobile-recent-grid .mobile-home-item-layout .path {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .home-places .places-strip {
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 10px), transparent 100%);
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 10px), transparent 100%);
  }
  .tabbar {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .tabbar button {
    min-height: 52px;
    padding: 3px 1px;
    border-radius: 10px;
  }
  .tabbar button.active {
    background: var(--accent-soft);
  }
  .compact-bottom-bar {
    padding-top: 6px;
  }
  .compact-bottom-bar .mobile-fab {
    bottom: calc(66px + env(safe-area-inset-bottom));
  }
  .mobile-sections-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(66px + env(safe-area-inset-bottom));
    z-index: 36;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .mobile-sections-menu button {
    min-height: 66px;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    gap: 1px 8px;
    padding: 10px;
    border: 0;
    border-radius: 13px;
    background: var(--sunken);
    color: var(--text);
    text-align: left;
  }
  .mobile-sections-menu button > span {
    grid-row: 1 / 3;
    font-size: 20px;
    text-align: center;
  }
  .mobile-sections-menu small { color: var(--muted); font-size: 11px; }
  .place-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }
  .place-actions .place-content-add {
    width: 100%;
  }
  .place-actions .action-more-menu > summary {
    min-height: 48px;
  }
  .action-more-menu > div {
    width: min(250px, calc(100vw - 32px));
  }
  .place-chips {
    display: none;
  }
  .kit-item-card .card-actions {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .kit-item-card .card-actions .action-more-menu > summary {
    min-height: 46px;
    padding-inline: 18px;
  }
  .profile-training-card {
    width: 100%;
    text-align: left;
  }
  .profile-page {
    gap: 10px;
  }
  .profile-hero {
    grid-template-columns: 52px minmax(0, 1fr) 44px;
    gap: 12px;
    padding: 14px;
    border-radius: 18px;
  }
  .profile-avatar {
    width: 52px;
    height: 52px;
    font-size: 16px;
  }
  .profile-title h1 {
    font-size: 21px;
    line-height: 1.15;
  }
  .profile-title p {
    margin-top: 3px;
    font-size: 12px;
  }
  .profile-hero .btn {
    grid-column: 3;
    grid-row: 1;
    width: 44px;
    min-height: 44px;
    border-radius: 12px;
  }
  .profile-panel {
    gap: 10px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .profile-data-section {
    display: grid;
    gap: 10px;
  }
  .profile-data-section .data-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .profile-stats,
  .profile-panel > .data-checks,
  .profile-panel > .profile-training-card,
  .profile-panel > .profile-data-section,
  .profile-panel > .advanced-settings,
  .profile-panel > .section-head:last-child {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
  }
  .profile-stats {
    gap: 0;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .profile-stats button {
    min-height: 50px;
    padding: 4px 2px;
    border: 0;
    border-right: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    font-size: 10px;
  }
  .profile-stats button:last-child {
    border-right: 0;
  }
  .profile-stats button strong {
    margin-bottom: 3px;
    font-size: 17px;
  }
  .profile-panel > .data-checks {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .profile-panel > .data-checks span {
    padding: 9px 11px;
    font-size: 12px;
  }
  .profile-panel > .profile-training-card {
    gap: 4px;
    min-height: 0;
  }
  .profile-panel > .profile-data-section,
  .profile-panel > .section-head:last-child {
    align-items: start;
  }
  .profile-panel > .profile-data-section p,
  .profile-panel > .section-head:last-child p {
    margin-top: 3px;
    font-size: 12px;
  }
  .profile-panel > .advanced-settings {
    overflow: hidden;
  }
  .profile-panel > .advanced-settings > summary {
    min-height: 28px;
  }
  .profile-panel > .section-head:last-child .btn-danger {
    width: 100%;
  }
  .advanced-settings-body .section-head {
    display: grid;
    gap: 10px;
  }
  .advanced-settings-body .data-actions {
    width: 100%;
    display: grid;
  }
  .location-current {
    display: grid;
    gap: 3px;
    padding: 11px 12px;
    border: 1px solid var(--accent);
    border-radius: 13px;
    background: var(--accent-soft);
  }
  .location-current span,
  .location-recent > span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
  }
  .location-current strong {
    font-size: 14px;
    line-height: 1.35;
  }
  .location-recent {
    display: grid;
    gap: 6px;
  }
  .location-recent > div {
    display: flex;
    gap: 6px;
    overflow-x: auto;
  }
  .location-recent button {
    min-height: 40px;
    flex: 0 0 auto;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
  }
  .location-all {
    border: 0;
    border-radius: 13px;
    background: transparent;
  }
  .location-all > summary {
    min-height: 46px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    list-style: none;
    cursor: pointer;
    font-weight: 700;
  }
  .location-all > summary::after {
    content: "⌄";
    margin-left: auto;
  }
  .location-all[open] > summary::after { transform: rotate(180deg); }
  .location-all > summary::-webkit-details-marker { display: none; }
  .location-all-body {
    display: grid;
    gap: 8px;
    padding: 8px 0 0;
  }
  .mobile-add-dialog .location-picker {
    gap: 10px;
  }
  .mobile-add-dialog .mobile-head-action:disabled {
    opacity: .48;
  }
  .mobile-add-dialog,
  .box-create-dialog {
    background: var(--sunken);
  }
  .mobile-add-dialog .dialog-head,
  .box-create-dialog .dialog-head {
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 97%, transparent);
  }
  .mobile-add-dialog .add-grid,
  .mobile-add-dialog > .row3,
  .mobile-add-dialog > .extra-fields,
  .box-create-dialog > .mobile-form-section {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
  }
  .mobile-add-dialog .add-grid {
    gap: 14px;
  }
  .mobile-add-dialog .photo-drop {
    border-color: var(--input);
    background: var(--sunken);
  }
  .mobile-add-dialog > .row3 {
    gap: 10px;
  }
  .mobile-add-dialog > .extra-fields {
    border-top: 1px solid var(--border);
  }
  .mobile-add-dialog > .extra-fields > summary {
    min-height: 28px;
  }
  .box-create-dialog {
    gap: 14px;
  }
  .box-create-dialog > .mobile-form-section {
    display: grid;
    gap: 16px;
  }
  .box-create-dialog > .dialog-actions {
    display: none;
  }
  .mobile-add-dialog .field > label,
  .box-create-dialog .field > label {
    margin-bottom: 2px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .main {
    padding: 22px 22px 28px;
  }
  .btn,
  .field input,
  .field select,
  .field textarea,
  .search-input {
    min-height: 44px;
  }
  .items-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .boxes-grid,
  .kits-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .page-search-line.with-inline-action {
    max-width: none;
  }
  .dialog {
    width: min(760px, calc(100vw - 32px));
  }
  .add-dialog,
  .item-dialog {
    width: min(820px, calc(100vw - 32px));
  }
}

@media (min-width: 768px) and (max-width: 1199px) and (orientation: portrait) {
  .app-shell {
    padding-bottom: 170px;
  }
  .topbar {
    height: 62px;
  }
  .nav,
  .top-actions [data-open-add] {
    display: none;
  }
  .bottom-bar {
    display: flex;
    left: 50%;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 28px));
    bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
  }
  .tabbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .tabbar button {
    min-height: 52px;
  }
  .items-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .places-layout {
    grid-template-columns: 320px minmax(0, 1fr);
  }
  .location-options {
    max-height: 34vh;
  }
}

@media (min-width: 768px) and (max-width: 1199px) and (orientation: landscape) {
  body {
    background: var(--bg);
  }
  .app-shell {
    padding-left: 188px;
  }
  .topbar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 24;
    width: 188px;
    height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    padding: 20px 14px;
    border-right: 1px solid var(--border);
    border-bottom: 0;
  }
  .brand {
    justify-content: flex-start;
  }
  .nav {
    display: grid;
    width: 100%;
    gap: 6px;
  }
  .nav button {
    justify-content: flex-start;
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    text-align: left;
  }
  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: auto;
  }
  .top-actions [data-open-add] {
    grid-column: 1 / -1;
    width: 100%;
  }
  .avatar {
    justify-self: stretch;
    width: auto;
  }
  .bottom-bar {
    display: none;
  }
  .main {
    max-width: none;
    min-height: 100dvh;
    padding: 24px;
  }
  .items-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .places-layout {
    grid-template-columns: 300px minmax(0, 1fr);
  }
  .places-panel {
    position: sticky;
    top: 24px;
    max-height: calc(100dvh - 48px);
  }
  .map {
    min-height: 360px;
  }
  .item-dialog,
  .add-dialog,
  .kit-dialog,
  .box-dialog {
    width: min(520px, 46vw);
    height: 100dvh;
    max-height: 100dvh;
    margin-left: auto;
    border-radius: 20px 0 0 20px;
  }
  .overlay {
    justify-content: flex-end;
    padding: 0;
  }
}

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