/* ==========================================================================
   First Notch Drive — interface styles

   A premium cloud-storage look: teal brand, generous white space, soft
   elevation, and restrained colour used only for actions, folders, file-type
   indicators and status.

   Every class name from the previous stylesheet is preserved, so the existing
   markup and JavaScript keep working.
   ========================================================================== */

/* ---- Tokens -------------------------------------------------------------- */

:root {
  /* ---- Brand ------------------------------------------------------------
     Sampled directly from assets/images/logo.png. The mark is a blue-to-cyan
     swoosh (54% of its coloured pixels), a deep purple-magenta ring (25%) and
     an orange flame (20%), so blue and cyan lead, purple and magenta are the
     secondary accents, and orange is the highlight.

     Everything below is expressed in terms of these values — no rule further
     down hard-codes a brand colour. */
  --brand-blue: #066bbd;           /* the swoosh at its bluest */
  --brand-blue-deep: #04518f;      /* darkened for hover and pressed */
  --brand-cyan: #02afbe;           /* the swoosh at its most cyan */
  --brand-teal: #01838e;           /* cyan darkened until legible as text */
  --brand-purple: #740b69;         /* the ring */
  --brand-violet: #520261;         /* the ring at its deepest */
  --brand-magenta: #8b0961;        /* the ring's warm edge */
  --brand-orange: #ea652e;         /* the flame */
  --brand-orange-deep: #a8481f;    /* flame darkened until legible as text */

  /* The one brand gradient: blue -> cyan -> purple, following the mark. */
  --brand-gradient: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-cyan) 52%, var(--brand-purple) 100%);

  /* ---- Semantic ---------------------------------------------------------- */
  --primary: var(--brand-blue);
  --primary-hover: var(--brand-blue-deep);
  --primary-soft: #e7f1fa;
  --primary-ink: #044f8c;
  --secondary: var(--brand-cyan);
  --secondary-ink: var(--brand-teal);

  /* Purple, for team spaces and small badges only. */
  --accent: var(--brand-purple);
  --accent-soft: #f6ecf5;
  --accent-ink: #68095e;

  /* Caution borrows the logo's orange. Success and failure stay green and red
     so status never has to be decoded. */
  --warn: var(--brand-orange);
  --warn-soft: #fcebe1;
  --warn-ink: #9c421c;

  --canvas: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;

  --line: #e3eaf3;
  --line-strong: #c6d4e3;

  --ink: #0f172a;
  --ink-2: #45586e;
  --ink-3: #5f6e83;

  --danger: #c81e1e;
  --danger-soft: #fee2e2;
  --success: #059669;
  --success-soft: #d1fae5;

  /* Ink used on top of a filled brand or status colour. */
  --on-brand: #ffffff;
  --on-danger: #ffffff;
  --on-success: #ffffff;
  --media-well: var(--surface-2);
  --stage-well: var(--surface-2);

  /* File-type accents, drawn from the brand family. */
  --ft-image: #0888a5;
  --ft-video: #a1156f;
  --ft-audio: #740b69;
  --ft-pdf: #c81e1e;
  --ft-word: #066bbd;
  --ft-excel: #01838e;
  --ft-ppt: #b34d22;
  --ft-archive: #8a5b1f;
  --ft-text: #5f6e83;

  --r-xs: 8px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(6, 42, 74, 0.05);
  --shadow-sm: 0 1px 3px rgba(6, 42, 74, 0.08), 0 1px 2px rgba(6, 42, 74, 0.04);
  --shadow: 0 4px 12px rgba(6, 42, 74, 0.09), 0 1px 3px rgba(6, 42, 74, 0.05);
  --shadow-md: 0 10px 24px rgba(6, 42, 74, 0.11), 0 2px 6px rgba(6, 42, 74, 0.05);
  --shadow-lg: 0 24px 56px rgba(6, 42, 74, 0.18), 0 4px 12px rgba(6, 42, 74, 0.08);
  --shadow-brand: 0 4px 14px rgba(6, 107, 189, 0.26);

  --font-display: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --topbar-h: 68px;
  --sidebar-w: 264px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="dark"] {
  /* Deep navy ground; the swoosh's cyan carries the accents. */
  --brand-blue: #4cb2ee;
  --brand-blue-deep: #7cc8f4;
  --brand-cyan: #22d3ee;
  --brand-teal: #2dd4bf;
  --brand-purple: #c084fc;
  --brand-violet: #a78bfa;
  --brand-magenta: #e879b8;
  --brand-orange: #fb923c;
  --brand-orange-deep: #fdba74;

  --brand-gradient: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-cyan) 52%, var(--brand-purple) 100%);

  --primary: var(--brand-cyan);
  --primary-hover: #67e8f9;
  --primary-soft: #0d2f3d;
  --primary-ink: #a5f0fc;
  --secondary: #06a6c7;
  --secondary-ink: var(--brand-teal);

  --accent: var(--brand-purple);
  --accent-soft: #2a1c3d;
  --accent-ink: #d8bafd;

  --warn: var(--brand-orange);
  --warn-soft: #3a2413;
  --warn-ink: #fdba74;

  --canvas: #0a1524;
  --surface: #111e30;
  --surface-2: #17263a;
  --surface-3: #22344b;

  --line: #22344b;
  --line-strong: #33475f;

  --ink: #e6edf6;
  --ink-2: #afc0d2;
  --ink-3: #8398af;

  --danger: #f87171;
  --danger-soft: #3a1d1d;
  --success: #34d399;
  --success-soft: #0f3129;

  --on-brand: #04202b;
  --on-danger: #2a0e0e;
  --on-success: #04231b;
  --media-well: #0c1929;
  --stage-well: #06111f;

  --ft-image: #22d3ee;
  --ft-video: #f0a0d0;
  --ft-audio: #c084fc;
  --ft-pdf: #f87171;
  --ft-word: #60a5fa;
  --ft-excel: #2dd4bf;
  --ft-ppt: #fb923c;
  --ft-archive: #fbbf24;
  --ft-text: #8398af;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.65);
  --shadow-brand: 0 4px 14px rgba(34, 211, 238, 0.2);
}

/* ---- Base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--primary-soft); color: var(--primary-ink); }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-pill);
  border: 4px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.mono { font-variant-numeric: tabular-nums; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The browser's own [hidden] rule is display:none, but any author rule with
   a display value beats it. Several elements here are toggled through the
   hidden property and are also flex or grid containers, so the attribute is
   made authoritative once, centrally. */
