* { box-sizing: border-box; margin: 0; padding: 0; }

/* ============================================================
   Fonts (self-hosted — CSP-friendly, no external CDN)
   ============================================================ */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/inter-700.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/source-serif-4-400.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/source-serif-4-500.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/source-serif-4-600.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/jetbrains-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/jetbrains-mono-500.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/jetbrains-mono-600.woff2') format('woff2'); }

/* ============================================================
   Theming — Claude house style
   ------------------------------------------------------------
   Default = light (warm off-white). Dark mode via
   `<html data-theme="dark">` (set by public/theme-init.js + the
   runtime toggle in public/src/util/theme.ts).
   ============================================================ */
:root {
  /* Surfaces */
  --bg: #FAF9F6;
  --surface: #FFFFFF;
  --surface-2: #F4F2EC;
  --surface-3: #ECE9E1;
  --surface-hover: #F0EDE5;
  --surface-selected: #EFEAE0;

  /* Borders / dividers */
  --border: #E4DFD3;
  --border-strong: #CFC8B8;
  --divider: #ECE7DB;

  /* Text */
  --text: #1A1916;
  --text-2: #3F3B34;
  --text-dim: #6B665C;
  --text-mute: #968F82;
  --text-faint: #B5AE9F;

  /* Brand / accent */
  --accent: #C96442;
  --accent-hover: #B5573A;
  --accent-soft: rgba(201, 100, 66, 0.10);
  --accent-soft-2: rgba(201, 100, 66, 0.18);

  /* Semantic */
  --danger: #B14545;
  --danger-hover: #963A3A;
  --danger-soft: rgba(177, 69, 69, 0.08);
  --success: #4F7A4C;
  --success-dot: #6CA567;
  --warn: #B58A2C;
  --warn-soft: rgba(181, 138, 44, 0.10);

  /* File-type accents (table badges) */
  --ft-pdf: #B14545;
  --ft-doc: #2F6BD3;
  --ft-img: #5B7F3B;
  --ft-zip: #7A5C2F;
  --ft-default: #6B665C;

  /* Focus + shadow */
  --ring: 0 0 0 3px rgba(201, 100, 66, 0.22);
  --shadow-sm: 0 1px 2px rgba(40, 30, 15, 0.04);
  --shadow-md: 0 4px 12px rgba(40, 30, 15, 0.06), 0 1px 3px rgba(40, 30, 15, 0.04);
  --shadow-lg: 0 24px 48px -16px rgba(40, 30, 15, 0.18), 0 6px 16px rgba(40, 30, 15, 0.08);

  /* Typography */
  --font-serif: 'Source Serif 4', 'Charter', Georgia, serif;
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Sizing */
  --sidebar-w: 260px;
  --info-w: 360px;

  /* Speed */
  --t-fast: 120ms;
  --t-base: 180ms;
}

[data-theme="dark"] {
  --bg: #1A1916;
  --surface: #22201C;
  --surface-2: #211F1B;
  --surface-3: #2D2A25;
  --surface-hover: #2A2722;
  --surface-selected: #34302A;
  --border: #322F2A;
  --border-strong: #4B463E;
  --divider: #2A2723;
  --text: #F0EDE6;
  --text-2: #D8D3C8;
  --text-dim: #A8A299;
  --text-mute: #7A7468;
  --text-faint: #5B564D;
  --accent: #DE7755;
  --accent-hover: #E58866;
  --accent-soft: rgba(222, 119, 85, 0.14);
  --accent-soft-2: rgba(222, 119, 85, 0.24);
  --danger: #D06868;
  --danger-hover: #DE7878;
  --danger-soft: rgba(208, 104, 104, 0.12);
  --success: #7AB075;
  --success-dot: #88BE83;
  --warn: #D4A856;
  --warn-soft: rgba(212, 168, 86, 0.14);
  --ft-pdf: #D86A6A;
  --ft-doc: #6A95E5;
  --ft-img: #9DBD75;
  --ft-zip: #C29A55;
  --ft-default: #A8A299;
  --ring: 0 0 0 3px rgba(222, 119, 85, 0.30);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.30), 0 1px 3px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, 0.55), 0 6px 16px rgba(0, 0, 0, 0.40);
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-soft-2); }
code, .mono { font-family: var(--font-mono); }
.serif { font-family: var(--font-serif); }

/* ============================================================
   Layout
   ============================================================ */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* The two-pane wrapper lives inside the main grid column. */
.panes-wrap {
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
}
.panes-wrap.dual { grid-template-columns: 1fr 1fr; }

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  overflow: hidden;
  position: relative;
  border-right: 1px solid var(--border);
}
.pane:last-child { border-right: 0; }
.pane[hidden] { display: none !important; }
.panes-wrap.dual .pane.active::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 2px 0 var(--accent);
  z-index: 1;
}

/* `.pane.with-info` is set by info-panel.ts when the slide-over is open.
   Visual is a no-op now (the .info-panel is absolutely positioned), but
   the class is observable from TS for layout-aware features. */

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  position: relative;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  font-size: 13.5px;
}

