/* ==========================================================================
   files.css — owner: FILE-BROWSER
   Uses ONLY colour tokens from tokens.css. Spacing/radii are written as
   literals from the 4px brand scale so this file never renders broken if a
   token is missing. Additive brand tokens (--accent-soft, --scrim, --hairline,
   --radius-pill) are used with a color-mix fallback for the same reason.
   ========================================================================== */

/* ---------- local fallbacks (no-ops when tokens.css already defines them) -- */
.fb {
  --fb-soft: var(--accent-soft, color-mix(in srgb, var(--accent) 18%, transparent));
  --fb-scrim: var(--scrim, rgba(12, 18, 21, .46));
  --fb-hair: var(--hairline, rgba(255, 255, 255, .05));
  --fb-hover: color-mix(in srgb, var(--accent) 5%, transparent);
  --fb-row-h: 40px;
  --fb-ease: var(--ease, cubic-bezier(.2, .8, .2, 1));
  --fb-ease-in: var(--ease-in, cubic-bezier(.4, 0, 1, 1));
  --fb-ease-out: var(--ease-out, cubic-bezier(.16, 1, .3, 1));
  --fb-spring: var(--ease-spring, cubic-bezier(.34, 1.28, .52, 1));
  --fb-fast: var(--dur-fast, 120ms);
  --fb-dur: var(--dur, 200ms);
  --fb-slow: var(--dur-slow, 320ms);
}

/* ---------- shell ---------- */
.fb {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  position: relative;
  color: var(--text);
  font-family: var(--font-sans);
}

.fb *,
.fb *::before,
.fb *::after { box-sizing: border-box; }

.fb-head {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

@media (min-width: 901px) {
  .fb-head { padding-left: 24px; padding-right: 24px; }
}

/* ---------- breadcrumbs ---------- */
.fb-crumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 28px;
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.fb-crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 240px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius, 9px);
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: .01em;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--fb-fast) var(--fb-ease),
              color var(--fb-fast) var(--fb-ease),
              border-color var(--fb-fast) var(--fb-ease);
}

.fb-crumb .ico { flex: 0 0 auto; }
.fb-crumb-txt { overflow: hidden; text-overflow: ellipsis; }

.fb-crumb:hover { background: var(--fb-hover); color: var(--text); }

.fb-crumb.is-current {
  color: var(--text);
  font-weight: 600;
  cursor: default;
  max-width: none;
}

.fb-crumb.is-current:hover { background: transparent; }

.fb-crumb.is-droptarget {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-hi);
}

.fb-crumb-sep {
  flex: 0 0 auto;
  color: var(--text-mute);
  opacity: .7;
  display: inline-flex;
}

/* ---------- toolbar ---------- */
.fb-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: nowrap;
}

.fb-tools-spacer { flex: 1 1 auto; min-width: 4px; }

.fb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  flex: 0 0 auto;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius, 9px);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--fb-fast) var(--fb-ease),
              border-color var(--fb-fast) var(--fb-ease),
              color var(--fb-fast) var(--fb-ease),
              transform var(--dur-press, 90ms) var(--fb-ease);
}

.fb-btn:hover { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.fb-btn:active { transform: scale(.972); }
.fb-btn[disabled] { opacity: .5; pointer-events: none; }

.fb-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.fb-btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.fb-btn.primary:active { transform: scale(.972) translateY(.5px); }

.fb-btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.fb-btn.danger:hover { background: var(--danger-soft, color-mix(in srgb, var(--danger) 12%, transparent)); }

.fb-icobtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius, 9px);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: background var(--fb-fast) var(--fb-ease),
              color var(--fb-fast) var(--fb-ease),
              border-color var(--fb-fast) var(--fb-ease),
              transform var(--dur-press, 90ms) var(--fb-ease);
}

.fb-icobtn::after {
  content: "";
  position: absolute;
  inset: -5px;
}

.fb-icobtn:hover { background: var(--fb-hover); color: var(--text); }
.fb-icobtn:active { transform: scale(.94); }
.fb-icobtn.is-on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-hi); }

/* segmented view toggle */
.fb-seg {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius, 9px);
  background: var(--surface-2);
}

.fb-seg button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
  transition: background var(--fb-fast) var(--fb-ease), color var(--fb-fast) var(--fb-ease);
}

.fb-seg button:hover { color: var(--text); }
.fb-seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow-1); }