[hidden] { display: none !important; }

/* Kept as a hook from the previous design; now a quiet brand edge. */
.notched { position: relative; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

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

/* ---- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background-color 0.16s var(--ease), border-color 0.16s var(--ease),
              color 0.16s var(--ease), box-shadow 0.16s var(--ease), transform 0.1s var(--ease);
}
.btn svg { flex-shrink: 0; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--primary); color: var(--on-brand); box-shadow: var(--shadow-brand); }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-2);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }

.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-danger:hover { filter: brightness(1.08); }

.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-pill);
  color: var(--ink-2);
  transition: background-color 0.16s var(--ease), color 0.16s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn.is-active { background: var(--primary-soft); color: var(--primary-ink); }
.icon-btn.is-danger { color: var(--danger); }
.icon-btn.is-danger:hover { background: var(--danger-soft); }

/* ---- Top bar ------------------------------------------------------------- */

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
  color: var(--ink);
  text-decoration: none;
  transition: opacity 0.16s var(--ease);
}
.brand:hover { text-decoration: none; opacity: 0.82; }
.brand img { display: block; }
/* The mark is portrait (80x97). Height drives the size, width follows, and
   object-fit guarantees it is never stretched at any breakpoint. */
.brand-mark {
  flex-shrink: 0;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}
.brand-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.brand-name em { font-style: normal; color: var(--primary); }

.search { position: relative; flex: 1; max-width: 620px; margin: 0 auto; }
.search > svg {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
  transition: color 0.16s var(--ease);
  z-index: 1;
}
.search input {
  width: 100%;
  height: 46px;
  padding: 0 44px 0 48px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14.5px;
  transition: background-color 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease);
}
.search input::placeholder { color: var(--ink-3); }
.search input::-webkit-search-cancel-button { display: none; }
.search input:hover { background: var(--surface-3); }
.search input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft), var(--shadow-sm);
}
.search:focus-within > svg { color: var(--primary); }

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: var(--r-pill);
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  z-index: 1;
}
.search-clear:hover { background: var(--surface-3); color: var(--ink); }
.search-clear.is-visible { display: flex; }

.topbar-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ---- Popover panels ------------------------------------------------------ */

.account { position: relative; }

.account-panel,
.help-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  width: 272px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  display: none;
  z-index: 60;
  animation: popIn 0.16s var(--ease-out);
}
.account-panel.is-open,
.help-panel.is-open { display: block; }
.help-panel { width: 300px; padding: 6px; }

.account-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 12px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.account-head strong {
  display: block;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}
.account-head span { display: block; font-size: 12.5px; color: var(--ink-3); word-break: break-all; }

.panel-title {
  padding: 12px 12px 8px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink-2);
}
.shortcut-row kbd {
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 7px;
  color: var(--ink-2);
  white-space: nowrap;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--ink-2);
  text-align: left;
  text-decoration: none;
  transition: background-color 0.13s var(--ease), color 0.13s var(--ease);
}
.menu-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.menu-item svg { color: var(--ink-3); flex-shrink: 0; }
.menu-item:hover svg { color: var(--primary); }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger svg, .menu-item.is-danger:hover svg { color: var(--danger); }
.menu-item.is-danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; background: var(--line); margin: 6px; }

/* ---- Avatar -------------------------------------------------------------- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--on-brand);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
  box-shadow: var(--shadow-xs);
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
button.avatar:hover { transform: scale(1.05); box-shadow: var(--shadow-sm); }
.avatar-lg { width: 46px; height: 46px; font-size: 15px; }

/* ---- Layout -------------------------------------------------------------- */

.shell { display: flex; flex: 1; min-height: 0; position: relative; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: 4px;
}

.sidebar-top { padding: 18px 16px 10px; position: relative; }

.new-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 52px;
  padding: 0 22px;
  border-radius: var(--r-lg);
  background: var(--primary);
  color: var(--on-brand);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-brand);
  transition: background-color 0.16s var(--ease), box-shadow 0.16s var(--ease), transform 0.12s var(--ease);
}
.new-btn:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.new-btn:active { transform: translateY(0); }
.new-btn:disabled {
  background: var(--surface-2);
  color: var(--ink-3);
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

.new-menu {
  position: absolute;
  left: 16px;
  right: 16px;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  display: none;
  z-index: 45;
  animation: popIn 0.16s var(--ease-out);
}
.new-menu.is-open { display: block; }

.sidebar-nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 11px 16px;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-2);
  text-align: left;
  text-decoration: none;
  transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}
.nav-item svg { color: var(--ink-3); flex-shrink: 0; transition: color 0.14s var(--ease); }
.nav-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-item:hover svg { color: var(--ink-2); }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary-ink); }
.nav-item.is-active svg { color: var(--primary); }

.sidebar-section {
  padding: 20px 22px 8px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.sidebar-scroll { flex: 1; overflow-y: auto; min-height: 0; padding-bottom: 8px; }

.recent-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: calc(100% - 20px);
  margin: 0 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--ink-2);
  transition: background-color 0.13s var(--ease);
}
.recent-item:hover { background: var(--surface-2); color: var(--ink); }
.recent-item span { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-empty { padding: 6px 22px 12px; font-size: 13px; color: var(--ink-3); }

/* ---- Storage card -------------------------------------------------------- */

.storage { padding: 14px 16px 18px; flex-shrink: 0; }

.storage-card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  background: linear-gradient(150deg, var(--primary-soft) 0%, var(--surface) 60%);
  box-shadow: var(--shadow-xs);
}
html[data-theme="dark"] .storage-card { background: var(--surface-2); }

.storage-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.storage-head svg { color: var(--primary); }
.storage-label {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.storage-pct {
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--surface);
  padding: 2px 9px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-xs);
}
html[data-theme="dark"] .storage-pct { background: var(--surface-3); }
.storage-amount {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.2;
}
.storage-text { font-size: 12.5px; color: var(--ink-3); margin: 3px 0 12px; }

.track { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.bar {
  height: 100%;
  width: 0;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-cyan) 58%, var(--brand-purple));
  transition: width 0.5s var(--ease-out);
}
.bar.is-done { background: linear-gradient(90deg, var(--success), var(--secondary)); }
.bar.is-error { background: var(--danger); }