/* ── Drag handles for resizable sidebar + info panel ─────────────────── */
.resize-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 6px;
  cursor: col-resize;
  user-select: none;
  background: transparent;
  z-index: 10;
  transition: background var(--t-fast);
}
.resize-handle::after {
  /* Visible bar drawn inside the wider hit area so the cursor target is
     forgiving (6px) but the visual line is crisp (1px). */
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 1px;
  background: transparent;
  transition: background var(--t-fast), width var(--t-fast);
}
.resize-handle:hover::after,
.resize-handle.dragging::after {
  background: var(--accent);
  width: 2px;
}
.resize-handle-sidebar {
  right: -3px;  /* straddle the border so the hit area is centered */
}
.resize-handle-info {
  left: -3px;
}
/* Hide the info-panel handle when the panel is closed (translated off-screen)
   — otherwise the handle's hit area still catches clicks at the edge. */
.info-panel:not(.open) .resize-handle-info { display: none; }
/* While dragging, suppress text selection across the page. */
body.is-resizing { cursor: col-resize !important; user-select: none; }
body.is-resizing * { user-select: none !important; }
@media (max-width: 768px) {
  /* Drawer mode — no resizing on mobile. */
  .resize-handle { display: none; }
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--divider);
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.10);
}
.brand-text { flex: 1; min-width: 0; }
.brand-title, .brand-name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.1;
}
.brand-sub { font-size: 11.5px; color: var(--text-mute); margin-top: 2px; }

/* The collapse toggle is a small chevron in the brand row. Hover brightens
   it; click toggles between full-width and the thin icon-only state.
   Hidden in mobile drawer mode (the drawer overlay isn't toggle-collapsible
   — it's already full-screen-or-hidden). */
.sidebar-collapse-btn {
  flex-shrink: 0;
  color: var(--text-mute);
  transition: color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.sidebar-collapse-btn:hover { color: var(--text); background: var(--surface-3); }
/* When the sidebar is collapsed the chevron points the opposite way. The
   JS swaps the data-icon attribute too, but the rotation fallback covers
   the brief frame before re-hydration. */
.sidebar.collapsed .sidebar-collapse-btn { transform: rotate(180deg); }
@media (max-width: 768px) {
  .sidebar-collapse-btn { display: none; }
}

/* ── Collapsed sidebar — narrow, icon-only ─────────────────────────────
   Width shrinks to ~52px (enough for the S3 mark + padding). Labels,
   section headers, connection tree text, and the status pill are hidden;
   only the brand mark, connection badges, footer icons, and user-action
   icons remain. The resize handle is disabled in this mode — to widen the
   sidebar back, click the toggle. */
.sidebar.collapsed {
  /* The grid template uses --sidebar-w; JS sets that to 52px when this
     class is on. The width here is a fallback for early paint. */
  width: 52px;
  min-width: 52px;
  overflow: hidden;
}
.sidebar.collapsed .brand {
  padding: 16px 8px 14px;
  justify-content: center;
}
.sidebar.collapsed .brand-text { display: none; }
.sidebar.collapsed .sidebar-collapse-btn {
  position: absolute;
  top: 18px;
  right: -14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  z-index: 5;
}
.sidebar.collapsed .section-header span { display: none; }
.sidebar.collapsed .section { padding: 14px 4px 4px; }
.sidebar.collapsed .section-header { padding: 6px 2px 8px; justify-content: center; }
.sidebar.collapsed .conn-tree .chevron,
.sidebar.collapsed .conn-tree .name,
.sidebar.collapsed .conn-tree .act-btn,
.sidebar.collapsed .conn-tree .bucket-children { display: none; }
.sidebar.collapsed .conn-tree .conn-row {
  justify-content: center;
  padding: 7px 4px;
}
.sidebar.collapsed .sidebar-foot {
  padding: 12px 4px;
  flex-direction: column;
  gap: 8px;
}
.sidebar.collapsed #conn-status { display: none; }
.sidebar.collapsed .sidebar-user {
  padding: 10px 4px 12px;
  flex-direction: column;
  gap: 8px;
}
.sidebar.collapsed .sidebar-user .user-name,
.sidebar.collapsed .sidebar-user .user-role { display: none; }
.sidebar.collapsed .sidebar-user .user-actions {
  flex-direction: column;
  gap: 4px;
}
/* Disable the resize handle when collapsed — the toggle owns the width. */
.sidebar.collapsed .resize-handle-sidebar { display: none; }

.section, .sb-section { padding: 14px 16px 4px; }
.section-header, .sb-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 4px 8px;
}
.section-header span, .sb-head h3 {
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
}

/* ─── Sidebar tree (connections → buckets) ──────────────────────────────── */

.conn-tree {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column;
  gap: 2px;
}
.conn-tree .conn-node { list-style: none; padding: 0; }

