/* ═════════════════════════════════════════════════════════════════════════════
   Vault — stylesheet
   Inter is loaded once, via <link> in index.html.

   The system, so new UI doesn't have to invent its own:

     TOKENS      :root holds the only colours, radii, shadows and control
                 metrics. Never hardcode a radius or a control height.
     SHAPE       Clickable things and surfaces are squircles using the --r-*
                 scale. Passive indicators (badges, chips, dots, spinners,
                 progress, toasts) are fully round. That's the whole rule.
     BUTTONS     .btn is the only button. Variants: .btn-primary,
                 .btn-danger, .btn-danger-solid, .btn-ghost. Modifiers:
                 .icon (square), .sm, .btn-block, .active, [disabled].
     MENUS       .menu + .menu-item + .menu-label + .menu-sep is the only
                 popover. openMenu() in main.js places it.
     TOOLBAR     .toolbar > .tb-rail > .tb-group. One non-wrapping row that
                 scrolls; dividers and empty groups handle themselves.
     MODALS      .modal-content (+ .modal-sm/.modal-md/.modal-lg),
                 .settings-section for grouping, .modal-buttons for the footer.

   Adding a toolbar button: put a <button class="btn icon"> in the right
   .tb-group in index.html. No CSS, no media query, no JS layout work.
   ═════════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  /* One shape language: every rounded box is a squircle. Circles and pills opt
     back out below (a superellipse at full radius looks squashed). Chromium 139+;
     everywhere else falls back to a plain border-radius, which is fine. */
  corner-shape: squircle;
}

/* The one shape rule, so this can't drift again:
     • anything you can click, and every surface → squircle, radius from the
       scale below;
     • passive indicators (badges, chips, dots, spinners, progress, toasts)
       → fully round pills and circles.
   These are the round ones. */
.badge, .spinner, .btn-spinner, .toast, .tag-badge, .tag-dot,
.tag-sv-knob, .progress-track, .progress-track .bar, .tag-hue,
input[type="range"], ::-webkit-scrollbar-thumb {
  corner-shape: round;
}

/* `hidden` must beat the display value a component sets on itself, so JS can
   hide any control with el.hidden = true and empty groups collapse cleanly. */
[hidden] { display: none !important; }

.file-item, .file-card, .btn, .seg, .menu-item, .breadcrumb span,
.preview-nav, .preview-action, .mode-bar-count {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  overscroll-behavior: none;
}

html {
  min-height: 100%;
  background:
    radial-gradient(120% 90% at 12% 8%, rgba(125, 178, 255, 0.50), transparent 46%),
    radial-gradient(120% 90% at 88% 6%, rgba(255, 176, 214, 0.45), transparent 42%),
    radial-gradient(130% 100% at 82% 92%, rgba(164, 197, 255, 0.45), transparent 46%),
    radial-gradient(120% 100% at 6% 96%, rgba(190, 228, 255, 0.45), transparent 46%),
    linear-gradient(165deg, #eef3fc 0%, #f6f5fb 48%, #fdeef5 100%);
  background-attachment: fixed;
}

:root {
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', ui-monospace, 'Inter', 'Menlo', monospace;

  --text: #2a2e3d;
  --text-soft: #545a6e;
  --muted: #939aab;
  --faint: #b6bccb;

  --accent: #0a84ff;
  --accent-strong: #0066e0;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --accent-ring: rgba(10, 132, 255, 0.22);

  --danger: #ff3b30;
  --danger-soft: rgba(255, 59, 48, 0.12);
  --gold: #f5a300;
  --success: #2bbd4f;

  /* Opaque enough to be legible WITHOUT backdrop-filter blur (which is killed
     globally at the end of this file — it was the pervasive GPU cost). */
  --glass: rgba(255, 255, 255, 0.85);
  --glass-2: rgba(255, 255, 255, 0.9);
  --glass-strong: rgba(255, 255, 255, 0.95);
  --glass-border: rgba(255, 255, 255, 0.75);
  --hairline: rgba(28, 32, 56, 0.08);
  --hairline-2: rgba(28, 32, 56, 0.06);

  --shadow-sm: 0 2px 10px rgba(36, 50, 92, 0.08);
  --shadow: 0 10px 34px rgba(36, 50, 92, 0.12);
  --shadow-lg: 0 24px 70px rgba(30, 42, 84, 0.22);

  /* ── Radius scale ──
     One ladder, used everywhere. Anything nested inside something else steps
     down one rung, which is why the numbers are evenly spaced.
       --r-xs  inner bits (segmented buttons, chips inside a menu)
       --r-sm  menu items, small fields
       --r     every control: button, input, select — the workhorse
       --r-lg  panels: menus, cards, popovers, toolbars
       --r-xl  modals and the big surfaces (file list) */
  --r-xs: 8px;
  --r-sm: 10px;
  --r: 13px;
  --r-lg: 18px;
  --r-xl: 24px;

  /* Control metrics — every button/field in the app is one of these two heights,
     so rows line up without per-component padding tweaks. */
  --ctl-h: 38px;
  --ctl-h-sm: 30px;
  --ctl-pad: 14px;
  --ctl-gap: 8px;
  --icon: 17px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);

  /* Masked shape — recoloured with `background`, so one copy serves every use. */
  --chevron-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 15l6-6 6 6'/%3E%3C/svg%3E");
}

body {
  font-family: var(--sans);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding: 28px;
  padding: max(28px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
  position: relative;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
}

body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}
body::before {
  width: 60vw;
  height: 60vw;
  max-width: 760px;
  max-height: 760px;
  top: -18vw;
  left: -14vw;
  background: radial-gradient(circle, rgba(120, 170, 255, 0.7), transparent 70%);
  /* ponytail: drift disabled. A 120px blur re-rasterising every frame (and forcing
     every backdrop-filter surface above it to re-sample) was the single biggest GPU
     cost — see note below. Static blobs look near-identical. Re-add `animation: drift1
     22s ease-in-out infinite alternate;` if you want the motion back. */
}
body::after {
  width: 55vw;
  height: 55vw;
  max-width: 680px;
  max-height: 680px;
  bottom: -20vw;
  right: -12vw;
  background: radial-gradient(circle, rgba(255, 182, 214, 0.6), transparent 70%);
  /* ponytail: drift disabled (see body::before). Re-add `animation: drift2 26s
     ease-in-out infinite alternate;` to restore motion. */
}

@keyframes drift1 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(8vw, 6vh) scale(1.12); }
}
@keyframes drift2 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-7vw, -5vh) scale(1.1); }
}

/* ── Mobile performance ──
   The background blobs are the one remaining per-frame cost on phones; shrink
   the blur radius and dim them. (Blur on chrome surfaces is gone entirely —
   they are opaque now, everywhere.) */
@media (max-width: 768px), (pointer: coarse) {
  body::before, body::after {
    animation: none;
    filter: blur(70px);
    opacity: 0.38;
  }
  .toolbar, .breadcrumb, .file-list { background: rgba(255, 255, 255, 0.92); }
  .preview-modal { background: rgba(18, 22, 36, 0.9); }
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.header {
  padding: 26px 4px 26px;
  margin-bottom: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  animation: settle 0.44s var(--ease) both;
}

.header h1 {
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1;
  color: #1c2030;
  /* Solid ink letters with the pink and blue split into two separate side glows
     (no gradient → no muddy purple). Slight white top edge for a glossy lift. */
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65),
    -4px 0 18px rgba(255, 110, 176, 0.55),
     4px 0 18px rgba(72, 148, 255, 0.55);
  cursor: pointer;
  transition: text-shadow 0.25s var(--ease), transform 0.25s var(--ease);
  display: inline-block;
  user-select: none;
  -webkit-user-select: none;
}
.header h1:hover {
  transform: translateY(-1px);
  /* glows spread wider and brighter on hover */
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65),
    -7px 0 24px rgba(255, 110, 176, 0.8),
     7px 0 24px rgba(72, 148, 255, 0.8);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Entry motion for content that loads with the page. `rise` slides 14px over
   0.7s, and with four of them stacked the whole page reads as one slow lift.
   `settle` barely travels and mostly scales in, so it resolves fast and feels
   like the page focusing rather than sliding. `rise` stays for the mode bar,
   where a bar actually sliding up from the bottom edge is the right read. */