/* ---- Main ---------------------------------------------------------------- */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 30px 16px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.toolbar-heading { min-width: 0; }
.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
}
.crumb {
  padding: 3px 8px;
  border-radius: var(--r-xs);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  transition: background-color 0.13s var(--ease), color 0.13s var(--ease);
}
.crumb:hover { background: var(--surface-2); color: var(--primary); }
.crumb:last-child { color: var(--ink-2); font-weight: 600; }
.crumb-sep { color: var(--line-strong); display: flex; }

.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.seg { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: var(--r-pill); }
.seg .icon-btn { width: 34px; height: 34px; }
.seg .icon-btn.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); }

/* Select all: matches the sort and filter pills beside it. */
.select-all {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 14px 0 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease), color 0.14s var(--ease);
}
.select-all:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }
.select-all:disabled { opacity: 0.45; cursor: not-allowed; }

.select-all-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 6px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  color: var(--on-brand);
  flex-shrink: 0;
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease);
}
.select-all-check,
.select-all-dash { display: none; }
.select-all-check { align-items: center; }
.select-all-dash { width: 9px; height: 2px; border-radius: 1px; background: currentColor; }

/* Checked: every visible file is selected. Indeterminate: only some are. */
.select-all.is-checked .select-all-box,
.select-all.is-indeterminate .select-all-box { background: var(--primary); border-color: var(--primary); }
.select-all.is-checked .select-all-check { display: flex; }
.select-all.is-indeterminate .select-all-dash { display: block; }
.select-all.is-checked,
.select-all.is-indeterminate { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* Sort / filter dropdowns */
.dropdown { position: relative; }
.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease), color 0.14s var(--ease);
}
.dropdown-toggle:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }
.dropdown-toggle.is-set { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 214px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 50;
  animation: popIn 0.15s var(--ease-out);
}
.dropdown-menu.is-open { display: block; }
.dropdown-menu .menu-item { font-size: 13.5px; padding: 9px 11px; }
.dropdown-menu .menu-item .check { margin-left: auto; color: var(--primary); visibility: hidden; }
.dropdown-menu .menu-item.is-chosen { color: var(--ink); font-weight: 600; }
.dropdown-menu .menu-item.is-chosen .check { visibility: visible; }

/* ---- Selection bar ------------------------------------------------------- */

.selection-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 30px 4px;
  padding: 10px 12px 10px 14px;
  background: var(--primary);
  border-radius: var(--r);
  box-shadow: var(--shadow-brand);
  flex-shrink: 0;
  animation: popIn 0.18s var(--ease-out);
}
.selection-bar.is-open { display: flex; }
.selection-count { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: var(--on-brand); }
.selection-bar .icon-btn { color: var(--on-brand); width: 36px; height: 36px; }
.selection-bar .icon-btn:hover { background: color-mix(in srgb, var(--on-brand) 18%, transparent); color: var(--on-brand); }
.selection-bar .icon-btn.is-danger { color: var(--on-brand); }
.selection-bar .icon-btn:disabled { opacity: 0.45; }

/* ---- Content ------------------------------------------------------------- */

.content { flex: 1; overflow-y: auto; padding: 6px 30px 110px; }

.section { margin-bottom: 32px; }
.section:last-of-type { margin-bottom: 0; }
.section-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink-2);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.count-pill {
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 1px 8px;
  border-radius: var(--r-pill);
}

/* ---- Folder cards -------------------------------------------------------- */

.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 12px; }

.folder-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  cursor: pointer;
  text-align: left;
  width: 100%;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
}
.folder-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.folder-card.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-sm);
}

.folder-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}
html[data-theme="dark"] .folder-icon { color: var(--primary); }
/* A team member's own space is the one place purple earns its keep. */
.folder-card.is-member .folder-icon { background: var(--accent-soft); color: var(--accent-ink); }
html[data-theme="dark"] .folder-card.is-member .folder-icon { color: var(--accent); }

.folder-body { min-width: 0; flex: 1; }
.folder-name {
  display: block;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-meta { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ---- File cards ---------------------------------------------------------- */

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

.file-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
}
.file-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.file-card.is-selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow); }

.file-thumb {
  position: relative;
  height: 142px;
  background: var(--media-well);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s var(--ease-out);
}
.file-card:hover .file-thumb img { transform: scale(1.045); }

.thumb-plate {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
html[data-theme="dark"] .thumb-plate { background: var(--surface-3); }

.play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.05), rgba(15, 23, 42, 0.42));
  color: #fff;
}
.play-badge svg {
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
  transition: transform 0.22s var(--ease-out);
}
.file-card:hover .play-badge svg { transform: scale(1.12); }

.duration-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
}

.type-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: var(--shadow-xs);
}

.file-info { padding: 12px 13px 13px; display: flex; gap: 10px; align-items: flex-start; }
.file-icon-slot { flex-shrink: 0; margin-top: 1px; display: flex; }
.file-name {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-meta {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-more {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease), background-color 0.16s var(--ease);
  z-index: 3;
}
.card-more:hover { background: var(--surface-2); color: var(--ink); }
.file-card:hover .card-more,
.folder-card:hover .card-more,
.card-more:focus-visible { opacity: 1; transform: none; }
.folder-card .card-more {
  position: static;
  flex-shrink: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
}
.folder-card .card-more:hover { background: var(--surface-2); }

.select-box {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  opacity: 0;
  transition: opacity 0.16s var(--ease), background-color 0.16s var(--ease), border-color 0.16s var(--ease);
  z-index: 3;
}
.file-card:hover .select-box,
.folder-card:hover .select-box,
.select-box:focus-visible { opacity: 1; }
.select-box.is-checked { opacity: 1; background: var(--primary); border-color: var(--primary); color: var(--on-brand); }
.folder-card .select-box {
  position: static;
  flex-shrink: 0;
  background: var(--surface-2);
  border-color: var(--line-strong);
  backdrop-filter: none;
}
.folder-card .select-box.is-checked { background: var(--primary); border-color: var(--primary); color: var(--on-brand); }

/* Star: sits beside the ... button and behaves the same way — revealed on
   hover, but always visible once the file is starred, so the state reads at a
   glance without hovering. */
.star-btn {
  position: absolute;
  top: 8px;
  right: 44px;
  width: 30px;
  height: 30px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease),
              background-color 0.16s var(--ease), color 0.16s var(--ease);
  z-index: 3;
}
.star-btn:hover { background: var(--surface-2); color: var(--warn); }
.file-card:hover .star-btn,
.star-btn:focus-visible { opacity: 1; transform: none; }
.star-btn.is-starred { opacity: 1; transform: none; color: var(--warn); }

