/* ==========================================================================
   CloudBox — Design System
   ========================================================================== */

:root {
  /* Palette — light (default) */
  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --card-hover: #fafbff;
  --primary: #4f6ef7;
  --primary-hover: #3f5ce6;
  --primary-soft: rgba(79, 110, 247, 0.10);
  --primary-dark: #3a56d4;
  --text: #0f1422;
  --text-soft: #35405c;
  --muted: #6b7280;
  --border: #e6e8ef;
  --border-strong: #d5d9e4;
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.10);
  --success: #1a9e6a;
  --shadow-sm: 0 1px 2px rgba(15, 20, 34, 0.04), 0 1px 3px rgba(15, 20, 34, 0.03);
  --shadow-md: 0 4px 12px rgba(15, 20, 34, 0.06), 0 2px 4px rgba(15, 20, 34, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 20, 34, 0.10), 0 4px 12px rgba(15, 20, 34, 0.05);
  --shadow-pop: 0 20px 60px rgba(15, 20, 34, 0.16), 0 8px 20px rgba(15, 20, 34, 0.08);

  /* Radius scale */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-pill: 999px;

  /* Spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  /* Motion */
  --t-fast: 120ms cubic-bezier(.4, 0, .2, 1);
  --t-base: 200ms cubic-bezier(.4, 0, .2, 1);
  --t-slow: 320ms cubic-bezier(.4, 0, .2, 1);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
}

