﻿:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-low: #ffffff;
  --surface-high: #eceef2;
  --text: #1a1c1e;
  --muted: #73777f;
  --line: #e6e9ef;
  --outline: #c3c6cf;
  --accent: #007aff;
  --accent-text: #ffffff;
  --accent-soft: rgba(0, 122, 255, 0.1);
  --warn-bg: #fff4e0;
  --warn-text: #8a5a00;
  --ok-bg: #eaf4ec;
  --ok-text: #2e6b36;
  --error-bg: #fdecec;
  --error-text: #ba1a1a;
  --shadow: 0 1px 3px rgba(18, 28, 45, 0.06);
  --shadow-pop: 0 10px 30px rgba(18, 28, 45, 0.16);
  --radius: 16px;
  --app-sidebar-width: 224px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111318;
    --surface: #1a1c21;
    --surface-low: #1a1c21;
    --surface-high: #292c31;
    --text: #e2e2e6;
    --muted: #8d9199;
    --line: #2a2e35;
    --outline: #43474e;
    --accent: #0a84ff;
    --accent-text: #ffffff;
    --accent-soft: rgba(10, 132, 255, 0.16);
    --warn-bg: #33280f;
    --warn-text: #f0c36a;
    --ok-bg: #172b1c;
    --ok-text: #8ed39a;
    --error-bg: #33191a;
    --error-text: #f1a1a1;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-pop: 0 12px 34px rgba(0, 0, 0, 0.5);
  }
}

