/* 源检台 — content-first asset browser
   Archetype: Browser + Inspector
   Calm paper workspace; media first; no FlipForge grid paper */

:root {
  --bg: #f3f1ec;
  --bg-side: #ebe8e1;
  --surface: #fffcf7;
  --surface-2: #f7f4ee;
  --ink: #1c1b19;
  --muted: #6f6b63;
  --line: #ddd6c8;
  --line-strong: #c9c0ae;
  --accent: #2f6f68;
  --accent-soft: rgba(47, 111, 104, 0.12);
  --pass: #2f7d4a;
  --pass-bg: #e7f5ec;
  --risk: #a66b1a;
  --risk-bg: #f8efd9;
  --block: #b23b2f;
  --block-bg: #f8e6e3;
  --shadow: 0 10px 28px rgba(28, 27, 25, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --nav-w: 300px;
  --inspector-w: min(400px, 34vw);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── Top ── */

.top {
  display: grid;
  grid-template-columns: minmax(180px, 220px) 1fr auto;
  gap: 1rem 1.25rem;
  align-items: end;
  padding: 0.95rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background:
    linear-gradient(145deg, rgba(47, 111, 104, 0.9), rgba(47, 111, 104, 0.25) 48%, transparent 49%),
    linear-gradient(320deg, rgba(178, 59, 47, 0.35), transparent 50%),
    var(--surface-2);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.brand p {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.scan-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
}

.field.grow {
  flex: 1;
  min-width: 220px;
}

.field span {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  font: 500 0.88rem/1.3 var(--mono);
  outline: none;
}

.field input:focus,
.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #fff;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.check.compact {
  font-size: 0.78rem;
  margin-top: 0.55rem;
}

.check input {
  accent-color: var(--accent);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.95rem;
  font: 600 0.88rem/1.2 var(--font);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  color: #f7fffd;
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn.secondary {
  background: var(--ink);
  color: #f7f4ee;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.top-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.pill em {
  font-style: normal;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.pill.pass {
  background: var(--pass-bg);
  border-color: rgba(47, 125, 74, 0.25);
  color: var(--pass);
}
.pill.pass em { color: var(--pass); }

.pill.risk {
  background: var(--risk-bg);
  border-color: rgba(166, 107, 26, 0.25);
  color: var(--risk);
}
.pill.risk em { color: var(--risk); }

.pill.block {
  background: var(--block-bg);
  border-color: rgba(178, 59, 47, 0.25);
  color: var(--block);
}
.pill.block em { color: var(--block); }

.progress {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 140px;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
}

.track {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.track i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease;
}

.toast {
  margin: 0;
  padding: 0.55rem 1.25rem;
  background: #fff8e8;
  border-bottom: 1px solid #e7d3a2;
  color: #6a4f16;
  font-size: 0.86rem;
}

.toast.error {
  background: var(--block-bg);
  border-color: #e8b4ae;
  color: var(--block);
}

.toast.ok {
  background: var(--pass-bg);
  border-color: #b9ddc4;
  color: var(--pass);
}

/* ── Workspace ── */

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr) auto;
}

.nav {
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  padding: 0.85rem 0.75rem 1.25rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.nav-head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
}

.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: 600 0.75rem/1 var(--font);
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
}

.seg-btn.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(28, 27, 25, 0.06);
}