@keyframes settle {
  from { opacity: 0; transform: translateY(5px) scale(0.986); }
  to   { opacity: 1; transform: none; }
}

/* Opening a vault used to replay `settle` on the toolbar and the list separately
   — #contentArea goes display:none → block, which restarts every descendant
   animation, so the two staggered slide-ups fired on every folder open and read
   as the page shuffling itself. One opacity-only fade on the whole panel
   instead: nothing moves, nothing arrives late, and it costs one composited
   layer for a quarter second. */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#contentArea { animation: fade 0.24s var(--ease-soft) both; }

.toast-container {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 13px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--sans);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.4s var(--ease), toast-out 0.35s var(--ease) 2.7s forwards;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  pointer-events: none;
  max-width: 440px;
  border: 1px solid var(--glass-border);
}

.toast svg { width: 17px; height: 17px; flex-shrink: 0; }

.toast-error   { background: rgba(255, 235, 234, 0.85); color: #d3322a; border-color: rgba(255, 59, 48, 0.28); }
.toast-error svg { stroke: #d3322a; }
.toast-success { background: rgba(231, 250, 236, 0.85); color: #178a3a; border-color: rgba(43, 189, 79, 0.3); }
.toast-success svg { stroke: #178a3a; }
.toast-info    { background: rgba(232, 242, 255, 0.85); color: #0a6fe0; border-color: rgba(10, 132, 255, 0.28); }
.toast-info svg { stroke: #0a6fe0; }
.toast-warning { background: rgba(255, 246, 228, 0.85); color: #b5790a; border-color: rgba(245, 163, 0, 0.32); }
.toast-warning svg { stroke: #b5790a; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(14px) scale(0.97); }
}

.header-actions { display: flex; gap: var(--ctl-gap); align-items: center; }

/* ─────────────────────────────────────────────────────────────────────────────
   BUTTONS
   One base, four variants, two sizes. Every button in the app uses this — no
   component invents its own padding, radius or height.
   ───────────────────────────────────────────────────────────────────────────── */
.btn {
  height: var(--ctl-h);
  padding: 0 var(--ctl-pad);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--sans);
  letter-spacing: -0.01em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-shrink: 0;
  position: relative;
  transition: transform 0.16s var(--ease), background 0.18s var(--ease-soft),
              border-color 0.18s, box-shadow 0.18s, color 0.18s, opacity 0.18s;
}
.btn > svg { width: var(--icon); height: var(--icon); flex-shrink: 0; }
.btn .btn-caret { width: 13px; height: 13px; opacity: 0.5; margin-left: -2px; }
.btn .btn-label { overflow: hidden; text-overflow: ellipsis; }

.btn:hover { background: #fff; box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(0.96); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; transform: none; }
.btn:disabled:hover { background: rgba(255, 255, 255, 0.82); }

/* Toggled-on state — same treatment for every toggle in the app. */
.btn.active { background: var(--accent-soft); border-color: var(--accent-ring); color: var(--accent-strong); }
.btn.active:hover { background: rgba(10, 132, 255, 0.18); }

.btn.icon { width: var(--ctl-h); padding: 0; }
.btn.sm { height: var(--ctl-h-sm); padding: 0 11px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn.sm.icon { width: var(--ctl-h-sm); }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--accent); border-color: transparent; color: #fff;
  box-shadow: 0 5px 16px rgba(10, 132, 255, 0.3);
}
.btn-primary:hover { background: var(--accent-strong); color: #fff; box-shadow: 0 8px 22px rgba(10, 132, 255, 0.4); }
.btn-primary:disabled:hover { background: var(--accent); }

.btn-danger { color: var(--danger); }
.btn-danger > svg { stroke: var(--danger); }
.btn-danger:hover, .btn-danger.active { background: var(--danger-soft); border-color: rgba(255, 59, 48, 0.32); color: var(--danger); }

.btn-danger-solid, .btn-danger-block {
  background: var(--danger); border-color: transparent; color: #fff;
  box-shadow: 0 5px 16px rgba(255, 59, 48, 0.28);
}
.btn-danger-solid:hover, .btn-danger-block:hover { background: #e02e24; color: #fff; box-shadow: 0 8px 22px rgba(255, 59, 48, 0.38); }
.btn-danger-solid > svg, .btn-danger-block > svg { stroke: #fff; }
.btn-danger-block { width: 100%; }
.btn-danger-solid:disabled:hover, .btn-danger-block:disabled:hover { background: var(--danger); }

/* Quiet button — cancels, dismissals. Reads as secondary without a second border. */
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); box-shadow: none; }
.btn-ghost:hover { background: rgba(28, 32, 56, 0.06); color: var(--text); box-shadow: none; }

.btn .btn-spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

#unlockBtn { min-width: 118px; }

/* Row of equal-width buttons (modal sections). */
.btn-row { display: flex; gap: var(--ctl-gap); align-items: center; }
.btn-row > .btn { flex: 1 1 0; }
.btn-row > input { flex: 1 1 auto; margin-bottom: 0; }

/* ─────────────────────────────────────────────────────────────────────────────
   BADGES — counts riding on an icon button.
   ───────────────────────────────────────────────────────────────────────────── */
.badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10px; font-weight: 800; line-height: 1;
  color: #fff;
  display: none; align-items: center; justify-content: center;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.badge-accent { background: var(--accent); box-shadow: 0 2px 6px rgba(10, 132, 255, 0.45); }
.badge-gold   { background: var(--gold);   box-shadow: 0 2px 6px rgba(245, 163, 0, 0.45); }

/* ─────────────────────────────────────────────────────────────────────────────
   TOOLBAR
   A single non-wrapping rail. Controls are grouped by purpose; groups are
   separated by a hairline that draws itself, so a group can be hidden without
   leaving an orphan divider. When the rail runs out of width it scrolls
   sideways — it never wraps, so nothing below it can ever be pushed down, and
   a new button needs no media query, no `order`, no width maths.
   ───────────────────────────────────────────────────────────────────────────── */
/* The rail, the path and the mode bars travel together as one sticky slab, so
   every control stays reachable however far down the grid you are. Backgrounds
   here are near-opaque on purpose: nothing blurs (see .file-list), so cards
   passing underneath have to be covered rather than frosted. */
.sticky-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  margin: 0 -10px;
  padding: 12px 10px 0;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  transition: background 0.2s, box-shadow 0.2s;
}
/* Only once it has actually stuck — at rest the page keeps its glass gaps. */
.sticky-bar.stuck {
  background: var(--glass-strong);
  box-shadow: var(--shadow-sm);
}
/* Back-to-top rides the same .stuck signal as the bar — no scroll listener of
   its own, so it's on screen exactly while the bar is overlaying content. */
#scrollTopBtn { display: none; }
.sticky-bar.stuck #scrollTopBtn { display: inline-flex; }

.toolbar {
  position: relative;
  margin-bottom: 18px;
  padding: 8px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  z-index: 30;
}

.tb-rail {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  /* Badges hang 5px above their button, and overflow-y: hidden was slicing the
     top off them. Room inside the scrollport, taken back with a negative margin
     so the rail's height doesn't change. */
  padding: 6px 0;
  margin: -6px 0;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.tb-rail::-webkit-scrollbar { display: none; }

.tb-group { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
/* Divider drawn by the group that follows another one, and only when both
   still have a visible control in them. */
.tb-group:has(> :not([hidden])) + .tb-group:has(> :not([hidden]))::before {
  content: '';
  width: 1px; height: 20px;
  margin: 0 4px;
  background: var(--hairline);
  flex-shrink: 0;
}
.tb-group:not(:has(> :not([hidden]))) { display: none; }
.tb-spacer { flex: 1 0 8px; }

/* Search overlays the rail instead of sitting in it: opening it cannot move a
   single other control. */
.tb-search {
  position: absolute;
  inset: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 12px;
  background: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--r);
  box-shadow: 0 0 0 3px var(--accent-ring);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.985);
  /* visibility is delayed on the way out (so the fade finishes first) but must
     flip instantly on the way in: a transitioning visibility is still `hidden`
     at progress 0, and focus() on a hidden field is a no-op — that was the
     "click search, then click the box" bug. */
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), visibility 0s 0.18s;
  z-index: 2;
}
.tb-search.search-open {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), visibility 0s;
}
.tb-search-icon { width: 16px; height: 16px; stroke: var(--muted); flex-shrink: 0; }
.tb-search input {
  flex: 1; min-width: 0;
  align-self: stretch;
  background: transparent; border: none; outline: none;
  color: var(--text);
  font: 600 13.5px var(--sans);
  letter-spacing: -0.01em;
  -webkit-user-select: text; user-select: text;
  touch-action: manipulation;
}
.tb-search input::placeholder { color: var(--muted); font-weight: 500; }
.tb-search-clear {
  width: 20px; height: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0; border: none; border-radius: 50%; cursor: pointer;
  background: rgba(28, 32, 56, 0.1);
  transition: background 0.15s;
}
.tb-search-clear:hover { background: rgba(28, 32, 56, 0.2); }
.tb-search-clear svg { width: 11px; height: 11px; stroke: var(--text-soft); }

/* ─────────────────────────────────────────────────────────────────────────────
   SEGMENTED CONTROL — mutually exclusive choices (layout, tile size).
   ───────────────────────────────────────────────────────────────────────────── */
.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: rgba(28, 32, 56, 0.06);
  border-radius: var(--r);
}
.seg {
  flex: 1 1 0;
  min-width: 0;
  height: var(--ctl-h-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 8px;
  background: transparent;
  border: none;
  border-radius: var(--r-xs);
  color: var(--text-soft);
  font: 600 12.5px var(--sans);
  cursor: pointer;
  transition: background 0.16s var(--ease-soft), color 0.16s, box-shadow 0.16s;
}
.seg svg { width: 15px; height: 15px; flex-shrink: 0; }
.seg:hover { color: var(--text); }
.seg.active {
  background: #fff;
  color: var(--accent-strong);
  box-shadow: var(--shadow-sm);
}
.seg:disabled { opacity: 0.4; cursor: not-allowed; }

.file-grid {
  background: transparent;
  border: none;
  overflow: visible;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb-size, 140px), 1fr));
  /* Entry motion lives on #contentArea now — one fade for the whole panel. */
}

.file-card {
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--glass-border);
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  /* Only animate transform — it's GPU-composited. Animating box-shadow repaints
     every frame, and the .file-list backdrop-filter behind each card re-samples
     its blur on every repaint, which is what made hovering the grid lag. */
  transition: transform 0.18s var(--ease);
  position: relative;
  box-shadow: var(--shadow-sm);
  /* ponytail: no more `transform: translateZ(0)`. It gave each card its own GPU
     layer to protect the .file-list backdrop-filter on hover — but that filter is
     gone now, so the only thing translateZ did was allocate a layer PER CARD (40+
     permanent layers = compositor overhead that made re-renders/scroll sluggish).
     The hover transform still composites on its own during the transition. */
}
.file-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);   /* snaps (no transition) — cheap, barely perceptible under the lift */
  border-color: #fff;
}
/* ponytail: touch devices have sticky :hover that fires on tap; native (hover: none) kills the lift so it doesn't animate/lag */
@media (hover: none) {
  .file-card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
    border-color: var(--glass-border);
  }
}