html[data-theme="dark"] {
  --bg: #111318;
  --surface: #1a1c21;
  --surface-low: #1a1c21;
  --surface-high: #292c31;
  --text: #e2e2e6;
  --muted: #8d9199;
  --line: #2a2e35;
  --outline: #43474e;
  --accent: #0a84ff;
  --accent-text: #ffffff;
  --accent-soft: rgba(10, 132, 255, 0.16);
  --warn-bg: #33280f;
  --warn-text: #f0c36a;
  --ok-bg: #172b1c;
  --ok-text: #8ed39a;
  --error-bg: #33191a;
  --error-text: #f1a1a1;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 12px 34px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) 20px calc(78px + env(safe-area-inset-bottom));
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 760px;
  margin-inline: auto;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.read-only .device-card,
body.read-only .box-card,
body.read-only .cell { cursor: default; }

body.read-only .cell.empty::after { display: none; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

header.app-header { margin-bottom: 10px; }

.brand { display: flex; align-items: baseline; gap: 10px; }

h1 { font-size: 24px; margin: 0; letter-spacing: -0.4px; }

.tag {
  font-size: 12px;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 1px 8px;
  line-height: 1.5;
}

.sub { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

#backup-banner {
  position: relative;
  padding-right: 40px;
  animation: banner-in 0.24s ease;
}

#backup-banner .banner-text { flex: 1; min-width: 0; }

#backup-banner .banner-close {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#backup-banner .banner-close .icon { width: 15px; height: 15px; }
#backup-banner .banner-close:hover:not(:disabled) { opacity: 1; border: 0; background: rgba(0,0,0,0.06); }

@keyframes banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.banner {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  margin-bottom: 12px;
  background: var(--ok-bg);
  color: var(--ok-text);
}

#backup-banner {
  display: flex;
  align-items: center;
  gap: 8px;
}

#backup-banner[hidden] { display: none; }

.banner[data-level="warn"] { background: var(--warn-bg); color: var(--warn-text); }
.banner[data-level="error"] { background: var(--error-bg); color: var(--error-text); }

.banner-button { cursor: pointer; }
.banner-button:hover { filter: brightness(0.98); }

.view[hidden] { display: none; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ==================== 工具栏 ==================== */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  min-height: 44px;
}

.toolbar-title { flex: 1; min-width: 0; }

.toolbar-title h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-title p {
  margin: 2px 0 0;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-actions { display: flex; align-items: center; gap: 6px; flex: none; }

button,
input,
select,
textarea { font: inherit; }

button {
  font-size: 14px;
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}

button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button.danger {
  color: var(--error-text);
  border-color: color-mix(in srgb, var(--error-text) 35%, var(--line));
  background: transparent;
}

button.danger:hover:not(:disabled) {
  background: var(--error-bg);
  border-color: var(--error-text);
}

button.danger-solid {
  background: var(--error-text);
  border-color: var(--error-text);
  color: #fff;
  font-weight: 600;
}

button.small { min-height: 36px; padding: 6px 12px; font-size: 13px; }

.icon-btn {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  flex: none;
}

.icon-btn:hover:not(:disabled) { background: var(--surface-high); border: 0; }

.icon-btn.tiny {
  width: 30px;
  height: 30px;
  min-height: 30px;
}

.icon-btn.tiny .icon { width: 18px; height: 18px; }

.danger-icon { color: var(--error-text); }

.link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

.link:hover { text-decoration: underline; }

/* ==================== 概览卡片 ==================== */

.cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}

.card span {
  display: block;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.card label {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.hint {
  margin: 16px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

/* ==================== 设备列表 ==================== */

.device-group { margin-bottom: 12px; }

.device-group > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.device-group > summary::-webkit-details-marker { display: none; }

.device-group > summary::before {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  margin-right: 2px;
}

.device-group[open] > summary::before { transform: rotate(45deg); }

.device-list { display: flex; flex-direction: column; gap: 8px; }

.recent-row {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scrollbar-width: none;
}

.recent-row::-webkit-scrollbar { display: none; }

.recent-card {
  position: relative;
  flex: 0 0 auto;
  width: 138px;
  min-height: 0;
  padding: 12px 12px 12px 15px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-color, var(--accent));
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
}

.recent-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-path {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.device-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.leading-icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.device-main { flex: 1; min-width: 0; }

.device-name {
  display: block;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-note {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-counts {
  flex: none;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.card-actions { display: flex; gap: 0; flex: none; }

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 4px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-high);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ==================== 冻存盒卡片 ==================== */

.box-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.box-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 82px;
  padding: 13px 34px 13px 18px;
  text-align: left;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-color, var(--accent));
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.box-card:hover { border-color: var(--accent-color, var(--accent)); }

.box-name {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.box-meta {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.box-note {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

details.menu.box-menu {
  position: absolute;
  top: 4px;
  right: 4px;
}

/* ==================== 层级手风琴 ==================== */

.layer {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.layer-head { display: flex; align-items: center; gap: 4px; padding-right: 6px; }

.layer-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 12px 4px 12px 14px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
}

.layer-toggle:hover:not(:disabled) { background: var(--accent-soft); border: 0; }

.layer-toggle .chevron {
  display: inline-flex;
  color: var(--muted);
  transition: transform 0.18s ease;
}

.layer.collapsed .layer-toggle .chevron { transform: rotate(-90deg); }

.layer-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-sub {
  flex: 0 1 auto;
  max-width: 35%;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-body { padding: 0 12px 12px; }

.layer.collapsed .layer-body { display: none; }

.layer-empty {
  margin: 0;
  padding: 4px 2px 6px;
  font-size: 12px;
  color: var(--muted);
}

/* ==================== 菜单 ==================== */

details.menu { position: relative; flex: none; }

details.menu > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

details.menu > summary::-webkit-details-marker { display: none; }

.menu-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 176px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.menu-list button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  text-align: left;
  color: var(--text);
}

.menu-list button:hover:not(:disabled) { background: var(--surface-high); border: 0; }

.menu-list button.danger { color: var(--error-text); background: transparent; }

.menu-list button.danger:hover { background: var(--error-bg); }

.menu-list .icon { width: 18px; height: 18px; }

.menu-list button.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.input-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.input-mode-btn .icon { width: 17px; height: 17px; }
.input-mode-btn .tiny-icon { width: 13px; height: 13px; color: var(--muted); }
.input-mode-list { min-width: 148px; }

.bottom-tab-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0;
}

.bottom-tab-section {
  margin: 10px 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.muted-section { margin-top: 16px; }

.bottom-tab-row.is-hidden { opacity: 0.7; }

.bottom-tab-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.bottom-tab-row > .icon { width: 19px; height: 19px; color: var(--muted); flex: none; }
.bottom-tab-name { flex: 1; min-width: 0; font-size: 14px; }
.bottom-tab-row .switch-row.compact { flex: none; width: auto; min-height: 0; padding: 0; border: 0; }
.bottom-tab-row .switch-row.compact input { width: 38px; height: 22px; }
.bottom-tab-row .icon-btn:disabled { opacity: 0.25; }

#sample-save-status { margin-left: 4px; white-space: nowrap; }

/* ==================== 盒内网格 ==================== */

.box-grid-cells {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 5), minmax(0, 1fr));
  gap: 6px;
  padding-bottom: 12px;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
}

.cell:hover { border-color: var(--accent); }

.cell.empty::after {
  content: '+';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.cell.empty:hover::after { opacity: 1; }

.cell.no-photo { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }

.cell.has-photo { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }

.cell-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cell-label {
  position: absolute;
  top: 3px;
  left: 4px;
  z-index: 2;
  padding: 0 3px;
  border-radius: 4px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
}

.cell-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: none;
  padding: 12px 4px 3px;
  font-size: 11px;
  line-height: 1.2;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.box-grid-cells.show-detail .cell-name,
.cell.no-photo .cell-name { display: block; }

.cell-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
}

.zoom {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
  font-size: 12px;
  color: var(--muted);
}

.zoom input[type='range'] { width: 110px; accent-color: var(--accent); }

/* ==================== 搜索 ==================== */

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.search-bar:focus-within { border-color: var(--accent); }

.search-icon { color: var(--muted); }

.search-bar input {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
}

.search-bar input::-webkit-search-cancel-button { display: none; }

.clear-btn { width: 36px; height: 36px; min-height: 36px; }

.search-history { margin-bottom: 14px; }

.history-head,
.facet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.facet-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text);
}

.facet-title .icon { width: 16px; height: 16px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.chip:hover:not(:disabled) { border-color: var(--accent); }

.chip[aria-pressed='true'],
.facet-chip[aria-pressed='true'] {
  border-color: var(--chip-color, var(--accent));
  background: color-mix(in srgb, var(--chip-color, var(--accent)) 12%, var(--surface));
  color: var(--text);
}

.chip-count { font-size: 10px; color: var(--muted); }

.search-facets { margin-bottom: 12px; }

.facet-group { margin-bottom: 10px; }

.facet-label {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  color: var(--muted);
}

.search-results { display: flex; flex-direction: column; gap: 8px; }

.result-count {
  margin: 4px 2px 2px;
  font-size: 12px;
  color: var(--muted);
}

.result-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 0;
  padding: 13px 14px;
  border-radius: max(12px, var(--radius));
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
}

.result-card .leading-icon { width: 36px; height: 36px; }

.result-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.result-name {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-sub {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-note {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-date { font-size: 11px; color: var(--accent); }

.result-card .chevron { color: var(--outline); display: inline-flex; }

.result-card.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ==================== 空状态 ==================== */

.empty-state {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  border: 1px dashed var(--outline);
  border-radius: var(--radius);
}

.empty-state strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* ==================== 底部导航 ==================== */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  padding: 8px max(10px, calc((100vw - 760px) / 2 + 10px));
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: 0 -6px 24px rgba(18, 28, 45, 0.08);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  padding: 4px 6px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.nav-item .icon { width: 23px; height: 23px; }

.nav-item[hidden] { display: none; }

.nav-item:hover:not(:disabled) { background: transparent; border: 0; }

.nav-item.active {
  color: var(--accent);
  background: transparent;
  font-weight: 700;
}

.nav-item.active .icon { stroke-width: 2.3; }

.nav-item:active { background: var(--surface-high); }

.fab-wrap {
  position: fixed;
  z-index: 22;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  right: max(16px, calc((100vw - 760px) / 2 + 16px));
  bottom: calc(78px + env(safe-area-inset-bottom));
}

.fab {
  width: 56px;
  height: 56px;
  min-height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 40%, transparent);
}

.fab:hover:not(:disabled) { border: 0; filter: brightness(1.05); }

.fab .icon { width: 26px; height: 26px; stroke-width: 2.2; }

.fab-menu {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.fab-option {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

/* ==================== 对话框 ==================== */

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 20px;
  max-width: min(92vw, 420px);
  box-shadow: var(--shadow-pop);
}

dialog::backdrop { background: rgba(10, 15, 22, 0.42); }

dialog p { margin: 0 0 16px; line-height: 1.6; font-size: 14px; }

#confirm-dialog form { display: flex; justify-content: flex-end; gap: 10px; }

dialog.sheet {
  width: min(94vw, 520px);
  max-height: 88dvh;
  overflow: auto;
  padding: 20px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.dialog-head > div { flex: 1; min-width: 0; }

.dialog-head > .sample-nav {
  flex: none;
  align-self: center;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sample-nav .icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.sample-nav .icon-btn {
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 10px;
}

.sample-nav .icon-btn .icon { width: 17px; height: 17px; }

.sample-nav .sample-nav-icon.prev { transform: rotate(180deg); }

.dialog-head h3 { margin: 0; font-size: 18px; }

.dialog-head p { margin: 2px 0 0; font-size: 12px; }

.field {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
}

.field-label { display: block; }

.field > input,
.field > textarea,
.field > select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  resize: vertical;
  -webkit-appearance: none;
  appearance: none;
}

.field > select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) calc(50% + 1px),
    calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.field > input:focus,
.field > textarea:focus,
.field > select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-color: var(--accent);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-row .field { margin-bottom: 0; }

.field + .field-row,
.field-row + .field { margin-top: 10px; }

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

.swatches { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 8px; }

.swatch {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface) inset;
}

.swatch .icon { width: 17px; height: 17px; stroke-width: 2.6; }

.tag-tool { margin: 0 0 12px; }

.inline-add {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.backup-csv { margin-top: 18px; }

.photo-orphans {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.photo-orphans .muted {
  margin-bottom: 8px;
  font-size: 12px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}

.switch-row span { flex: 1; min-width: 0; }

.switch-row strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.switch-row small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

.switch-row input {
  width: 20px;
  height: 20px;
  min-height: 0;
  flex: none;
  accent-color: var(--accent);
}

.inline-add input { flex: 1; min-width: 0; }

.tag-manage-list { display: flex; flex-direction: column; gap: 8px; }

.tag-color-dot {
  position: relative;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--tag-color) 35%, var(--line));
  background: color-mix(in srgb, var(--tag-color) 16%, var(--surface));
}

.tag-color-dot::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--tag-color);
  transform: translate(-50%, -50%);
}

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.tag-chip .tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tag-color, var(--accent));
}

.tag-chip[aria-pressed='true'] {
  border-color: var(--tag-color, var(--accent));
  color: var(--text);
  background: color-mix(in srgb, var(--tag-color, var(--accent)) 12%, var(--surface));
}

.photo-editor {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 4px 0 18px;
}

/* ==================== 样本照片（安卓同款布局） ==================== */

dialog.sample-sheet {
  width: min(96vw, 640px);
  height: min(92dvh, 860px);
  max-height: 92dvh;
  padding: 14px 16px 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

dialog.sample-sheet[open] { display: flex; flex-direction: column; }

dialog.sample-sheet #sample-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.sample-photo-card {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-high);
  box-shadow: var(--shadow);
}

.sample-photo-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 180px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  cursor: zoom-in;
}

.sample-photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sample-photo-frame img[hidden] { display: none; }

.sample-photo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.sample-photo-empty[hidden] { display: none; }

.sample-photo-empty .icon {
  width: 44px;
  height: 44px;
  color: var(--muted);
  opacity: 0.7;
}

.sample-photo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sample-photo-actions button[hidden] { display: none; }

.sample-photo-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.sample-photo-actions .icon { width: 18px; height: 18px; }
.sample-photo-actions button.danger { color: var(--error-text); }

.ocr-setup-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 16px 0;
}