/* search */
.fb-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  min-width: 120px;
  max-width: 380px;
}

.fb-search > .ico {
  position: absolute;
  left: 10px;
  color: var(--text-mute);
  pointer-events: none;
}

.fb-search input {
  width: 100%;
  height: 34px;
  padding: 0 32px 0 34px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius, 9px);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  transition: border-color var(--fb-fast) var(--fb-ease), box-shadow var(--fb-fast) var(--fb-ease);
}

.fb-search input::placeholder { color: var(--text-mute); }

.fb-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--fb-soft);
}

.fb-search-clear {
  position: absolute;
  right: 4px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
}

.fb-search-clear:hover { background: var(--surface-2); color: var(--text); }
.fb-search.has-value .fb-search-clear { display: inline-flex; }

/* search context strip */
.fb-searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius, 9px);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12.5px;
  letter-spacing: .005em;
  animation: fb-fade var(--fb-fast) var(--fb-ease) both;
}

.fb-searchbar strong { color: var(--text); font-weight: 600; }
.fb-searchbar .fb-btn { height: 28px; padding: 0 10px; font-size: 12.5px; margin-left: auto; }

/* ---------- body / scroll area ---------- */
.fb-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 240px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

@media (min-width: 901px) {
  .fb-body { padding-left: 24px; padding-right: 24px; }
}

.fb-stage { position: relative; min-height: 200px; }

/* ---------- LIST VIEW ---------- */
.fb-list {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius, 9px);
  background: var(--surface);
  overflow: hidden;
}

.fb-lhead,
.fb-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px 156px 84px;
  align-items: center;
  gap: 12px;
}

.fb-lhead {
  position: sticky;
  top: 0;
  z-index: 12;
  height: 34px;
  padding: 0 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.fb-lhead button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-mute);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--fb-fast) var(--fb-ease);
}

.fb-lhead button:hover { color: var(--text); }
.fb-lhead button.is-sorted { color: var(--accent-text); }
.fb-lhead .ico { opacity: 0; transition: opacity var(--fb-fast) var(--fb-ease); }
.fb-lhead button.is-sorted .ico { opacity: 1; }
.fb-lhead .col-size,
.fb-lhead .col-mtime,
.fb-lhead .col-type { justify-content: flex-start; }

.fb-row {
  position: relative;
  height: var(--fb-row-h);
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--fb-fast) var(--fb-ease),
              box-shadow var(--fb-fast) var(--fb-ease),
              transform var(--dur-press, 90ms) var(--fb-ease);
}

.fb-row:last-child { border-bottom: 0; }
.fb-row:hover { background: var(--fb-hover); }
.fb-row:active { transform: scale(.994); }