.thumb {
  height: var(--thumb-size, 140px);
  width: 100%;
  background: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--hairline-2);
  position: relative;
}
.video-error {
  max-width: 92vw;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  color: #fff;
}
.video-error-title { font-size: 15px; font-weight: 600; text-align: center; }
.video-error-details {
  margin: 0;
  padding: 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  user-select: text;
  -webkit-user-select: text;
}
.video-error-copy { align-self: center; }

/* Fast-scroll (shuffle / back-to-top) is a no-op visually — no hover repaints
   while the list flies past. The work it saves is JS-side: the thumb queue is
   held for the duration of the scroll (beginFastScroll in main.js).
   Keyed off the id, not .file-list — the element swaps to .file-grid in grid
   view, which is the mode that actually has thumbnails. */
#fileList.fast-scroll { pointer-events: none; }

.thumb img  { width: 100%; height: 100%; object-fit: cover; }
.thumb video { max-width: 100%; max-height: 100%; object-fit: cover; }
.thumb .thumb-icon { width: 40px; height: 40px; opacity: 0.55; }
.thumb .file-icon  { width: 40px; height: 40px; margin-right: 0; }
/* Don't let the thumbnail start a native image drag — the card owns the drag-to-move */
.thumb img, .thumb svg, .thumb .thumb-icon { -webkit-user-drag: none; user-select: none; }