.ocr-setup-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
}

.ocr-setup-icon .icon { width: 28px; height: 28px; }

.ocr-setup-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.ocr-setup-list[hidden] { display: none; }

.ocr-setup-progress { display: flex; flex-direction: column; gap: 6px; }
.ocr-setup-progress[hidden] { display: none; }

.ocr-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-high);
  overflow: hidden;
}

.ocr-progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.4s ease;
}

#sample-photo-img { cursor: zoom-in; }

#sample-photo-img[hidden],
.photo-empty[hidden] { display: none; }

dialog.photo-viewer {
  display: none;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

dialog.photo-viewer[open] {
  display: flex;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  align-items: center;
  justify-content: center;
}

dialog.photo-viewer::backdrop { background: rgba(0, 0, 0, 0.86); }

#photo-dialog-img {
  max-width: 94vw;
  max-height: 88dvh;
  object-fit: contain;
  border-radius: 8px;
}

.photo-viewer #photo-dialog-close,
.photo-viewer-save {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  z-index: 2;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.photo-viewer #photo-dialog-close { right: 14px; }

.photo-viewer-save {
  left: 14px;
  min-height: 36px;
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  font-size: 13px;
}

.photo-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.photo-actions button { min-height: 36px; padding: 6px 12px; font-size: 12px; }

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.dialog-actions .spacer { flex: 1; }

#backup-dialog .hint { margin-top: 14px; }

/* ==================== 忙碌 / 提示 ==================== */

.busy {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 22, 0.32);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #fff;
  font-size: 14px;
  z-index: 60;
}