.fb-row.is-selected {
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.fb-row.is-selected .fb-meta { color: var(--text-dim); }

.fb-row.is-cursor::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.fb-row.is-droptarget,
.fb-tile.is-droptarget {
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.fb-row.is-dragging,
.fb-tile.is-dragging { opacity: .45; }

.fb-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.fb-name-txt {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  unicode-bidi: plaintext;
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
}

/* .ico-ft (colour) comes from tokens.css; only alignment is set here */
.fb-row .ico-ft,
.fb-tile .ico-ft { flex: 0 0 auto; }

.fb-meta {
  font-size: 12.5px;
  font-weight: 450;
  line-height: 1.3;
  letter-spacing: .005em;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fb-type-chip {
  display: inline-block;
  max-width: 100%;
  padding: 2px 6px;
  border-radius: var(--radius-sm, 5px);
  background: color-mix(in srgb, var(--ft, var(--text-mute)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--ft, var(--text-mute)) 30%, transparent);
  color: var(--ft, var(--text-mute));
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.4;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* the containing-folder line shown in search results */
.fb-row.is-result { height: auto; min-height: 52px; padding-top: 6px; padding-bottom: 6px; }
.fb-row.is-result .fb-name { align-items: flex-start; }
.fb-row.is-result .ico-ft { margin-top: 2px; }
.fb-namewrap { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fb-where {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-mute);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* inline rename */
.fb-rename {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm, 5px);
  background: var(--bg-elev);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  box-shadow: 0 0 0 4px var(--fb-soft);
}

.fb-rename:focus { outline: none; }

/* ---------- GRID VIEW ---------- */
.fb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 16px;
  align-content: start;
}

.fb-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 164px;
  padding: 14px 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius, 9px);
  background: var(--surface);
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
  transition: background var(--fb-fast) var(--fb-ease),
              border-color var(--fb-fast) var(--fb-ease),
              box-shadow var(--fb-fast) var(--fb-ease),
              transform var(--dur-press, 90ms) var(--fb-ease);
}

.fb-tile:hover { background: var(--fb-hover); border-color: var(--border-hi); }
.fb-tile:active { transform: scale(.994); }

.fb-tile.is-selected {
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 1px var(--accent);
  border-color: var(--accent);
}

.fb-tile.is-selected .fb-meta { color: var(--text-dim); }
.fb-tile.is-cursor { border-color: var(--accent); }

.fb-well {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: var(--radius, 9px);
  background: var(--surface-2);
}

.fb-well .fb-ext {
  position: absolute;
  right: -4px;
  bottom: -4px;
  max-width: 46px;
  padding: 2px 5px;
  border-radius: var(--radius-sm, 5px);
  background: color-mix(in srgb, var(--ft, var(--text-mute)) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ft, var(--text-mute)) 30%, transparent);
  color: var(--ft, var(--text-mute));
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fb-tile .fb-tname {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  width: 100%;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
}

.fb-tile .fb-rename { text-align: center; }

/* ---------- entrance stagger ---------- */
@keyframes fb-row-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

@keyframes fb-tile-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

@keyframes fb-fade { from { opacity: 0; } to { opacity: 1; } }

.fb-anim .fb-row {
  animation: fb-row-in var(--fb-dur) var(--fb-ease) both;
  animation-delay: calc(var(--i, 0) * 14ms);
}

.fb-anim .fb-tile {
  animation: fb-tile-in var(--fb-dur) var(--fb-ease) both;
  animation-delay: calc(var(--i, 0) * 12ms);
}

/* ---------- skeleton ---------- */
.fb-skel {
  border: 1px solid var(--border);
  border-radius: var(--radius, 9px);
  background: var(--surface);
  overflow: hidden;
}

.fb-skel-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 84px 120px;
  align-items: center;
  gap: 12px;
  height: var(--fb-row-h);
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}

.fb-skel-row:last-child { border-bottom: 0; }

.fb-sk {
  height: 10px;
  border-radius: var(--radius-sm, 5px);
  background: var(--surface-2);
  background-image: linear-gradient(90deg,
    transparent 0%,
    color-mix(in srgb, var(--text) 7%, transparent) 45%,
    transparent 90%);
  background-size: 220% 100%;
  background-repeat: no-repeat;
  animation: fb-sweep 1.35s linear infinite;
}

.fb-sk.b { height: 20px; border-radius: var(--radius-sm, 5px); }

@keyframes fb-sweep {
  from { background-position: -140% 0; }
  to   { background-position: 240% 0; }
}

.fb-skel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 16px;
}

.fb-skel-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 164px;
  padding: 14px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius, 9px);
  background: var(--surface);
}

.fb-skel-tile .fb-sk.w { width: 64px; height: 64px; border-radius: var(--radius, 9px); }
.fb-skel-tile .fb-sk.l1 { width: 82%; }
.fb-skel-tile .fb-sk.l2 { width: 52%; }

/* ---------- empty / error states ---------- */
.fb-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 320px;
  padding: 40px 24px;
  text-align: center;
  animation: fb-fade var(--fb-dur) var(--fb-ease) both;
}

.fb-state-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-mute);
}

.fb-state.is-error .fb-state-mark {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  background: var(--danger-soft, color-mix(in srgb, var(--danger) 12%, transparent));
}

.fb-state h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
}

.fb-state p {
  margin: 0;
  max-width: 40ch;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-mute);
}

.fb-state-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- drop overlay ----------
   Lives in .fb (not in the scrolling .fb-body) so it stays put while the list
   scrolls underneath; its top edge is set inline from the header height. */
.fb-stage { transition: opacity var(--fb-fast) var(--fb-ease), filter var(--fb-fast) var(--fb-ease); }
.fb.is-dropping .fb-stage { filter: saturate(.6); opacity: .72; }

.fb-drop {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  top: 8px;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg, 14px);
  background: var(--fb-soft);
  pointer-events: none;
}