.conn-tree .conn-row,
.conn-tree .bucket-node {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px 7px 4px;
  border-radius: 5px;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.conn-tree .conn-row:hover,
.conn-tree .bucket-node:hover {
  background: var(--surface-hover); color: var(--text);
}
.conn-tree .conn-node.active > .conn-row {
  color: var(--text);
}
.conn-tree .bucket-node.active {
  background: var(--surface-3); color: var(--text);
}
.conn-tree .bucket-node.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.conn-tree .chevron {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  color: var(--text-mute);
  border-radius: 3px;
  transition: transform var(--t-fast), background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.conn-tree .chevron:hover { background: var(--surface-3); color: var(--text); }
.conn-tree .chevron.open { transform: rotate(90deg); }

.conn-tree .conn-row .name,
.conn-tree .bucket-node .name {
  flex: 1; min-width: 0;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.conn-tree .act-btn {
  visibility: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-mute);
  padding: 3px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}
.conn-tree .conn-row:hover .act-btn,
.conn-tree .bucket-node:hover .act-btn { visibility: visible; }
.conn-tree .act-btn:hover { background: var(--surface-3); color: var(--text); }

.conn-tree .bucket-children {
  list-style: none;
  margin: 2px 0 4px;
  padding: 0;
  /* Indent the children under the chevron + S3 badge column so buckets
     visually align under the connection name. */
  padding-left: 22px;
  position: relative;
}
.conn-tree .bucket-children::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 2px; bottom: 4px;
  width: 1px;
  background: var(--divider);
}
.conn-tree .bucket-node {
  padding: 5px 8px 5px 8px;
  font-size: 13px;
}
.conn-tree .bucket-empty {
  padding: 5px 8px 5px 8px;
  font-size: 12px;
  color: var(--text-mute);
  font-style: italic;
}

/* ─── Breadcrumb connection prefix ──────────────────────────────────────── */
.crumbs .crumb-conn {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-mute);
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  letter-spacing: 0.01em;
}

.sidebar-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--divider);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.status {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
}
.status::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-mute);
}
.status.online::before { background: var(--success-dot); }
.status.stale::before { background: var(--warn); }

.sidebar-user {
  padding: 10px 16px 12px;
  border-top: 1px solid var(--divider);
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.sidebar-user .user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.sidebar-user .user-role {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--text-dim);
  margin-left: 8px;
}
.sidebar-user .user-role.admin {
  background: var(--accent-soft);
  color: var(--accent);
}
.sidebar-user .user-actions { display: flex; gap: 2px; }

/* ============================================================
   Toolbar
   ============================================================ */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  min-height: 58px;
  flex-shrink: 0;
  flex-wrap: wrap;
  row-gap: 10px;
}

/* Per-pane back / forward navigation buttons. Sit at the very start of the
   toolbar, before the breadcrumb. Disabled state dims the icon and shows a
   not-allowed cursor — same as a browser's history buttons at the edges of
   their stack. */