.file-card-meta { padding: 9px 12px; }
.file-card-name {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
  color: var(--text);
}
.file-card-sub {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  background: var(--glass);
  border-radius: var(--r);
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.breadcrumb span { cursor: pointer; transition: color 0.2s; color: var(--text-soft); }
.breadcrumb span:not(.breadcrumb-separator):not(.breadcrumb-count):hover { color: var(--accent-strong); }
/* The *current* crumb is bold — it used to be :last-of-type, which actually hit
   the trailing file-count span. */
.breadcrumb .breadcrumb-here { color: var(--text); font-weight: 600; }
.breadcrumb-separator { color: var(--faint); cursor: default; }
.breadcrumb-count { color: var(--muted); font-size: 12px; margin-left: 4px; font-weight: 500; cursor: default; }

.file-list {
  /* ponytail: opaque bg + no backdrop-filter. This surface scrolls under the whole
     grid and gets repainted on every select/delete toggle; blurring it re-samples
     the backdrop each time = the desktop lag. Frost kept on cards/modals/toolbars. */
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.file-item {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--hairline-2);
  cursor: pointer;
  /* ponytail: animate transform (GPU-composited), not padding-left. Indenting via
     padding-left is fine for one hovered row, but delete mode sets padding-left:52px
     on EVERY row at once — animating that reflowed the whole list = the select/delete
     lag. translateX slides with zero reflow; delete-mode padding now snaps instantly. */
  transition: background 0.18s var(--ease-soft), transform 0.18s var(--ease);
}
.file-item:hover {
  background: rgba(10, 132, 255, 0.06);
  transform: translateX(6px);
}
.file-item:last-child { border-bottom: none; }

.file-icon {
  width: 22px; height: 22px;
  margin-right: 13px;
  flex-shrink: 0;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s;
}
.file-item:hover .file-icon { stroke: var(--accent); }

.file-name {
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-size {
  font-size: 12.5px;
  color: var(--muted);
  min-width: 78px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   MENUS — one popover component. The sort menu, the tags panel, the view
   options, the right-click menu and the icon pickers are all this, so they
   cannot drift apart again.
   Menus are position:fixed and placed by openMenu() in main.js: the toolbar
   rail scrolls, and an absolutely-positioned child of a scroll container gets
   clipped.
   ───────────────────────────────────────────────────────────────────────────── */
.menu-anchor { position: relative; display: inline-flex; flex-shrink: 0; }

.menu {
  position: fixed;
  top: 0; left: 0;
  z-index: 10001;
  display: none;
  min-width: 190px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 6px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.menu.open { display: block; animation: pop 0.16s var(--ease); }

.menu-label {
  padding: 7px 10px 5px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--faint);
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
/* The label fills the row — but not when the first span is a tag's colour dot
   or icon, which must keep its own size. */
.menu-item > span:first-of-type:not(.tag-dot):not(.tag-row-icon) {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-item svg { width: 15px; height: 15px; stroke: currentColor; fill: none; flex-shrink: 0; }
.menu-item:hover { background: var(--accent-soft); }
.menu-item.active { color: var(--accent-strong); font-weight: 600; }
.menu-sep { height: 1px; margin: 5px 8px; background: var(--hairline); }
.menu .segmented { margin: 0 2px 6px; }
.menu .segmented:last-child { margin-bottom: 2px; }

.preview-filename {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 55vw;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 1003;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
  opacity: 0;
  box-shadow: var(--shadow);
  transition: opacity 0.25s, max-width 0.22s ease, white-space 0s, border-radius 0.18s, background 0.15s, color 0.15s;
}
.preview-filename:not(:empty) { opacity: 1; pointer-events: auto; }
.preview-filename.expanded {
  max-width: 78vw;
  white-space: normal;
  word-break: break-all;
  text-overflow: clip;
  border-radius: 16px;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
@media (max-width: 768px) {
  .preview-filename { max-width: 62vw; font-size: 11.5px; }
  .preview-filename.expanded { max-width: 80vw; }
}

@media (pointer: coarse) {
  .preview-filename,
  .preview-filename.expanded {
    user-select: none;
    -webkit-user-select: none;
    cursor: default;
  }
}

.preview-position {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 24, 38, 0.45);
  color: rgba(255, 255, 255, 0.78);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  z-index: 1003;
  border: 1px solid rgba(255, 255, 255, 0.18);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 768px) {
  .preview-position { bottom: 48px; }
}

.preview-modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(18, 22, 36, 0.82); /* darker: no blur now, so dim more to separate the media */
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.preview-modal.active { display: flex; animation: overlay-in 0.28s var(--ease); }

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.preview-content {
  max-width: 90%; max-height: 90%;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-content img,
.preview-content video {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 16px;
  display: block;
  margin: auto;
  box-shadow: var(--shadow-lg);
  animation: pop 0.32s var(--ease);
}
.preview-content audio {
  display: flex; align-items: center; justify-content: center;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.preview-content .audio-player-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  max-width: 400px;
  width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: pop 0.32s var(--ease);
}
.preview-content .audio-cover-art {
  width: 200px; height: 200px;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.6);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--hairline);
}
.preview-content .audio-cover-art svg {
  width: 70px; height: 70px;
  stroke: var(--muted); fill: none; stroke-width: 1.5;
}
.preview-content .audio-cover-art img {
  width: 100%; height: 100%; object-fit: cover;
}
.preview-content .audio-info { text-align: center; max-width: 100%; }
.preview-content .audio-title {
  font-size: 15px; font-weight: 700;
  color: var(--text);
  word-break: break-word; margin-bottom: 4px;
}
.preview-content .audio-size {
  font-size: 12px; color: var(--muted); font-weight: 500;
}
.preview-content .audio-player-container audio {
  width: 100%; max-width: 340px; height: 40px; border-radius: 20px;
}

.preview-content pre {
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  padding: 24px;
  border-radius: var(--r);
  overflow: auto;
  max-height: 80vh;
  max-width: 800px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--mono);
  box-shadow: var(--shadow-lg);
  animation: pop 0.32s var(--ease);
}

.preview-nav {
  position: fixed;
  top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px;
  border-radius: var(--r);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  color: var(--text);
  cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
  z-index: 1001;
  transition: background 0.2s, transform 0.2s var(--ease), box-shadow 0.2s;
  box-shadow: var(--shadow);
}
.preview-nav:hover {
  background: #fff;
  transform: translateY(-50%) scale(1.07);
  box-shadow: var(--shadow-lg);
}
.preview-nav:active { transform: translateY(-50%) scale(0.94); }
.preview-modal.active .preview-nav { display: inline-flex; }
.preview-nav.prev { left: 20px; }
.preview-nav.next { right: 20px; }
.preview-nav:disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }
.preview-nav svg { width: 20px; height: 20px; stroke-width: 2.5; }

.preview-loading {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  z-index: 1002; pointer-events: none;
}
.preview-modal.active .preview-loading.active { display: flex; }

.spinner {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(10, 132, 255, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.zip-loading {
  display: none;
  flex-direction: column;
  align-items: center; justify-content: center;
  padding: 70px 20px; gap: 16px; color: var(--muted);
}
.zip-loading p { margin: 0; font-size: 13.5px; font-weight: 500; }

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

@keyframes jump-glow {
  0%, 100% { box-shadow: 0 0 10px 3px rgba(10, 132, 255, 0.5); }
  50%      { box-shadow: 0 0 26px 9px rgba(10, 132, 255, 0.7); }
}

.jump-highlight {
  animation: jump-glow 0.7s ease-in-out 3;
  outline: 2px solid var(--accent) !important;
  outline-offset: 3px !important;
  border-radius: var(--r-sm);
  position: relative; z-index: 10;
}

.swipe-edge {
  position: fixed; pointer-events: none; z-index: 1005;
  opacity: 0; transition: opacity 0.15s ease;
}
.swipe-edge.visible { opacity: 1; }
.swipe-edge-left, .swipe-edge-right {
  top: 0; bottom: 0; width: 80px;
  display: flex; align-items: center; justify-content: center;
}
.swipe-edge-left  { left: 0;  background: linear-gradient(to right, rgba(10, 132, 255, 0.22), transparent); }
.swipe-edge-right { right: 0; background: linear-gradient(to left,  rgba(10, 132, 255, 0.22), transparent); }
.swipe-edge-down {
  top: 0; left: 0; right: 0; height: 80px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(to bottom, rgba(10, 132, 255, 0.22), transparent);
}
.swipe-edge-up {
  bottom: 0; left: 0; right: 0; height: 88px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s;
}
.swipe-edge-up svg {
  width: 30px; height: 30px;
  stroke-width: 1.8;
  transition: stroke 0.1s, fill 0.1s;
}
.swipe-edge-up.will-add {
  background: linear-gradient(to top, rgba(245, 163, 0, 0.28), transparent);
}
.swipe-edge-up.will-add svg {
  stroke: var(--gold);
  fill: var(--gold);
}
.swipe-edge-up.will-remove {
  background: linear-gradient(to top, rgba(255, 255, 255, 0.2), transparent);
}
.swipe-edge-up.will-remove svg {
  stroke: rgba(255, 255, 255, 0.7);
  fill: none;
}
.swipe-edge svg { width: 28px; height: 28px; stroke: rgba(255, 255, 255, 0.85); }
.swipe-indicator { display: none; }

/* Preview chrome: one rail, so the buttons space themselves and hiding one
   (delete on a folder you don't own, favourite on touch) leaves no hole. */
.preview-actions {
  position: fixed; top: 20px; right: 20px;
  z-index: 1003;
  display: flex; align-items: center; gap: 8px;
}
.preview-action {
  width: 40px; height: 40px;
  flex-shrink: 0;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--r);
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  transition: background 0.2s, transform 0.2s var(--ease), box-shadow 0.2s;
}
.preview-action svg {
  width: 18px; height: 18px;
  stroke: var(--text-soft); fill: none;
  transition: stroke 0.2s, fill 0.2s, transform 0.2s var(--ease);
}
.preview-action:hover { background: #fff; transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.preview-action:active { transform: scale(0.94); }

.favorite-btn.is-favorite svg { stroke: var(--gold); fill: var(--gold); transform: scale(1.1); }
.favorite-btn:hover svg { stroke: var(--gold); }
.delete-btn:hover svg { stroke: var(--danger); }
.close-preview svg { stroke: var(--text); }

/* Touch: swipe gestures replace these, and the OS chrome needs the corner. */
@media (max-width: 768px), (pointer: coarse) {
  .preview-actions { display: none; }
}

/* Favorites filter keeps the gold accent instead of the generic blue toggle. */
.favorites-filter-btn.active {
  background: rgba(245, 163, 0, 0.14);
  border-color: rgba(245, 163, 0, 0.4);
  color: #b5790a;
}
.favorites-filter-btn.active:hover { background: rgba(245, 163, 0, 0.22); }
.favorites-filter-btn.active > svg { fill: var(--gold); stroke: var(--gold); animation: heart-pulse 0.45s var(--ease); }

@keyframes heart-pulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.3); }
  60% { transform: scale(0.92); }
  100% { transform: scale(1); }
}

/* Context menu = a .menu placed at the pointer. */
.context-menu { min-width: 210px; }
.context-menu-item.jump-to { color: var(--accent-strong); }
.context-menu-item.remove,
.context-menu-item.delete { color: var(--danger); }
.context-menu-item.remove:hover,
.context-menu-item.delete:hover { background: var(--danger-soft); }

/* Direction arrow: a masked chevron matching the toolbar's stroked icons,
   instead of the ▲/▼ text glyphs (which render in the font's own weight and
   sit off the text baseline). One shape, rotated for descending. */
.sort-dropdown-item .sort-indicator {
  width: 13px; height: 13px;
  flex-shrink: 0;
  opacity: 0;
  background: var(--accent-strong);
  -webkit-mask: var(--chevron-up) center / contain no-repeat;
  mask: var(--chevron-up) center / contain no-repeat;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}
.sort-dropdown-item.active .sort-indicator { opacity: 1; }
.sort-dropdown-item.active.desc .sort-indicator { transform: rotate(180deg); }

/* The caret rests pointing up and swings down while the menu is open (openMenu
   puts .active on the anchor button). */
#sortDropdownBtn { cursor: default; }
#sortDropdownBtn .btn-caret {
  transform: rotate(180deg);
  transition: transform 0.24s var(--ease);
}
#sortDropdownBtn.active .btn-caret { transform: rotate(0deg); }