/* In the list the star is a normal inline control, not an overlay. */
.row-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.row-actions .star-btn {
  position: static;
  width: 30px;
  height: 30px;
  background: transparent;
  box-shadow: none;
  opacity: 0;
  transform: none;
}
.file-row:hover .row-actions .star-btn,
.row-actions .star-btn.is-starred,
.row-actions .star-btn:focus-visible { opacity: 1; }
.row-actions .star-btn:hover { background: var(--surface-3); }

/* Preview footer button picks up the same amber once starred. */
#previewStar.is-starred { color: var(--warn); border-color: var(--warn); }

@media (hover: none) {
  .star-btn { opacity: 1; transform: none; }
  .row-actions .star-btn { opacity: 1; }
}

/* ---- Sharing ------------------------------------------------------------- */

.share-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.share-file-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-file-meta { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

.share-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 13.5px;
  color: var(--ink-2);
}

.share-url-row { display: flex; gap: 8px; align-items: center; }
.share-url-row .input {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
}
.share-url-row .btn { flex-shrink: 0; height: 44px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip-share { background: var(--primary-soft); color: var(--primary-ink); }
.chip-lock { background: var(--warn-soft); color: var(--warn-ink); padding: 0 6px; }
html[data-theme="dark"] .chip-lock { color: var(--warn); }
.row-name .chip { flex-shrink: 0; }

/* The public landing page reuses the auth card. */
.share-stage {
  margin: 4px 0 22px;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.share-stage img,
.share-stage video { max-width: 100%; max-height: 52vh; display: block; }
.share-stage audio { width: 100%; padding: 18px; }
.share-stage iframe { width: 100%; height: 52vh; border: none; background: #fff; }

@media (max-width: 560px) {
  .share-url-row { flex-direction: column; align-items: stretch; }
  .share-url-row .btn { width: 100%; }
  .share-stage img, .share-stage video { max-height: 40vh; }
  .share-stage iframe { height: 40vh; }
}

/* Download ZIP sits inside the selection bar, so it reads as an action on the
   selection rather than a toolbar button. */
.bulk-zip {
  background: color-mix(in srgb, var(--on-brand) 18%, transparent);
  color: var(--on-brand);
  border: 1px solid color-mix(in srgb, var(--on-brand) 30%, transparent);
  margin-left: 4px;
  white-space: nowrap;
}
.bulk-zip:hover:not(:disabled) { background: color-mix(in srgb, var(--on-brand) 28%, transparent); }
.bulk-zip:disabled { opacity: 0.5; cursor: not-allowed; }
.bulk-zip.is-busy svg { animation: spin 1.1s linear infinite; }

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

@media (max-width: 560px) {
  /* On a phone the icons stay and the label goes, to keep the bar on one line. */
  .bulk-zip #bulkZipLabel { display: none; }
  .bulk-zip { padding: 0 11px; margin-left: 2px; }
}

/* ---- Admin dashboard ----------------------------------------------------- */
/* Built from the existing panel, chip, track and status parts so it reads as
   the same product, not a separate admin skin. */

.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.dash-card {
  display: flex;
  flex-direction: column;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.dash-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.dash-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: 14px;
}
.dash-value {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: var(--ink);
}
.dash-label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-top: 4px; }
.dash-note { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }

.dash-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 20px;
  align-items: start;
}
.dash-split .panel { margin-bottom: 20px; }

.dash-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-3);
}
.dash-legend strong { color: var(--ink); font-family: var(--font-display); }

.dash-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.dash-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font-display);
  text-decoration: none;
  transition: background-color 0.16s var(--ease), border-color 0.16s var(--ease), color 0.16s var(--ease);
}
.dash-action:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-ink);
  text-decoration: none;
}
.dash-action svg { color: var(--primary); flex-shrink: 0; }

.dash-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
}
.dash-row:last-child { border-bottom: none; }
.dash-row-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--ink-3);
  flex-shrink: 0;
}
.dash-row-body { flex: 1; min-width: 0; }
.dash-row-main {
  display: block;
  font-size: 13.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-row-main strong { color: var(--ink); font-weight: 600; }
.dash-row-detail { color: var(--ink-3); }
.dash-row-sub { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.dash-row-time { font-size: 12px; color: var(--ink-3); white-space: nowrap; flex-shrink: 0; padding-top: 2px; }

@media (max-width: 560px) {
  .dash-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dash-card { padding: 14px; }
  .dash-value { font-size: 22px; }
  .dash-icon { width: 32px; height: 32px; margin-bottom: 10px; }
  .dash-row { padding: 11px 16px; }
  .dash-actions { grid-template-columns: 1fr 1fr; }
}

/* ---- File pager ----------------------------------------------------------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.pager-count { margin: 0; font-size: 13px; color: var(--ink-3); }
.pager-buttons { display: flex; align-items: center; gap: 10px; }
.pager-position {
  font-size: 13px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 560px) {
  /* On a phone the buttons matter more than the running total. */
  .pager { justify-content: center; }
  .pager-count { width: 100%; text-align: center; order: 2; }
  .pager-buttons { width: 100%; justify-content: space-between; }
}

/* ---- Team management ------------------------------------------------------ */

.team-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.team-filters .input { height: 34px; font-size: 13px; min-width: 140px; }

/* The row whose details are open, so the panel above has an obvious source. */
tr.is-viewing { background: var(--primary-soft); }

.avatar.is-lg { width: 44px; height: 44px; font-size: 15px; }

.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

/* A button mid-submit: the page is about to reload, so say so. */
.btn.is-working { opacity: 0.65; pointer-events: none; }

@media (max-width: 720px) {
  .team-filters { width: 100%; }
  .team-filters .input { flex: 1; min-width: 0; }
  .detail-actions .btn { flex: 1; justify-content: center; }
}

/* ---- Storage -------------------------------------------------------------- */

.storage-headline {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.storage-used {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.storage-of { font-size: 14px; color: var(--ink-3); }
.storage-percent {
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-2);
}

/* The bar keeps the app's usual fill until usage is worth remarking on. */
.bar.is-warning  { background: var(--warn); }
.bar.is-critical { background: var(--danger); }

.storage-level.is-normal   { background: var(--success-soft); color: var(--success); }
.storage-level.is-warning  { background: var(--warn-soft); color: var(--warn-ink); }
html[data-theme="dark"] .storage-level.is-warning { color: var(--warn); }
.storage-level.is-critical { background: var(--danger-soft); color: var(--danger); }

.storage-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.storage-filters .input { height: 34px; font-size: 13px; min-width: 140px; }

.storage-open { color: var(--primary); text-decoration: none; }
.storage-open:hover { text-decoration: underline; }

.type-list { display: flex; flex-direction: column; gap: 4px; }

.type-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) minmax(80px, 2fr) auto;
  align-items: center;
  gap: 16px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
}
.type-row:last-child { border-bottom: 0; }