.busy[hidden] { display: none !important; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(90vw, 520px);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  background: var(--ok-bg);
  color: var(--ok-text);
  box-shadow: var(--shadow-pop);
  z-index: 70;
}

.toast[data-level="error"] { background: var(--error-bg); color: var(--error-text); }

.toast[hidden] { display: none !important; }

/* ==================== 响应式 ==================== */

@media (max-width: 640px) {
  body { padding-inline: 16px; padding-bottom: calc(78px + env(safe-area-inset-bottom)); }

  h1 { font-size: 22px; }

  .cards { grid-template-columns: repeat(3, 1fr); }

  .layer-sub { display: none; }

  .device-counts { display: none; }

  .toolbar { flex-wrap: wrap; }

  .toolbar-actions { flex-wrap: wrap; justify-content: flex-end; }

  #view-box .toolbar .zoom {
    order: 3;
    width: 100%;
    justify-content: flex-end;
    padding-top: 4px;
  }

  #view-box .toolbar .zoom input[type='range'] { width: 150px; }

  dialog.sheet {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    margin: 0;
    border-radius: 20px 20px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }
}

/* ==================== 偏好设置 / 多选 / 移动 ==================== */

.header-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.spacer { flex: 1; }

.selection-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -6px 0 14px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-pop);
}