/* Search overlays the rail, but a badge sits at top:-5px on its button and so
   pokes out above the overlay's inset edge. Visibility, not display — the JS
   owns display on these. */
.toolbar:has(.tb-search.search-open) .badge { visibility: hidden; }

.modal {
  display: none; position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(28, 34, 58, 0.5);
  z-index: 1000;
  align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.modal.active { display: flex; animation: overlay-in 0.25s var(--ease); }

.modal-content {
  background: var(--glass-strong);
  padding: 26px;
  border-radius: var(--r-xl);
  max-width: 420px; width: 100%;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  animation: modal-pop 0.34s var(--ease);
}
/* Three widths, nothing hand-rolled per modal. */
.modal-sm { max-width: 380px; }
.modal-md { max-width: 470px; }
.modal-lg { max-width: 540px; }

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-content h2 {
  font-size: 18px;
  margin-bottom: 6px; font-weight: 700;
  letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 10px;
  user-select: none;
  -webkit-user-select: none;
}
.modal-content h2 svg { width: 20px; height: 20px; stroke: var(--accent); fill: none; flex-shrink: 0; }
.modal-content > h2 + .settings-section,
.modal-content > h2 + .password-field,
.modal-content > h2 + input,
.modal-content > h2 + .upload-dropzone { margin-top: 18px; }

.modal-content input {
  width: 100%;
  height: 44px;
  padding: 0 15px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  color: var(--text);
  font-size: 14px;
  font-family: var(--sans);
  font-weight: 500;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  touch-action: manipulation;
  -webkit-user-select: text;
  user-select: text;
}
.modal-content input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.modal-content input::placeholder { color: var(--muted); }
.modal-content input[readonly] { color: var(--text-soft); }

/* Every modal footer is separated from the body the same way, so no dialog ends
   up with its confirm button crowding whatever sits above it. */
.modal-buttons {
  display: flex; gap: 10px; justify-content: flex-end; align-items: center;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline-2);
}

.modal-hint { color: var(--text-soft); font-size: 13px; line-height: 1.5; margin: 12px 0 4px; }
.modal-hint:empty { display: none; }

.code-input {
  text-transform: uppercase;
  letter-spacing: 3px;
  text-align: center;
  font-size: 17px !important;
  font-family: var(--mono) !important;
}
.qr-block { text-align: center; margin-top: 14px; }

.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 32px; height: 32px; border: none; background: transparent;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  color: var(--muted); border-radius: var(--r-xs);
  transition: color 0.2s, background 0.2s;
}
.password-toggle:hover { color: var(--accent); background: var(--accent-soft); }
.password-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; }

.vault-item { padding: 14px 18px; }
.vault-icon-btn {
  width: 36px; height: 36px; margin-right: 13px; flex-shrink: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: var(--accent-soft); cursor: pointer;
  transition: background 0.2s, transform 0.15s var(--ease), box-shadow 0.2s;
}
.vault-icon-btn:hover { background: rgba(10, 132, 255, 0.18); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.vault-icon-btn:active { transform: scale(0.94); }
.vault-icon-btn svg.file-icon { width: 19px; height: 19px; margin-right: 0; stroke: var(--accent); }
.vault-item:hover .vault-icon-btn svg.file-icon { stroke: var(--accent); }
.vault-item .file-name { font-weight: 600; }

.vault-icon-btn.is-static { cursor: default; }
.vault-icon-btn.is-static:hover { background: var(--accent-soft); transform: none; box-shadow: none; }
.vault-icon-btn.is-static:active { transform: none; }

.vault-visibility {
  display: inline-flex; align-items: center; gap: 6px;
  margin-right: 10px; flex-shrink: 0;
  padding: 5px 11px 5px 9px;
  font-size: 12px; font-weight: 600; line-height: 1;
  border-radius: var(--r-sm); border: 1px solid transparent;
  cursor: pointer; user-select: none;
  transition: background 0.18s, border-color 0.18s, transform 0.12s var(--ease), box-shadow 0.18s;
}
.vault-visibility svg { width: 13px; height: 13px; transition: transform 0.2s var(--ease); }
.vault-visibility:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.vault-visibility:hover svg { transform: scale(1.18) rotate(-8deg); }
.vault-visibility:active { transform: scale(0.96); }
.vault-visibility:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }
.vault-visibility:disabled svg { transform: none; }

.vault-visibility.is-public {
  color: var(--success);
  background: rgba(43, 189, 79, 0.12);
  border-color: rgba(43, 189, 79, 0.28);
}
.vault-visibility.is-public:hover { background: rgba(43, 189, 79, 0.2); }
.vault-visibility.is-private {
  color: #9a7400;
  background: rgba(245, 163, 0, 0.13);
  border-color: rgba(245, 163, 0, 0.3);
}
.vault-visibility.is-private:hover { background: rgba(245, 163, 0, 0.22); }

/* Tighter cascade: 26ms apart instead of 50ms, so the last visible row has
   landed before the old timing had reached row four. */
.vault-item { animation: settle 0.38s var(--ease) both; }
.vault-item:nth-child(1) { animation-delay: 0.10s; }
.vault-item:nth-child(2) { animation-delay: 0.126s; }
.vault-item:nth-child(3) { animation-delay: 0.152s; }
.vault-item:nth-child(4) { animation-delay: 0.178s; }
.vault-item:nth-child(5) { animation-delay: 0.204s; }
.vault-item:nth-child(6) { animation-delay: 0.23s; }
.vault-item:nth-child(7) { animation-delay: 0.256s; }
.vault-item:nth-child(8) { animation-delay: 0.282s; }
.vault-item:nth-child(n+9) { animation-delay: 0.3s; }

@media (prefers-reduced-motion: reduce) {
  .vault-item, #zipList, #contentArea, .header { animation: none; }
}

.icon-picker {
  position: fixed; z-index: 10002; display: none;
  width: 268px; padding: 12px;
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
.icon-picker.active { display: block; animation: pop 0.18s var(--ease); }
.icon-picker-title { font-size: 12px; font-weight: 700; color: var(--text-soft); margin: 0 2px 10px; }
.icon-picker-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px;
  max-height: 216px; overflow-y: auto; padding-right: 4px;
  overscroll-behavior: contain;
}
.icon-picker-item {
  height: 44px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.55); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.12s var(--ease), border-color 0.15s;
}
/* ponytail: hover:hover keeps touch from sticking the highlight on whatever
   icon your finger started the scroll on */
@media (hover: hover) {
  .icon-picker-item:hover { background: var(--accent-soft); transform: translateY(-2px); }
}
.icon-picker-item.active { background: var(--accent-soft); border-color: rgba(10, 132, 255, 0.45); }
.icon-picker-item svg.file-icon { width: 21px; height: 21px; margin-right: 0; stroke: var(--accent); }
.icon-picker-grid::-webkit-scrollbar { width: 7px; }
.icon-picker-grid::-webkit-scrollbar-track { background: transparent; }
.icon-picker-grid::-webkit-scrollbar-thumb { background: rgba(28, 32, 56, 0.18); border-radius: 999px; }