/* ---------- Themes ---------- */
[data-theme="dark"] {
  --bg: #0e1116;
  --bg-elevated: #161a22;
  --card: #161a22;
  --card-hover: #1c212b;
  --primary: #8296ff;
  --primary-hover: #95a5ff;
  --primary-soft: rgba(130, 150, 255, 0.14);
  --primary-dark: #6d82f5;
  --text: #eef1f7;
  --text-soft: #cdd2df;
  --muted: #98a0b3;
  --border: #262b36;
  --border-strong: #333a48;
  --danger: #ff6b70;
  --danger-soft: rgba(255, 107, 112, 0.14);
  --success: #46c691;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.30);
  --shadow-pop: 0 20px 60px rgba(0, 0, 0, 0.55), 0 8px 20px rgba(0, 0, 0, 0.35);
}
[data-theme="ocean"] {
  --bg: #eaf6fb;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --card-hover: #f5fbfe;
  --primary: #0d8eb0;
  --primary-hover: #0a7c9a;
  --primary-soft: rgba(13, 142, 176, 0.12);
  --primary-dark: #067089;
  --text: #07303a;
  --text-soft: #1f4f5e;
  --muted: #4f7f8a;
  --border: #cfe8f1;
  --border-strong: #b6d9e5;
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.10);
  --success: #12926a;
  --shadow-sm: 0 1px 2px rgba(7, 48, 58, 0.05);
  --shadow-md: 0 4px 12px rgba(7, 48, 58, 0.08), 0 2px 4px rgba(7, 48, 58, 0.04);
  --shadow-lg: 0 12px 32px rgba(7, 48, 58, 0.12), 0 4px 12px rgba(7, 48, 58, 0.05);
  --shadow-pop: 0 20px 60px rgba(7, 48, 58, 0.18), 0 8px 20px rgba(7, 48, 58, 0.08);
}
[data-theme="sunset"] {
  --bg: #fff4ec;
  --bg-elevated: #fffbf7;
  --card: #fffbf7;
  --card-hover: #fff7f0;
  --primary: #ec5a2a;
  --primary-hover: #d94c1c;
  --primary-soft: rgba(236, 90, 42, 0.12);
  --primary-dark: #c0431a;
  --text: #3a1a10;
  --text-soft: #663423;
  --muted: #9c7360;
  --border: #f4dccb;
  --border-strong: #ecc9b2;
  --danger: #d1341f;
  --danger-soft: rgba(209, 52, 31, 0.10);
  --success: #158a5b;
  --shadow-sm: 0 1px 2px rgba(58, 26, 16, 0.05);
  --shadow-md: 0 4px 12px rgba(58, 26, 16, 0.07), 0 2px 4px rgba(58, 26, 16, 0.04);
  --shadow-lg: 0 12px 32px rgba(58, 26, 16, 0.12), 0 4px 12px rgba(58, 26, 16, 0.05);
  --shadow-pop: 0 20px 60px rgba(58, 26, 16, 0.18), 0 8px 20px rgba(58, 26, 16, 0.08);
}
[data-theme="private"] {
  --bg: #0a0912;
  --bg-elevated: #131120;
  --card: #131120;
  --card-hover: #1a1730;
  --primary: #b46cff;
  --primary-hover: #c084ff;
  --primary-soft: rgba(180, 108, 255, 0.16);
  --primary-dark: #9747e6;
  --text: #f1e9ff;
  --text-soft: #d4c6ec;
  --muted: #9486b3;
  --border: #251f3a;
  --border-strong: #342b52;
  --danger: #ff5c8a;
  --danger-soft: rgba(255, 92, 138, 0.14);
  --success: #4ad29a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 20px 60px rgba(0, 0, 0, 0.65), 0 8px 20px rgba(0, 0, 0, 0.40);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  transition: background var(--t-base), color var(--t-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; transition: color var(--t-fast); }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-weight: 650; letter-spacing: -0.01em; }
::selection { background: var(--primary-soft); color: var(--text); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background-color: var(--muted); background-clip: content-box; }

/* ---------- Auth pages ---------- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--s-6);
  background:
    radial-gradient(circle at 15% 20%, rgba(79, 110, 247, 0.35), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(124, 58, 237, 0.35), transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(14, 165, 233, 0.20), transparent 60%),
    linear-gradient(135deg, #4f6ef7 0%, #7c3aed 100%);
  position: relative;
}
.auth-page::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.14) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.4;
  pointer-events: none;
}
.auth-card {
  position: relative;
  background: var(--card);
  padding: var(--s-10) var(--s-8);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  width: 100%;
  max-width: 400px;
  border: 1px solid rgba(255, 255, 255, 0.6);
}
[data-theme="dark"] .auth-card,
[data-theme="private"] .auth-card { border-color: var(--border); }
.auth-card h1 {
  margin: 0 0 var(--s-2);
  font-size: 24px;
  letter-spacing: -0.02em;
}
.auth-card h1 + p,
.auth-card .auth-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 var(--s-5);
}
.auth-card label {
  display: block;
  margin: var(--s-4) 0 var(--s-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.auth-card input {
  width: 100%;
  padding: 11px var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.auth-card input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.auth-card .btn-primary { width: 100%; justify-content: center; margin-top: var(--s-5); }
.auth-switch {
  margin-top: var(--s-5);
  font-size: 13px;
  text-align: center;
  color: var(--muted);
}
.alert {
  background: var(--danger-soft);
  color: var(--danger);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: var(--s-2);
  border: 1px solid rgba(229, 72, 77, 0.20);
}

/* ---------- Buttons ---------- */
.btn, .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 9px var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 550;
  font-family: inherit;
  color: var(--text);
  line-height: 1.2;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), color var(--t-fast);
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--card-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08), 0 2px 8px var(--primary-soft);
}
.btn-primary:hover { background: var(--primary-hover); border-color: transparent; }
.btn-logout {
  padding: 7px var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  background: transparent;
  color: var(--text);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn-logout:hover { background: var(--bg); border-color: var(--border-strong); }
.danger-btn {
  color: var(--danger);
  border-color: rgba(229, 72, 77, 0.35);
}
.danger-btn:hover { background: var(--danger-soft); border-color: var(--danger); }

/* ---------- Top bar ---------- */
.topbar {
  background: color-mix(in srgb, var(--card) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--s-3) var(--s-6);
  display: flex;
  align-items: center;
  gap: var(--s-5);
}
.brand a {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  white-space: nowrap;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.brand a:hover { text-decoration: none; color: var(--primary); }

.nav-search { position: relative; flex: 1; max-width: 340px; }
.nav-search input {
  width: 100%;
  padding: 9px var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.nav-search input:focus {
  outline: none;
  background: var(--card);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.nav-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  max-height: 340px;
  overflow-y: auto;
  z-index: 60;
  padding: 6px;
  animation: popIn var(--t-base);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.nav-search-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 9px var(--s-3);
  font-size: 13px;
  color: var(--text);
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}
.nav-search-item:hover { background: var(--bg); text-decoration: none; }
.nav-search-avatar img {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}
.nav-search-empty {
  padding: var(--s-4);
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.nav-icons { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.nav-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  font-size: 17px;
  color: var(--text-soft);
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-icon:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.nav-icon.active {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: none;
}
.nav-badge {
  position: absolute;
  top: 0; right: 0;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--r-pill);
  min-width: 18px; height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  box-shadow: 0 0 0 2px var(--card);
  animation: badgePop var(--t-base);
}
@keyframes badgePop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.nav-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* ---------- Layout ---------- */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--s-8) var(--s-6);
}
.page-sub { color: var(--muted); margin-top: -6px; font-size: 14px; }

/* ---------- Dashboard ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-4);
  margin: var(--s-6) 0;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  text-align: center;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.stat-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-label {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
  font-weight: 550;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.quick-actions { display: flex; gap: var(--s-4); margin: var(--s-6) 0; }
.action-card {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  text-align: center;
  font-weight: 600;
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  box-shadow: var(--shadow-sm);
}
.action-card:hover {
  border-color: var(--primary);
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ---------- Tables ---------- */
.file-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.file-table th, .file-table td {
  padding: var(--s-3) var(--s-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.file-table tr:last-child td { border-bottom: none; }
.file-table tbody tr { transition: background var(--t-fast); }
.file-table tbody tr:hover { background: var(--card-hover); }
.file-table th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.row-actions { display: flex; gap: var(--s-1); align-items: center; }
.row-actions a, .row-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  font-size: 15px;
  transition: background var(--t-fast), color var(--t-fast);
}
.row-actions a:hover, .row-actions button:hover { background: var(--bg); text-decoration: none; }
.link-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-soft);
  font-family: inherit;
  transition: color var(--t-fast);
}
.link-btn:hover { color: var(--text); }
.link-btn.danger { color: var(--danger); }
.empty-hint {
  color: var(--muted);
  padding: var(--s-10) var(--s-4);
  text-align: center;
  font-size: 14px;
}

/* ---------- File manager toolbar ---------- */
.fm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
  gap: var(--s-3);
}
.breadcrumbs {
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.breadcrumbs a { color: var(--text-soft); }
.fm-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.inline-form { display: flex; gap: var(--s-2); margin-bottom: var(--s-4); }
.inline-form input[type=text] {
  padding: 9px var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.inline-form input[type=text]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.hidden { display: none !important; }

/* ---------- Gallery / lightbox ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--s-3);
}
.gallery-item {
  position: relative;
  background: #000;
  border-radius: var(--r-md);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-base), box-shadow var(--t-base);
}
.gallery-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.gallery-item img, .gallery-item video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--t-slow);
}
.gallery-item:hover img, .gallery-item:hover video { transform: scale(1.04); }
.gallery-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 20px 10px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.78));
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.video-badge {
  position: absolute;
  top: var(--s-2); right: var(--s-2);
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(6px);
  color: #fff;
  border-radius: 50%;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 16, 0.92);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--s-5);
}
.lightbox.open { display: flex; animation: fadeIn var(--t-base); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.lightbox-content { max-width: 90vw; max-height: 90vh; }
.lightbox-content img, .lightbox-content video {
  max-width: 90vw;
  max-height: 75vh;
  border-radius: var(--r-lg);
  display: block;
  margin: 0 auto;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.lightbox-content .post-caption {
  color: #fff;
  text-align: center;
  margin-top: var(--s-3);
  font-size: 14px;
}
.lightbox-content .danger-btn {
  display: block;
  margin: var(--s-4) auto 0;
  background: var(--card);
}

/* ---------- Editor ---------- */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.editor-toolbar input[type=text] {
  flex: 1;
  padding: 10px var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.editor-toolbar input[type=text]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.save-status {
  color: var(--success);
  font-size: 13px;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.save-status::before {
  content: "●";
  font-size: 8px;
}
#editorArea {
  width: 100%;
  height: 65vh;
  padding: var(--s-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  resize: vertical;
  background: var(--card);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
#editorArea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

/* ---------- Quota bar ---------- */
.quota-bar-wrap {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
.quota-bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: var(--r-pill);
  overflow: hidden;
  position: relative;
}
.quota-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  border-radius: var(--r-pill);
  transition: width var(--t-slow);
}
.quota-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 550;
}

/* ---------- Upload progress ---------- */
.upload-progress-wrap { margin: var(--s-1) 0 var(--s-4); }
.upload-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 550;
}
.upload-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  border-radius: var(--r-pill);
  transition: width 150ms ease;
}

/* ---------- Shared file view ---------- */
.shared-text {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.65;
  box-shadow: var(--shadow-sm);
}

/* ---------- Settings page ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-6);
}
.settings-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  box-shadow: var(--shadow-sm);
}
.settings-card h2 {
  margin: 0 0 var(--s-4);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.settings-card label {
  display: block;
  margin: var(--s-3) 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.settings-card input[type=text],
.settings-card input[type=password],
.settings-card input[type=email],
.settings-card textarea {
  width: 100%;
  padding: 10px var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.settings-card input:focus,
.settings-card textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.avatar-preview {
  width: 88px; height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  background: var(--bg);
  display: block;
  margin-bottom: var(--s-3);
  box-shadow: var(--shadow-sm);
}
.directory-url {
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--s-3);
  font-family: var(--font-mono);
  font-size: 12.5px;
  word-break: break-all;
  color: var(--muted);
}
.theme-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
  margin-top: var(--s-3);
}
.theme-option {
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: 13px;
  font-weight: 550;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  background: var(--card);
}
.theme-option:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.theme-option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.theme-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06), var(--shadow-sm);
}
.swatch-light   { background: linear-gradient(135deg, #f6f7fb, #4f6ef7); }
.swatch-dark    { background: linear-gradient(135deg, #0e1116, #8296ff); }
.swatch-ocean   { background: linear-gradient(135deg, #eaf6fb, #0d8eb0); }
.swatch-sunset  { background: linear-gradient(135deg, #fff4ec, #ec5a2a); }
.swatch-private { background: linear-gradient(135deg, #0a0912, #b46cff); }
.success-msg {
  color: var(--success);
  font-size: 13px;
  margin-top: var(--s-3);
  font-weight: 550;
}

/* ---------- Profile ---------- */
.profile-header {
  display: flex;
  gap: var(--s-6);
  align-items: flex-start;
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
}
.profile-avatar {
  width: 104px; height: 104px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--card);
  outline: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}