.selection-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selection-actions { display: flex; align-items: center; gap: 2px; flex: none; }

body.selecting { user-select: none; -webkit-user-select: none; }

body.selecting .card-actions,
body.selecting .box-menu,
body.selecting .layer-head .menu,
body.selecting .fab-wrap {
  display: none !important;
}

body.selecting .cell.empty::after { display: none; }

[data-select-kind].selectable { position: relative; cursor: pointer; }

[data-select-kind].selectable.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow);
}

.device-card.selectable.selected,
.layer-head.selectable.selected {
  background: var(--accent-soft);
}

.layer-head.selectable.selected { border-radius: var(--radius); }

.cell.selectable.selected {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.select-check {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--muted) 70%, transparent);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.select-check.checked {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.select-check .icon { width: 14px; height: 14px; stroke-width: 3; }

.cell .select-check { top: 3px; right: 3px; width: 18px; height: 18px; }
.cell .select-check .icon { width: 12px; height: 12px; }

.device-card { position: relative; }

#view-settings .pref-group { margin-bottom: 18px; }

#view-settings .pref-group:first-of-type { margin-top: 18px; }

.pref-group h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
}

#ocr-download { margin-bottom: 12px; }

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-high);
}

.segmented button {
  flex: 1;
  min-height: 36px;
  padding: 6px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.select,
#view-settings select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}

button.block {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  text-align: center;
}

.prefs-footer {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

dialog.move-sheet {
  width: min(96vw, 640px);
  height: min(90dvh, 820px);
  max-height: 90dvh;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
}

dialog.move-sheet[open] { display: flex; }

.move-head { align-items: center; margin-bottom: 10px; }
.move-head-main { flex: 1; min-width: 0; }
.move-sheet .dialog-head h3 { font-size: 17px; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
}

.crumb {
  min-height: 0;
  padding: 2px 3px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
}

.crumb:hover:not(:disabled) { border: 0; text-decoration: underline; }
.crumb.current { color: var(--text); font-weight: 600; }
.crumb-sep { display: inline-flex; color: var(--outline); }
.crumb-sep .icon { width: 12px; height: 12px; }

.move-search { margin-bottom: 10px; flex: none; }

.move-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
}

.move-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
}

.move-row.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.move-icon {
  width: 34px;
  height: 34px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.move-icon .icon { width: 18px; height: 18px; }

.move-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }

.move-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.move-sub {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.move-check { color: var(--accent); display: inline-flex; }
.move-check .icon { width: 20px; height: 20px; }

.move-section {
  margin: 10px 4px 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.move-empty {
  padding: 36px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.move-footer {
  flex: none;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.move-grid-head { margin-bottom: 8px; font-size: 12px; color: var(--muted); }

.move-hint {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

.move-grid {
  display: grid;
  grid-template-columns: repeat(var(--move-cols, 5), minmax(0, 1fr));
  gap: 5px;
}

.move-cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 10px;
  color: var(--muted);
}

.move-cell.free { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.move-cell.selected { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 700; }
.move-cell.occupied { opacity: 0.55; background: var(--surface-high); }
.move-cell-x {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--error-text);
  font-size: 16px;
}
.move-cell-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.8;
}
.move-cell-label { font-weight: 600; }

/* ==================== 宽屏：底栏变侧边栏 ==================== */

@media (min-width: 900px) {
  body {
    max-width: none;
    margin-inline: 0;
    padding: 28px 40px 40px calc(var(--app-sidebar-width) + 40px);
  }

  .app-header { margin-bottom: 8px; }

  .app-header .header-row { min-height: 8px; }

  .bottom-nav {
    top: 0;
    left: 0;
    right: auto;
    bottom: 0;
    width: var(--app-sidebar-width);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    padding: 22px 12px;
    padding-bottom: calc(22px + env(safe-area-inset-bottom));
    border-top: 0;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    box-shadow: none;
  }

  .bottom-nav::before {
    content: "LabFreezer";
    display: none;
    margin: 0 10px 18px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text);
  }

  .nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    min-height: 46px;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
  }

  .nav-item .icon { width: 21px; height: 21px; }

  .nav-item.active {
    background: var(--accent-soft);
    font-weight: 600;
  }

  .nav-item:hover:not(:disabled) { background: var(--surface-high); }

  .fab-wrap {
    right: 40px;
    bottom: 40px;
  }

  .toast { bottom: 40px; }

  #main { padding-bottom: 0; }

  .selection-bar { top: 0; }

  dialog.sheet {
    margin: auto;
    border-radius: 18px;
  }
}

/* 超宽屏：内容分栏，避免单列过长 */

@media (min-width: 1280px) {
  #main { max-width: 1180px; }

  #devices-grid,
  #device-body .device-list,
  #device-body .box-grid,
  #recent-list,
  #tag-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-content: start;
  }

  #recent-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-content: start;
  }

  #recent-list .recent-card {
    width: auto;
    min-width: 0;
  }

  #view-settings {
    max-width: 720px;
    margin-inline: auto;
  }

  #view-settings .toolbar,
  #view-settings .pref-group,
  #view-settings .prefs-footer {
    width: 100%;
  }
}

@media (min-width: 1600px) {
  #main { max-width: 1400px; }

  #devices-grid,
  #device-body .device-list,
  #device-body .box-grid,
  #tag-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .bottom-nav::before { display: block; }

  body {
    max-width: calc(1360px + var(--app-sidebar-width) + 40px);
    margin-inline: 0;
    padding-left: calc(var(--app-sidebar-width) + 40px);
  }
}

/* ==================== 宽屏三栏：侧边栏 / 页面 / 样本编辑 ==================== */

@media (min-width: 1200px) {

  body {
    max-width: none;
    padding-right: 0;
    transition: padding-right 0.22s ease;
  }

  body.sample-panel-open {
    --sample-panel-width: 400px;
    --sample-panel-gap: 32px;
    padding-right: calc(var(--sample-panel-width) + var(--sample-panel-gap));
  }

  dialog.sample-sheet {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    z-index: 80;
    width: var(--sample-panel-width, 400px);
    max-width: 46vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 18px 18px 0;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;
    background: var(--surface);
    box-shadow: -12px 0 32px rgba(18, 28, 45, 0.08);
    overflow-y: auto;
    opacity: 0;
    transform: translateX(16px);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  dialog.sample-sheet[open] {
    display: flex;
    flex-direction: column;
    margin: 0;
    opacity: 1;
    transform: none;
  }

  dialog.sample-sheet::backdrop { background: transparent; }

  dialog.sample-sheet #sample-form { gap: 12px; }

  #box-grid .cell.is-current {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
}

@media (min-width: 1600px) {
  body.sample-panel-open { --sample-panel-width: 440px; }
}

@media (max-width: 640px) {
  .selection-bar { margin-top: -8px; padding: 6px 8px; }

  dialog.move-sheet {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    padding: max(12px, env(safe-area-inset-top)) 14px calc(12px + env(safe-area-inset-bottom));
  }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0.01ms !important; }
}