.nav-buttons { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.nav-btn { color: var(--text-2); }
.nav-btn:not(:disabled):hover { background: var(--surface-3); color: var(--text); }
.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.nav-btn:disabled:hover { background: transparent; color: var(--text-2); }
.crumbs {
  display: flex; align-items: center; gap: 2px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  flex: 1 1 auto;
  min-width: 0;
}
.crumbs a, .crumbs .crumb {
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.crumbs a:hover, .crumbs .crumb:hover {
  background: var(--surface-2); color: var(--text);
}
.crumbs .sep { color: var(--text-faint); padding: 0 2px; user-select: none; }
.crumbs .current { color: var(--text); font-weight: 500; }

/* Breadcrumb segments are also drop targets: dropping a row onto a parent
   segment moves/copies it UP the hierarchy. Highlight mirrors the folder-row
   drop-target style so the gesture feels consistent. */
.crumbs a.drop-target-crumb {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
  font-weight: 600;
}

/* Edit button at the end of the breadcrumb — toggles the chips to a
   free-form text input for jumping to a known path. Subtle until hover so
   it doesn't compete with the path itself. */
.crumb-edit-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 5px;
  color: var(--text-mute);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
/* Brighten the edit button while the user is hovering anywhere in the
   breadcrumb — it's a discovery affordance, not the primary action. */
.crumbs:hover .crumb-edit-btn { opacity: 0.95; }
.crumb-edit-btn:hover {
  opacity: 1;
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.crumb-edit-btn:focus-visible {
  opacity: 1;
  outline: none;
  box-shadow: var(--ring);
}

/* When the breadcrumb is in edit mode the chips are replaced by a text
   input + accept/cancel buttons. Use the available width so even long
   paths fit comfortably. */
.crumbs.editing { gap: 6px; }
.crumb-edit-input {
  flex: 1;
  min-width: 200px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.01em;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.crumb-edit-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.crumb-edit-input.err {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.crumb-edit-action {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.crumb-edit-action.ok:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.crumb-edit-action.cancel:hover {
  background: var(--surface-3);
  color: var(--text);
}

.actions {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; row-gap: 6px;
}

.search-box {
  position: relative;
  flex: 1 1 220px;
  max-width: 380px;
  min-width: 180px;
}
.search-box input {
  width: 100%;
  height: 32px;
  padding: 0 36px 0 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search-box input::placeholder { color: var(--text-mute); }
.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.search-box input:disabled { opacity: 0.5; cursor: not-allowed; }
.search-box::before {
  content: '';
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23968F82' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='M20 20l-3.5-3.5'/></svg>") center/contain no-repeat;
  pointer-events: none;
}
.search-box .btn-icon[data-el="btn-search-clear"],
.search-box [data-el="btn-search-clear"] {
  position: absolute;
  right: 4px; top: 50%;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  padding: 0;
  font-size: 11px;
}

.search-banner {
  padding: 8px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
  display: flex; gap: 12px; align-items: center;
}
.search-banner .truncated { color: var(--warn); }
.search-banner button { font-size: 12px; padding: 4px 10px; }
.path-cell {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 2px;
}

.toggle-deleted {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 0 8px;
  cursor: pointer;
  user-select: none;
}
.toggle-deleted:hover { color: var(--text); }
.toggle-deleted input { cursor: pointer; }

.index-status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
}
.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger-solid:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}
.btn-ghost {
  border-color: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: transparent;
  color: var(--text);
}
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; gap: 5px; }
.btn.sm svg { width: 12px; height: 12px; }
.btn.lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn.xs { height: 22px; padding: 0 7px; font-size: 11.5px; gap: 4px; border-radius: 4px; }
.btn.xs svg { width: 11px; height: 11px; }
.btn.full { width: 100%; justify-content: center; }

/* Icon-only buttons */
.btn-icon {
  width: 28px; height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 6px;
  display: inline-grid; place-items: center;
  color: var(--text-dim);
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon[disabled] { opacity: 0.4; cursor: not-allowed; }

/* Close button inside a modal header: larger hit area, perfectly round so
   the hover/focus background matches the icon's optical center. Without
   this override, the default 28×28 with 5px radius looked like a clipped
   rectangle next to the title's larger line-height. */
.modal header .btn-icon,
.modal .modal-head .btn-icon,
.modal .header-actions .btn-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  margin-top: -2px;  /* nudge into optical alignment with serif title */
}
.modal header .btn-icon svg,
.modal .modal-head .btn-icon svg,
.modal .header-actions .btn-icon svg {
  width: 15px; height: 15px;
}

/* The dual-pane toggle button in the toolbar actions cluster. */
.dual-only-trigger { color: var(--text-dim); }
.panes-wrap.dual .dual-only-trigger { color: var(--accent); }

/* Buttons that should only appear once dual mode is active (e.g. the sync-
   nav toggle — meaningless in single pane). Hidden by default; revealed
   when `.panes-wrap.dual` is on. */
.dual-only-visible { display: none; }
.panes-wrap.dual .dual-only-visible { display: inline-grid; }

/* Synced-nav toggle button — sits next to the dual-toggle. Outline when
   off, accent-filled pill (icon + "SYNC ON" label) when on so the user
   can tell at a glance the panes are linked. */
.btn-sync-nav { color: var(--text-dim); }
.btn-sync-nav:hover { color: var(--text); background: var(--surface-3); }
/* Scoped under .panes-wrap.dual so this beats the
   `.panes-wrap.dual .dual-only-visible { display: inline-grid }` rule
   (same specificity tier but more selectors). Otherwise the grid layout
   wins and the svg + label stack vertically inside the same cell. */
.panes-wrap.dual .btn-sync-nav.active {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  padding: 0 10px;
}
.btn-sync-nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  text-decoration: none;
}

/* Dedicated "close this pane" button in the toolbar actions cluster.
   Hidden in single-pane mode (nothing to close). Visible on BOTH panes in
   dual mode so the user can close whichever one they want — closing the
   left pane migrates the right pane's content into the single view. */
.btn-close-pane { display: none; }
.panes-wrap.dual .btn-close-pane { display: inline-grid; }
.btn-close-pane:hover { color: var(--danger); background: var(--danger-soft); }

/* ============================================================
   Status pills
   ============================================================ */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
}
.pill.on  { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.pill.ok  { background: rgba(108,165,103,0.10); border-color: transparent; color: var(--success); }
.pill.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.pill.muted { color: var(--text-mute); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ============================================================
   Content area / Empty / Dropzone
   ============================================================ */
.content {
  flex: 1; min-height: 0;
  overflow: auto;
  position: relative;
}
.empty {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 48px 32px;
  text-align: center;
}
.empty > * { max-width: 540px; }
.empty h1, .empty h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 14px;
}
.empty p {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-dim);
  margin: 0 auto 24px;
  max-width: 480px;
  text-wrap: pretty;
}

.dropzone {
  display: none;
  position: absolute;
  inset: 14px;
  z-index: 5;
  pointer-events: none;
  border: 2px dashed var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
}
.dropzone.show { display: block; }
.dropzone::after {
  content: 'Suelta archivos aquí';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  color: var(--accent);
  font-weight: 500;
  font-size: 14px;
  padding: 14px 22px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-md);
}

/* Drop target highlight on a receiving pane during cross-pane drag. */
.pane.drop-target::after {
  content: '';
  position: absolute;
  inset: 14px;
  pointer-events: none;
  border: 2px dashed var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
  z-index: 4;
}

/* Drop target highlight on a SINGLE folder row when something is being
   dragged over it — distinguishes "drop into this sub-folder" from "drop
   into the currently-open folder" (which is the pane-level highlight). */
.grid tr.drop-target-row > td {
  background: var(--accent-soft) !important;
  box-shadow: inset 2px 0 0 var(--accent);
}
.grid tr.drop-target-row .cell-name {
  color: var(--text);
  font-weight: 600;
}

/* ============================================================
   Grid (table) — selector kept as `.grid` for TS bindings
   ============================================================ */
.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  /* table-layout: fixed locks column widths to what the first row / explicit
     `width` on <th>/<td> says, regardless of subsequent row content. Without
     this, browsers use auto layout which recalculates widths on re-render and
     can produce subtle column shifts when a row has slightly wider content
     (e.g. one row's date wrapping when others don't, or a delete-marker row
     with '—' next to a row with '12.34 GB'). */
  table-layout: fixed;
}
/* Note: we intentionally do NOT set `overflow: hidden` on table cells.
   See the comment on `.cell-name` below — cell-level overflow clips the
   cell's own bottom border on some browsers, breaking the row divider.
   Column widths (col-size 96px, col-date 152px) are sized for the worst
   realistic case so content always fits without needing an overflow clip. */