.profile-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
}
.profile-info { flex: 1; min-width: 260px; }
.profile-name-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}
.profile-name-row h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.profile-display-name {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}
.profile-bio {
  font-size: 14px;
  margin-top: var(--s-3);
  white-space: pre-wrap;
  line-height: 1.55;
  color: var(--text-soft);
}
.profile-stats {
  display: flex;
  gap: var(--s-5);
  font-size: 14px;
  margin-top: var(--s-4);
  color: var(--muted);
}
.profile-stats strong {
  color: var(--text);
  font-weight: 700;
  margin-right: 4px;
}
.profile-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--s-6) 0;
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 6px;
}
.post-tile {
  position: relative;
  aspect-ratio: 1/1;
  background: #000;
  overflow: hidden;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.post-tile:hover { transform: scale(1.01); box-shadow: var(--shadow-md); }
.post-tile img, .post-tile video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.post-tile-file {
  background: var(--card);
  border: 1px solid var(--border);
  cursor: default;
}
.post-tile-file:hover { transform: none; }
.post-tile-file a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--s-3);
  color: var(--text);
  padding: var(--s-3);
  text-align: center;
}
.post-tile-file a:hover { text-decoration: none; background: var(--bg); }
.post-file-icon { font-size: 34px; }
.post-file-name {
  font-size: 11px;
  word-break: break-word;
  color: var(--muted);
}
.post-file-delete {
  position: absolute;
  top: var(--s-2); right: var(--s-2);
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(6px);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px; height: 24px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
}
.post-file-delete:hover { background: var(--danger); }

/* ---------- Search results / follow requests ---------- */
.request-list { display: flex; flex-direction: column; gap: 0; }
.request-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
}
.request-row:last-child { border-bottom: none; }
.request-user {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--text);
  font-size: 14px;
}
.request-user:hover { text-decoration: none; }
.request-actions { display: flex; gap: var(--s-2); }
.request-link {
  margin-left: auto;
  font-size: 12px;
  color: var(--primary);
  font-weight: 550;
}

/* ---------- Messages / chat ---------- */
.messages-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--s-4);
  height: 72vh;
  min-height: 440px;
}
.conversation-list {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}
.conversation-list-header {
  display: flex;
  align-items: center;
  padding: var(--s-3) var(--s-4);
  font-weight: 650;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}