.settings-section {
  margin-top: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
}
.settings-section-title { margin: 0 0 8px 0; font-size: 13px; font-weight: 700; color: var(--text); }
.settings-section-desc { margin: 0 0 14px 0; font-size: 13px; color: var(--text-soft); line-height: 1.5; }
.sync-row { display: flex; gap: 10px; margin-bottom: 14px; }
.sync-row-last { margin-bottom: 0; }
.sync-code-box {
  display: none; text-align: center; padding: 16px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--hairline);
  border-radius: var(--r); margin-bottom: 14px;
}
.sync-code-value {
  font-size: 30px; font-family: var(--mono); font-weight: 700;
  letter-spacing: 6px; color: var(--accent-strong);
}
.sync-code-timer { font-size: 12px; color: var(--muted); margin-top: 8px; }
.sync-qr { margin-top: 15px; display: flex; justify-content: center; }
.sync-code-hint { font-size: 11px; color: var(--faint); margin-top: 8px; }
.btn-danger-block {
  width: 100%;
  background: var(--danger);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(255, 59, 48, 0.3);
}
.btn-danger-block:hover { background: #e02e24; color: #fff; box-shadow: 0 10px 22px rgba(255, 59, 48, 0.4); }
.btn-danger-block svg { stroke: #fff; }

.upload-dropzone {
  border: 2px dashed var(--faint);
  border-radius: var(--r-lg);
  padding: 40px 20px;
  text-align: center;
  margin: 20px 0;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.4);
}
.upload-dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.upload-dropzone svg { stroke: var(--muted); margin-bottom: 12px; }
.upload-dropzone-title { color: var(--text-soft); margin: 0 0 6px 0; font-weight: 600; font-size: 14px; }
.upload-dropzone-sub { color: var(--muted); font-size: 13px; margin: 0; }

.upload-file-row {
  display: flex; align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  margin-bottom: 8px;
}
.upload-file-row.is-done { opacity: 0.65; }
.upload-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 500; }
.upload-file-size { color: var(--muted); font-size: 12px; margin: 0 12px; font-variant-numeric: tabular-nums; }
.upload-file-status { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; position: relative; }
.upload-file-status span { position: absolute; font-size: 9px; color: var(--success); font-weight: 700; }