.grid thead th {
  position: sticky; top: 0;
  background: var(--bg);
  z-index: 1;
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.grid th.sortable { cursor: pointer; }
.grid th.sortable:hover { color: var(--text); }
.grid th.sortable .sort-indicator {
  display: inline-block;
  width: 0; height: 0; vertical-align: middle;
  margin-left: 4px;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.grid th.sortable.active .sort-indicator { opacity: 1; }
/* Sort arrows via ::after pseudo so we don't need extra markup. The TS
   toggles .active + writes direction via CSS attribute on the th. */
.grid th.sortable.active { color: var(--accent); }
.grid th.sortable[data-sort-dir="asc"] .sort-indicator::before  { content: '▲'; font-size: 9px; opacity: 0.9; }
.grid th.sortable[data-sort-dir="desc"] .sort-indicator::before { content: '▼'; font-size: 9px; opacity: 0.9; }

.grid tbody tr {
  cursor: pointer;
  transition: background var(--t-fast);
}
.grid tbody tr:hover { background: var(--surface-2); }
.grid tbody tr.selected,
.grid tbody tr.selected:hover { background: var(--surface-selected); }
.grid tbody tr.dragging { opacity: 0.45; }
.grid tbody tr.is-folder .cell-name { font-weight: 600; }

.grid td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
  color: var(--text-2);
}
/* Column-specific sizing + padding. Selectors are written as
   `.grid td.col-X, .grid th.col-X` so they beat the generic
   `.grid td { padding: 11px 16px }` and `.grid thead th { padding: 12px 16px }`
   rules on specificity. Without `.grid` in front, the generic padding rule
   wins and the column ends up with 32px of horizontal padding inside a
   tight width — content gets clipped (e.g. "793.3 KB" → "793.3 …"). */
.grid td.col-check, .grid th.col-check {
  width: 38px;
  padding-left: 14px;
  padding-right: 4px;
}
.grid td.col-size, .grid th.col-size {
  width: 96px;
  padding-left: 8px;
  padding-right: 8px;
  white-space: nowrap;
}
.grid td.col-size {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.grid td.col-date, .grid th.col-date {
  width: 152px;
  padding-left: 8px;
  padding-right: 8px;
  white-space: nowrap;
}
.grid td.col-date {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.grid td.col-act, .grid th.col-act {
  width: 44px;
  padding-left: 4px;
  padding-right: 10px;
  text-align: right;
}

.cell-name {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
  /* IMPORTANT: do NOT set `overflow: hidden` on the <td> itself.
     Combined with `border-collapse: collapse`, some browsers clip the
     cell's own bottom border at the overflow boundary, producing a
     visibly truncated divider line between rows. The inner .name-text /
     .name-stack already handle text overflow with ellipsis, so the cell
     never needs its own overflow clip. */
}
.cell-name .name-text {
  flex: 1; min-width: 0;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Search mode: the cell-name contains a 2-row stack (filename + parent
   path). Both rows ellipsis-clip independently. */
.cell-name .name-stack {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  gap: 2px;
}
.cell-name .name-stack > div {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Deleted rows (showing version history with delete markers) */
tr.deleted .cell-name { color: var(--text-mute); text-decoration: line-through; }
tr.deleted .badge-deleted {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 8px;
}

/* File-type badges */
.ft-badge {
  width: 32px; height: 22px;
  border-radius: 3px;
  display: grid; place-items: center;
  font-size: 9.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  color: #fff;
  flex-shrink: 0;
}
.ft-badge.folder {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}
.ft-badge.pdf { background: var(--ft-pdf); }
.ft-badge.doc { background: var(--ft-doc); }
.ft-badge.img { background: var(--ft-img); }
.ft-badge.zip { background: var(--ft-zip); }
.ft-badge.def { background: var(--ft-default); }

/* Row action button (the per-row menu trigger that shows on hover) */
.menu-btn, .row-menu, .row-action-btn {
  width: 28px; height: 28px;
  border-radius: 4px;
  display: inline-grid; place-items: center;
  color: var(--text-mute);
  background: transparent;
  border: none;
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.grid tbody tr:hover .menu-btn,
.grid tbody tr:hover .row-menu,
.grid tbody tr:hover .row-action-btn { opacity: 1; }
.menu-btn:hover, .row-menu:hover, .row-action-btn:hover {
  background: var(--surface-3); color: var(--text);
}
.menu-btn svg, .row-menu svg, .row-action-btn svg { width: 14px; height: 14px; }

/* Right-click context dropdowns */
.dropdown {
  position: fixed;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  padding: 4px 0;
  min-width: 160px;
  font-size: 13px;
}
.dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  color: var(--text-2);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.dropdown button:hover { background: var(--surface-2); color: var(--text); }
.dropdown button.danger { color: var(--danger); }
.dropdown button.danger:hover { background: var(--danger-soft); }

/* Batch bar (appears below table when rows selected) */
.batch-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.batch-bar span { font-size: 13px; font-weight: 500; color: var(--text); }

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 10, 0.34);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: grid; place-items: center;
  padding: 32px 24px;
  z-index: 100;
  overflow-y: auto;
  animation: bd-in 180ms ease;
}
[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, 0.55); }
@keyframes bd-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 480px;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: m-in 200ms cubic-bezier(.2,.8,.2,1);
  margin: auto;
}
.modal-lg { width: 680px; }
.modal-xl { width: 880px; }
@keyframes m-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.modal header,
.modal .modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--divider);
  gap: 14px;
}
.modal header h3,
.modal .modal-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.25;
}
.modal .modal-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; }