.type-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.type-size { text-align: right; font-size: 13.5px; white-space: nowrap; }
.type-size .act-ago { display: block; }

@media (max-width: 720px) {
  /* The bar is the first thing to go; the numbers matter more on a phone. */
  .type-row { grid-template-columns: 1fr auto; gap: 10px; }
  .type-bar { display: none; }
  .storage-filters { width: 100%; }
  .storage-filters .input { flex: 1; min-width: 0; }
  .storage-used { font-size: 25px; }
  .storage-percent { margin-left: 0; }
}

/* ---- Drive Sync Center --------------------------------------------------- */

.sync-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.sync-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.sync-filters .input { height: 34px; font-size: 13px; min-width: 150px; }

.sync-progress { margin-top: 16px; }

.progress {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: var(--r-pill);
  background: var(--primary);
  transition: width 0.3s var(--ease);
}

/* The four states a file can be in, as the table shows them. */
.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.sync-state.is-synced  { color: var(--success); }
.sync-state.is-failed  { color: var(--danger); }
.sync-state.is-pending { color: var(--ink-3); }
.sync-state.is-syncing { color: var(--primary); }

.sync-error {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--ink-3);
  max-width: 320px;
}

/* The one spinning thing on the page, while a file is actually in flight. */
.spin { display: inline-block; animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
}

@media (max-width: 720px) {
  .sync-filters { width: 100%; }
  .sync-filters .input { flex: 1; min-width: 0; }
  .sync-error { max-width: none; }
}

/* ---- Dragging items into folders ----------------------------------------- */

/* The item being carried, and its neighbours, while a move drag is running. */
body.is-moving-items .file-card,
body.is-moving-items .file-row,
body.is-moving-items .folder-card { cursor: grabbing; }

body.is-moving-items .folder-card:not(.is-member) {
  border-style: dashed;
  border-color: var(--line-strong);
}

/* The folder under the pointer, ready to take the drop. */
.folder-card.is-drop-target {
  border: 2px solid var(--primary);
  border-style: solid;
  background: var(--primary-soft);
  transform: translateY(-1px);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent);
}
.folder-card.is-drop-target .folder-icon { color: var(--primary); }

/* A folder that cannot take these items says so rather than staying silent. */
.folder-card.is-drop-blocked {
  border: 2px dashed var(--danger);
  background: var(--danger-soft);
  cursor: not-allowed;
  opacity: 0.85;
}

/* ---- Tags ---------------------------------------------------------------- */

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

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 4px 0 9px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 500;
  max-width: 100%;
}
.tag-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  color: inherit;
  opacity: 0.6;
  transition: opacity 0.14s var(--ease), background-color 0.14s var(--ease);
}
.tag-chip button:hover { opacity: 1; background: color-mix(in srgb, var(--accent) 22%, transparent); }

.tag-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 9px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-pill);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
  transition: border-color 0.14s var(--ease), color 0.14s var(--ease);
}
.tag-add-btn:hover { border-color: var(--primary); color: var(--primary); }

.tag-add { margin-top: 10px; }
.tag-suggest { margin-top: 6px; max-height: 190px; overflow-y: auto; }
.tag-suggest-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  text-align: left;
  font-size: 13px;
  color: var(--ink-2);
  transition: background-color 0.13s var(--ease);
}
.tag-suggest-item:hover { background: var(--surface-2); color: var(--ink); }
.tag-suggest-item.is-new { color: var(--primary); }
.tag-uses { margin-left: auto; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Tag chips on cards and rows stay quiet so they never dominate the name. */
.chip-tag { background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }
.chip-more { opacity: 0.75; }
html[data-theme="dark"] .chip-tag { color: var(--accent); }

/* The multi-select filter in advanced search. */
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; max-height: 96px; overflow-y: auto; }
.tag-pick {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 27px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12.5px;
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease), color 0.14s var(--ease);
}
.tag-pick:hover { border-color: var(--line-strong); color: var(--ink); }
.tag-pick.is-on {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-ink);
  font-weight: 600;
}
.tag-pick.is-on .tag-uses { color: inherit; opacity: 0.7; }

@media (max-width: 560px) {
  /* A phone card has no room for tags beside the name. */
  .file-card .chip-tag { display: none; }
}

/* ---- Preview and details ------------------------------------------------- */

/* Preview on the left, details on the right; stacked once there is no room. */
.preview-body { display: flex; flex: 1; min-height: 0; }
.preview-body .preview-stage { flex: 1; min-width: 0; }

.preview-details {
  width: 300px;
  flex-shrink: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
  padding: 18px;
}

.preview-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.preview-actions .btn { width: 100%; }
.preview-actions .btn:first-child { grid-column: 1 / -1; }
.preview-actions .btn.is-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.preview-actions .btn.is-danger:hover { background: var(--danger-soft); }

.detail-section { margin-bottom: 20px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}

.detail-list { margin: 0; display: grid; grid-template-columns: 84px 1fr; gap: 7px 12px; }
.detail-list dt { font-size: 12.5px; color: var(--ink-3); }
.detail-list dd {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
}
.detail-dim { color: var(--ink-3); }

@media (max-width: 900px) {
  /* The panel becomes a sheet the info button slides in over the preview. */
  .preview-body { position: relative; }
  .preview-details {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 88%);
    transform: translateX(100%);
    transition: transform 0.24s var(--ease-out);
    box-shadow: var(--shadow-lg);
    z-index: 5;
  }
  .preview-details.is-open { transform: none; }
}

