:root {
  --bg: #0c0c0e;
  --bg-elev: #15151a;
  --bg-card: #1a1a20;
  --border: #2a2a32;
  --text: #f1f1f3;
  --muted: #8b8b96;
  --accent: #ff4d8d;
  --accent-2: #b06bff;
  --acid: #c4ff3a;
  --ok: #4ade80;
  --err: #f87171;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
html, body { height: 100vh; height: 100dvh; height: 100svh; overflow: hidden; }   /* lock page; iOS 100vh is taller than visible */
body { font-family: -apple-system, "Inter Tight", "Inter", BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; font-size: 14px; line-height: 1.5; display: flex; flex-direction: column; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }
code, pre { font-family: "JetBrains Mono", "SF Mono", Menlo, ui-monospace, monospace; }
.muted { color: var(--muted); }
.small { font-size: 11px; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--bg-elev); border-bottom: 1px solid var(--border); z-index: 50; flex-shrink: 0; }

/* ============== V4UL7 Loader (initial page-load + slow nav) ============== */
.v4ul7-loader {
  position: fixed; inset: 0; z-index: 9999; background: #0A0A0A;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.28s ease-out; overflow: hidden;
}
.v4ul7-loader.is-visible { opacity: 1; pointer-events: auto; }
.v4ul7-loader.is-gone { display: none; }
.v4l-scene{ position:relative; width:760px; height:240px; transform-origin:center; }
.v4l-scene::before{ content:""; position:absolute; inset:-30%; z-index:0; pointer-events:none; background: radial-gradient(closest-side, rgba(255,45,148,0.12), transparent 70%); background-repeat:no-repeat; background-position:78% 50%; background-size:55% 90%; filter:blur(30px); animation:v4l-bg 16s ease-in-out infinite; }
@keyframes v4l-bg{ 0%,100%{transform:translate(0,-3%)} 50%{transform:translate(2%,3%)} }
.v4l-planet{ position:absolute; left:50%; top:50%; width:460px; height:460px; margin:-230px 0 0 -230px; border-radius:50%; background:#FF2D94; transform:translateX(390px); z-index:3; animation:v4l-planet-bob 12s ease-in-out infinite; }
@keyframes v4l-planet-bob{ 0%,100%{transform:translateX(390px) translateY(0)} 50%{transform:translateX(390px) translateY(-8px)} }
.v4l-wordmark{ position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); width:280px; z-index:5; display:flex; flex-direction:column; align-items:center; }
.v4l-line{ width:100%; height:auto; display:block; overflow:visible; }
.v4l-line path{ fill:#F8F6EF; }
.v4l-divider{ position:relative; width:84%; height:2px; background:#F8F6EF; margin:5px 0; }
.v4l-divider::before,.v4l-divider::after{ content:""; position:absolute; top:-4px; width:2px; height:10px; background:#F8F6EF; }
.v4l-divider::before{ left:0; } .v4l-divider::after{ right:0; }
.v4l-measure{ position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); width:360px; height:210px; z-index:6; overflow:visible; pointer-events:none; }
.v4l-measure .m{ opacity:0; animation:v4l-flash 13s ease-in-out infinite; }
.v4l-measure .m1{ animation-delay:-0.5s } .v4l-measure .m2{ animation-delay:-3.6s }
.v4l-measure .m5{ animation-delay:-7.0s } .v4l-measure .m6{ animation-delay:-10.4s }
@keyframes v4l-flash{ 0%,3%{opacity:0} 6%{opacity:.9} 12%{opacity:.9} 16%{opacity:0} 100%{opacity:0} }
@keyframes v4l-orbit2{ 0%{transform:translate(-410px,26px) scale(0.80);opacity:0} 8%{transform:translate(-320px,24px) scale(0.95);opacity:1} 45%{transform:translate(30px,4px) scale(0.46);opacity:0.95} 72%{transform:translate(250px,-8px) scale(0.20);opacity:0.55} 88%{transform:translate(370px,-14px) scale(0.07);opacity:0} 100%{transform:translate(-410px,26px) scale(0.80);opacity:0} }
.v4l-moon{ position:absolute; left:50%; top:50%; width:58px; height:58px; margin:-29px 0 0 -29px; border-radius:50%; border:2px solid rgba(248,246,239,0.82); background:rgba(248,246,239,0.06); box-shadow:inset -6px -6px 0 rgba(10,10,10,0.18); z-index:2; animation:v4l-orbit2 11s linear infinite; }
.v4l-vault{ position:absolute; left:50%; top:50%; width:70px; height:70px; margin:-35px 0 0 -35px; z-index:2; perspective:240px; animation:v4l-orbit2 11s linear infinite; animation-delay:-5.5s; }
.v4l-vault-3d{ position:absolute; inset:0; transform-style:preserve-3d; }
.v4l-vault-shell{ position:absolute; inset:0; background:#0A0A0A; border:3px solid #6E6E76; border-radius:5px; box-shadow:inset 0 0 0 1px #1c1c22; }
.v4l-vault-interior{ position:absolute; inset:4px; overflow:hidden; border-radius:3px; background:radial-gradient(circle at 50% 34%, #51515e 0%, #2a2a32 60%, #16161b 100%); }
.v4l-peeker{ position:absolute; left:50%; bottom:1px; width:58%; transform:translateX(-50%) translateY(12px); opacity:0; animation:v4l-peek 11s ease-in-out infinite; animation-delay:-5.5s; }
.v4l-peeker svg{ width:100%; height:auto; display:block; image-rendering:pixelated; filter:drop-shadow(0 1px 0 rgba(0,0,0,.4)); }
.v4l-vault-door{ position:absolute; inset:0; transform-origin:left center; backface-visibility:hidden; animation:v4l-door 11s ease-in-out infinite; animation-delay:-5.5s; }
.v4l-vault-door svg{ width:100%; height:100%; display:block; }
@keyframes v4l-door{ 0%,5%{transform:rotateY(0deg)} 9%,17%{transform:rotateY(-118deg)} 22%,100%{transform:rotateY(0deg)} }
@keyframes v4l-peek{ 0%,7%{transform:translateX(-50%) translateY(12px);opacity:0} 10%,16%{transform:translateX(-50%) translateY(-1px);opacity:1} 21%,100%{transform:translateX(-50%) translateY(12px);opacity:0} }
@media (max-width: 820px){ .v4l-scene{ transform:scale(.78) } }
@media (max-width: 560px){ .v4l-scene{ transform:scale(.56) } }
@media (max-width: 400px){ .v4l-scene{ transform:scale(.46) } }
@media (prefers-reduced-motion: reduce){
  .v4l-scene::before,.v4l-planet,.v4l-moon,.v4l-vault,.v4l-peeker,.v4l-vault-door,.v4l-measure .m{ animation:none }
  .v4l-moon{ transform:translate(-300px,24px) scale(0.95) } .v4l-vault{ transform:translate(120px,0) scale(0.6) }
}


/* V4UL7 · AQ13R wordmark (Bone-Glyphen + Magenta-Punkt #FF2D94) */
.brand-logo { display: inline-flex; align-items: center; padding: 0; line-height: 0; }
.brand-logo img { display: block; height: 26px; width: auto; }
.brand-logo:hover img { opacity: 0.85; }
.brand-logo-login { margin: 0 0 14px; }
.brand-logo-login img { height: 42px; }
@media (max-width: 600px) {
  .brand-logo img { height: 22px; }
  .brand-logo-login img { height: 36px; }
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; color: var(--text); }
.topbar #search { flex: 1; max-width: 520px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; color: var(--text); font: inherit; }
.topbar #search:focus { outline: 1px solid var(--accent-2); border-color: var(--accent-2); }
.zoom-control { display: flex; align-items: center; gap: 6px; padding: 4px 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.zoom-control .zoom-icon { color: var(--muted); font-size: 12px; }
.zoom-control input[type="range"] { width: 100px; cursor: pointer; accent-color: var(--accent-2); }
@media (max-width: 800px) { .zoom-control { display: none; } }

/* Bulk-download individual list */
.bulk-dl-list {
  margin-top: 14px; max-height: 280px; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px; display: flex; flex-direction: column; gap: 6px;
}
.bulk-dl-row { display: flex; align-items: center; gap: 8px; font-size: 12px; cursor: pointer; }
.bulk-dl-row input { accent-color: var(--acid); }
.bulk-dl-list .btn { margin-top: 10px; align-self: flex-end; }
.meta { color: var(--muted); font-size: 13px; margin-left: auto; display: flex; align-items: center; gap: 12px; }
.meta-link { color: var(--muted); border: 1px solid var(--border); padding: 4px 10px; border-radius: 4px; }
.meta-link:hover { color: var(--text); border-color: var(--accent-2); }
.back-btn {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  padding: 5px 12px; border-radius: 4px; cursor: pointer;
  font: inherit; font-size: 13px;
  transition: border-color 0.12s, background 0.12s;
}
.back-btn:hover { border-color: var(--accent-2); background: var(--bg); }
.back-btn:active { transform: translateY(1px); }
.back-btn:disabled { opacity: 0.4; cursor: not-allowed; }
a.brand { cursor: pointer; }

/* Rating widget (5 stars + clear) */
.rating-widget { display: inline-flex; align-items: center; gap: 2px; margin: 6px 0 12px; }
.rating-widget .star {
  background: transparent; border: none; cursor: pointer;
  font-size: 22px; color: var(--border); padding: 2px 4px;
  transition: color 0.08s, transform 0.08s;
}
.rating-widget .star:hover { transform: scale(1.1); }
/* Saved state: stars 1..N (with .filled) are acid */
.rating-widget .star.filled { color: var(--acid); }
/* Hover preview: hovered star + all preceding stars light up acid */
.rating-widget .star:hover,
.rating-widget .star:has(~ .star:hover) { color: var(--acid); }
/* While hovering: dim filled stars that come AFTER the hovered one (preview lower rating) */
.rating-widget:has(.star:hover) .star.filled:not(:hover):not(:has(~ .star:hover)) {
  color: var(--border);
}
.rating-widget .star-clear {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 12px; padding: 4px 6px; margin-left: 8px;
}
.rating-widget .star-clear:hover { color: var(--err); }
.meta-link-dashboard {
  color: #dff7ff;
  border-color: rgba(61, 224, 255, 0.55);
  background: rgba(61, 224, 255, 0.10);
  font-weight: 650;
}
.meta-link-dashboard:hover {
  color: #fff;
  border-color: #3de0ff;
  box-shadow: 0 0 0 1px rgba(61, 224, 255, 0.55);
}
.meta-link-cta {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border-color: transparent; color: #fff; font-weight: 600;
}
.meta-link-cta:hover { color: #fff; border-color: var(--acid); box-shadow: 0 0 0 1px var(--acid); }
.upload-btn { cursor: pointer; padding: 6px 12px; background: var(--accent-2); color:#fff; border-radius: 4px; font-weight: 600; font-size: 13px; }
.upload-btn:hover { background: var(--accent); }
.user-menu { position: relative; }
.user-menu summary { cursor: pointer; padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px; list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu[open] summary { color: var(--text); border-color: var(--accent-2); }
.user-menu-body { position: absolute; right: 0; top: 100%; margin-top: 6px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; min-width: 200px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }

.layout { display: grid; grid-template-columns: 240px 1fr; flex: 1; min-height: 0; overflow: hidden; }
.sidebar { background: var(--bg-elev); border-right: 1px solid var(--border); padding: 16px; overflow-y: auto; height: 100%; }
.sidebar h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 18px 0 6px; }
.sidebar h3:first-child { margin-top: 0; }
.facet-item { display: flex; justify-content: space-between; gap: 8px; padding: 3px 6px; border-radius: 4px; cursor: pointer; color: var(--text); font-size: 13px; }
.facet-item:hover { background: var(--bg-card); }
.facet-item.active { background: var(--accent); color: #fff; }
.facet-item.active .count { color: rgba(255,255,255,0.8); }
.facet-item .count { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ============== MOBILE LAYOUT (Phase E, <768px) ============== */
.mobile-toolbar { display: none; }
.mobile-filter-fab { display: none; }
.mobile-filter-sheet { display: none; }

@media (max-width: 767px) {
  /* Hide desktop chrome that doesn't fit on mobile */
  .zoom-control { display: none; }
  .meta-link, .upload-btn, .user-menu { font-size: 12px; }
  .meta-link-cta { padding: 4px 8px; font-size: 11px; }

  /* Sidebar becomes a left-sliding sheet (hidden by default) */
  .layout { display: block; }
  .dock-column {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(85vw, 340px); max-width: 100%;
    background: var(--bg-elev); border-right: 1px solid var(--border);
    z-index: 300; overflow-y: auto; padding: 12px;
    transform: translateX(-105%); transition: transform 0.25s ease-out;
    box-shadow: 4px 0 24px rgba(0,0,0,0.6);
  }
  body.mobile-sheet-open .dock-column { transform: translateX(0); }
  body.mobile-sheet-open::before {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 290;
  }

  /* Mobile toolbar (sort buttons) — sticky under topbar */
  .mobile-toolbar {
    display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto;
    background: var(--bg-elev); border-bottom: 1px solid var(--border);
    position: sticky; top: 49px; z-index: 40; scrollbar-width: none;
  }
  .mobile-toolbar::-webkit-scrollbar { display: none; }
  .mob-sort-btn {
    flex-shrink: 0; padding: 6px 12px; border-radius: 999px;
    background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
    font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap;
  }
  .mob-sort-btn:hover { border-color: var(--accent-2); }
  .mob-sort-btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

  /* Floating Filter button bottom-right */
  .mobile-filter-fab {
    display: flex; align-items: center; justify-content: center;
    position: fixed; bottom: 20px; right: 20px; z-index: 250;
    width: 56px; height: 56px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    color: #fff; border: none; font-size: 22px; cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  }
  .mobile-filter-fab:active { transform: scale(0.95); }
  body.mobile-sheet-open .mobile-filter-fab { display: none; }

  /* De-clutter the topbar on phones: drop secondary chrome, keep the essentials
     (brand · search · count · upload · account). Filters live behind the ⚙ FAB. */
  #doc-toggle { display: none; }
  .meta-link { display: none; }     /* AutoEdit-CTA + ops/admin = desktop only */

  /* Grid → clean uniform 2-column overview. The old full-screen snap-cards
     destroyed the overview (one item filled the whole screen). */
  .grid-wrap { padding: 8px; scroll-snap-type: none; }
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .card {
    scroll-snap-align: none;
    border-radius: 10px; border: 1px solid var(--border);
    min-height: 0;
    display: flex; flex-direction: column; overflow: hidden;
  }
  .card .thumb-wrap {
    aspect-ratio: 1 / 1; flex: none; min-height: 0;
    background: #000;
  }
  .card .thumb-wrap img { object-fit: cover; }
  .card .meta-row { padding: 6px 8px; font-size: 11px; }
  .card .badge { font-size: 10px; padding: 2px 7px; }

  /* On mobile asset detail, stack media on top, meta below.
     Only .detail-meta scrolls; the page itself remains locked. */
  .detail { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: hidden; }
  .detail-media { height: 50vh; max-height: 50vh; flex-shrink: 0; }
  .detail-meta { border-left: none; border-top: 1px solid var(--border); height: auto; min-height: 0; }
  .detail-media img, .detail-media video { max-height: calc(50vh - 24px); }
}

/* Rating filter (sub-section in Organisation panel) */
.rating-filter { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.rating-filter-btn {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font: inherit; font-size: 13px;
  cursor: pointer; transition: background 0.1s, border-color 0.1s;
}
.rating-filter-btn:hover { background: var(--bg); border-color: var(--accent-2); }
.rating-filter-btn.is-active { background: var(--acid); color: #0c0c0e; border-color: var(--acid); font-weight: 600; }
.rating-filter-btn.is-active .muted { color: rgba(0,0,0,0.55); }
.rating-filter-btn .cnt { font-variant-numeric: tabular-nums; color: var(--muted); }
.rating-filter-btn.is-active .cnt { color: rgba(0,0,0,0.75); }

/* Collapsible tree (Phase C — Channels panel) */
.tree, .tree-children { list-style: none; padding: 0; margin: 0; }
.tree-children { padding-left: 12px; border-left: 1px dashed var(--border); margin-left: 6px; }
.tree-node { font-size: 13px; }
.tree-row {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 6px; border-radius: 4px;
  cursor: pointer; color: var(--text);
  transition: background 0.1s;
}
.tree-row:hover { background: var(--bg-card); }
.tree-row.is-active { background: var(--accent); color: #fff; }
.tree-row.is-active .tree-count { color: rgba(255,255,255,0.85); }
.tree-toggle { width: 14px; text-align: center; color: var(--muted); font-size: 11px; user-select: none; }
.tree-toggle:hover { color: var(--text); }
.tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; }
.tree-node.level-0 > .tree-row { font-weight: 600; }
.tree-node.level-1 > .tree-row { font-size: 12px; }

/* Production hierarchy tree (Film › Akt › Szene › Shot, music-video trees) */
.prod-tree, .prod-children { list-style: none; margin: 0; padding: 0; }
.prod-children { padding-left: 12px; border-left: 1px solid var(--border); margin-left: 7px; }
.prod-children.collapsed { display: none; }
.prod-item { font-size: 13px; }
.prod-row {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 6px; border-radius: 4px; cursor: pointer; color: var(--text);
  transition: background 0.1s;
}
.prod-row:hover { background: var(--bg-card); }
.prod-row.is-project { font-weight: 700; letter-spacing: 0.01em; }
.prod-toggle { width: 13px; text-align: center; color: var(--muted); font-size: 10px; user-select: none; flex: none; }
.prod-row .prod-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod-count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; flex: none; }
.prod-leaf {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 6px 3px 17px; border-radius: 4px;
  color: var(--muted); text-decoration: none; font-size: 12px;
  transition: background 0.1s, color 0.1s;
}
.prod-leaf:hover { background: var(--bg-card); color: var(--text); }
.prod-leaf .prod-ico { flex: none; font-size: 11px; opacity: 0.85; }
.prod-leaf .prod-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod-row.is-selected { background: var(--accent); color: #fff; }
.prod-row.is-selected .prod-count { color: rgba(255,255,255,0.85); }
.prod-row.is-selected .prod-toggle { color: rgba(255,255,255,0.8); }

/* Active-selection chip above the grid (a Production node scopes the gallery) */
.selection-chip {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px; padding: 8px 12px;
  background: var(--bg-card); border: 1px solid var(--accent);
  border-radius: 8px; font-size: 13px;
}
.selection-chip .sel-ico { color: var(--accent-2); flex: none; }
.selection-chip .sel-label { font-weight: 600; color: var(--text); }
.selection-chip .sel-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.selection-chip .sel-clear {
  margin-left: auto; padding: 3px 10px; cursor: pointer;
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); font: inherit;
}
.selection-chip .sel-clear:hover { border-color: var(--accent); color: var(--text); }
.tree-node.level-2 > .tree-row { font-size: 11px; color: var(--muted); }
.tree-node.level-2 > .tree-row:hover { color: var(--text); }

/* ============== Quick-Rate stars on cards (hover) ============== */
.card .quick-rate {
  position: absolute; bottom: 32px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 2px;
  padding: 4px 6px;
  background: linear-gradient(0deg, rgba(0,0,0,0.78), rgba(0,0,0,0));
  opacity: 0; pointer-events: none;
  transition: opacity 0.12s;
  z-index: 5;
}
.card:hover .quick-rate, .card:focus-within .quick-rate { opacity: 1; pointer-events: auto; }
.card .quick-star {
  background: transparent; border: none; cursor: pointer;
  font-size: 16px; color: rgba(255,255,255,0.45); padding: 1px 3px;
  transition: color 0.08s, transform 0.06s;
}
.card .quick-star:hover { color: var(--acid); transform: scale(1.15); }
.card .quick-star.filled { color: var(--acid); }
.card:focus { outline: 2px solid var(--accent-2); outline-offset: -2px; }

/* ============== Recently viewed dropdown ============== */
.user-menu-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; }
.user-menu-toggle input { accent-color: var(--acid); }
.recent-views { margin: 4px 0; }
.recent-views summary { font-size: 12px; padding: 4px 0; cursor: pointer; list-style: none; }
.recent-views summary::-webkit-details-marker { display: none; }
.recent-views summary::before { content: "▸ "; color: var(--muted); transition: transform 0.1s; display: inline-block; }
.recent-views[open] summary::before { transform: rotate(90deg); }
.recent-views-list { display: flex; flex-direction: column; gap: 4px; padding: 4px 0; max-height: 280px; overflow-y: auto; }
.recent-view-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px; border-radius: 4px; text-decoration: none; color: var(--text);
  font-size: 11px;
}
.recent-view-row:hover { background: var(--bg-card); color: var(--accent-2); }
.recent-view-row img { width: 32px; height: 24px; object-fit: cover; border-radius: 2px; flex-shrink: 0; }
.recent-view-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============== Bulk-Tag modal ============== */
.bulk-tag-catalog { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; padding-right: 6px; margin: 14px 0; }
.bulk-tag-group h4 { font-size: 10px; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; letter-spacing: 0.05em; }

/* Tag-Groups: size-scaled buttons, multi-select */
.tag-group { margin-bottom: 18px; }
.tag-group h3 { margin: 0 0 8px; }
.tag-buttons { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); font: inherit;
  cursor: pointer; line-height: 1.2;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.tag-btn:hover { background: var(--bg); border-color: var(--accent-2); }
.tag-btn:active { transform: translateY(1px); }
.tag-btn .cnt { color: var(--muted); font-variant-numeric: tabular-nums; }
.tag-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tag-btn.active .cnt { color: rgba(255,255,255,0.85); }
/* Size buckets (xl/l/m/s) — driven by count proportion in current view */
.tag-btn.tag-xl { font-size: 15px; padding: 6px 12px; font-weight: 600; }
.tag-btn.tag-l  { font-size: 13px; padding: 4px 10px; font-weight: 500; }
.tag-btn.tag-m  { font-size: 11px; padding: 3px 8px; }
.tag-btn.tag-s  { font-size: 10px; padding: 2px 7px; opacity: 0.85; }

.grid-wrap { padding: 16px; height: 100%; overflow-y: auto; }
.grid { display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-min-card, 220px), 1fr));
  gap: 12px;
}
/* Min 2 columns clamp — when --grid-min-card is so big we'd fit <2 cols,
   force a 2-column layout instead of going to single-column. */
@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(var(--grid-min-card, 220px), 45%), 1fr)); }
}
.grid.drag-over { outline: 2px dashed var(--accent-2); outline-offset: -4px; }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; transition: transform 0.15s, border-color 0.15s; position: relative; }
.card:hover { transform: translateY(-2px); border-color: var(--accent-2); }
.card .thumb-wrap { width: 100%; aspect-ratio: 1 / 1; background: #0a0a0c; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.card .thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
/* media-type badge shifted right so the always-visible approval control owns the top-left corner */
.card .badge { position: absolute; top: 6px; left: 74px; background: rgba(0,0,0,0.75); color: var(--text); padding: 2px 6px; border-radius: 3px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.card .badge.video { background: rgba(176,107,255,0.9); color:#fff; }
.card .badge.audio { background: rgba(196,255,58,0.9); color:#0c0c0e; }

/* Always-visible approval status control (top-left). Active state is bright + filled;
   the other two stay faint until you hover the card, then all three are clickable. */
.card .card-approval { position: absolute; top: 6px; left: 6px; z-index: 6; display: flex; gap: 3px; }
.card .card-approval .appr-btn {
  width: 19px; height: 19px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1; cursor: pointer;
  background: rgba(0,0,0,0.5); border: 1.5px solid rgba(255,255,255,0.4); color: #fff;
  opacity: 0.3; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  transition: opacity 0.1s, transform 0.06s;
}
.card:hover .card-approval .appr-btn, .card:focus-within .card-approval .appr-btn { opacity: 0.85; }
.card .card-approval .appr-btn:hover { opacity: 1; transform: scale(1.15); }
.card .card-approval.busy { opacity: 0.5; pointer-events: none; }
/* active state — always fully visible + colored */
.card .card-approval[data-approval="approved"] .is-approve { opacity: 1; background: #2fbf71; border-color: #2fbf71; color: #04220f; }
.card .card-approval[data-approval="declined"] .is-decline { opacity: 1; background: #ff5470; border-color: #ff5470; color: #2a0009; }
.card .card-approval[data-approval="open"] .is-open { opacity: 1; background: transparent; border-color: #ffcf40; color: #ffcf40; }
/* per-button hover hint colors */
.card .card-approval .is-approve:hover { border-color: #2fbf71; color: #2fbf71; }
.card .card-approval .is-decline:hover { border-color: #ff5470; color: #ff5470; }
.card .card-approval .is-open:hover { border-color: #ffcf40; color: #ffcf40; }
.card .meta-row { padding: 6px 8px; display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); gap: 6px; }
.card .meta-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.card.selected { outline: 3px solid var(--acid); outline-offset: -3px; }
.card .select-marker { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; background: rgba(0,0,0,0.6); border: 1px solid var(--border); border-radius: 50%; display: none; align-items: center; justify-content: center; color: var(--acid); font-weight: 700; font-size: 12px; }
.card.selected .select-marker { display: flex; background: var(--acid); color: #0c0c0e; border-color: var(--acid); }

/* AI-janitor review marker — bottom-right of the thumbnail (above the meta rows) */
.card .card-bot {
  position: absolute; right: 6px; bottom: 52px; z-index: 4;
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
}
.card .card-bot svg { display: block; }
.card .card-bot.is-checked { color: #2fbf71; }                                  /* geprüft */
.card .card-bot.is-checked { box-shadow: 0 0 0 1px rgba(47,191,113,0.5), 0 0 6px rgba(47,191,113,0.35); }
.card .card-bot.is-open { color: #ffa53a; }                                     /* offen */

/* AI-janitor change documentation (asset detail) */
.bot-review { border: 1px solid var(--border); border-left: 3px solid #2fbf71; border-radius: 6px; padding: 8px 10px; margin: 4px 0 8px; background: var(--bg-card); }
.bot-review-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; color: var(--muted); }
.bot-review .bot-chip { display: inline-block; padding: 1px 7px; border-radius: 10px; background: rgba(47,191,113,0.16); color: #7ee6ab; border: 1px solid rgba(47,191,113,0.35); font-size: 11px; }
.bot-review .bot-note { margin-top: 6px; font-size: 12px; color: var(--text); font-style: italic; opacity: 0.9; }
.load-more { display: block; margin: 24px auto; padding: 10px 24px; background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font: inherit; }
.load-more:hover { border-color: var(--accent-2); }

.upload-progress { padding: 10px 14px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.upload-progress.ok { border-color: var(--ok); color: var(--ok); }
.upload-progress.err { border-color: var(--err); color: var(--err); }

/* grid-template-rows: minmax(0,1fr) is the key fix:
   without it, the row height is "auto" (determined by content),
   so max-height:100% on the child video has no real number to reference → ignored.
   With it, the row fills the remaining flex space and the video can constrain itself. */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: minmax(0, 1fr); gap: 0; flex: 1; min-height: 0; overflow: hidden; }
/* detail-media: grid child stretches by default (align-items:stretch), min-height:0 prevents overflow */
.detail-media { background: #050507; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: hidden; min-height: 0; position: relative; }
/* Default: always show the full media (contain). Zoom via JS transform.
   max:100% (not calc(100% - 40px)) — the 20px container padding already insets the
   media; the extra -40px was double-padding that shrank the visible frame. */
.detail-media img, .detail-media video {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.12s ease;
  cursor: default;
  user-select: none;
}
.detail-media.is-zoomed img,
.detail-media.is-zoomed video { cursor: grab; }
.detail-media.is-zoomed.is-dragging img,
.detail-media.is-zoomed.is-dragging video { cursor: grabbing; transition: none; }
/* Zoom badge — bottom-left corner */
.zoom-badge {
  position: absolute; bottom: 10px; left: 12px;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 11px;
  padding: 3px 8px; border-radius: 4px; pointer-events: none;
  opacity: 0; transition: opacity 0.3s; backdrop-filter: blur(4px);
  font-family: "JetBrains Mono", monospace;
}
.zoom-badge.visible { opacity: 1; }
.detail-meta { padding: 20px 24px; border-left: 1px solid var(--border); background: var(--bg-elev); overflow-y: auto; height: 100%; }
.detail-meta h1 { font-size: 16px; margin: 0 0 16px; word-break: break-all; }
.detail-meta h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 18px 0 6px; }
.detail-meta dl { display: grid; grid-template-columns: 100px 1fr; gap: 4px 12px; font-size: 13px; margin: 0; }
.detail-meta dt { color: var(--muted); }
.detail-meta dd { margin: 0; word-break: break-word; }
.detail-meta dd.path { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--muted); }
.prompt { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--border); padding: 10px; border-radius: 6px; font-size: 12px; max-height: 240px; overflow-y: auto; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.tag { background: var(--bg-card); color: var(--muted); padding: 3px 8px; border-radius: 12px; font-size: 11px; border: 1px solid var(--border); }
.actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.btn { background: var(--accent); color: #fff; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; font: inherit; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--accent-2); }
.btn.danger { background: transparent; color: var(--err); border: 1px solid var(--err); }
.btn.danger:hover { background: var(--err); color: #fff; }

.compare-grid { display: grid; gap: 12px; padding: 12px; min-height: calc(100vh - 49px); }
.compare-cols-1 { grid-template-columns: 1fr; }
.compare-cols-2 { grid-template-columns: 1fr 1fr; }
.compare-cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.compare-cols-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.compare-cols-5, .compare-cols-6 { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr; }
.compare-cell { margin: 0; display: flex; flex-direction: column; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; min-height: 0; }
.compare-media { flex: 1; background: #050507; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 8px; }
.compare-media img, .compare-media video { max-width: 100%; max-height: 100%; object-fit: contain; }
.compare-cell figcaption { padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12px; }
.cell-name { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-name a { color: var(--text); }
.cell-letter { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-weight: 700; border-radius: 4px; font-size: 12px; }
.cell-meta { color: var(--muted); font-size: 11px; display: flex; gap: 4px; flex-wrap: wrap; }
.cell-prompt summary { cursor: pointer; color: var(--muted); margin-top: 6px; font-size: 11px; }
.cell-prompt pre { background: var(--bg); padding: 8px; border-radius: 4px; margin: 4px 0 0; font-size: 11px; max-height: 100px; overflow-y: auto; white-space: pre-wrap; }
.compare-bar { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bg-elev); border: 1px solid var(--accent-2); border-radius: 32px; padding: 10px 18px; display: none; align-items: center; gap: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.5); z-index: 100; }
.compare-bar.show { display: flex; }
.compare-bar .count { background: var(--accent); color: #fff; padding: 2px 10px; border-radius: 12px; font-weight: 700; }
.compare-bar button { background: var(--accent-2); border: none; color: #fff; padding: 6px 14px; border-radius: 16px; cursor: pointer; font: inherit; font-weight: 600; }
.compare-bar button:hover:not(:disabled) { background: var(--accent); }
.compare-bar button:disabled { opacity: 0.35; cursor: not-allowed; filter: grayscale(0.4); }
.compare-bar button.ghost { background: transparent; color: var(--muted); font-weight: 400; }
.compare-bar button.ghost:hover { color: var(--text); }
.compare-bar button.ba-approve { background: var(--ok); color: #06210f; }
.compare-bar button.ba-approve:hover:not(:disabled) { background: #3ec26a; }
.compare-bar button.ba-decline { background: var(--err); color: #2a0606; }
.compare-bar button.ba-decline:hover:not(:disabled) { background: #ff6161; }

.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 100%; max-width: 420px; }
.auth-card-wide { max-width: 780px; }
.auth-card h1 { font-size: 22px; margin: 0 0 8px; }
.auth-card > p { color: var(--muted); margin: 0 0 24px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.auth-field span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.auth-field input { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; color: var(--text); font: inherit; }
.auth-field input:focus { outline: 1px solid var(--accent-2); border-color: var(--accent-2); }
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 10px 18px; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 600; width: 100%; }
.btn-primary:hover { background: var(--accent-2); }
.btn-link { background: transparent; border: none; color: var(--accent-2); cursor: pointer; font: inherit; padding: 6px 0; text-decoration: none; }
.btn-link:hover { color: var(--accent); }
.factor-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.factor-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; color: var(--text); cursor: pointer; font: inherit; text-align: left; }
.factor-btn:hover { border-color: var(--accent-2); }
.auth-msg { padding: 10px 12px; border-radius: 6px; margin-top: 16px; background: var(--bg-card); border: 1px solid var(--border); font-size: 13px; }
.auth-msg.ok { border-color: var(--ok); color: var(--ok); }
.auth-msg.err { border-color: var(--err); color: var(--err); }
#email-summary { margin-bottom: 16px; }
.expired-icon { font-size: 42px; margin-bottom: 12px; opacity: 0.7; text-align: center; }
.auth-card-divider { height: 1px; background: var(--border); margin: 18px 0; }

.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 24px 0; }
.setup-method { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.setup-method h2 { font-size: 16px; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.badge-ok { background: var(--ok); color: #0c0c0e; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.setup-method p { color: var(--muted); margin: 0 0 12px; }
.setup-actions { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding-top: 16px; border-top: 1px solid var(--border); }
.setup-actions .btn-primary { width: auto; }
#totp-qr { display: block; margin: 12px 0; width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 6px; }
.totp-secret { font-size: 11px; color: var(--muted); margin: 8px 0 12px; word-break: break-all; }
.totp-secret code { background: var(--bg); padding: 2px 6px; border-radius: 3px; user-select: all; }
.passkey-hint { margin-top: 10px; font-size: 12px; color: var(--muted); }
.passkey-hint summary { cursor: pointer; padding: 4px 0; }
.passkey-hint summary:hover { color: var(--text); }
.passkey-hint ul { padding-left: 18px; margin: 6px 0; }
.passkey-hint li { margin-bottom: 4px; }
@media (max-width: 700px) { .setup-grid { grid-template-columns: 1fr; } }

.modal-shell { position: fixed; inset: 0; background: rgba(0,0,0,0.8); align-items: center; justify-content: center; padding: 24px; z-index: 200; display: none; }
.modal-shell:not([hidden]) { display: flex; }
.modal { background: var(--bg-elev); border: 2px solid var(--err); border-radius: 10px; padding: 28px; max-width: 480px; width: 100%; }
.modal h2 { margin: 0 0 12px; color: var(--err); }
.modal p { margin: 0 0 12px; }
.modal.info-modal { border-color: var(--accent-2); }
.modal.info-modal h2 { color: var(--accent-2); }
.modal.info-modal h3 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.modal.info-modal ul, .modal.info-modal ol { padding-left: 20px; margin: 0 0 12px; }
.modal.info-modal li { margin-bottom: 4px; }
.modal.info-modal a { color: var(--accent-2); }
.twofa-hint { margin-top: 18px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font-size: 12px; color: var(--muted); line-height: 1.5; }
.twofa-hint a { color: var(--accent-2); margin-left: 4px; }
.modal code { background: var(--bg); padding: 2px 6px; border-radius: 3px; user-select: all; }
.confirm-input { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; }
.confirm-input span { color: var(--muted); font-size: 12px; }
.confirm-input input { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; color: var(--text); font: inherit; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 12px; }

.admin-shell { padding: 24px; display: grid; gap: 32px; max-width: 1200px; margin: 0 auto; }
.admin-shell h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 12px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { color: var(--muted); text-align: left; padding: 8px 10px; font-weight: 600; font-size: 11px; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.admin-table tr:hover td { background: var(--bg-card); }
.admin-table code { font-size: 12px; }
.audit-table small { color: var(--muted); }
.invite-form { display: grid; grid-template-columns: 1.5fr 1.5fr 1fr 0.6fr auto; gap: 8px; align-items: stretch; }
.invite-form input, .invite-form select { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; color: var(--text); font: inherit; }
.invite-form button { width: auto; padding: 8px 16px; }
@media (max-width: 800px) { .invite-form { grid-template-columns: 1fr; } }

/* ----- Mission Control ----- */
.operator-shell { padding: 20px; display: flex; flex-direction: column; gap: 24px; max-width: 1400px; margin: 0 auto; }
.op-section { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 18px 22px; }
.op-section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 12px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.op-section.op-row { background: transparent; border: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.op-section.op-row .op-col { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 18px 22px; }
.op-section.op-kpis { background: transparent; border: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; }
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.pulse-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: middle; }
.pulse-dot.ok { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2s infinite; }
.pulse-dot.err { background: var(--err); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); } 70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }

.op-list { display: flex; flex-direction: column; gap: 4px; }
.op-row-item { display: grid; grid-template-columns: auto 1fr 2fr auto; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; font-size: 12px; text-decoration: none; color: var(--text); }
.op-row-item:hover { border-color: var(--accent-2); }
.op-row-item.warn { border-color: var(--err); }
.op-row-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.op-row-item .meta { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-row-item .age { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; min-width: 50px; text-align: right; }
.op-row-item .badge { font-size: 10px; padding: 2px 6px; border-radius: 3px; background: rgba(0,0,0,0.5); }
.op-row-item .badge.audit { background: var(--bg); color: var(--accent-2); }

.op-bars { display: flex; flex-direction: column; gap: 6px; }
.op-bar { display: grid; grid-template-columns: 140px 1fr 60px; align-items: center; gap: 10px; font-size: 12px; }
.op-bar-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-bar-label small { color: var(--muted); }
.op-bar-track { height: 16px; background: var(--bg); border-radius: 3px; overflow: hidden; border: 1px solid var(--border); }
.op-bar-fill { height: 100%; background: var(--accent); transition: width 0.3s; }
.op-bar-fill.alt { background: var(--accent-2); }
.op-bar-value { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 11px; }

.op-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.op-table th { color: var(--muted); text-align: left; padding: 8px 10px; font-weight: 600; font-size: 11px; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.op-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.op-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { color: var(--muted); padding: 16px 10px; text-align: center; font-style: italic; }

@media (max-width: 900px) {
  .op-section.op-row { grid-template-columns: 1fr; }
  .op-row-item { grid-template-columns: 1fr; gap: 4px; }
  .op-bar { grid-template-columns: 100px 1fr 50px; }
}

/* ===================================================================
   MOBILE OPTIMIZATION (< 768px) — finger-friendly, single-column
   =================================================================== */

@media (max-width: 768px) {

  /* Topbar — wraps, search full-width on second row */
  .topbar {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 8px;
  }
  .topbar #search {
    order: 100;          /* push to second row */
    flex-basis: 100%;
    max-width: 100%;
  }
  .meta { gap: 8px; font-size: 12px; }
  .meta-link { padding: 6px 10px; min-height: 36px; display: inline-flex; align-items: center; }
  .upload-btn { padding: 8px 12px; min-height: 36px; }

  /* User-menu — keeps dropdown but adjusts position */
  .user-menu-body { right: 0; left: auto; min-width: 200px; max-width: 90vw; }

  /* NOTE: gallery grid + sidebar layout are owned by the (max-width:767px)
     block above — the TikTok-snap / multi-column rules that used to live here
     conflicted with it (140px-wide × 100vh-tall cards). Removed on purpose. */
  .facet-item { padding: 6px 8px; min-height: 36px; align-items: center; }

  /* Detail view — fully stacked, no fixed-width sidebar */
  .detail { grid-template-columns: 1fr; }
  .detail-media { padding: 12px; min-height: 240px; height: 60vh; }
  .detail-media img, .detail-media video { max-height: calc(60vh - 24px); }
  .detail-meta {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: none;
    padding: 16px;
  }
  .detail-meta dl { grid-template-columns: 90px 1fr; gap: 4px 10px; }
  .actions { gap: 10px; }
  .btn { padding: 10px 16px; min-height: 44px; font-size: 14px; }
  .copy-url, .btn.danger { min-height: 44px; }

  /* Compare bar — full-width bottom strip on mobile */
  .compare-bar {
    bottom: 12px; left: 12px; right: 12px;
    transform: none;
    border-radius: 12px;
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .compare-bar button { padding: 10px 14px; min-height: 40px; }

  /* Compare grid — already 1fr on mobile via existing rule */

  /* Modal — fits viewport */
  .modal { padding: 20px; }
  .modal h2 { font-size: 16px; }

  /* Auth/login pages — full-width card */
  .auth-shell { padding: 12px; }
  .auth-card { padding: 22px 18px; }
  .auth-card h1 { font-size: 19px; }
  .auth-field input { padding: 12px 14px; min-height: 44px; font-size: 16px; /* prevent iOS-zoom */ }
  .factor-btn { padding: 16px; min-height: 64px; }
  .btn-primary { padding: 14px 18px; min-height: 48px; font-size: 15px; }
  #totp-qr { width: 180px; height: 180px; }

  /* Setup grid */
  .setup-grid { grid-template-columns: 1fr; gap: 14px; }
  .setup-method { padding: 16px; }
  .setup-actions { flex-direction: column; align-items: stretch; gap: 8px; }
  .setup-actions .btn-primary { width: 100%; }

  /* Admin tables — horizontal scroll, smaller font */
  .admin-shell { padding: 12px; gap: 22px; }
  .admin-table { font-size: 12px; display: block; overflow-x: auto; white-space: nowrap; }
  .admin-table th, .admin-table td { padding: 8px 6px; }
  .invite-form { grid-template-columns: 1fr; gap: 8px; }
  .invite-form input, .invite-form select { padding: 12px 14px; min-height: 44px; font-size: 16px; }

  /* Operator (Mission Control) */
  .operator-shell { padding: 12px; gap: 16px; }
  .op-section { padding: 14px 16px; }
  .op-section.op-row .op-col { padding: 14px 16px; }
  .op-section.op-kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 12px 14px; }
  .kpi-label { font-size: 10px; }
  .kpi-value { font-size: 18px; }

  .op-row-item {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px;
    min-height: 56px;
  }
  .op-row-item .age { text-align: left; min-width: 0; }

  .op-bar { grid-template-columns: 80px 1fr 40px; gap: 6px; font-size: 11px; }
  .op-bar-label small { display: none; }

  .op-table { font-size: 11px; }
  .op-table th, .op-table td { padding: 6px 8px; }
}

/* Very small viewports (iPhone SE etc.) */
@media (max-width: 380px) {
  .op-section.op-kpis { grid-template-columns: 1fr; }
  /* keep 2 clean columns even on the smallest phones (3+ would be too tiny) */
  .grid { grid-template-columns: repeat(2, 1fr); }
  .upload-btn { padding: 6px 8px; font-size: 12px; }
}

/* Prevent iOS double-tap-zoom inflation of buttons + good touch defaults */
button, .btn, .btn-primary, .btn-link, .meta-link, .upload-btn, .factor-btn, .facet-item, .card, .op-row-item, summary {
  touch-action: manipulation;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .detail { grid-template-columns: 1fr; }
  .detail-meta { border-left: none; border-top: 1px solid var(--border); max-height: none; }
  .compare-grid, .compare-cols-2, .compare-cols-3, .compare-cols-4, .compare-cols-5, .compare-cols-6 { grid-template-columns: 1fr; grid-template-rows: none; }
}

/* ======================================================================
   PANELS + DOCK COLUMN (v3 layout)
   ====================================================================== */

/* override the old .layout grid: column auto-shrinks when fullscreen mode */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 14px;
  padding: 14px;
  align-items: start;
}
body.all-undocked .layout { grid-template-columns: 1fr; padding: 14px; }
body.all-undocked .grid-wrap { padding: 0; }

.dock-column {
  display: flex; flex-direction: column; gap: 12px;
  height: 100%;          /* fills .layout grid-cell, page itself doesn't scroll */
  overflow-y: auto;
  padding: 12px 4px 12px 12px;
}
.dock-column::-webkit-scrollbar { width: 8px; }
.dock-column::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.panel--floating {
  position: fixed;
  width: 300px;
  max-height: 70vh;
  z-index: 60;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--accent-2);
}
.panel--dragging { user-select: none; cursor: grabbing; opacity: 0.95; }

.panel-head {
  display: flex; align-items: center;
  padding: 6px 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.panel-title {
  flex: 1;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}
.panel-dock,
.panel-move {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 6px;
  line-height: 1;
}
.panel-dock:hover, .panel-move:hover { background: var(--bg); color: var(--text); }
.panel--floating .panel-move { cursor: grab; }
.panel--floating .panel-move:active { cursor: grabbing; }
/* Dock arrow flip: docked → ⬑, floating → ⬎ */
.panel--floating .panel-dock::before { content: "⬎"; }
.panel:not(.panel--floating) .panel-dock { color: var(--muted); }
.panel:not(.panel--floating) .panel-dock::before { content: "⬑"; }
.panel-dock { font-size: 0; }
.panel-dock::before { font-size: 14px; }

.panel-body {
  padding: 12px 14px;
  overflow-y: auto;
  max-height: 60vh;
}

.sub-section { margin-bottom: 14px; }
.sub-section:last-child { margin-bottom: 0; }
.sub-section h4 {
  margin: 0 0 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}
.panel-empty { font-size: 11px; color: var(--muted); font-style: italic; }

/* ====== Bubble cloud ====== */
.bubble-cloud {
  display: flex; flex-wrap: wrap;
  gap: 6px 5px;
  align-items: center;
}
.bubble-cloud--compact { gap: 4px; }

.bubble {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  line-height: 1.2;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.bubble:hover { background: var(--bg); border-color: var(--accent-2); }
.bubble:active { transform: translateY(1px); }
.bubble-lbl { white-space: nowrap; }
.bubble-cnt {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.85em;
  background: rgba(255,255,255,0.04);
  padding: 1px 6px;
  border-radius: 999px;
}
.bubble.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.bubble.is-active .bubble-cnt { color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.18); }

/* Bubble size buckets — visual hierarchy by count */
.bubble.sz-xl { font-size: 15px; padding: 7px 14px; font-weight: 600; }
.bubble.sz-l  { font-size: 13px; padding: 5px 11px; font-weight: 500; }
.bubble.sz-m  { font-size: 11px; padding: 4px 10px; }
.bubble.sz-s  { font-size: 10px; padding: 3px 8px; opacity: 0.92; }
.bubble.sz-sm { font-size: 11px; padding: 3px 9px; }
.bubble.sz-lg { font-size: 13px; padding: 7px 14px; font-weight: 600; }

/* Per-namespace accent (subtle left border on bubbles) — playful color coding */
.bubble--status   { border-left: 3px solid var(--accent); }
.bubble--people   { border-left: 3px solid var(--acid); }
.bubble--type     { border-left: 3px solid var(--accent-2); }
.bubble--theme    { border-left: 3px solid #5be1ff; }
.bubble--mood     { border-left: 3px solid #ffb84d; }
.bubble--stage    { border-left: 3px solid var(--ok); }
.bubble--format   { border-left: 3px solid #c0c0c8; }
.bubble--channel  { border-left: 3px solid var(--accent-2); }
.bubble--pillar   { border-left: 3px solid #ff6ec7; }
.bubble--campaign { border-left: 3px solid #7ee787; }
.bubble--facet    { border-left: 3px solid var(--accent); }

/* ====== Reset Layout button in user menu ====== */
#reset-layout-btn {
  text-align: left;
  font-size: 13px;
  padding: 0;
}

/* ====== Responsive — narrow viewports collapse panels under each other ====== */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .dock-column { max-height: none; }
  .panel--floating { width: 92vw; left: 4vw !important; }
}

/* Doc-Toggle Button (added 2026-05-25) */
.topbar-btn {
  background: var(--card-bg, #1a1a1a);
  border: 1px solid var(--border, #333);
  color: var(--text, #e0e0e0);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.topbar-btn:hover {
  background: var(--card-bg-hover, #252525);
  border-color: var(--border-hover, #555);
}
.topbar-btn.active {
  background: var(--accent, #c5ff00);
  color: var(--bg, #0a0a0a);
  border-color: var(--accent, #c5ff00);
}

/* ── Text / Markdown / PDF preview (Hard-Rule 2026-05-30) ──────────────── */
/* Modifier auf .detail-media: ohne ihn clipt overflow:hidden den Preview.
 * Mit ihm: scrollbar, kein Center-Align, full-height. */
.detail-media.detail-media--doc {
  overflow-y: auto;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 28px;
}
.text-preview {
  width: 100%;
  max-width: 920px;
  background: #0e0e0e;
  border: 1px solid #1f1f1f;
  border-radius: 8px;
  padding: 28px 36px;
  color: #e6e6e6;
  font-size: 15px;
  line-height: 1.55;
  /* Kein eigenes max-height/overflow mehr — Parent .detail-media--doc scrollt. */
}
.text-preview-pre {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #d8d8d8;
}
.markdown-body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  color: #fff;
  margin: 1.4em 0 0.6em;
  line-height: 1.25;
}
.markdown-body h1 { font-size: 1.9em; border-bottom: 1px solid #2a2a2a; padding-bottom: 0.25em; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid #1f1f1f; padding-bottom: 0.2em; }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body p { margin: 0.8em 0; }
.markdown-body a { color: #c5ff00; }
.markdown-body code {
  background: #1a1a1a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.92em;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.markdown-body pre {
  background: #050505;
  border: 1px solid #1f1f1f;
  border-radius: 6px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}
.markdown-body pre code { background: transparent; padding: 0; }
.markdown-body blockquote {
  border-left: 3px solid #c5ff00;
  margin: 1em 0;
  padding: 0.4em 1em;
  color: #b8b8b8;
  background: #131313;
  border-radius: 0 6px 6px 0;
}
.markdown-body table {
  border-collapse: collapse;
  margin: 1em 0;
  width: 100%;
  font-size: 0.95em;
}
.markdown-body th, .markdown-body td {
  border: 1px solid #2a2a2a;
  padding: 8px 12px;
  text-align: left;
}
.markdown-body th { background: #1a1a1a; color: #fff; }
.markdown-body ul, .markdown-body ol { padding-left: 1.4em; margin: 0.8em 0; }
.markdown-body li { margin: 0.2em 0; }
.markdown-body hr { border: 0; border-top: 1px solid #2a2a2a; margin: 1.5em 0; }
.markdown-body img { max-width: 100%; border-radius: 6px; }
.text-preview-truncated {
  margin-top: 1.5em;
  padding-top: 1em;
  border-top: 1px dashed #2a2a2a;
}
.pdf-preview {
  width: 100%;
  height: calc(100vh - 140px);
  max-width: 1200px;
  border: 1px solid #1f1f1f;
  border-radius: 8px;
  background: #0e0e0e;
}
/* Auto-Linking (Hard-Rule 2026-05-30): URLs + Vault-Paths klickbar in Previews */
.text-preview .auto-link,
.markdown-body .auto-link {
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
  transition: background 0.15s, border-color 0.15s;
}
.text-preview .auto-link--url,
.markdown-body .auto-link--url {
  color: #c5ff00;
  border-bottom-style: solid;
  word-break: break-all;
}
.text-preview .auto-link--url:hover,
.markdown-body .auto-link--url:hover {
  background: rgba(197, 255, 0, 0.12);
}
.text-preview .auto-link--path,
.markdown-body .auto-link--path {
  color: #67d8ff;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 0 2px;
  word-break: break-all;
}
.text-preview .auto-link--path:hover,
.markdown-body .auto-link--path:hover {
  background: rgba(103, 216, 255, 0.15);
  border-bottom-color: #67d8ff;
}
.text-preview .auto-link--path-unindexed,
.markdown-body .auto-link--path-unindexed {
  color: #8a8a8a;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92em;
  border-bottom: 1px dotted #555;
  word-break: break-all;
  cursor: help;
}
/* Mobile: stack + scroll natural */
@media (max-width: 880px) {
  .detail-media.detail-media--doc { padding: 14px; max-height: none; }
  .text-preview { padding: 18px 20px; font-size: 14px; }
  .pdf-preview { height: 70vh; }
}

/* ============================================================
   REELS — mobile TikTok-style swipe browser
   ============================================================ */
.reels-launch-btn {
  background: linear-gradient(135deg, var(--accent-2), var(--accent)) !important;
  color: #fff !important; border: none !important; font-weight: 700 !important;
}
.reels { position: fixed; inset: 0; z-index: 1000; background: #000; overscroll-behavior: none; }
.reels[hidden] { display: none; }
body.reels-open { overflow: hidden; }

.reels-stage {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  overflow: hidden; touch-action: pan-y; background: #000;
}
.reels-slide { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.reels-slide img, .reels-slide video {
  max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block;
}
.reels-empty { color: #888; font-size: 14px; text-align: center; padding: 30px; }

/* slide-in animations per swipe direction */
@keyframes reelsInLeft  { from { transform: translateX(60px);  opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes reelsInRight { from { transform: translateX(-60px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes reelsInUp    { from { transform: translateY(60px);  opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes reelsInDown  { from { transform: translateY(-60px); opacity: 0; } to { transform: none; opacity: 1; } }
.reels-slide.in-left  { animation: reelsInLeft  .18s ease-out; }
.reels-slide.in-right { animation: reelsInRight .18s ease-out; }
.reels-slide.in-up    { animation: reelsInUp    .2s  ease-out; }
.reels-slide.in-down  { animation: reelsInDown  .2s  ease-out; }
.reels-slide.bounce-left  { animation: reelsBounceL .22s ease; }
.reels-slide.bounce-right { animation: reelsBounceR .22s ease; }
.reels-slide.bounce-up    { animation: reelsBounceU .22s ease; }
.reels-slide.bounce-down  { animation: reelsBounceD .22s ease; }
@keyframes reelsBounceL { 0%,100%{transform:none} 50%{transform:translateX(-14px)} }
@keyframes reelsBounceR { 0%,100%{transform:none} 50%{transform:translateX(14px)} }
@keyframes reelsBounceU { 0%,100%{transform:none} 50%{transform:translateY(-14px)} }
@keyframes reelsBounceD { 0%,100%{transform:none} 50%{transform:translateY(14px)} }

/* top: close + breadcrumb */
.reels-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: flex-start; gap: 10px; padding: 14px 14px 28px;
  background: linear-gradient(180deg, rgba(0,0,0,0.75), transparent);
  pointer-events: none;
}
.reels-close {
  pointer-events: auto; flex-shrink: 0;
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.5); color: #fff; font-size: 18px; cursor: pointer;
}
.reels-crumb { font-size: 12px; color: #cfcfcf; line-height: 1.5; padding-top: 6px; }
.reels-crumb i { color: #666; margin: 0 5px; font-style: normal; }
.reels-crumb .cur { color: var(--accent); font-weight: 700; }

/* right-side action rail (TikTok style) */
.reels-side {
  position: absolute; right: 8px; bottom: 130px; z-index: 5;
  display: flex; flex-direction: column; gap: 18px; align-items: center;
}
.reels-side button {
  background: none; border: none; color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 24px; line-height: 1; text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.reels-side button span { font-size: 10px; font-weight: 600; }
.reels-side button.ok { color: var(--acid); }
.reels-side button.disabled { opacity: 0.35; pointer-events: none; }

/* bottom: level pips + label + hint */
.reels-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 28px 14px 18px; pointer-events: none;
  background: linear-gradient(0deg, rgba(0,0,0,0.8), transparent);
}
.reels-level { display: flex; gap: 6px; margin-bottom: 10px; }
.reels-level span {
  font-size: 10px; letter-spacing: .04em; color: #777; padding: 3px 9px;
  border-radius: 999px; border: 1px solid #333; text-transform: uppercase;
}
.reels-level span.done { color: #aaa; border-color: #555; }
.reels-level span.on { color: #fff; background: var(--accent); border-color: var(--accent); }
.reels-label { color: #fff; font-size: 15px; max-width: 78%; }
.reels-label .reels-pos { color: #bbb; font-size: 12px; margin-left: 6px; }
.reels-label .reels-deeper { color: var(--accent-2); font-size: 12px; }
.reels-hint { color: #888; font-size: 11px; margin-top: 6px; }

/* info sheet */
.reels-info-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  max-height: 60%; overflow-y: auto;
  background: var(--bg-elev); border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0; padding: 18px 18px 28px;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.6);
  animation: reelsInUp .2s ease-out;
}
.reels-info-sheet[hidden] { display: none; }
.reels-info-sheet h3 { margin: 0 0 12px; font-size: 16px; color: var(--text); }
.reels-info-row { font-size: 13px; color: var(--text); margin: 4px 0; }
.reels-info-row b { color: var(--muted); display: inline-block; min-width: 60px; }
.reels-info-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 12px 0; }
.reels-info-tags span { font-size: 11px; background: var(--bg-card); border: 1px solid var(--border); color: var(--muted); padding: 3px 8px; border-radius: 10px; }
.reels-info-open { display: inline-block; margin-top: 8px; color: var(--accent); font-weight: 600; }

/* desktop: the reels overlay still works (keyboard) but launch lives in mobile bar */

/* ============================================================
   3D MODEL PREVIEW (detail view)
   ============================================================ */
.model-preview {
  width: 100%; height: 100%; min-height: 50vh;
  background: radial-gradient(circle at 50% 40%, #1a1a22, #0d0d10 70%);
  --poster-color: transparent;
  border-radius: 4px;
}
.model-fallback {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center; color: var(--text); padding: 30px 24px; max-width: 420px;
}
.model-fallback .model-3d-icon {
  font-size: 72px; line-height: 1; color: var(--accent-2);
  filter: drop-shadow(0 0 16px rgba(176,107,255,0.4));
}
.model-fallback p { margin: 0; }
.model-fallback .btn, .model-fallback .dl-link { margin-top: 4px; }

/* Gallery card: 3D model badge */
.card .badge.model { background: var(--accent-2); color: #fff; }

/* Synced Paperclip approvals */
.approval-inbox { position: relative; display: inline-flex; }
.approval-inbox-btn.has-items { border-color: var(--accent); color: var(--accent); }
.approval-inbox-btn span {
  margin-left: 4px; padding: 1px 6px; border-radius: 999px;
  background: var(--accent); color: #050505; font-size: 11px; font-weight: 800;
}
.approval-inbox-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  width: min(360px, 90vw); padding: 8px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-elev); box-shadow: 0 18px 50px rgba(0,0,0,.45);
}
.approval-inbox-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.approval-inbox-head button { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.approval-inbox-head button:hover { color: var(--accent); }
.approval-inbox-list { max-height: 340px; overflow-y: auto; display: grid; gap: 6px; }
.approval-empty { padding: 10px; border-radius: 6px; background: var(--bg-card); color: var(--muted); font-size: 13px; }
.approval-item {
  display: grid; gap: 2px; width: 100%; padding: 9px 10px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card); color: var(--text);
}
.approval-item:hover { border-color: var(--accent); }
.approval-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.approval-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.approval-modal-shell {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  padding: 18px; background: rgba(0,0,0,.72);
}
.approval-modal-shell[hidden] { display: none; }
.approval-modal {
  width: min(620px, 96vw); padding: 18px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-elev); box-shadow: 0 22px 70px rgba(0,0,0,.6);
}
.approval-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.approval-kicker { color: var(--accent); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.approval-modal h2 { margin: 4px 0; font-size: 20px; }
.approval-modal p { color: var(--muted); }
.approval-modal-head button { border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--muted); padding: 5px 9px; cursor: pointer; }
.approval-summary { max-height: 220px; overflow-y: auto; padding: 12px; border-radius: 6px; background: var(--bg-card); white-space: pre-wrap; color: var(--text) !important; }
.approval-notice { margin-top: 12px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 6px; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--text); font-size: 13px; line-height: 1.45; }
.approval-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.approval-links a { padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px; color: var(--text); text-decoration: none; }
.approval-links a:hover { border-color: var(--accent); color: var(--accent); }
.approval-error { margin-top: 12px; padding: 10px; border: 1px solid #d34; border-radius: 6px; color: #ffb4c0; background: rgba(221,51,68,.12); }
.approval-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.approval-actions button { border: 0; border-radius: 6px; padding: 8px 12px; font-weight: 800; cursor: pointer; }
.approval-actions button:disabled { opacity: .55; cursor: wait; }
.approval-reject { background: #d33; color: #fff; }
.approval-approve { background: var(--acid); color: #050505; }

/* ---------- 3D-Viewer (obj/stl, three.js) + 3D-Bundles (2026-07-09) ---------- */
.viewer3d {
  position: relative; width: 100%; height: 100%; min-height: 50vh;
  background: radial-gradient(circle at 50% 40%, #1a1a22, #0d0d10 70%);
  border-radius: 4px; overflow: hidden;
}
.viewer3d canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.viewer3d-status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; pointer-events: none; padding: 20px; text-align: center;
}
.viewer3d-bar {
  position: absolute; bottom: 10px; right: 10px; display: flex; gap: 6px;
}
.viewer3d-bar button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.15);
  background: rgba(20,20,26,0.75); color: var(--muted); font-size: 16px; cursor: pointer;
  backdrop-filter: blur(4px);
}
.viewer3d-bar button:hover { color: var(--text); border-color: rgba(255,255,255,0.35); }
.viewer3d-bar button.on { color: #FF2D94; border-color: #FF2D94; }

.badge.bundle { letter-spacing: 0; }

.bundle-files { list-style: none; margin: 8px 0 0; padding: 0; }
.bundle-file {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 6px; border: 1px solid transparent;
}
.bundle-file:hover { background: rgba(255,255,255,0.04); }
.bundle-file.current { border-color: rgba(255,45,148,0.45); background: rgba(255,45,148,0.06); }
.bundle-open {
  display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1;
  color: var(--text); text-decoration: none;
}
.bundle-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.bundle-ext {
  flex: none; font-size: 9.5px; font-weight: 700; letter-spacing: 0.4px;
  padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,0.09); color: var(--muted);
}
.bundle-ext--model { background: rgba(176,107,255,0.18); color: #b06bff; }
.bundle-ext--image { background: rgba(80,200,255,0.14); color: #6fc9ff; }
.bundle-size { flex: none; }
.bundle-dl {
  flex: none; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid rgba(255,255,255,0.14); color: var(--muted);
  text-decoration: none; font-size: 14px;
}
.bundle-dl:hover { color: #FF2D94; border-color: #FF2D94; }


/* PNG sequence card mark — BOTTOM LEFT of the thumbnail (not the 3D badge,
   not the bottom-right robot). */
.card .thumb-wrap { position: relative; }
.card .card-seq {
  position: absolute; left: 6px; bottom: 6px; z-index: 4;
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 7px 0 5px; border-radius: 4px;
  background: rgba(0,0,0,0.72); color: #F8F6EF;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  pointer-events: none;
}
.card .card-seq svg { display: block; opacity: 0.95; }
.card .card-seq-n { font-variant-numeric: tabular-nums; }

/* Detail: sequence timeline under the media + neighbor strip beneath it. */
.detail-media.has-seq {
  flex-direction: column; justify-content: flex-end; align-items: stretch;
  padding-bottom: 0; gap: 0;
}
.detail-media.has-seq img {
  flex: 1 1 auto; min-height: 0;
  margin: auto;
}
.detail-media.has-seq .zoom-badge { bottom: auto; top: 10px; }
.seq-chrome {
  flex: none; width: 100%;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.55) 30%, rgba(8,8,12,0.92));
  padding: 8px 12px 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.seq-timeline-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.seq-glyph { font-size: 14px; }
.seq-track { position: relative; height: 28px; display: flex; align-items: center; }
.seq-track input[type="range"] {
  width: 100%; margin: 0; height: 28px; cursor: ew-resize;
  accent-color: #FF2D94;
}
.seq-playhead { display: none; }
.seq-neighbors {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.seq-neighbor {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 6px 8px; border-radius: 6px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
  color: var(--text); text-decoration: none; font-size: 12px;
}
.seq-neighbor img {
  width: 36px; height: 36px; object-fit: cover; border-radius: 4px; flex: none;
  max-width: 36px; max-height: 36px;
}
.seq-neighbor span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seq-neighbor.is-next { justify-content: flex-end; }
.seq-neighbor.is-empty { opacity: 0.35; pointer-events: none; border-style: dashed; }
.seq-neighbor:hover { border-color: #FF2D94; }

/* ======================================================================
   AQ13R mobile override 2026-08-29 — MUST stay last.
   The v3 .layout { display:grid; 300px 1fr } block below the original
   767px sheet rules won on source order, so on phones the dock column
   became a full-height first grid row (rail covering the gallery).
   Login also could not scroll (html/body overflow:hidden + 100vh).
   ====================================================================== */
html { overflow-x: hidden; }
@media (max-width: 767px) {
  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }
  .layout {
    display: block !important;
    grid-template-columns: none !important;
    gap: 0 !important;
    padding: 8px !important;
    align-items: stretch !important;
  }
  .dock-column {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: min(85vw, 340px) !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    z-index: 300;
    overflow-y: auto;
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    transform: translateX(-105%) !important;
    transition: transform 0.25s ease-out;
    box-shadow: 4px 0 24px rgba(0,0,0,0.6);
  }
  body.mobile-sheet-open .dock-column { transform: translateX(0) !important; }
  .grid-wrap, .grid, .card { min-width: 0; max-width: 100%; }
  .v4ul7-loader, .v4l-scene { max-width: 100vw; overflow: hidden; }
  .topbar {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .btn, .btn-primary, .factor-btn, .upload-btn, .back-btn, .meta-link,
  .topbar-btn, .mob-sort-btn {
    min-height: 44px;
  }
  .mobile-filter-fab {
    display: flex;
    bottom: calc(56px + env(safe-area-inset-bottom) + 12px) !important;
    right: max(20px, env(safe-area-inset-right));
  }
  html, body {
    height: 100dvh !important;
    height: 100svh !important;
  }
  #mobile-toolbar {
    position: fixed !important;
    left: 0; right: 0; top: auto !important; bottom: 0 !important;
    z-index: 200;
    display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
    background: var(--bg-elev);
    border-bottom: none;
    border-top: 1px solid var(--border);
    padding: 8px 12px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  #mobile-toolbar::-webkit-scrollbar { display: none; }
  .grid-wrap {
    padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }
  .grid { padding-bottom: 8px; }
}


/* Login / passkey / magic-link: page must scroll; thumbs need 44px+ targets.
   html/body { height:100vh; overflow:hidden } is for the gallery shell. */
body:has(.auth-shell) {
  height: auto !important;
  min-height: 100dvh;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}
.auth-shell {
  min-height: 100dvh;
  min-height: 100svh;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.auth-card { max-width: min(420px, 100%); }
.factor-list { display: flex; flex-direction: column; gap: 10px; }
.factor-btn { min-height: 56px; width: 100%; }
.btn-primary { min-height: 48px; }