.conversation-item {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.conversation-item:hover,
.conversation-item.active { background: var(--bg); }
.conversation-preview {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 2px;
}
.conversation-preview strong { font-size: 13px; font-weight: 600; }
.conversation-preview span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}
.chat-header {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  background: var(--card);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.chat-bubble {
  max-width: 72%;
  padding: 9px 14px;
  border-radius: var(--r-lg);
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  animation: bubbleIn var(--t-base);
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-bubble.mine {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: var(--r-xs);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.chat-bubble.theirs {
  align-self: flex-start;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--r-xs);
}
.chat-input-row {
  display: flex;
  gap: var(--s-2);
  padding: var(--s-3);
  border-top: 1px solid var(--border);
  background: var(--card);
}
.chat-input-row input {
  flex: 1;
  padding: 10px var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.chat-input-row input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

/* ---------- OAuth ---------- */
.oauth-divider {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin: var(--s-5) 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.oauth-divider::before, .oauth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  width: 100%;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fff;
  color: #3c4043;
  font-size: 14px;
  font-weight: 550;
  font-family: inherit;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
  box-shadow: var(--shadow-sm);
}
.btn-google:hover {
  background: #f8f9fa;
  text-decoration: none;
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed;
  bottom: var(--s-5);
  right: var(--s-5);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--card);
  padding: 11px var(--s-4);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity var(--t-base), transform var(--t-base);
  pointer-events: auto;
  max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast-error { background: var(--danger); color: #fff; }

/* ---------- Chat context menu & selection ---------- */
.context-menu {
  position: fixed;
  z-index: 150;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  min-width: 170px;
  padding: 4px;
  animation: popIn var(--t-fast);
}
.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px var(--s-3);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}
.context-menu button:hover { background: var(--bg); }
.chat-select-box { margin-right: 4px; align-self: center; }
.chat-bubble-row { display: flex; align-items: center; gap: 6px; }
.chat-bubble-row.mine { justify-content: flex-end; }
.chat-bubble-row.theirs { justify-content: flex-start; }
.chat-bubble.system {
  opacity: 0.7;
  font-style: italic;
  background: transparent !important;
  border: 1px dashed var(--border) !important;
  color: var(--muted) !important;
  align-self: center;
  font-size: 12.5px;
  padding: 6px 12px;
}
.chat-edited-tag {
  font-size: 10px;
  opacity: 0.65;
  margin-left: 6px;
  font-style: italic;
}
.chat-edit-input {
  width: 100%;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--primary);
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
}
.selection-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  background: var(--bg);
}
.conversation-link {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex: 1;
  padding: var(--s-3) var(--s-4);
  color: var(--text);
  min-width: 0;
}
.conversation-link:hover { text-decoration: none; }
.conversation-unread { position: static; margin-left: auto; }
.pin-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 0 var(--s-3);
  opacity: 0.5;
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.pin-btn:hover { opacity: 1; transform: scale(1.15); }

/* ---------- Mobile / device-friendly ---------- */
@media (max-width: 720px) {
  .messages-layout { grid-template-columns: 1fr; height: auto; }
  .conversation-list { max-height: 240px; }
  .nav-search { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
  .topbar-inner { padding: var(--s-2) var(--s-3); gap: var(--s-2); }
  .brand a { font-size: 15px; }
  .nav-icon { width: 34px; height: 34px; font-size: 16px; }
  .container { padding: var(--s-5) var(--s-3); }
  .stats-grid { grid-template-columns: 1fr; }
  .quick-actions { flex-direction: column; }
  .profile-header { gap: var(--s-4); }
  .profile-avatar { width: 80px; height: 80px; }
  .profile-name-row { gap: var(--s-2); }
  .profile-name-row h1 { font-size: 20px; }
  .fm-toolbar { flex-direction: column; align-items: stretch; }
  .fm-actions { flex-wrap: wrap; }
  .fm-actions .btn, .fm-actions .btn-primary { flex: 1; text-align: center; }
  .file-table { display: block; overflow-x: auto; white-space: nowrap; }
  .posts-grid, .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .auth-card { width: 100%; max-width: 360px; padding: var(--s-6) var(--s-5); }
  .auth-card h1 { font-size: 20px; }
  .chat-bubble { max-width: 85%; }
  .toast-container { right: var(--s-3); bottom: var(--s-3); left: var(--s-3); }
  .toast { max-width: none; }
}
@media (max-width: 420px) {
  .nav-icons { gap: 0; }
  .nav-icon { width: 32px; height: 32px; font-size: 15px; }
  .stat-value { font-size: 24px; }
}

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

/* ==========================================================================
   Topbar — v2
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 58px;
}

/* ---------- Brand ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  transition: opacity var(--t-fast);
}
.brand:hover { text-decoration: none; opacity: 0.85; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-soft), inset 0 1px 0 rgba(255,255,255,0.25);
}
.brand-name { display: inline; }

/* ---------- Search ---------- */
.nav-search {
  position: relative;
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
}
.nav-search-icon {
  position: absolute;
  left: 14px;
  color: var(--muted);
  pointer-events: none;
  transition: color var(--t-fast);
}
.nav-search input {
  width: 100%;
  padding: 9px 44px 9px 38px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.nav-search input::placeholder { color: var(--muted); }
.nav-search input:focus {
  outline: none;
  background: var(--card);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.nav-search:focus-within .nav-search-icon { color: var(--primary); }
.nav-search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 5px;
  pointer-events: none;
  line-height: 1.4;
}
.nav-search input:focus ~ .nav-search-kbd { opacity: 0; }
.nav-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow-y: auto;
  z-index: 60;
  padding: 6px;
  animation: topbarPop var(--t-base);
}
@keyframes topbarPop {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
.nav-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}
.nav-search-item:hover { background: var(--bg); text-decoration: none; }
.nav-search-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg);
  font-size: 15px;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border);
}
.nav-search-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.nav-search-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.nav-search-name { font-weight: 600; font-size: 13px; }
.nav-search-sub  { font-size: 11.5px; color: var(--muted); }
.nav-search-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* ---------- Primary nav links ---------- */
.nav-primary {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-soft);
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.nav-link:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.nav-link svg { flex-shrink: 0; }
.nav-link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ---------- Right-side action buttons ---------- */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.nav-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  color: var(--text-soft);
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-action:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.nav-action.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}
.nav-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 17px; height: 17px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--card);
  animation: navBadgePop var(--t-base);
}
@keyframes navBadgePop {
  0%   { transform: scale(0.5); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ---------- User menu ---------- */
.nav-user { position: relative; }
.nav-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 4px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--r-pill);
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.nav-user-trigger:hover {
  background: var(--bg);
  border-color: var(--border);
}
.nav-avatar-img,
.nav-avatar-fallback {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-avatar-img { object-fit: cover; border: 1px solid var(--border); }
.nav-avatar-fallback {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}
.nav-user-chevron {
  color: var(--muted);
  transition: transform var(--t-fast);
}
.nav-user-trigger[aria-expanded="true"] .nav-user-chevron { transform: rotate(180deg); }

.nav-user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 240px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition: opacity var(--t-base), transform var(--t-base), visibility var(--t-base);
  z-index: 80;
}
.nav-user-dropdown.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}
.nav-user-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--bg);
  margin-bottom: 4px;
}
.nav-user-head-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.nav-user-head-avatar img { width: 100%; height: 100%; object-fit: cover; }
.nav-user-head-meta { min-width: 0; overflow: hidden; }
.nav-user-head-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-user-head-handle {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-user-section { padding: 4px 0; }
.nav-user-section + .nav-user-section {
  border-top: 1px solid var(--border);
}
.nav-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-user-item:hover { background: var(--bg); text-decoration: none; }
.nav-user-item svg { color: var(--muted); flex-shrink: 0; }
.nav-user-item:hover svg { color: var(--text); }
.nav-user-item.is-active { background: var(--primary-soft); color: var(--primary); }
.nav-user-item.is-active svg { color: var(--primary); }
.nav-user-item.is-danger { color: var(--danger); }
.nav-user-item.is-danger svg { color: var(--danger); }
.nav-user-item.is-danger:hover { background: var(--danger-soft); }

/* ---------- Mobile ---------- */
@media (max-width: 880px) {
  .nav-link span { display: none; }
  .nav-link { padding: 8px 10px; }
}
@media (max-width: 720px) {
  .topbar-inner { padding: 8px 14px; gap: 10px; min-height: 54px; }
  .brand-name { display: none; }
  .nav-search { max-width: none; }
  .nav-search-kbd { display: none; }
  .nav-search input { padding: 8px 12px 8px 34px; font-size: 13px; }
  .nav-search-icon { left: 12px; }
  .nav-action { width: 34px; height: 34px; }
  .nav-avatar-img, .nav-avatar-fallback { width: 28px; height: 28px; }
  .nav-user-chevron { display: none; }
  .nav-user-trigger { padding: 3px; }
  .nav-user-dropdown { min-width: 220px; right: -8px; }
}
@media (max-width: 480px) {
  .nav-primary { display: none; }
}

/* ==========================================================================
   Dashboard
   ========================================================================== */

.dashboard { padding-top: 28px; }

/* ---------- Welcome ---------- */
.welcome {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.welcome-text h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.welcome-sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.welcome-sub strong { color: var(--text); font-weight: 650; }
.welcome-actions { display: flex; gap: 8px; }

/* ---------- Storage card ---------- */
.storage-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.storage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.storage-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
  color: var(--text-soft);
  letter-spacing: 0.01em;
}
.storage-title svg { color: var(--muted); }
.storage-meta {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.storage-meta strong { color: var(--text); font-size: 14px; font-weight: 700; }
.storage-pct {
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 650;
  font-size: 11.5px;
  margin-left: 4px;
}
.storage-bar {
  height: 10px;
  background: var(--border);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.storage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  border-radius: var(--r-pill);
  transition: width var(--t-slow);
}
.storage-bar--warn .storage-bar-fill {
  background: linear-gradient(90deg, #f59e0b, #f97316);
}
.storage-bar--danger .storage-bar-fill {
  background: linear-gradient(90deg, #ef4444, var(--danger));
}
.storage-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.storage-warn { color: #d97706; font-weight: 600; }

/* ---------- Stat cards with icons ---------- */
.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 16px 18px;
}
.stat-icon {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stat-icon--primary { background: var(--primary-soft); color: var(--primary); }
.stat-icon--ocean   { background: rgba(14, 165, 233, 0.12); color: #0ea5e9; }
.stat-icon--sunset  { background: rgba(236, 90, 42, 0.12); color: #ec5a2a; }
[data-theme="dark"]  .stat-icon--ocean { background: rgba(56, 189, 248, 0.16); color: #38bdf8; }
[data-theme="dark"]  .stat-icon--sunset { background: rgba(251, 146, 60, 0.16); color: #fb923c; }
[data-theme="private"] .stat-icon--ocean { background: rgba(56, 189, 248, 0.16); color: #38bdf8; }
[data-theme="private"] .stat-icon--sunset { background: rgba(251, 146, 60, 0.16); color: #fb923c; }

.stat-body { min-width: 0; }
.stat-body .stat-value {
  font-size: 22px;
  text-align: left;
  line-height: 1.1;
}
.stat-body .stat-label {
  font-size: 11.5px;
  text-align: left;
  margin-top: 2px;
}

/* ---------- Section blocks ---------- */
.section-block { margin: 32px 0 8px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.section-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 550;
  color: var(--primary);
}
.section-link:hover { text-decoration: none; }
.section-link svg { transition: transform var(--t-fast); }
.section-link:hover svg { transform: translateX(2px); }

/* ---------- Quick actions (rewrite) ---------- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0;
}
.action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.action-card:hover {
  border-color: var(--primary);
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.action-icon {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.action-icon--primary { background: var(--primary-soft); color: var(--primary); }
.action-icon--ocean   { background: rgba(14, 165, 233, 0.12); color: #0ea5e9; }
.action-icon--sunset  { background: rgba(236, 90, 42, 0.12); color: #ec5a2a; }
[data-theme="dark"]  .action-icon--ocean { background: rgba(56, 189, 248, 0.16); color: #38bdf8; }
[data-theme="dark"]  .action-icon--sunset { background: rgba(251, 146, 60, 0.16); color: #fb923c; }

.action-body { display: flex; flex-direction: column; min-width: 0; }
.action-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  line-height: 1.2;
}
.action-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Recent list ---------- */
.recent-list {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.recent-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.recent-row:last-child { border-bottom: none; }
.recent-row:hover { background: var(--card-hover); }

.recent-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-image  { background: rgba(14, 165, 233, 0.14); color: #0ea5e9; }
.icon-video  { background: rgba(168, 85, 247, 0.14); color: #a855f7; }
.icon-text   { background: rgba(34, 197, 94, 0.14);  color: #16a34a; }
.icon-folder { background: rgba(245, 158, 11, 0.14); color: #d97706; }
.icon-other  { background: var(--bg); color: var(--muted); }

[data-theme="dark"]  .icon-image  { background: rgba(56, 189, 248, 0.18); color: #38bdf8; }
[data-theme="dark"]  .icon-video  { background: rgba(192, 132, 252, 0.18); color: #c084fc; }
[data-theme="dark"]  .icon-text   { background: rgba(74, 222, 128, 0.16); color: #4ade80; }
[data-theme="dark"]  .icon-folder { background: rgba(251, 191, 36, 0.16); color: #fbbf24; }
[data-theme="private"] .icon-image  { background: rgba(56, 189, 248, 0.18); color: #38bdf8; }
[data-theme="private"] .icon-video  { background: rgba(192, 132, 252, 0.18); color: #c084fc; }
[data-theme="private"] .icon-text   { background: rgba(74, 222, 128, 0.16); color: #4ade80; }
[data-theme="private"] .icon-folder { background: rgba(251, 191, 36, 0.16); color: #fbbf24; }

.recent-info { flex: 1; min-width: 0; }
.recent-name {
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.recent-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}
.recent-type {
  text-transform: capitalize;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 600;
}
.dot { opacity: 0.6; }
.recent-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- Empty state ---------- */
.empty-state {
  background: var(--card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 44px 24px;
  text-align: center;
}
.empty-state-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
}
.empty-state h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 650;
}
.empty-state p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .quick-actions { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .welcome { align-items: flex-start; }
  .welcome-text h1 { font-size: 21px; }
  .welcome-actions { width: 100%; }
  .welcome-actions .btn,
  .welcome-actions .btn-primary { flex: 1; justify-content: center; }
  .stats-grid { grid-template-columns: 1fr; }
  .recent-row { padding: 10px 12px; gap: 10px; }
  .recent-icon { width: 32px; height: 32px; }
  .recent-time { font-size: 11px; }
}

/* ==========================================================================
   File Manager
   ========================================================================== */

.fm { padding-top: 28px; }

/* ---------- Alert (with icon) ---------- */
.alert-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 18px 0;
  padding: 12px 14px;
}
.alert-error svg { flex-shrink: 0; margin-top: 1px; }

/* ---------- Header: crumbs + tools ---------- */
.fm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 22px 0 18px;
  flex-wrap: wrap;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
  font-size: 13.5px;
}
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--r-md);
  color: var(--text-soft);
  font-weight: 550;
  transition: background var(--t-fast), color var(--t-fast);
  max-width: 220px;
}
.crumb span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.crumb:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.crumb svg { color: var(--muted); flex-shrink: 0; }
.crumb:last-of-type {
  color: var(--text);
  font-weight: 650;
}
.crumb-sep {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  opacity: 0.55;
}

.fm-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.fm-tool {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.fm-tool:hover {
  background: var(--bg);
  border-color: var(--border-strong);
  text-decoration: none;
}
.fm-tool svg { color: var(--muted); flex-shrink: 0; }
.fm-tool:hover svg { color: var(--text); }

.fm-upload-btn { padding: 9px 14px; }

/* ---------- Inline new-folder form ---------- */
.inline-form {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  animation: fmFormIn var(--t-base);
}
@keyframes fmFormIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.inline-form input[type=text] {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.inline-form input[type=text]:focus {
  outline: none;
  background: var(--card);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

/* ---------- Upload progress ---------- */
.upload-progress-wrap {
  margin: 0 0 18px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

/* ---------- List header (count) ---------- */
.fm-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px;
  padding: 0 4px;
}
.fm-list-meta { font-size: 13px; color: var(--muted); }
.fm-count strong { color: var(--text); font-weight: 650; }
.fm-count-sep { margin: 0 4px; opacity: 0.5; }

/* ---------- File list ---------- */
.fm-list {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--t-fast), border-color var(--t-fast);
}
.fm-list.is-drop-target,
.empty-state.is-drop-target {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft), var(--shadow-md);
}

.fm-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) 100px 100px 130px 190px;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.fm-row:last-child { border-bottom: none; }
.fm-row:not(.fm-row--head):hover { background: var(--card-hover); }

.fm-row--head {
  background: var(--bg);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 10px;
  padding-bottom: 10px;
  position: sticky;
  top: 58px;
  z-index: 5;
  border-bottom: 1px solid var(--border);
}

.fm-col-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.fm-name {
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}
.fm-name:hover { color: var(--primary); text-decoration: none; }

.fm-icon {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-image  { background: rgba(14, 165, 233, 0.14); color: #0ea5e9; }
.icon-video  { background: rgba(168, 85, 247, 0.14); color: #a855f7; }
.icon-text   { background: rgba(34, 197, 94, 0.14);  color: #16a34a; }
.icon-folder { background: rgba(245, 158, 11, 0.14); color: #d97706; }
.icon-other  { background: var(--bg); color: var(--muted); }

[data-theme="dark"]  .icon-image  { background: rgba(56, 189, 248, 0.18); color: #38bdf8; }
[data-theme="dark"]  .icon-video  { background: rgba(192, 132, 252, 0.18); color: #c084fc; }
[data-theme="dark"]  .icon-text   { background: rgba(74, 222, 128, 0.16); color: #4ade80; }
[data-theme="dark"]  .icon-folder { background: rgba(251, 191, 36, 0.16); color: #fbbf24; }
[data-theme="private"] .icon-image  { background: rgba(56, 189, 248, 0.18); color: #38bdf8; }
[data-theme="private"] .icon-video  { background: rgba(192, 132, 252, 0.18); color: #c084fc; }
[data-theme="private"] .icon-text   { background: rgba(74, 222, 128, 0.16); color: #4ade80; }
[data-theme="private"] .icon-folder { background: rgba(251, 191, 36, 0.16); color: #fbbf24; }

.type-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: capitalize;
}

.fm-col-size, .fm-col-time {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.muted { color: var(--muted); }

.fm-col-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  justify-content: flex-end;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  font-family: inherit;
  text-decoration: none;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.icon-btn--danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- Empty state (reuse from dashboard) ---------- */
.empty-state { cursor: default; }
.empty-state-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .fm-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name actions"
      "meta actions";
    row-gap: 4px;
    padding: 12px 14px;
  }
  .fm-col-name    { grid-area: name; }
  .fm-col-actions { grid-area: actions; }
  .fm-col-type,
  .fm-col-size,
  .fm-col-time {
    display: inline;
    font-size: 11.5px;
    color: var(--muted);
  }
  .fm-col-type  { margin-right: 8px; }
  .fm-col-size  { margin-right: 8px; }
  .fm-row--head { display: none; }
  .fm-col-type::before  { content: ""; }
  .fm-row > .fm-col-type,
  .fm-row > .fm-col-size,
  .fm-row > .fm-col-time {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    display: inline;
    margin-right: 8px;
  }
  .fm-col-actions { grid-column: 2 / 3; grid-row: 1 / 3; align-self: center; }
}
@media (max-width: 560px) {
  .fm-tool span { display: none; }
  .fm-tool { padding: 8px 10px; }
  .fm-upload-btn span { display: inline; }
  .fm-header { gap: 8px; }
  .crumbs { font-size: 12.5px; }
  .crumb { padding: 5px 8px; max-width: 150px; }
}

/* ==========================================================================
   File Manager — simpler
   ========================================================================== */

.fm { padding-top: 26px; }

/* Storage line */
.fm-storage { margin-bottom: 22px; }
.fm-storage-bar {
  height: 6px;
  background: var(--border);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.fm-storage-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-pill);
  transition: width var(--t-slow);
}
.fm-storage-label {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

/* Toolbar */
.fm-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.fm-crumbs {
  font-size: 13.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.fm-crumbs a {
  color: var(--text-soft);
  font-weight: 500;
}
.fm-crumbs a:hover { color: var(--primary); }
.fm-crumb-sep { opacity: 0.55; }
.fm-buttons { display: flex; gap: 6px; flex-wrap: wrap; }

/* Table tweaks — leans on existing .file-table styling */
.fm-table td { vertical-align: middle; }
.fm-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.fm-name-cell a {
  color: var(--text);
  font-weight: 550;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.fm-name-cell a:hover { color: var(--primary); text-decoration: none; }

.fm-icon {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}
.fm-icon.is-folder { color: var(--primary); }

.fm-th-type, .fm-th-size, .fm-th-time {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.fm-th-type { text-transform: capitalize; }
.fm-th-actions { width: 1%; white-space: nowrap; }

/* Row action buttons — inline, subtle */
.fm-table .row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  justify-content: flex-end;
}
.fm-table .row-actions a,
.fm-table .row-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  margin: 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.fm-table .row-actions a:hover,
.fm-table .row-actions button:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.fm-table .row-actions .danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Inline new-folder form */
.fm .inline-form {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.fm .inline-form input[type=text] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.fm .inline-form input[type=text]:focus {
  outline: none;
  background: var(--card);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Responsive */
@media (max-width: 780px) {
  .fm-th-type, .fm-th-size { display: none; }
  .fm-bar { flex-direction: column; align-items: stretch; }
  .fm-buttons { width: 100%; }
  .fm-buttons .btn,
  .fm-buttons .btn-primary { flex: 1; text-align: center; justify-content: center; }
}
@media (max-width: 480px) {
  .fm-th-time { display: none; }
  .fm-table td, .fm-table th { padding: 10px 12px; }
  .fm-name-cell { gap: 8px; }
  .fm-icon { width: 26px; height: 26px; }
}

/* ==========================================================================
   Page header (shared by gallery, links, etc.)
   ========================================================================== */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head h1 {
  margin: 0 0 2px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-sub { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ==========================================================================
   Gallery — polish
   ========================================================================== */
.gallery-item {
  /* reset button defaults */
  padding: 0;
  border: none;
  font: inherit;
  text-align: left;
  color: inherit;
}
.gallery-item::after {
  /* subtle inner ring so images don't bleed into each other */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  pointer-events: none;
}
.gallery-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.gallery-caption {
  /* slide-up reveal on hover instead of always-visible */
  transform: translateY(100%);
  opacity: 0;
  transition: transform var(--t-base), opacity var(--t-base);
}
.gallery-item:hover .gallery-caption,
.gallery-item:focus-visible .gallery-caption {
  transform: translateY(0);
  opacity: 1;
}

.video-badge {
  /* keep it as a floating play icon, no circle outline */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform var(--t-fast), background var(--t-fast);
}
.gallery-item:hover .video-badge {
  transform: translate(-50%, -50%) scale(1.08);
  background: rgba(0, 0, 0, 0.7);
}

.gallery-item img,
.gallery-item video {
  transition: transform var(--t-slow);
}
.gallery-item:hover img,
.gallery-item:hover video {
  transform: scale(1.03);
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .page-head h1 { font-size: 19px; }
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
  }
  .gallery-caption {
    /* always show on mobile since there's no hover */
    transform: translateY(0);
    opacity: 1;
  }
}
@media (max-width: 420px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
}
/* ==========================================================================
   Auth pages — modern refresh
   ========================================================================== */

.auth-page {
  padding: 24px;
  background: #f1f3f8;
}

[data-theme="dark"] .auth-page,
[data-theme="private"] .auth-page {
  background: #0a0c12;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 34px 30px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(15, 20, 34, 0.06);
}
@keyframes authCardIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-card h1 {
  margin: 0 0 22px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-card label {
  display: block;
  margin: 16px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft, var(--muted));
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.auth-card input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.auth-card input:focus {
  outline: none;
  background: var(--card);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 110, 247, 0.12);
}

.auth-forgot {
  text-align: right;
  margin: 8px 0 0;
  font-size: 12.5px;
}
.auth-forgot a {
  color: var(--muted);
  font-weight: 500;
}
.auth-forgot a:hover {
  color: var(--primary);
  text-decoration: none;
}

.auth-card .btn-primary {
  width: 100%;
  margin-top: 18px;
  padding: 11px 16px;
  font-size: 14px;
  border-radius: 10px;
  justify-content: center;
}

.auth-card .alert {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 4px;
  background: rgba(229, 72, 77, 0.10);
  color: var(--danger);
  border: 1px solid rgba(229, 72, 77, 0.20);
}

.oauth-divider {
  margin: 20px 0 14px;
  font-size: 12px;
}

.btn-google {
  width: 100%;
  padding: 11px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 550;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn-google:hover {
  background: #f8f9fa;
  border-color: var(--border-strong, var(--border));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.auth-switch {
  margin-top: 22px;
  font-size: 13px;
  color: var(--muted);
}
.auth-switch a { font-weight: 600; }

@media (max-width: 420px) {
  .auth-card { padding: 28px 22px; }
  .auth-page { padding: 16px; }
}

/* ==========================================================================
   Profile page
   ========================================================================== */

.profile { padding-top: 30px; }

.profile-card {
  display: flex;
  gap: 26px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.profile-avatar-wrap { flex-shrink: 0; }

.profile-avatar {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--card);
  outline: 1px solid var(--border);
  background: var(--bg);
  display: block;
}
.profile-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  letter-spacing: -0.02em;
}

.profile-info { flex: 1; min-width: 240px; }

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.profile-name-row h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.profile-name-row .btn,
.profile-name-row .btn-primary {
  padding: 7px 12px;
  font-size: 13px;
  gap: 6px;
}

.profile-display-name {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 4px;
}
.profile-bio {
  font-size: 14px;
  margin-top: 8px;
  color: var(--text-soft);
  line-height: 1.55;
  white-space: pre-wrap;
  max-width: 600px;
}

.profile-stats {
  display: flex;
  gap: 6px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.profile-stats .stat {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.profile-stats a.stat:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}
.profile-stats .stat strong {
  color: var(--text);
  font-weight: 700;
}
.profile-stats a.stat:hover strong { color: var(--primary); }

/* Pending requests banner */
.pending-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  color: var(--primary);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 22px;
  text-decoration: none;
  transition: background var(--t-fast);
}
.pending-banner:hover {
  text-decoration: none;
  background: rgba(79, 110, 247, 0.16);
}
.pending-banner strong { font-weight: 700; }
.pending-banner svg:last-child { margin-left: auto; }

/* Posts grid */
.profile .posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 6px;
}
.profile .post-tile {
  aspect-ratio: 1 / 1;
  background: #000;
  border-radius: var(--r-sm);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: none;
  padding: 0;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.profile .post-tile:hover { transform: scale(1.01); box-shadow: var(--shadow-md); }
.profile .post-tile img,
.profile .post-tile video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.profile .post-tile-file {
  background: var(--card);
  border: 1px solid var(--border);
  cursor: default;
}
.profile .post-tile-file:hover { transform: none; }
.profile .post-tile-file a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  padding: 12px;
  color: var(--text);
  text-align: center;
}
.profile .post-tile-file a:hover {
  text-decoration: none;
  background: var(--bg);
}
.post-file-icon { color: var(--muted); }
.post-file-name {
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-word;
}
.post-file-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--t-fast);
}
.post-file-delete:hover { background: var(--danger); }

.profile .video-badge {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  pointer-events: none;
}

/* Responsive */
@media (max-width: 720px) {
  .profile-avatar { width: 84px; height: 84px; }
  .profile-avatar-placeholder { font-size: 32px; }
  .profile-name-row h1 { font-size: 19px; }
  .profile-name-row { gap: 6px; }
  .profile .posts-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 4px;
  }
  .pending-banner { font-size: 12.5px; padding: 10px 12px; }
}
@media (max-width: 420px) {
  .profile .posts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}