.upload-progress-wrap { margin-bottom: 15px; }
.progress-head {
  display: flex; justify-content: space-between; margin-bottom: 8px;
  color: var(--text-soft); font-size: 13px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.progress-track { height: 7px; background: rgba(28, 32, 56, 0.1); border-radius: 999px; overflow: hidden; }
.progress-track .bar { height: 100%; width: 0%; border-radius: 999px; }
.progress-track .bar.accent { background: linear-gradient(90deg, var(--success), #5fd97a); transition: width 0.2s; }
.progress-track .bar.danger { background: linear-gradient(90deg, var(--danger), #ff7b73); transition: width 0.15s; }

.confirm-message { color: var(--text-soft); font-size: 14px; line-height: 1.6; margin: 16px 0; }

.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 90px 20px;
  color: var(--muted); text-align: center;
}
.empty-state svg {
  width: 58px; height: 58px;
  /* fill:none was missing — the icon rendered as a solid black blob. */
  fill: none; stroke: var(--faint); stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
  margin-bottom: 16px;
}
.empty-state p { font-size: 15px; font-weight: 500; }

.empty-folder-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 70px 20px;
  color: var(--muted); text-align: center;
  grid-column: 1 / -1; width: 100%;
  background: var(--glass);
  border-radius: var(--r-lg);
  border: 1px solid var(--glass-border);
}
.empty-folder-state svg { width: 58px; height: 58px; stroke: var(--faint); margin-bottom: 16px; }
.empty-folder-state p { font-size: 15px; margin: 0 0 8px 0; color: var(--text-soft); font-weight: 500; }
.empty-folder-state .empty-hint { font-size: 12.5px; color: var(--muted); }

#uploadFileList::-webkit-scrollbar { width: 7px; }
#uploadFileList::-webkit-scrollbar-track { background: transparent; border-radius: 999px; }
#uploadFileList::-webkit-scrollbar-thumb { background: rgba(28, 32, 56, 0.18); border-radius: 999px; }
#uploadFileList::-webkit-scrollbar-thumb:hover { background: var(--accent); }
#uploadFileList { scrollbar-width: thin; scrollbar-color: rgba(28, 32, 56, 0.2) transparent; max-height: 200px; overflow-y: auto; margin-bottom: 15px; }

/* Delete mode: same paint-cheap design as select mode — NO per-item checkbox, so
   entering/leaving the mode doesn't repaint/reflow the whole grid (that was the lag
   on both list and thumbnails). Unselected items get only a cursor; selected items
   get a red badge + tint. */
.delete-mode .file-item,
.delete-mode .file-card { cursor: pointer; position: relative; }
.delete-mode .file-item.selected,
.delete-mode .file-card.selected {
  background: rgba(255, 59, 48, 0.1);
  border-color: rgba(255, 59, 48, 0.4);
}
.delete-mode .file-card.selected::after,
.delete-mode .file-item.selected::after {
  content: '';
  position: absolute; left: 8px; top: 8px;
  width: 20px; height: 20px; z-index: 11;
  background-color: var(--danger);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 11px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(255, 59, 48, 0.4);
}
/* list rows: badge on the right so it doesn't sit on the file icon */
.delete-mode .file-item.selected::after { left: auto; right: 16px; top: 50%; transform: translateY(-50%); }

.selection-box {
  position: fixed;
  border: 1.5px solid var(--accent);
  background: rgba(10, 132, 255, 0.1);
  pointer-events: none; z-index: 1000; border-radius: 6px;
}

/* Select-to-move mode. Deliberately paint-cheap: unselected items get nothing
   but a cursor, so entering/leaving the mode doesn't repaint the whole grid.
   Only selected items render a badge. */
.select-mode .file-item,
.select-mode .file-card { cursor: pointer; position: relative; }
.select-mode .file-item.selected,
.select-mode .file-card.selected {
  background: var(--accent-soft);
  border-color: var(--accent-ring);
}
/* checkmark badge only on the selected items */
.select-mode .file-card.selected::after,
.select-mode .file-item.selected::after {
  content: '';
  position: absolute; left: 8px; top: 8px;
  width: 20px; height: 20px; z-index: 11;
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 12px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(10, 132, 255, 0.35);
}
/* list rows: badge on the right so it doesn't sit on the file icon */
.select-mode .file-item.selected::after { left: auto; right: 16px; top: 50%; transform: translateY(-50%); }
/* Give a selected list row room on the right so the badge doesn't crowd the size/date
   or sit against the edge. Only the selected row reflows — mode-entry stays cheap. */
.select-mode .file-item.selected,
.delete-mode .file-item.selected { padding-right: 50px; }

/* ─────────────────────────────────────────────────────────────────────────────
   MODE BAR — the contextual toolbar for select / delete mode. Same rail
   mechanics as the main toolbar: one row, scrolls rather than wraps.
   ───────────────────────────────────────────────────────────────────────────── */
.mode-bar {
  display: none;
  align-items: center; gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 10px 8px 16px;
  border: 1px solid var(--accent-ring);
  border-radius: var(--r-lg);
  margin-bottom: 18px;
  /* ponytail: opaque bg — this bar slides in via `rise`, and a blurred backdrop
     re-samples every frame of that slide. */
  background: rgba(233, 242, 255, 0.96);
  box-shadow: var(--shadow-sm);
}
.mode-bar::-webkit-scrollbar { display: none; }
.mode-bar.active { display: flex; animation: rise 0.4s var(--ease); }
.mode-bar-count {
  color: var(--accent-strong);
  font-size: 13.5px; font-weight: 700;
  white-space: nowrap; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.mode-bar-danger { border-color: rgba(255, 59, 48, 0.25); background: rgba(255, 241, 240, 0.96); }
.mode-bar-danger .mode-bar-count { color: var(--danger); }

.move-picker-list {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
}
.move-picker-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hairline-2);
  font-size: 13.5px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.move-picker-item:last-child { border-bottom: none; }
.move-picker-item:hover { background: var(--accent-soft); color: var(--accent-strong); }
.move-picker-item svg { flex-shrink: 0; opacity: 0.6; }
.move-picker-item:hover svg { opacity: 1; stroke: var(--accent); }

#zipList {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: settle 0.44s var(--ease) 0.08s both;
}

#zipListLoading {
  display: none;
  flex-direction: column;
  align-items: center; justify-content: center;
  padding: 70px 20px; gap: 16px; color: var(--muted);
}

@media (max-width: 768px) {
  body {
    padding: 14px;
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  .header { padding: 18px 4px 18px; }
  .header h1 { font-size: 1.8rem; }
  /* No per-button `order` / width overrides any more: the rail scrolls, so the
     phone layout is the desktop layout. A new button needs nothing here. */
  .toolbar { padding: 7px; }
  .tb-search { inset: 7px; }
  .file-size { display: none; }
  .file-item { padding: 14px 14px; }
  .preview-modal { touch-action: none; }
  .preview-nav { display: none !important; }
  .preview-content { max-width: 100%; max-height: 100%; width: 100%; height: 100%; }
  .preview-content img,
  .preview-content video {
    max-width: 100%; max-height: 100vh; max-height: 100dvh;
    border-radius: 0; object-fit: contain; box-shadow: none;
  }
  .breadcrumb { padding: 11px 14px; font-size: 12.5px; flex-wrap: wrap; }
  .file-grid { gap: 8px; }
  .file-card-meta { padding: 8px 10px; }
  .file-card-name { font-size: 11.5px; }
  .file-card .favorite-overlay-btn { opacity: 1; }
}

@media (max-width: 480px) {
  .preview-nav { width: 38px; height: 38px; }
  .preview-nav svg { width: 15px; height: 15px; }
}

.file-card { position: relative; }
.file-card .favorite-overlay-btn {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s var(--ease); /* composited props only */
  z-index: 5;
  box-shadow: var(--shadow-sm);
}
.file-card:hover .favorite-overlay-btn { opacity: 1; }
.file-card .favorite-overlay-btn:hover {
  transform: scale(1.12);
  box-shadow: var(--shadow); /* snaps, no per-frame repaint */
}
.file-card .favorite-overlay-btn svg {
  width: 15px; height: 15px;
  stroke: var(--text-soft); fill: none;
  transition: stroke 0.2s, fill 0.2s;
}
.file-card .favorite-overlay-btn:hover svg { stroke: var(--gold); }
.file-card .favorite-overlay-btn.is-favorite svg { stroke: var(--gold); fill: var(--gold); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(28, 32, 56, 0.18); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(28, 32, 56, 0.3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.05ms !important;
  }
  body::before, body::after { animation: none !important; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Sorting tags. The chips are the one glassy thing left — panels and popovers
   are the shared .menu surface. Each tag's color arrives as --tag-color (set
   inline in tags.js) and everything tinted is derived from it.
   ───────────────────────────────────────────────────────────────────────────── */
#sortDropdownBtn.filtering {
  background: var(--accent-soft);
  border-color: var(--accent-ring);
  color: var(--accent-strong);
}

/* One tag per row in the sort menu: click to show only files carrying it. */
.sort-tag-item { gap: 9px; }
.sort-tag-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sort-tag-check { font-size: 11px; opacity: 0; color: var(--accent-strong); }
.sort-tag-item.active .sort-tag-check { opacity: 1; }

/* The tags panel is a .menu; only its width and rows are special. */
#tagsPanel { min-width: 272px; }
/* The assign dialog and the toolbar panel now render the exact same rows; this
   just gives the dialog's copy a surface to sit on. */
.tag-surface {
  margin-top: 14px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
}

.tag-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.15s;
}
.tag-row:not(.static):hover { background: var(--accent-soft); }
.tag-row.static { cursor: default; }
.tag-row.active { color: var(--accent-strong); font-weight: 600; }
.tag-row.active .tag-row-name::after { content: ' ✓'; }
.tag-dot {
  width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0;
  background: var(--tag-color);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.tag-row-icon, .sort-tag-item .tag-row-icon {
  width: 16px; height: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--tag-color);
}
.tag-row-icon .tag-icon { width: 16px; height: 16px; }
.tag-row-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-row-count { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
/* Small inline "remove" buttons (delete a tag, drop a queued upload) share one
   shape so they don't each invent a hover. */
.tag-row-del, .upload-file-remove {
  width: 24px; height: 24px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0; background: none; border: none; cursor: pointer;
  border-radius: var(--r-xs);
  color: var(--faint);
  transition: color 0.15s, background 0.15s;
}
.tag-row-del svg, .upload-file-remove svg { width: 14px; height: 14px; fill: none; }
.tag-row-del:hover, .upload-file-remove:hover { color: var(--danger); background: var(--danger-soft); }

/* Panel actions under the tag rows: hide the chips (view only, tags untouched)
   and export this vault's tag data. */
.tag-hide-row { margin-top: 4px; border-top: 1px solid var(--hairline-2); border-radius: 0; }
.tag-hide-row, .tag-export-row { color: var(--text-soft); }
.tag-hide-row .tag-hide-icon, .tag-export-row .tag-hide-icon {
  width: 15px; height: 15px; flex-shrink: 0; fill: none;
}
.tag-hide-row.active { color: var(--accent-strong); font-weight: 600; }

.tag-empty { padding: 8px 9px; font-size: 12.5px; color: var(--muted); }
.tag-panel-hint { padding: 7px 9px 2px; font-size: 11.5px; color: var(--faint); }

/* New-tag row: a field plus three same-sized square controls (icon, colour,
   add). Nothing here is a special shape any more. */
.tag-new-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; padding-top: 10px;
  border-top: 1px solid var(--hairline-2);
}
.tag-new-row input[type="text"] {
  flex: 1; min-width: 0; margin: 0;
  height: var(--ctl-h-sm);
  padding: 0 11px;
  font: 500 13px var(--sans);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: #fff; color: var(--text);
  transition: border-color 0.18s, box-shadow 0.18s;
}
.tag-new-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* ── Quick sort ──
   Same tag rows as the assign dialog, plus a contact sheet and a number in
   front of every row. The number comes from a CSS counter, so it always
   matches the 1-9 key that toggles that row - nothing to keep in sync. */
.qs-count { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.qs-stage {
  position: relative;
  width: 100%; margin-top: 16px;
  aspect-ratio: 640 / 360;      /* fixed: playing a vertical clip must not resize the dialog */
  background: #000;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.qs-sheet, .qs-video {
  display: block; width: 100%; height: 100%;
  object-fit: contain;          /* black bars rather than a crop */
}
.qs-sheet { cursor: pointer; }
.qs-sheet[hidden], .qs-video[hidden] { display: none; }
.qs-sheet.loading { opacity: 0.35; }
/* One line, always. A wrapping filename resized the dialog between files and
   moved the buttons out from under the cursor. */
.qs-nameline { display: flex; align-items: baseline; gap: 10px; margin-top: 10px; }
.qs-name {
  flex: 1; min-width: 0; margin: 0; font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qs-pos { flex-shrink: 0; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.qs-play svg { width: 15px; height: 15px; fill: none; }
.qs-fav.is-favorite { color: var(--gold); }
.qs-fav.is-favorite svg { fill: var(--gold); }
/* Play / favourite / delete act on this file; prev / next / done are navigation. */
#qsDelete { margin-right: auto; }
.qs-tags .tag-rows { counter-reset: qsn; }
.qs-tags .tag-row::before {
  counter-increment: qsn;
  content: counter(qsn);
  width: 18px; flex-shrink: 0;
  font: 600 11px var(--mono);
  color: var(--faint);
  text-align: center;
}
.qs-tags .tag-row.active::before { color: var(--accent-strong); }
/* The tag list is the one part that can't be a fixed height (it grows with the
   number of tags), so scroll it instead of letting the dialog resize. */
.qs-tags .tag-rows { max-height: 168px; overflow-y: auto; }

/* Manage mode swaps the dot for a picker and the name for a field. Both keep
   the row's height so the panel doesn't jump when it opens. */
.tag-row-color .tag-color-btn { width: 20px; height: 20px; border-width: 1.5px; }
.tag-row-rename {
  min-width: 0; height: 24px; padding: 0 6px;
  font: 500 13.5px var(--sans); color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
}
.tag-row-rename:hover { border-color: var(--hairline); }
.tag-row-rename:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.qs-keys { margin: 10px 2px 0; font-size: 11.5px; color: var(--faint); }

/* ── Color picker: swatch button → saturation/brightness pad + hue + hex ── */
.tag-color-wrap, .tag-icon-wrap { position: relative; flex-shrink: 0; line-height: 0; }
/* Same square as the icon and add buttons it sits between — it's a control, so
   it follows the control shape, not the round-indicator shape. */
.tag-color-btn {
  width: var(--ctl-h-sm); height: var(--ctl-h-sm); padding: 0;
  border-radius: var(--r-sm);
  border: 2px solid #fff;
  background: var(--tag-color);
  cursor: pointer;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--tag-color) 42%, transparent),
              0 0 0 1px var(--hairline);
  transition: transform 0.18s var(--ease);
}
.tag-icon-btn {
  width: var(--ctl-h-sm); height: var(--ctl-h-sm); padding: 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: #fff;
  color: var(--text-soft);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.18s var(--ease), color 0.18s var(--ease), background 0.18s;
}
.tag-icon-btn:hover { background: var(--accent-soft); color: var(--accent-strong); }
.tag-icon-btn .tag-icon { width: 16px; height: 16px; }
.tag-color-btn:hover { transform: scale(1.08); }
.tag-color-btn:active, .tag-icon-btn:active { transform: scale(0.94); }

.tag-color-pop, .tag-icon-pop {
  display: none;
  /* opens downward: the new-tag row sits at the bottom of the panel, so opening
     upward would cover the tag list it belongs to */
  position: absolute; top: calc(100% + 10px); right: -4px;
  z-index: 120;
  padding: 11px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.tag-color-pop.active, .tag-icon-pop.active { display: block; animation: pop 0.16s var(--ease); }

.tag-sv-pad {
  position: relative;
  width: 176px; height: 112px;
  border-radius: var(--r-sm);
  cursor: crosshair;
  touch-action: none;
  border: 1px solid var(--hairline);
  background:
    linear-gradient(to top, #000, rgba(0, 0, 0, 0)),
    linear-gradient(to right, #fff, hsl(var(--hue, 210), 100%, 50%));
}
.tag-sv-knob {
  position: absolute;
  width: 15px; height: 15px;
  margin: -7.5px 0 0 -7.5px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--tag-color);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.tag-hue {
  -webkit-appearance: none; appearance: none;
  display: block;
  width: 100%; height: 12px;
  margin: 11px 0 0;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: linear-gradient(to right,
    #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.tag-hue::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.18);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.32);
  cursor: pointer;
}
.tag-hue::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.18);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.32);
  cursor: pointer;
}
.tag-hex-row {
  display: flex; align-items: center; gap: 4px;
  margin-top: 11px; padding-top: 10px;
  border-top: 1px solid var(--hairline-2);
}
.tag-hex-row span { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--muted); }
.tag-hex-row input {
  width: 100%; min-width: 0; margin: 0;
  height: 28px; padding: 0 10px;
  font-family: var(--mono); font-size: 12.5px; letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--hairline); border-radius: var(--r-xs);
}
.tag-hex-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* ── Icon picker: same library the folder icons use ── */
.tag-icon-pop { width: 202px; }
.tag-icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.tag-icon-item {
  width: 28px; height: 28px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent; border-radius: 8px;
  color: var(--text-soft); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tag-icon-item .tag-icon { width: 17px; height: 17px; }
.tag-icon-item:hover { background: var(--accent-soft); color: var(--accent-strong); }
.tag-icon-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-ring);
  color: var(--accent-strong);
}