.modal form { padding: 20px 22px; overflow-y: auto; flex: 1; }
.modal .modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }

.modal form label {
  display: block;
  margin-bottom: 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.modal form input[type=text],
.modal form input[type=password],
.modal form input:not([type]),
.modal form textarea,
.modal form select,
.input, .textarea, .select {
  display: block;
  width: 100%;
  height: 36px;
  margin-top: 6px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.modal form input:hover,
.modal form textarea:hover,
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-strong); }
.modal form input:focus,
.modal form textarea:focus,
.modal form select:focus,
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.modal form textarea, .textarea {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}
.input.mono, .textarea.mono { font-family: var(--font-mono); font-size: 12.5px; }
.input::placeholder, .textarea::placeholder { color: var(--text-mute); }

.modal .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.modal label.check, .check-confirm {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2);
  text-transform: none; letter-spacing: 0;
  margin-bottom: 14px;
}
.modal label.check input, .check-confirm input { width: auto; height: auto; margin: 0; }
.modal .hint, .hint, .help {
  color: var(--text-dim);
  font-size: 12px;
  margin: -8px 0 14px;
  line-height: 1.5;
  text-transform: none;
  letter-spacing: 0;
}
.modal .hint code, .hint code { font-family: var(--font-mono); font-size: 11.5px; }

.modal footer, .modal .modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--divider);
  background: var(--surface-2);
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
}
.test-result { flex: 1; font-size: 12px; color: var(--text-dim); }
.test-result.ok { color: var(--success); }
.test-result.err { color: var(--danger); }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* Import row (dashed callout in Nueva conexión modal) */
.import-row {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  margin-bottom: 16px;
}
.import-row button { white-space: nowrap; }
.import-row.dragover { border-color: var(--accent); background: var(--accent-soft); }

/* Modal tabs (Mi cuenta: Contraseña / Segundo factor / Recuperación) */
.modal-tabs {
  display: flex; gap: 4px;
  padding: 0 22px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
  margin-bottom: 4px;
}
.modal-tab {
  position: relative;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mute);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color var(--t-fast);
}
.modal-tab:hover { color: var(--text); }
.modal-tab.active { color: var(--text); }
.modal-tab.active::after {
  content: '';
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}
.modal-tab-content { padding: 18px 22px 4px; }

/* Field stack (handoff component, used optionally in new markup) */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .field .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
}

/* Custom checkbox / switch */
.chk {
  appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  display: inline-grid; place-items: center;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  flex-shrink: 0;
  position: relative;
  vertical-align: middle;
}
.chk:hover { border-color: var(--text-dim); }
.chk:checked { background: var(--accent); border-color: var(--accent); }
.chk:checked::after {
  content: '';
  width: 10px; height: 10px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='2.5,6.5 5,9 9.5,3.5'/></svg>") center/contain no-repeat;
}
.chk:focus-visible { outline: none; box-shadow: var(--ring); }

.switch {
  appearance: none;
  width: 34px; height: 20px;
  background: var(--border-strong);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background var(--t-fast);
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-fast);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }

/* Warn block (used in overwrite modal) */
.warn-block {
  display: flex; gap: 12px;
  padding: 14px 16px;
  background: var(--warn-soft);
  border: 1px solid rgba(181,138,44,0.30);
  border-radius: 8px;
  margin-bottom: 16px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

/* ============================================================
   Preview body / Versions
   ============================================================ */
.preview-body {
  flex: 1; min-height: 240px;
  display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(45deg, var(--surface-3) 25%, transparent 25%),
    linear-gradient(-45deg, var(--surface-3) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--surface-3) 75%),
    linear-gradient(-45deg, transparent 75%, var(--surface-3) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: var(--surface-2);
  overflow: auto;
  padding: 18px;
}
.preview-body img,
.preview-body video {
  max-width: 100%; max-height: 60vh;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
}
.preview-body iframe { width: 100%; height: 60vh; border: 0; background: #fff; border-radius: 6px; }
.preview-body pre {
  width: 100%; max-height: 60vh;
  margin: 0; padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  overflow: auto;
  text-align: left;
}

.preview-meta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  border-top: 1px solid var(--divider);
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--surface-2);
  flex-shrink: 0;
}
.versions-panel {
  border-top: 1px solid var(--divider);
  padding: 12px 22px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
}
.version-row {
  display: grid;
  /* vid stretches, the rest hug their content. minmax(0, 1fr) is required
     so the long version-id can shrink + ellipsis instead of overflowing
     into the date column. */
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 14px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--divider);
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
}
.version-row:last-child { border-bottom: 0; }
.version-row.viewing { background: var(--accent-soft); border-radius: 4px; padding: 8px 6px; }
.version-row.viewing .vid::before { content: '▶ '; color: var(--accent); }
.version-row .vid {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.version-row .latest { color: var(--success); font-weight: 600; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.version-row .delete-marker { color: var(--danger); font-weight: 600; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.version-row .actions { display: flex; gap: 6px; }
.version-row button { font-size: 11px; padding: 4px 8px; }

/* ============================================================
   Toasts
   ============================================================ */
#toast-container, .toast-stack {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 200;
  display: flex; flex-direction: column;
  gap: 8px;
  width: 320px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text);
  display: flex; gap: 10px; align-items: flex-start;
  animation: toast-in 200ms cubic-bezier(.2,.8,.2,1);
  border-left: 3px solid var(--accent);
  pointer-events: auto;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.info    { border-left-color: var(--accent); }
.toast-error-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mute);
  cursor: pointer;
}
.toast-error-id:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Object info panel — slides over the right of its pane
   ============================================================ */
.info-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: var(--info-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 220ms cubic-bezier(.2,.8,.2,1);
  z-index: 6;
}
.info-panel.open { transform: translateX(0); }
.info-panel header,
.info-panel .info-head {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--divider);
  display: flex; gap: 12px;
  align-items: flex-start;
}
.info-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.info-title [data-el="info-icon"] {
  width: 36px; height: 36px;
  border-radius: 5px;
  font-size: 12px;
  flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-weight: 600;
}
.info-name-wrap { min-width: 0; flex: 1; }
.info-name {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
  word-break: break-all;
}
.info-path {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-mute);
  margin-top: 6px;
  word-break: break-all;
}
.info-actions {
  display: flex; flex-direction: column;
  gap: 6px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--divider);
}
.info-actions .btn { width: 100%; justify-content: center; }
.info-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--divider);
  overflow-y: auto;
}
.info-section:last-child { border-bottom: 0; flex: 1; }
.info-section h4 {
  margin: 0 0 12px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
}
.info-section dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 14px;
  font-size: 12.5px;
}
.info-section dl > div { display: contents; }
.info-section dt { color: var(--text-mute); }
.info-section dd {
  margin: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  word-break: break-all;
}
.info-section dd.plain { font-family: var(--font-sans); font-size: 12.5px; }
.info-section .mono { font-family: var(--font-mono); font-size: 11.5px; }

/* ============================================================
   Transfer progress modal
   ============================================================ */
.transfer-progress-bar {
  width: 100%; height: 6px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
  position: relative;
}
.transfer-progress-bar > div {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 240ms ease;
  position: relative;
  z-index: 1;
}
/* Sweep stripe across the whole track while transfer is active. Visible
 * regardless of fill width (vs `> div::after` which has 0 width at 0%).
 * Toggled from JS via `.in-progress` on the outer bar.
 */
.transfer-progress-bar.in-progress::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: -30%;
  width: 30%;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
  opacity: 0.55;
  animation: transfer-sweep 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes transfer-sweep {
  0%   { left: -30%; }
  100% { left: 100%; }
}
.transfer-item-list {
  list-style: none;
  padding: 0; margin: 12px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  max-height: 320px;
  overflow-y: auto;
}
.transfer-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
}
.transfer-item:last-child { border-bottom: 0; }
/* Status badge: plain-text colored pill per row state. Text content is set
 * from JS in setRowStatus(); CSS handles the per-state color scheme.
 */
.transfer-item .status {
  flex-shrink: 0;
  min-width: 84px;
  padding: 2px 10px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.transfer-item .key {
  flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}
.transfer-item.done .key   { color: var(--success); }
.transfer-item.error .key  { color: var(--danger); }
.transfer-item.pending .status {
  background: var(--surface-3);
  color: var(--text-mute);
}
.transfer-item.active .status {
  background: var(--accent-soft);
  color: var(--accent);
  animation: transfer-state-pulse 1.6s ease-in-out infinite;
}
.transfer-item.done .status {
  background: rgba(79, 122, 76, 0.15);
  color: var(--success);
}
.transfer-item.error .status {
  background: var(--danger-soft);
  color: var(--danger);
}
@keyframes transfer-state-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}
.transfer-item .err-msg {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 6px;
}