@media (min-width: 901px) { #previewInfoToggle { display: none; } }

@media (max-width: 560px) {
  .preview-actions { grid-template-columns: 1fr; }
}

/* ---- People with access -------------------------------------------------- */

.access-block { margin-top: 18px; }
.access-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.access-list {
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.access-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.access-row:last-child { border-bottom: none; }
.access-row.is-inactive { opacity: 0.6; }
.access-who { flex: 1; min-width: 0; }
.access-who strong { display: block; font-size: 13.5px; font-weight: 600; }
.access-sub {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.access-level { width: auto; height: 34px; font-size: 13px; padding: 0 8px; flex-shrink: 0; }
.access-empty { padding: 14px 12px; margin: 0; font-size: 13px; color: var(--ink-3); }

.access-add { margin-top: 10px; }
.access-results { margin-top: 8px; max-height: 200px; overflow-y: auto; }
.access-candidate {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--ink-2);
  transition: background-color 0.13s var(--ease);
}
.access-candidate:hover { background: var(--surface-2); color: var(--ink); }
.access-candidate svg { color: var(--primary); flex-shrink: 0; }

.share-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 14px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.share-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

@media (max-width: 560px) {
  .access-row { flex-wrap: wrap; }
  .access-level { width: 100%; }
}

/* ---- Download analytics in the preview ----------------------------------- */

.preview-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 6px;
}
.preview-stats-head { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.preview-stats-head strong { color: var(--ink); font-family: var(--font-display); }
.preview-stats-empty,
.preview-stats-load { display: inline-flex; align-items: center; gap: 6px; }
.preview-stats-list { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.preview-stats-row { display: inline-flex; align-items: center; gap: 6px; }
.preview-stats-row strong { color: var(--ink-2); font-weight: 600; }

@media (max-width: 560px) {
  /* On a phone the footer is tight, so only the headline figure stays. */
  .preview-stats-list { display: none; }
}

/* ---- Advanced search ----------------------------------------------------- */

.adv-panel {
  width: min(430px, calc(100vw - 32px));
  min-width: 0;
  padding: 16px;
}
.adv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.adv-span { grid-column: 1 / -1; }
.adv-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 30px 12px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 4px 0 10px;
  border-radius: var(--r-pill);
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-size: 12.5px;
  font-weight: 500;
  max-width: 100%;
}
.filter-chip-key {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0.75;
}
.filter-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: inherit;
  opacity: 0.65;
  transition: opacity 0.14s var(--ease), background-color 0.14s var(--ease);
}
.filter-chip button:hover { opacity: 1; background: color-mix(in srgb, var(--primary) 18%, transparent); }

.filter-chip-count { font-size: 12.5px; color: var(--ink-3); margin-left: 2px; }
.filter-chip-clear {
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--primary);
  padding: 4px 8px;
  border-radius: var(--r-xs);
}
.filter-chip-clear:hover { background: var(--primary-soft); }

/* Results dim while the server answers, so a slow query still feels handled. */
.content.is-loading { opacity: 0.55; transition: opacity 0.12s var(--ease); pointer-events: none; }

@media (max-width: 1100px) { .filter-chips { margin: 0 22px 10px; } }
@media (max-width: 860px)  { .filter-chips { margin: 0 16px 10px; } }
@media (max-width: 560px) {
  .adv-panel { width: calc(100vw - 24px); }
  .adv-grid { grid-template-columns: 1fr; }
  .toolbar-actions #advToggle span { display: none; }
}

/* ---- Activity log -------------------------------------------------------- */

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}
.filter-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.act-verb {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}
.act-verb svg { color: var(--primary); flex-shrink: 0; }

.act-item {
  font-size: 13.5px;
  color: var(--ink-2);
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.act-ago { display: block; font-size: 12px; color: var(--ink-3); margin-top: 1px; }

.activity-table td { vertical-align: middle; }
.only-small { display: none; }
@media (max-width: 760px) { .only-small { display: block; } }

/* Dimmed while the next page loads, so a slow query still feels answered. */
#activityResults.is-loading { opacity: 0.5; pointer-events: none; transition: opacity 0.15s var(--ease); }

.btn.is-disabled { opacity: 0.4; pointer-events: none; }

@media (max-width: 760px) {
  /* The timestamp column is the first to go; the relative time stays with the
     row instead, so the table still fits without sideways scrolling. */
  .activity-table .col-when { display: none; }
  .activity-table { min-width: 0; }
  .act-item { max-width: 46vw; }
  .filter-actions .preview-meta { margin-left: 0 !important; width: 100%; }
}

/* ---- File list ----------------------------------------------------------- */

.file-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.list-head,
.file-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 140px 116px 96px 72px;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
}
.list-head {
  height: 42px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.file-row {
  height: 58px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background-color 0.12s var(--ease);
}
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--surface-2); }
.file-row.is-selected { background: var(--primary-soft); }

.row-thumb {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: var(--r-xs);
  overflow: hidden;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-row.is-selected .row-thumb { background: var(--surface); }
.row-name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.row-dim { font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Chips --------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--ink-2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-owner { background: var(--primary-soft); color: var(--primary-ink); }
.chip-warn { background: var(--danger-soft); color: var(--danger); }
.chip-ok { background: var(--success-soft); color: var(--success); }
.chip-muted { background: var(--surface-2); color: var(--ink-3); }
.chip-brass { background: var(--warn-soft); color: var(--warn-ink); }
html[data-theme="dark"] .chip-brass { color: var(--warn); }
.chip-accent { background: var(--accent-soft); color: var(--accent-ink); }
html[data-theme="dark"] .chip-accent { color: var(--accent); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ---- Empty state --------------------------------------------------------- */

.empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 76px 24px 40px;
  animation: riseIn 0.3s var(--ease-out);
}
.empty.is-visible { display: flex; }
.empty-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 116px;
  height: 116px;
  margin-bottom: 24px;
  border-radius: 32px;
  color: var(--primary);
  background: linear-gradient(140deg, var(--primary-soft), color-mix(in srgb, var(--accent-soft) 60%, var(--surface-2)));
  box-shadow: var(--shadow-sm);
}
.empty h3 { font-size: 20px; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 7px; }
.empty p { margin: 0 0 24px; font-size: 14.5px; color: var(--ink-3); max-width: 40ch; }
.empty-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---- Drop overlay -------------------------------------------------------- */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, var(--canvas) 82%, transparent);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.16s var(--ease);
}
body.is-dragging .drop-overlay { display: flex; }
.drop-frame {
  border: 2.5px dashed var(--primary);
  border-radius: var(--r-xl);
  background: var(--surface);
  padding: 52px 72px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: riseIn 0.24s var(--ease-out);
}
.drop-frame svg { color: var(--primary); margin-bottom: 16px; }
.drop-frame h3 { font-size: 22px; margin-bottom: 6px; }
.drop-frame p { margin: 0; color: var(--ink-3); font-size: 14.5px; }