.tag-icon { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Chips: free-floating pills, one shape, two surfaces.
   Everything visible is derived from --tag-color (set inline in tags.js) with
   color-mix, so a chip is one hue at three weights — fill, ring, label — and a
   new tag colour needs no CSS. The old design put the colour in a 6px dot on a
   shared grey slab, which made two tags indistinguishable at a glance; here the
   whole pill carries the hue, and it still doesn't shout because the *fill* is
   where the colour gets diluted. No dot: the pill itself is the swatch.
     • tile — dark hue-shaded pill floating over the image, light label
     • row  — pale hue-tinted pill on the white row, dark label
   ── */
.tag-badges { display: flex; gap: 4px; max-width: 100%; min-width: 0; }
.thumb .tag-badges {
  position: absolute; bottom: 7px; left: 7px;
  max-width: calc(100% - 14px);
  min-width: 0;
}
.file-item .tag-badges { margin-right: 12px; overflow: hidden; }

.tag-badge {
  display: inline-flex; align-items: center; gap: 0.42em;
  min-width: 0;
  /* Inter, not the --sans stack: on macOS --sans resolves to SF Pro, so pinning
     the (already-loaded) Inter is what makes a chip read as metadata rather than
     as more filename. Its bigger x-height also survives the 9.5px floor on a
     small tile, where SF Pro's tight apertures start to mush. */
  font-family: 'Inter', var(--sans);
  font-weight: 700; line-height: 1;
  font-size: 11px;
  letter-spacing: 0.005em;
  padding: 0.42em 0.66em;
  border-radius: 999px;   /* a passive indicator, so: pill (see the shape rule up top) */
  max-width: 10em;
}
.tag-badge .tag-icon {
  width: 1.05em; height: 1.05em; flex-shrink: 0; stroke-width: 2.3;
  color: var(--tag-color);
}
.tag-badge-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* On a tile the chip has to survive whatever pixels are under it: a dark
   translucent body tinted with the tag's own hue, a hairline of the same hue to
   cut it out of a busy frame, and a light tint of the hue for the label. */
.thumb .tag-badge {
  font-size: clamp(9.5px, calc(var(--thumb-size, 140px) * 0.075), 13.5px);
  color: color-mix(in srgb, var(--tag-color) 38%, #fff);
  background: color-mix(in srgb, var(--tag-color) 26%, rgba(12, 16, 26, 0.82));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tag-color) 32%, rgba(255, 255, 255, 0.14)),
              0 2px 7px rgba(8, 12, 22, 0.36);
}
.thumb .tag-badge .tag-icon { color: color-mix(in srgb, var(--tag-color) 45%, #fff); }
/* Three names never fit a tile without shredding to "Ac…" — past two, only the
   first keeps its label and the rest shrink to a bead of their colour (an icon
   if the tag has one, otherwise the bare pill). Full names stay on the tooltips. */
.thumb .tag-badges:has(> .tag-badge:nth-child(3)) .tag-badge:not(:first-child):not(.tag-badge-more) {
  /* fixed square, not padding — with the label hidden there's no in-flow child
     left to give the pill its height. "+2" keeps its padding, it has text. */
  padding: 0;
  width: 1.75em; height: 1.75em;
  justify-content: center;
}
.thumb .tag-badges:has(> .tag-badge:nth-child(3)) .tag-badge:not(:first-child) .tag-badge-label {
  display: none;
}

/* In list view the row is already light, so the pill inverts: a wash of the hue
   for the fill and ring, the hue darkened into near-text for the label. The
   fill is mixed with `transparent`, not white, so the row's blue hover and the
   selected state read straight through it. */
.file-item .tag-badge {
  color: color-mix(in srgb, var(--tag-color) 42%, #1e2330);
  background: color-mix(in srgb, var(--tag-color) 11%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tag-color) 22%, transparent);
}

/* "+2" carries no tag of its own, so it borrows a neutral one and every rule
   above styles it for free. */
.tag-badge-more { --tag-color: #98a0b0; }

/* Hover hint (js/utils.js). Same surface as .menu one rung down the radius
   ladder — it's a popover, just a very small one. Fixed-positioned because the
   toolbar rail scrolls and would clip an absolutely-placed tooltip. */
#tooltip {
  position: fixed; top: 0; left: 0;
  z-index: 10005;
  pointer-events: none;
  padding: 6px 10px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  transform: scale(0.96) translateY(-2px);
  transform-origin: top center;
  transition: opacity 0.14s var(--ease), transform 0.14s var(--ease);
}
/* Flipped above the button near the bottom of the viewport: grow from the edge
   nearest the button, so it still reads as coming out of it. */
#tooltip.above { transform-origin: bottom center; transform: scale(0.96) translateY(2px); }
#tooltip.visible { opacity: 1; transform: none; }