.fb.is-dropping .fb-drop {
  display: flex;
  animation: fb-drop-in var(--fb-fast) var(--fb-ease) both;
}

@keyframes fb-drop-in {
  from { opacity: 0; transform: scale(.995); }
  to   { opacity: 1; transform: none; }
}

.fb-drop-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 20px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--accent-hi);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-2);
  animation: fb-pill-in var(--fb-dur) var(--fb-ease) both;
}

@keyframes fb-pill-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- marquee ---------- */
.fb-marquee {
  position: fixed;
  z-index: 70;
  border: 1px solid var(--accent);
  background: var(--fb-soft);
  border-radius: 2px;
  pointer-events: none;
}

/* ---------- selection action bar ---------- */
.fb-actionbar {
  /* fixed, so it never reserves layout space while hidden */
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 620;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg, 14px);
  background: var(--bg-elev);
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--fb-hair);
  transform: translate(-50%, 160%);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--fb-dur) var(--fb-spring), opacity var(--fb-fast) var(--fb-ease);
}

.fb-actionbar.is-on { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }

/* the FAB would sit under the action bar on phones */
.fb.has-selection .fb-fab { display: none; }

.fb-actionbar-count {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fb-actionbar-count b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12.5px;
  font-weight: 650;
}

.fb-actionbar .fb-ab-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.fb-actionbar .fb-ab-actions::-webkit-scrollbar { display: none; }

/* ---------- context menu ---------- */
.fb-menu {
  position: fixed;
  z-index: 900;
  min-width: 208px;
  max-width: 280px;
  padding: 5px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius, 9px);
  background: var(--bg-elev);
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--fb-hair);
  animation: fb-menu-in var(--fb-fast) var(--fb-ease) both;
}

@keyframes fb-menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.fb-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--fb-fast) var(--fb-ease), color var(--fb-fast) var(--fb-ease);
}

.fb-menu button:hover,
.fb-menu button:focus-visible { background: var(--fb-hover); }
.fb-menu button .ico { color: var(--text-mute); flex: 0 0 auto; }
.fb-menu button:hover .ico { color: var(--accent-text); }
.fb-menu button.danger { color: var(--danger); }
.fb-menu button.danger .ico,
.fb-menu button.danger:hover .ico { color: var(--danger); }
.fb-menu button.danger:hover { background: var(--danger-soft, color-mix(in srgb, var(--danger) 12%, transparent)); }
.fb-menu button[disabled] { opacity: .42; pointer-events: none; }
.fb-menu .kbd { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-mute); }
.fb-menu hr { height: 1px; margin: 5px 4px; border: 0; background: var(--border); }

/* ---------- uploads panel ---------- */
.fb-uploads {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 800;
  width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg, 14px);
  background: var(--bg-elev);
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--fb-hair);
  overflow: hidden;
  animation: fb-up-in var(--fb-dur) var(--fb-spring) both;
}

@keyframes fb-up-in {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.fb-uploads-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.fb-uploads-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.fb-uploads-head .fb-icobtn { width: 28px; height: 28px; border-color: transparent; background: transparent; }

.fb-uploads-total {
  height: 3px;
  background: var(--surface-2);
}

.fb-uploads-total i {
  display: block;
  height: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform var(--fb-fast) linear;
}

.fb-uploads-list {
  max-height: min(46vh, 320px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.fb-uploads.is-collapsed .fb-uploads-list { display: none; }

.fb-up {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 10px;
  padding: 9px 10px 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: opacity 160ms var(--fb-ease-in);
}

.fb-up:last-child { border-bottom: 0; }
.fb-up.is-gone { opacity: 0; }

.fb-up-name {
  grid-column: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.fb-up-side { grid-column: 2; grid-row: 1 / span 2; display: flex; align-items: center; gap: 4px; }

.fb-up-pct {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-mute);
  min-width: 38px;
  text-align: right;
}

.fb-up-bar {
  grid-column: 1;
  position: relative;
  height: 3px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.fb-up-bar i {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform var(--fb-fast) linear;
}

.fb-up.is-indeterminate .fb-up-bar i {
  width: 28%;
  inset: 0 auto 0 0;
  transform: none;
  animation: fb-indet 1100ms linear infinite;
}

@keyframes fb-indet {
  from { transform: translateX(-100%); }
  to   { transform: translateX(360%); }
}

.fb-up.is-done .fb-up-bar i { background: var(--ok); }
.fb-up.is-done .fb-up-pct { color: var(--ok); }
.fb-up.is-error .fb-up-bar i { background: var(--danger); transform: scaleX(1); }
.fb-up.is-error .fb-up-name { color: var(--danger); }
.fb-up.is-error .fb-up-pct { color: var(--danger); }
.fb-up.is-cancelled { opacity: .55; }
.fb-up.is-cancelled .fb-up-bar i { background: var(--text-mute); }

.fb-up-err {
  grid-column: 1 / -1;
  margin-top: 6px;
  font-size: 12px;
  color: var(--danger);
  overflow-wrap: anywhere;
}

.fb-up-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.fb-up-mini:hover { background: var(--fb-hover); color: var(--text); }

.fb-up-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
}

.fb-up-x:hover { background: var(--surface-2); color: var(--danger); }

/* ---------- FAB (mobile) ---------- */
.fb-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-2);
  cursor: pointer;
  transition: transform var(--dur-press, 90ms) var(--fb-ease), background var(--fb-fast) var(--fb-ease);
}

.fb-fab:active { transform: scale(.94); }

/* ---------- shortcuts overlay ---------- */
.fb-help {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--fb-scrim);
  animation: fb-fade var(--fb-fast) var(--fb-ease) both;
}