/* ---- Upload experience --------------------------------------------------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 46px 24px;
  border: 2px dashed color-mix(in srgb, var(--primary) 42%, transparent);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface));
  cursor: pointer;
  transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  border-radius: 22px;
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.dropzone-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; }
.dropzone h4 { font-size: 17px; margin-bottom: 5px; }
.dropzone p { margin: 0 0 18px; font-size: 13.5px; color: var(--ink-3); }

.upload-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r);
  background: var(--surface-2);
  margin-bottom: 12px;
  font-size: 13.5px;
}
.upload-summary strong { font-family: var(--font-display); font-weight: 700; }

.upload-list { max-height: 340px; overflow-y: auto; }

.upload-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 70;
  display: none;
  animation: riseIn 0.24s var(--ease-out);
}
.upload-panel.is-open { display: block; }
.upload-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 12px 13px 18px;
  background: var(--primary);
  color: var(--on-brand);
}
.upload-head h4 { font-size: 14px; color: inherit; font-weight: 700; }
.upload-head .icon-btn { color: inherit; width: 30px; height: 30px; }
.upload-head .icon-btn:hover { background: rgba(255, 255, 255, 0.2); color: inherit; }

.upload-row { padding: 13px 18px; border-bottom: 1px solid var(--line); }
.upload-row:last-child { border-bottom: none; }
.upload-row-top { display: flex; align-items: center; gap: 11px; margin-bottom: 9px; }
.upload-row-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--ink-3);
  flex-shrink: 0;
}
.upload-row-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-row-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; font-weight: 400; }
.upload-row-status { font-size: 12px; font-weight: 600; color: var(--ink-3); flex-shrink: 0; }
.upload-row-status.is-error { color: var(--danger); }
.upload-row-status.is-done { color: var(--success); }
.upload-row-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 8px;
  background: var(--danger-soft);
  padding: 7px 10px;
  border-radius: var(--r-xs);
}
.upload-row .track { height: 6px; }

/* ---- Modals -------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.16s var(--ease);
}
.modal.is-open { display: flex; }
.modal-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  max-height: min(88vh, 800px);
  overflow: hidden;
  animation: riseIn 0.22s var(--ease-out);
}
.modal-card.is-wide { max-width: 540px; }
.modal-card.is-preview { max-width: 1040px; max-height: 94vh; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-head h3 { font-size: 17px; }
.modal-title-wrap { display: flex; align-items: center; gap: 11px; min-width: 0; }
.modal-title-wrap span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-body.is-flush { padding: 0; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.modal-foot-right { display: flex; gap: 9px; align-items: center; margin-left: auto; }

/* ---- Preview / lightbox -------------------------------------------------- */

.preview-stage {
  position: relative;
  flex: 1;
  min-height: 300px;
  max-width: 100%;
  background: var(--stage-well);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
}
.preview-stage img,
.preview-stage video {
  max-width: 100%;
  max-height: 68vh;
  border-radius: var(--r-xs);
  display: block;
  box-shadow: var(--shadow-md);
}
.preview-stage img { transition: transform 0.22s var(--ease-out); cursor: zoom-in; }
.preview-stage.is-zoomed { overflow: auto; }
.preview-stage.is-zoomed img { cursor: zoom-out; max-width: none; max-height: none; }
.preview-stage iframe {
  width: 100%;
  height: 68vh;
  border: none;
  border-radius: var(--r-xs);
  background: #fff;
}
.preview-stage audio { width: min(520px, 100%); }
.preview-none {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 20px;
  color: var(--ink-3);
  text-align: center;
}
.preview-none p { margin: 0; font-size: 14px; }
.preview-meta { font-size: 12.5px; color: var(--ink-3); }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--shadow-md);
  transition: background-color 0.16s var(--ease), transform 0.16s var(--ease);
  z-index: 4;
}
.lightbox-nav:hover { background: var(--surface-2); color: var(--ink); transform: translateY(-50%) scale(1.06); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

.zoom-controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--surface);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-md);
  z-index: 4;
}
.zoom-controls .icon-btn { width: 34px; height: 34px; }
.zoom-level { font-size: 12px; font-weight: 600; color: var(--ink-2); min-width: 48px; text-align: center; }

/* ---- Forms --------------------------------------------------------------- */

.field { margin-bottom: 17px; }
.field:last-child { margin-bottom: 0; }
.label {
  display: block;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 7px;
}
.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input::placeholder { color: var(--ink-3); }
select.input { appearance: none; padding-right: 34px; cursor: pointer; }
.hint { font-size: 12.5px; color: var(--ink-3); margin-top: 7px; }
.error-text { font-size: 13px; color: var(--danger); margin-top: 7px; display: none; }
.error-text.is-visible { display: block; }