.seg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tree {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tree-item {
  appearance: none;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.42rem 0.5rem;
  border-radius: 7px;
  color: var(--ink);
  font: 500 0.84rem/1.3 var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.tree-item:hover {
  background: rgba(255, 255, 255, 0.55);
}

.tree-item.on {
  background: var(--accent-soft);
  color: var(--accent);
}

.tree-item .label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item .count {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tree-item.depth-1 { padding-left: 1rem; }
.tree-item.depth-2 { padding-left: 1.55rem; }
.tree-item.depth-3 { padding-left: 2.1rem; }
.tree-item.depth-4 { padding-left: 2.65rem; }

.tree-folder {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.55rem 0.5rem 0.2rem;
}

.export-fold {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.45);
  padding: 0.15rem 0.7rem 0.7rem;
}

.export-fold summary {
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.6rem 0;
  list-style: none;
}

.export-fold summary::-webkit-details-marker {
  display: none;
}

.export-box {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.row {
  display: flex;
  gap: 0.35rem;
}

.row input {
  flex: 1;
  min-width: 0;
}

.hint {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ── Browser ── */

.browser {
  min-width: 0;
  overflow: auto;
  padding: 0.85rem 1rem 1.5rem;
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.65), transparent 120px),
    var(--bg);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.35rem 0 0.55rem;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.32rem 0.7rem;
  font: 600 0.75rem/1 var(--font);
  cursor: pointer;
}

.chip.on {
  color: var(--ink);
  border-color: var(--line-strong);
}

.chip.block.on {
  color: var(--block);
  background: var(--block-bg);
  border-color: rgba(178, 59, 47, 0.3);
}
.chip.risk.on {
  color: var(--risk);
  background: var(--risk-bg);
  border-color: rgba(166, 107, 26, 0.3);
}
.chip.pass.on {
  color: var(--pass);
  background: var(--pass-bg);
  border-color: rgba(47, 125, 74, 0.3);
}

.search {
  flex: 1;
  min-width: 160px;
}

.empty {
  max-width: 460px;
  margin: 4rem auto;
  text-align: center;
  padding: 1.5rem;
}

.empty h2 {
  margin: 0 0 0.55rem;
  font-size: 1.35rem;
}

.empty p {
  margin: 0 0 1.1rem;
  color: var(--muted);
  line-height: 1.55;
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.75rem;
}

.grid.list-mode {
  grid-template-columns: 1fr;
  gap: 0.4rem;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.thumb {
  aspect-ratio: 16 / 11;
  width: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  background:
    linear-gradient(45deg, #e4e0d6 25%, transparent 25%) 0 0 / 12px 12px,
    linear-gradient(-45deg, #e4e0d6 25%, transparent 25%) 0 6px / 12px 12px,
    #efebe3;
}

.thumb:not([src]),
.thumb[src=""] {
  min-height: 4rem;
}

.meta {
  padding: 0.65rem 0.75rem 0.3rem;
  flex: 1;
}

.meta h3 {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta p {
  margin: 0.28rem 0 0;
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--muted);
}

.card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.65rem 0.65rem;
}

.btn-locate {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 0.22rem 0.45rem;
  font: 500 0.7rem/1 var(--font);
  cursor: pointer;
}

.btn-locate:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.badge {
  display: inline-flex;
  padding: 0.2rem 0.48rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
}

.badge.pass { color: var(--pass); background: var(--pass-bg); }
.badge.risk { color: var(--risk); background: var(--risk-bg); }
.badge.block { color: var(--block); background: var(--block-bg); }

.grid.list-mode .card {
  flex-direction: row;
  align-items: center;
  transform: none;
}

.grid.list-mode .thumb {
  width: 84px;
  aspect-ratio: 1;
  flex-shrink: 0;
}

.grid.list-mode .meta h3 {
  -webkit-line-clamp: 1;
}

.grid.list-mode .card-actions {
  margin-left: auto;
}

/* ── Inspector ── */

.inspector {
  width: var(--inspector-w);
  border-left: 1px solid var(--line);
  background: var(--surface);
  overflow: auto;
  padding: 0.9rem 0.95rem 1.5rem;
}

.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.inspector-head h2 {
  margin: 0;
  font-size: 0.95rem;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  width: 28px;
  height: 28px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}

.detail-body .hero-thumb {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin-bottom: 0.7rem;
}

.detail-body h3 {
  margin: 0.45rem 0 0.3rem;
  font-size: 0.95rem;
  word-break: break-all;
}

.abs-path {
  margin: 0 0 0.7rem;
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--muted);
  word-break: break-all;
}

.path-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 0.7rem;
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
}

.kv dt { color: var(--muted); }
.kv dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 0.3rem;
  vertical-align: -1px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.swatch-lg {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.findings {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.find {
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.find strong {
  display: block;
  color: var(--ink);
  margin-bottom: 0.12rem;
  font-size: 0.75rem;
}

.aside-label {
  margin: 0 0 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.compare-hint,
.compare-engine,
.compare-summary,
.compare-disclaimer {
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 0.45rem;
}

.compare-loading {
  padding: 0.85rem;
  text-align: center;
  color: var(--muted);
}

.key-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 0.65rem;
}

.key-banner .rgb-text {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.compare-grid {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.compare-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.compare-card img {
  width: 100%;
  display: block;
  cursor: zoom-in;
  background:
    linear-gradient(45deg, #ddd 25%, transparent 25%) 0 0 / 12px 12px,
    linear-gradient(-45deg, #ddd 25%, transparent 25%) 0 6px / 12px 12px,
    #eee;
}

.compare-card img:hover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ── Image lightbox (matte compare detail) ── */

.img-lightbox {
  border: none;
  padding: 0;
  max-width: min(96vw, 1200px);
  max-height: 94vh;
  width: 96vw;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(28, 27, 25, 0.28);
}

.img-lightbox::backdrop {
  background: rgba(20, 18, 16, 0.62);
  backdrop-filter: blur(2px);
}

.img-lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.img-lightbox-title {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.img-lightbox-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.img-lightbox-stage {
  overflow: auto;
  max-height: calc(94vh - 3.5rem);
  padding: 0.75rem;
  background:
    linear-gradient(45deg, #e4e0d6 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #e4e0d6 25%, transparent 25%) 0 8px / 16px 16px,
    #efebe3;
  text-align: center;
}

.img-lightbox-stage img {
  display: inline-block;
  max-width: 100%;
  height: auto;
  vertical-align: middle;
  transform-origin: center top;
  transition: transform 0.12s ease;
}

.compare-card figcaption {
  padding: 0.6rem 0.7rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.compare-card .note,
.compare-card em {
  font-size: 0.72rem;
  color: var(--muted);
  font-style: normal;
}

.chroma-fields {
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.chroma-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
}

.chroma-label { color: var(--muted); }
.chroma-val { font-family: var(--mono); }

.copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

/* ── Footer ── */

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
}

#lanUrls {
  flex: 1;
  text-align: center;
  color: var(--accent);
  word-break: break-all;
}

/* ── Phone chrome (desktop defaults; phone MQ overrides) ── */

.phone-only {
  display: none !important;
}

.nav-scrim {
  display: none !important;
}

/* Unwrap manage fold so .scan-row still sits in .top grid on desktop */
.manage-fold {
  display: contents;
}

.manage-fold > .manage-summary {
  display: none;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .inspector {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    width: var(--inspector-w);
    box-shadow: var(--shadow);
  }

  .top {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  /* Phone chrome visible (!important beats desktop .phone-only { display:none }) */
  .phone-only {
    display: block !important;
  }

  .phone-top,
  #phoneTop,
  .phone-top.phone-only,
  #phoneTop.phone-only {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem 0.75rem;
    padding: 0.65rem 0.85rem;
    padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 25;
  }

  .phone-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
  }

  .phone-brand h1,
  .phone-brand .brand-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.15;
  }

  .phone-progress {
    flex: 1 1 100%;
    min-width: 0;
    font-size: 0.72rem;
    color: var(--muted);
    font-family: var(--mono);
  }

  .phone-actions,
  .phone-actions.phone-only {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
  }

  /* Compact header: brand lives in phone-top */
  .top {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.65rem 0.85rem;
    align-items: stretch;
  }

  .top .brand {
    display: none;
  }

  .top-stats {
    justify-content: flex-start;
    gap: 0.3rem;
  }

  .top-stats .progress {
    min-width: 0;
    flex: 1 1 100%;
  }

  /* Manage fold: scan controls behind summary button */
  .manage-fold {
    display: block;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    overflow: hidden;
  }

  .manage-fold > .manage-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    list-style: none;
    cursor: pointer;
    padding: 0.65rem 0.8rem;
    min-height: 40px;
    font: 600 0.88rem/1.2 var(--font);
    color: var(--ink);
    user-select: none;
  }

  .manage-fold > .manage-summary::-webkit-details-marker {
    display: none;
  }

  .manage-fold > .manage-summary::after {
    content: "▾";
    color: var(--muted);
    font-size: 0.85rem;
    transition: transform 0.15s ease;
  }

  .manage-fold[open] > .manage-summary::after,
  body.manage-open .manage-fold > .manage-summary::after {
    transform: rotate(-180deg);
  }

  .manage-fold .scan-row {
    padding: 0.15rem 0.75rem 0.75rem;
    flex-direction: column;
    align-items: stretch;
  }

  .manage-fold .field.grow {
    min-width: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  /* Nav: off-canvas drawer */
  .nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(88vw, 320px);
    max-height: 100dvh;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    border-right: 1px solid var(--line);
    border-bottom: none;
    box-shadow: var(--shadow);
    overflow: auto;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }

  body.nav-open .nav {
    transform: none;
  }

  .nav .drawer-head,
  .nav .drawer-head.phone-only {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
  }

  /* Scrim under drawer (above inspector sheet, below nav) */
  .nav-scrim,
  #navScrim.nav-scrim {
    display: none !important;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(28, 27, 25, 0.42);
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
  }

  body.nav-open .nav-scrim,
  body.nav-open #navScrim.nav-scrim {
    display: block !important;
  }

  body.nav-open #navScrim.nav-scrim[hidden] {
    display: block !important;
  }

  /* Inspector: fullscreen sheet */
  .inspector:not([hidden]),
  #inspector:not([hidden]) {
    position: fixed;
    inset: 0;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: none;
    z-index: 40;
    border-left: none;
    box-shadow: none;
    background: var(--surface);
    padding: 0.9rem 0.95rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .inspector-head {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: -0.9rem -0.95rem 0.65rem;
    padding: 0.75rem 0.95rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }

  .icon-btn {
    width: 40px;
    height: 40px;
  }

  /* Toolbar + chips */
  .toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    padding-bottom: 0.15rem;
  }

  .chip,
  .btn {
    min-height: 40px;
  }

  .chip {
    padding: 0.45rem 0.85rem;
    flex-shrink: 0;
  }

  .seg-btn {
    min-height: 40px;
    padding: 0.45rem 0.75rem;
  }

  /* Grid: 2 columns, touch-friendly */
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .meta {
    padding: 0.55rem 0.6rem 0.25rem;
  }

  .card-actions {
    padding: 0.35rem 0.55rem 0.55rem;
  }

  .btn-locate {
    min-height: 36px;
    padding: 0.35rem 0.55rem;
  }

  .browser {
    padding: 0.7rem 0.75rem 1.25rem;
  }

  /* Compact footer */
  .foot {
    padding: 0.4rem 0.75rem;
    gap: 0.35rem 0.6rem;
    font-size: 0.68rem;
  }

  .foot > span:first-child,
  #lanUrls {
    display: none;
  }

  /* Lightbox: stack actions */
  .img-lightbox {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }

  .img-lightbox-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .img-lightbox-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .img-lightbox-actions .btn,
  .img-lightbox-actions .seg-btn {
    min-height: 40px;
  }

  .img-lightbox-stage {
    max-height: calc(100dvh - 7rem);
  }

  @media (max-width: 360px) {
    .grid {
      grid-template-columns: 1fr;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .track i,
  .btn,
  .nav {
    transition: none !important;
  }
}