.fb-help-panel {
  width: min(520px, 100%);
  max-height: min(80vh, 620px);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 14px);
  background: var(--bg-elev);
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--fb-hair);
  animation: fb-modal-in var(--fb-dur) var(--fb-spring) both;
}

@keyframes fb-modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.fb-help-panel h3 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
}

.fb-help-panel p { margin: 0 0 16px; font-size: 12.5px; color: var(--text-mute); }

.fb-help-list { display: grid; gap: 2px; }

.fb-help-list div {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text-dim);
}

.fb-help-list div:nth-child(odd) { background: var(--surface-2); }

.fb-help-list kbd {
  flex: 0 0 auto;
  min-width: 96px;
  padding: 3px 7px;
  border: 1px solid var(--border-hi);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm, 5px);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-align: center;
}

.fb-help-close { margin-top: 18px; width: 100%; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .fb-lhead,
  .fb-row { grid-template-columns: minmax(0, 1fr) 92px 118px; }
  .fb-lhead .col-type,
  .fb-row .col-type { display: none; }
}

@media (max-width: 768px) {
  .fb { --fb-row-h: 48px; }
  .fb-head { padding-top: 12px; gap: 8px; }
  .fb-lhead,
  .fb-row { grid-template-columns: minmax(0, 1fr) 84px; }
  .fb-lhead .col-mtime,
  .fb-row .col-mtime { display: none; }
  .fb-name-txt { font-size: 15px; }
  .fb-icobtn { width: 40px; height: 40px; }
  .fb-btn { height: 40px; }
  .fb-seg button { width: 38px; height: 34px; }
  .fb-search input { height: 40px; font-size: 16px; }
  .fb-fab { display: inline-flex; }
  .fb-uploads { bottom: calc(88px + env(safe-area-inset-bottom)); }
  .fb-actionbar { left: 16px; right: 16px; width: auto; max-width: none; transform: translateY(160%); }
  .fb-actionbar.is-on { transform: none; }
  .fb-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
  .fb-tile:hover { background: var(--surface); }
  .fb-row:hover { background: transparent; }
  .fb-menu { min-width: 240px; }
  .fb-menu button { padding: 11px 12px; font-size: 14.5px; }
}

@media (max-width: 560px) {
  .fb-tools { flex-wrap: wrap; }
  .fb-search { flex-basis: 100%; order: 5; max-width: none; }
  .fb-btn.hide-sm { display: none; }
  .fb-tools-spacer { display: none; }
  .fb-actionbar { padding-left: 12px; }
  .fb-actionbar-count span { display: none; }
}

/* ---------- misc ----------
   File-type colours (.ft-*), the .ico base rule, .ico-16, .ico-ft, .ico-spin
   and the global focus ring all live in tokens.css and are used as-is —
   nothing is redefined here, so a palette change there reaches this view. */
.fb-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .fb-anim .fb-row,
  .fb-anim .fb-tile { animation: none; }
  .fb-sk { animation: none; background-image: none; }
  .fb-up.is-indeterminate .fb-up-bar i { animation: none; width: 40%; transform: none; }
}