/* Drag ghost shown while dragging items between panes */
.drag-ghost {
  position: fixed;
  z-index: 500;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--text);
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-sans);
}

/* ============================================================
   Auth overlay + auth card
   ============================================================ */
.auth-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 50% -10%, var(--accent-soft) 0%, transparent 55%),
    var(--bg);
  z-index: 1000;
  display: grid; place-items: center;
  padding: 32px 24px;
  overflow-y: auto;
}
.auth-card {
  width: 420px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 28px 28px 22px;
}
.auth-brand {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--divider);
}
.auth-brand .brand-mark {
  width: 40px; height: 40px;
  font-size: 17px;
}
.auth-brand .brand-title { font-size: 19px; }
.auth-brand .brand-sub { font-size: 12.5px; }

.auth-form { display: flex; flex-direction: column; }
.auth-form label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 14px;
}
.auth-form label input {
  display: block;
  width: 100%;
  height: 36px;
  margin-top: 6px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13.5px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.auth-form label input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.auth-form .hint {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  text-transform: none;
  letter-spacing: 0;
}
.auth-submit { width: 100%; height: 40px; font-size: 14px; margin-top: 4px; justify-content: center; }
.auth-back   { width: 100%; height: 32px; font-size: 12px; margin-top: 8px; justify-content: center; }

.enroll-qr {
  display: grid; place-items: center;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 0 auto 14px;
  max-width: 220px;
}
.enroll-qr svg { display: block; max-width: 190px; height: auto; }
.enroll-secret {
  display: inline-block;
  padding: 4px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  letter-spacing: 0.04em;
}

.recovery-codes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 12px;
}
.recovery-codes .code {
  letter-spacing: 0.04em;
  color: var(--text);
  padding: 4px 0;
}
.recovery-codes .code.used {
  color: var(--text-mute);
  text-decoration: line-through;
}

.check-confirm {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  margin: 12px 0;
}
.check-confirm input { cursor: pointer; width: auto; height: auto; }

/* Account modal sections */
.account-section {
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--divider);
}
.account-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.account-section h4 {
  margin: 0 0 14px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
}

/* TOTP cell grid (login step 2 + enrollment) */
.totp-grid { display: flex; gap: 8px; justify-content: center; margin: 6px 0; }
.totp-cell {
  width: 46px; height: 54px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  color: var(--text);
}
.totp-cell:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.totp-cell.filled { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ============================================================
   Overwrite confirmation modal
   ============================================================ */
.overwrite-list {
  list-style: none;
  padding: 0; margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--surface);
}
.overwrite-item {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  row-gap: 2px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  align-items: start;
}
.overwrite-item:last-child { border-bottom: 0; }
.overwrite-item:hover { background: var(--surface-2); }
.overwrite-icon { grid-row: 1 / 3; align-self: center; }
.overwrite-name {
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.overwrite-meta {
  color: var(--text-mute);
  font-size: 11.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.overwrite-meta .sep { opacity: .6; }
.overwrite-rename-preview {
  color: var(--accent);
  font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; border: 2px solid transparent; }

/* ============================================================
   Responsive (basic — mobile redesign lands in a follow-up MR)
   ============================================================ */
.mobile-only { display: none; }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 10, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 999;
}

@media (max-width: 900px) {
  /* Two-pane mode disabled below this breakpoint. */
  .panes-wrap.dual { grid-template-columns: 1fr; }
  .pane[data-pane="right"] { display: none !important; }
  .dual-only-trigger { display: none !important; }
}

@media (max-width: 768px) {
  #app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 78%;
    max-width: 320px;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(.2,.8,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .mobile-only { display: inline-grid; }

  .toolbar { padding: 10px 14px; }
  .actions { gap: 4px; }
  .search-box { flex: 1 1 100%; max-width: 100%; }

  .info-panel { width: 100%; }

  .grid td, .grid th { padding: 10px 12px; }
  .grid .col-size, .grid .col-date,
  .grid th.col-size, .grid th.col-date { display: none; }
}

@media (max-width: 480px) {
  .auth-card { padding: 22px 20px; border-radius: 10px; }
}

/* ============================================================
   In-app dialogs (confirm / prompt / choice) — replace
   browser-native window.confirm/alert/prompt.
   ============================================================ */
.dialog-backdrop .modal.modal-sm {
  width: 440px;
  max-width: 100%;
}
.dialog-body {
  padding: 18px 22px 8px;
}
.dialog-msg {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.dialog-msg code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.dialog-input {
  display: block;
  width: 100%;
  height: 38px;
  margin-top: 14px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.dialog-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.dialog-error {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--danger);
}
.dialog-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 18px 18px;
  border-top: 1px solid var(--divider);
  background: var(--surface-2);
}
.dialog-foot .btn { min-width: 90px; }
.dialog-foot .btn:empty,
.dialog-foot .btn[data-act="cancel"]:not(:has(*))[hidden] { display: none; }

.dialog-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.dialog-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.dialog-choice:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}
.dialog-choice:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.dialog-choice.recommended {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dialog-choice-label {
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.dialog-choice-label .recommended-tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 999px;
}
.dialog-choice-hint {
  font-size: 12.5px;
  color: var(--text-dim);
}