.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r);
  font-size: 13.5px;
  margin-bottom: 18px;
  border: 1px solid transparent;
  animation: riseIn 0.24s var(--ease-out);
}
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.alert-ok { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.alert-info { background: var(--primary-soft); color: var(--primary-ink); border-color: color-mix(in srgb, var(--primary) 22%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
html[data-theme="dark"] .alert-warn { color: var(--warn); }
.alert strong { display: block; margin-bottom: 3px; font-family: var(--font-display); font-weight: 700; }

/* ---- Move picker --------------------------------------------------------- */

.picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 20px;
  text-align: left;
  color: var(--ink-2);
  transition: background-color 0.12s var(--ease);
}
.picker-row:hover { background: var(--surface-2); color: var(--ink); }
.picker-row > svg:first-child { color: var(--primary); flex-shrink: 0; }
.picker-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.picker-row small { font-size: 12px; color: var(--ink-3); }
.picker-empty { padding: 38px 20px; text-align: center; color: var(--ink-3); font-size: 13.5px; }

/* ---- Context menu -------------------------------------------------------- */

.context-menu {
  position: fixed;
  z-index: 110;
  min-width: 224px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  animation: popIn 0.14s var(--ease-out);
}
.context-menu.is-open { display: block; }

/* ---- Toast --------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 16px);
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(540px, calc(100vw - 32px));
  padding: 13px 20px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--canvas);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s var(--ease-out), transform 0.22s var(--ease-out);
}
.toast.is-open { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); color: var(--on-danger); }
.toast.is-success { background: var(--success); color: var(--on-success); }

.fab { display: none; }

/* ---- Auth pages ---------------------------------------------------------- */

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(80% 55% at 50% -5%, var(--primary-soft) 0%, transparent 60%),
    radial-gradient(60% 50% at 100% 100%, color-mix(in srgb, var(--secondary) 12%, transparent) 0%, transparent 60%),
    var(--canvas);
}
.auth-card {
  width: 100%;
  max-width: 428px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: 36px 34px 30px;
  overflow: hidden;
  animation: riseIn 0.34s var(--ease-out);
}
/* Brand edge across the top, replacing the old corner cut. */
.auth-card.notched::before {
  content: "";
  display: block;
  height: 4px;
  margin: -36px -34px 30px;
  background: var(--brand-gradient);
}
.auth-card.is-wide { max-width: 520px; }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.auth-title { font-size: 24px; margin-bottom: 7px; letter-spacing: -0.035em; }
.auth-sub { color: var(--ink-3); font-size: 14px; margin: 0 0 26px; }
.auth-foot {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
}
.auth-card .btn { width: 100%; height: 46px; }
.password-wrap { position: relative; }
.password-toggle {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
}
.password-toggle:hover { background: var(--surface-2); color: var(--ink); }

/* ---- Settings pages ------------------------------------------------------ */

.page { flex: 1; overflow-y: auto; }
.page-inner { max-width: 1000px; margin: 0 auto; padding: 34px 28px 80px; }
.page-head { margin-bottom: 28px; }
.page-head h1 { font-size: 28px; margin-bottom: 7px; letter-spacing: -0.035em; }
.page-head p { margin: 0; color: var(--ink-3); font-size: 14.5px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 16.5px; }
.panel-head p { margin: 4px 0 0; font-size: 13px; color: var(--ink-3); }
.panel-body { padding: 22px; }
.panel-body.is-flush { padding: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; background: var(--line); }
.stat { background: var(--surface); padding: 20px 22px; }
.stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -0.035em; }
.stat-label { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  padding: 12px 22px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
.table td { padding: 14px 22px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color 0.12s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { font-size: 13.5px; color: var(--ink-2); white-space: nowrap; }
.table-actions { display: flex; gap: 8px; justify-content: flex-end; }

.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person-name { font-family: var(--font-display); font-weight: 700; font-size: 14px; }
.person-email { font-size: 12.5px; color: var(--ink-3); word-break: break-all; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }

.credential {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  margin-top: 14px;
  flex-wrap: wrap;
}
.credential code {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--r);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); flex-shrink: 0; }
.status-dot.is-on { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 20%, transparent); }
.status-dot.is-off { background: var(--ink-3); }

.kv { display: flex; flex-direction: column; gap: 12px; }
.kv-row { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; font-size: 13.5px; flex-wrap: wrap; }
.kv-row dt { color: var(--ink-3); }
.kv-row dd { margin: 0; font-size: 13.5px; font-weight: 500; text-align: right; word-break: break-all; }

.steps { counter-reset: step; margin: 0; padding: 0; list-style: none; }
.steps li { counter-increment: step; position: relative; padding: 0 0 16px 38px; font-size: 14px; color: var(--ink-2); }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -1px;
  width: 26px;
  height: 26px;
  border-radius: var(--r-xs);
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.steps li:last-child { padding-bottom: 0; }
.steps code { font-size: 13px; background: var(--surface-2); padding: 2px 6px; border-radius: 5px; word-break: break-all; }

/* ---- Responsive ---------------------------------------------------------- */

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 45;
}
.menu-toggle { display: none; }

/* Touch devices never fire hover, so controls that appear on hover would be
   unreachable. Show them permanently there instead. */
@media (hover: none) {
  .card-more { opacity: 1; transform: none; }
  .select-box { opacity: 1; }
  .file-card:hover, .folder-card:hover { transform: none; }
  .file-card:hover .file-thumb img { transform: none; }
}

/* Tablet: compact sidebar, three cards across */
@media (max-width: 1100px) {
  :root { --sidebar-w: 232px; }
  .content { padding: 6px 22px 110px; }
  .toolbar { padding: 18px 22px 14px; }
  .selection-bar { margin: 0 22px 4px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); }
  .folder-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* Mobile: collapsible sidebar */
@media (max-width: 860px) {
  :root { --sidebar-w: 280px; --topbar-h: 62px; }

  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .brand-name { display: none; }
  .search { max-width: none; }
  .search input { height: 42px; }

  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.26s var(--ease-out);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop.is-open { display: block; }

  .toolbar { padding: 16px 16px 12px; align-items: flex-start; }
  .page-title { font-size: 21px; }
  .content { padding: 4px 16px 120px; }
  .selection-bar { margin: 0 16px 4px; }

  .list-head, .file-row { grid-template-columns: 38px minmax(0, 1fr) 84px 68px; gap: 10px; padding: 0 12px; }
  .col-date, .col-kind { display: none; }

  .fab {
    display: flex;
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 58px;
    height: 58px;
    border-radius: 20px;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: var(--on-brand);
    box-shadow: var(--shadow-lg);
    z-index: 60;
    transition: transform 0.16s var(--ease);
  }
  .fab:active { transform: scale(0.94); }

  .upload-panel { right: 12px; left: 12px; bottom: 12px; width: auto; }

  .modal { padding: 0; }
  .modal-card { max-width: none; border-radius: 0; max-height: 100dvh; height: 100dvh; }
  .modal-card.is-preview { max-height: 100dvh; }
  .preview-stage img, .preview-stage video { max-height: 56vh; }
  .preview-stage iframe { height: 56vh; }
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }

  .page-inner { padding: 22px 16px 72px; }
  .table-scroll { overflow-x: auto; }
  .table { min-width: 660px; }
  .drop-frame { padding: 36px 28px; }
  .auth-card { padding: 28px 22px 24px; }
  .auth-card.notched::before { margin: -28px -22px 24px; }
}

/* Small phones: two cards across */
@media (max-width: 560px) {
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
  .folder-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .file-thumb { height: 112px; }
  .folder-card { padding: 11px; gap: 10px; }
  .folder-icon { width: 36px; height: 36px; }
  .toolbar-actions .dropdown-toggle span { display: none; }
  .dropdown-toggle { padding: 0 11px; }
  .empty-art { width: 96px; height: 96px; border-radius: 26px; }
}

@media (max-width: 400px) {
  .file-grid { grid-template-columns: 1fr; }
  .folder-grid { grid-template-columns: 1fr; }
}
