/* style.css */

/* ==========================================
   THEME VARIABLES
   ========================================== */
:root {
  /* DARK (default) */
  --bg-base: #0b0d1a;
  --bg-base-2: #101322;
  --bg-card: rgba(24, 28, 48, 0.65);
  --bg-elevated: rgba(30, 35, 60, 0.7);
  --bg-modal: #151829;
  --bg-sidebar: rgba(14, 17, 30, 0.95);
  --bg-input: rgba(28, 33, 56, 0.95);
  --bg-hover: rgba(255, 255, 255, 0.04);

  --border-subtle: rgba(130, 150, 255, 0.12);
  --border-hover: rgba(140, 170, 255, 0.35);
  --border-strong: rgba(140, 170, 255, 0.4);

  --text-primary: #f0f4ff;
  --text-secondary: #9ba9d4;
  --text-muted: #7f8bb6;
  --text-inverse: #0b0d1a;

  --accent-1: #4f7aff;
  --accent-2: #8a4fff;
  --accent-gradient: linear-gradient(135deg, #4f7aff, #8a4fff);
  --accent-soft: rgba(80, 120, 255, 0.14);
  --accent-soft-hover: rgba(80, 120, 255, 0.2);

  --danger: #ff5c5c;
  --danger-soft: rgba(255, 90, 90, 0.15);
  --success: #6be09e;
  --success-soft: rgba(70, 200, 120, 0.15);
  --star: #ffc46b;
  --star-soft: rgba(255, 200, 100, 0.15);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-accent: 0 6px 18px rgba(80, 110, 255, 0.35);

  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* LIGHT THEME */
[data-theme="light"] {
  --bg-base: #eef1f8;
  --bg-base-2: #f6f8fc;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-elevated: rgba(255, 255, 255, 0.95);
  --bg-modal: #ffffff;
  --bg-sidebar: rgba(255, 255, 255, 0.98);
  --bg-input: rgba(240, 244, 252, 0.95);
  --bg-hover: rgba(80, 120, 255, 0.06);

  --border-subtle: rgba(80, 100, 180, 0.12);
  --border-hover: rgba(80, 120, 255, 0.35);
  --border-strong: rgba(80, 120, 255, 0.5);

  --text-primary: #131830;
  --text-secondary: #5a6785;
  --text-muted: #8a95b5;
  --text-inverse: #ffffff;

  --accent-soft: rgba(80, 120, 255, 0.1);
  --accent-soft-hover: rgba(80, 120, 255, 0.16);

  --danger-soft: rgba(255, 90, 90, 0.1);
  --success-soft: rgba(70, 200, 120, 0.1);
  --star-soft: rgba(255, 180, 60, 0.15);

  --shadow-sm: 0 2px 8px rgba(80, 100, 180, 0.08);
  --shadow-md: 0 8px 24px rgba(80, 100, 180, 0.12);
  --shadow-lg: 0 20px 60px rgba(80, 100, 180, 0.18);
  --shadow-accent: 0 6px 18px rgba(80, 110, 255, 0.25);
}

[data-theme="light"] body {
  background: var(--bg-base);
}

[data-theme="light"] .loading-screen { background: var(--bg-base); }
[data-theme="light"] .donut-chart::after { background: #ffffff; }
[data-theme="light"] .preview-overlay { background: rgba(240, 244, 250, 0.98); }

/* Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ==========================================
   RESPONSIVE LAYOUT SWITCHING
   ========================================== */
.layout-desktop { display: none; }
.layout-mobile { display: flex; }

@media (min-width: 900px) {
  .layout-mobile { display: none; }
  .layout-desktop { display: grid; }
}

/* ==========================================
   LOADING SCREEN
   ========================================== */
body.loading { overflow: hidden; }
body.loading .app-wrapper {
  opacity: 0;
  transform: scale(0.98);
  pointer-events: none;
}
.app-wrapper {
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
.loading-screen.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loading-screen::before {
  content: '';
  position: absolute;
  inset: -30%;
  background:
    radial-gradient(circle at 25% 20%, rgba(80, 120, 255, 0.18), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(180, 80, 255, 0.15), transparent 45%);
  z-index: 0;
  pointer-events: none;
  animation: bgShift 15s ease-in-out infinite alternate;
}
.loading-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(130, 150, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(130, 150, 255, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: 0;
  pointer-events: none;
  mask-image: radial-gradient(circle at center, black, transparent 70%);
  -webkit-mask-image: radial-gradient(circle at center, black, transparent 70%);
}
@keyframes bgShift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-2%, -2%) scale(1.04); }
}
.loading-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
  animation: loadingFadeIn 0.6s ease-out;
}
@keyframes loadingFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.loading-logo-wrap {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.loading-logo {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: #fff;
  z-index: 3;
  box-shadow: var(--shadow-accent);
  animation: logoPop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1), logoFloat 3s ease-in-out infinite 0.7s;
}
@keyframes logoPop {
  0%   { transform: scale(0) rotate(-45deg); opacity: 0; }
  60%  { transform: scale(1.1) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
.loading-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  border: 1.5px solid rgba(140, 170, 255, 0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
}
.loading-ring-1 { animation: ringPulseLoad 2.4s ease-out infinite 0s; }
.loading-ring-2 { animation: ringPulseLoad 2.4s ease-out infinite 0.8s; }
.loading-ring-3 { animation: ringPulseLoad 2.4s ease-out infinite 1.6s; }
@keyframes ringPulseLoad {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 0.7; border-radius: 22px; }
  100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; border-radius: 50%; }
}
.loading-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary) 0%, #b8c6ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-top: 4px;
}
.loading-subtitle {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: -4px;
}
.loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8aa9ff;
  opacity: 0.4;
  animation: dotPulse 1.4s ease-in-out infinite;
}
.loading-dot:nth-child(1) { animation-delay: 0s; }
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50%      { opacity: 1; transform: scale(1.15); }
}
.loading-progress {
  width: 200px;
  height: 4px;
  background: var(--bg-hover);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 16px;
}
.loading-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: 10px;
  transition: width 0.4s ease;
  position: relative;
  overflow: hidden;
}
.loading-progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: progressShine 1.5s ease-in-out infinite;
}
@keyframes progressShine {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.loading-status {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 8px;
  min-height: 18px;
  transition: opacity 0.3s ease;
}
.loading-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 24px;
  padding: 6px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  animation: hintFadeIn 1s ease-out 0.5s backwards;
}
@keyframes hintFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.loading-hint i { color: #ffd66b; font-size: 11px; }
.loading-particles {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.loading-particles span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #8aa9ff;
  opacity: 0;
  animation: particleFloat 8s ease-in-out infinite;
}
.loading-particles span:nth-child(1) { left: 15%; top: 20%; animation-delay: 0s; background: #4f7aff; }
.loading-particles span:nth-child(2) { left: 80%; top: 30%; animation-delay: 1.2s; background: #8a4fff; width: 5px; height: 5px; }
.loading-particles span:nth-child(3) { left: 25%; top: 75%; animation-delay: 2.4s; background: #c29bff; }
.loading-particles span:nth-child(4) { left: 70%; top: 80%; animation-delay: 3.6s; background: #6be09e; width: 3px; height: 3px; }
.loading-particles span:nth-child(5) { left: 50%; top: 15%; animation-delay: 4.8s; background: #ffc46b; width: 5px; height: 5px; }
.loading-particles span:nth-child(6) { left: 90%; top: 60%; animation-delay: 6s; background: #ff7b7b; }
@keyframes particleFloat {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0; }
  10%      { opacity: 0.8; }
  50%      { transform: translateY(-40px) scale(1.3); opacity: 0.6; }
  90%      { opacity: 0; }
}

/* ==========================================
   SHARED COMPONENTS
   ========================================== */
.logo-area { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 44px;
  height: 44px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  color: #fff;
  box-shadow: var(--shadow-accent);
  transition: var(--transition);
  flex-shrink: 0;
}
.logo-icon:hover { transform: rotate(-6deg) scale(1.05); }
.logo-text h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.15;
  color: var(--text-primary);
}
.logo-text .badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.6px;
  background: var(--accent-gradient);
  padding: 3px 8px;
  border-radius: 20px;
  color: #fff;
  margin-top: 3px;
  opacity: 0.9;
}

.progress-bar {
  height: 3px;
  background: var(--bg-hover);
  border-radius: 10px;
  overflow: hidden;
}
.progress {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 10px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* File icons */
.file-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  position: relative;
}
.file-icon.pdf   { background: rgba(255, 70, 70, 0.15);  color: #ff7b7b; }
.file-icon.img   { background: rgba(70, 200, 120, 0.15); color: #6be09e; }
.file-icon.zip   { background: rgba(255, 180, 60, 0.15); color: #ffc46b; }
.file-icon.doc   { background: rgba(90, 150, 255, 0.15); color: #7aaaff; }
.file-icon.video { background: rgba(180, 80, 255, 0.15); color: #c29bff; }
.file-icon.audio { background: rgba(255, 140, 200, 0.15); color: #ff9bc8; }
.file-icon.chat  { background: rgba(255, 70, 70, 0.15);  color: #ff7b7b; }
.file-icon.code  { background: rgba(70, 220, 200, 0.15); color: #5ce0c8; }
.file-icon.ebook { background: rgba(200, 150, 100, 0.15); color: #d4a373; }
.file-icon.font  { background: rgba(255, 200, 100, 0.15); color: #ffc46b; }
.file-icon.exe   { background: rgba(150, 150, 180, 0.15); color: #a0a4c8; }
.file-icon.generic { background: rgba(130, 150, 200, 0.15); color: #9ba9d4; }
.file-icon.folder { background: rgba(255, 200, 60, 0.15); color: #ffc46b; }

.file-star-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 14px;
  height: 14px;
  background: var(--star);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  color: #1a1a2e;
  border: 1.5px solid var(--bg-base);
}

.file-details { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}
.file-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-actions-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.file-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.file-action:hover { background: var(--bg-hover); color: var(--text-primary); }
.file-action.starred { color: var(--star); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  text-align: center;
  flex: 1;
}
.empty-state i { font-size: 42px; color: var(--text-muted); opacity: 0.4; margin-bottom: 4px; }
.empty-state p { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.empty-state span { font-size: 12px; color: var(--text-muted); }

/* ==========================================
   MOBILE LAYOUT
   ========================================== */
.layout-mobile {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  background: var(--bg-base-2);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
  animation: fadeIn 0.4s ease-out;
}
.layout-mobile::before {
  content: '';
  position: absolute;
  top: -30%;
  left: -30%;
  width: 160%;
  height: 160%;
  background:
    radial-gradient(circle at 25% 20%, rgba(80, 120, 255, 0.1), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(180, 80, 255, 0.08), transparent 45%);
  z-index: 0;
  pointer-events: none;
  animation: bgShift 20s ease-in-out infinite alternate;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.layout-mobile .app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 5;
  flex-shrink: 0;
  transition: opacity 0.25s ease;
}
body.search-mode .layout-mobile .app-header {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.header-actions { display: flex; gap: 8px; align-items: center; }
.theme-btn-m, .search-btn {
  width: 42px;
  height: 42px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.theme-btn-m:hover, .search-btn:hover {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
}
.theme-btn-m:hover { transform: rotate(20deg); }

/* Search mobile */
.layout-mobile .search-bar {
  display: none;
  align-items: center;
  gap: 10px;
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  left: 16px;
  right: 16px;
  z-index: 10;
  animation: searchSlide 0.28s ease;
}
.layout-mobile .search-bar.active { display: flex; }
@keyframes searchSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-hover);
  border-radius: 14px;
  padding: 0 14px;
  height: 44px;
  box-shadow: var(--shadow-md);
}
.search-input-wrap > i { color: var(--accent-1); font-size: 15px; flex-shrink: 0; }
.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  min-width: 0;
}
.search-input::placeholder { color: var(--text-muted); }
.search-clear {
  background: var(--bg-hover);
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.search-clear:hover { background: var(--danger-soft); color: var(--danger); }
.search-cancel {
  background: transparent;
  border: none;
  color: var(--accent-1);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 4px;
  flex-shrink: 0;
}

/* Search results mobile */
.layout-mobile .search-results {
  display: none;
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 72px);
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: var(--bg-base-2);
  backdrop-filter: blur(24px);
  border-radius: 22px;
  border: 1px solid var(--border-subtle);
  z-index: 9;
  padding: 16px 14px;
  flex-direction: column;
  overflow: hidden;
  animation: searchSlide 0.28s ease;
}
.layout-mobile .search-results.active { display: flex; }
.search-results-header {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 10px;
}
.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  scrollbar-width: none;
  flex: 1;
}
.search-results-list::-webkit-scrollbar { display: none; }
.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}
.search-result-item:hover {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
}
.search-result-item .file-icon { width: 38px; height: 38px; font-size: 16px; flex-shrink: 0; }
.search-result-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.search-result-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}
.search-result-name mark {
  background: var(--accent-soft-hover);
  color: var(--accent-1);
  border-radius: 3px;
  padding: 0 2px;
}
.search-result-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-arrow { color: var(--text-muted); font-size: 11px; }
.search-suggestions-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 4px 8px;
}
.search-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 0 4px; }
.search-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
}
.search-chip:hover {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
}
.search-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  text-align: center;
  flex: 1;
}
.search-empty i { font-size: 36px; color: var(--text-muted); opacity: 0.5; }
.search-empty p { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.search-empty span { font-size: 12px; color: var(--text-muted); }

/* Tab content mobile */
.layout-mobile .tab-content {
  display: none;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
  position: relative;
  z-index: 1;
  animation: tabFade 0.3s ease;
}
.layout-mobile .tab-content.active { display: flex; }
@keyframes tabFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tab-header { margin-bottom: 4px; }
.tab-header h2 {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}
.tab-header h2 i { color: var(--accent-1); font-size: 16px; }
.tab-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 4px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  flex-shrink: 0;
}
.stats-grid-2 { grid-template-columns: 1fr 1fr; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: var(--transition);
  cursor: pointer;
  min-width: 0;
}
.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  background: var(--bg-elevated);
}
.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-1);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-label {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--text-primary);
}
.stat-value small {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 1px;
}
.stat-value-sm {
  font-size: 14px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-unlimited .stat-icon {
  background: var(--star-soft);
  color: var(--star);
}
.stat-unlimited .progress {
  background: linear-gradient(90deg, #ffd66b, #ff9b6b, #ff6b9b);
}

.filter-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  flex-shrink: 0;
}
.filter-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.filter-btn i { font-size: 17px; color: var(--accent-1); transition: var(--transition); }
.filter-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  transform: translateY(-2px);
}
.filter-btn.active {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-accent);
}
.filter-btn.active i { color: #fff; }

.recent-files {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.section-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
}
.section-header h2 i { font-size: 12px; color: var(--accent-1); }
.file-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  scrollbar-width: none;
  padding-right: 2px;
  padding-bottom: 90px;
  flex: 1;
}
.file-list::-webkit-scrollbar { display: none; }
.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  transition: var(--transition);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}
.file-item:hover {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
}
.file-item.is-folder .file-icon {
  background: var(--star-soft);
  color: var(--star);
}

/* Bottom nav */
.bottom-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  border-radius: 24px;
  padding: 6px;
  border: 1px solid var(--border-subtle);
  position: relative;
  z-index: 5;
  flex-shrink: 0;
  transition: opacity 0.25s ease;
}
body.search-mode .bottom-nav { opacity: 0; pointer-events: none; }
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  padding: 7px 4px;
  border-radius: 18px;
  transition: var(--transition);
  position: relative;
}
.nav-item i { font-size: 16px; }
.nav-item:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.nav-item.active {
  color: #fff;
  background: var(--accent-gradient);
  box-shadow: var(--shadow-accent);
}
.nav-dot {
  position: absolute;
  top: 6px;
  right: calc(50% - 14px);
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 1.5px solid var(--bg-modal);
}

/* Analytics mobile */
.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}
.analytics-card h3 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
}
.chart-container { display: flex; align-items: center; gap: 20px; }
.donut-chart {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  background: var(--bg-hover);
}
.donut-chart::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68%;
  height: 68%;
  background: var(--bg-modal);
  border-radius: 50%;
}
.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
}
.donut-value { font-size: 20px; font-weight: 700; line-height: 1; color: var(--text-primary); }
.donut-label { font-size: 10px; color: var(--text-secondary); }
.chart-legend { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-color { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-label { color: var(--text-secondary); flex: 1; }
.legend-value { color: var(--text-primary); font-weight: 600; }
.bar-chart {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 120px;
  gap: 6px;
  padding-top: 10px;
}
.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}
.bar {
  width: 100%;
  max-width: 26px;
  background: var(--accent-gradient);
  border-radius: 6px 6px 2px 2px;
  min-height: 4px;
}
.bar-item span { font-size: 10px; color: var(--text-muted); }
.analytics-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mini-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.mini-stat i {
  font-size: 18px;
  color: var(--accent-1);
  background: var(--accent-soft);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mini-stat div { display: flex; flex-direction: column; }
.mini-value { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.mini-label { font-size: 10.5px; color: var(--text-secondary); }

/* Notifications */
.notification-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  scrollbar-width: none;
  flex: 1;
  padding-right: 2px;
}
.notification-list::-webkit-scrollbar { display: none; }
.notification-item {
  display: flex;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 13px;
  transition: var(--transition);
  cursor: pointer;
  align-items: flex-start;
}
.notification-item:hover {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
}
.notification-item.unread { border-left: 3px solid var(--accent-1); }
.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.notif-icon.blue   { background: rgba(80, 120, 255, 0.15); color: #7aaaff; }
.notif-icon.purple { background: rgba(180, 80, 255, 0.15); color: #c29bff; }
.notif-icon.green  { background: rgba(70, 200, 120, 0.15); color: #6be09e; }
.notif-icon.orange { background: rgba(255, 180, 60, 0.15); color: #ffc46b; }
.notif-icon.gold   { background: rgba(255, 200, 60, 0.15); color: #ffd66b; }
.notif-icon.red    { background: rgba(255, 90, 90, 0.15);  color: #ff7b7b; }
.notif-content { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.notif-title-row { display: flex; align-items: center; gap: 6px; }
.notif-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.notif-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-1); }
.notif-desc { font-size: 11.5px; color: var(--text-secondary); line-height: 1.4; }
.notif-time { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

/* Profile */
.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 0 4px;
}
.profile-avatar {
  position: relative;
  width: 76px;
  height: 76px;
  background: var(--accent-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: #fff;
  box-shadow: var(--shadow-accent);
}
.profile-avatar-lg { width: 96px; height: 96px; font-size: 42px; }
.avatar-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--border-hover);
  animation: ringPulse 3s ease-in-out infinite;
}
@keyframes ringPulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50%      { transform: scale(1.05); opacity: 0.3; }
}
.profile-name { font-size: 19px; font-weight: 700; margin-top: 4px; color: var(--text-primary); }
.profile-email { font-size: 12px; color: var(--text-secondary); }
.profile-plan {
  font-size: 11px;
  font-weight: 600;
  background: linear-gradient(135deg, rgba(255, 200, 60, 0.2), rgba(255, 150, 60, 0.2));
  color: #d4a02a;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 200, 60, 0.3);
  margin-top: 4px;
}
[data-theme="dark"] .profile-plan { color: #ffd66b; }
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 8px;
}
.profile-stats-4 { grid-template-columns: repeat(4, 1fr); }
.profile-stat { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.ps-value { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.ps-label { font-size: 10.5px; color: var(--text-secondary); }
.profile-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}
.profile-menu::-webkit-scrollbar { display: none; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  border-bottom: 1px solid var(--border-subtle);
}
.menu-item:last-child { border-bottom: none; }
.menu-item:hover { background: var(--bg-hover); }
.menu-item i:first-child { color: var(--accent-1); font-size: 15px; width: 20px; text-align: center; }
.menu-item span { flex: 1; }
.menu-item i:last-child { font-size: 11px; color: var(--text-muted); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger i:first-child { color: var(--danger); }

/* FAB */
.layout-mobile .fab-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.24s ease, visibility 0s linear 0.24s;
}
.layout-mobile .fab-backdrop.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.24s ease, visibility 0s linear 0s;
}
.layout-mobile .fab-container {
  position: absolute;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
body.search-mode .fab-container {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
}
.fab-main {
  pointer-events: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-accent), 0 0 0 4px var(--accent-soft);
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.28s ease, background 0.28s ease;
  position: relative;
  z-index: 2;
}
.fab-main i {
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 22px;
  line-height: 1;
  display: block;
}
.fab-main:hover { transform: scale(1.06); }
.fab-container.open .fab-main {
  transform: rotate(135deg);
  background: linear-gradient(135deg, #ff5c5c, #ff2e63);
  box-shadow: 0 8px 24px rgba(255, 60, 90, 0.5), 0 0 0 4px rgba(255, 90, 90, 0.15);
}
.fab-container.open .fab-main:hover { transform: rotate(135deg) scale(1.06); }
.fab-menu {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
  visibility: hidden;
}
.fab-container.open .fab-menu { visibility: visible; }
.fab-sub {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  opacity: 0;
  transform: translateY(20px) scale(0.6);
  transition: opacity 0.24s ease, transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fab-container.open .fab-sub { opacity: 1; transform: translateY(0) scale(1); }
.fab-container.open .fab-sub[data-fab="upload"] { transition-delay: 0.04s; }
.fab-container.open .fab-sub[data-fab="folder"] { transition-delay: 0.1s; }
.fab-sub-label {
  background: var(--bg-elevated);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-hover);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.fab-sub-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg-elevated);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 17px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}
.fab-sub:hover .fab-sub-icon {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
  transform: scale(1.08);
}
.fab-sub:active .fab-sub-icon { transform: scale(0.94); }

/* ==========================================
   DESKTOP LAYOUT (REFINED)
   ========================================== */
.layout-desktop {
  width: 100vw;
  height: 100vh;
  max-width: 100%;
  max-height: 100%;
  background: var(--bg-base);
  grid-template-columns: 260px 1fr;
  overflow: hidden;
  position: relative;
  animation: fadeIn 0.4s ease-out;
}

/* Sidebar */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  gap: 28px;
  position: relative;
  overflow: hidden;
}
.sidebar::before {
  content: '';
  position: absolute;
  top: -40%;
  left: -40%;
  width: 180%;
  height: 180%;
  background:
    radial-gradient(circle at 30% 20%, rgba(80, 120, 255, 0.08), transparent 40%),
    radial-gradient(circle at 70% 80%, rgba(180, 80, 255, 0.06), transparent 40%);
  pointer-events: none;
  z-index: 0;
}
[data-theme="light"] .sidebar::before { opacity: 0.5; }
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
  padding: 0 4px;
}
.sidebar-header .logo-text h1 { font-size: 20px; }
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  z-index: 1;
  flex: 1;
}
.side-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  position: relative;
}
.side-nav-item i { font-size: 16px; width: 20px; text-align: center; transition: var(--transition); }
.side-nav-item span { flex: 1; }
.side-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.side-nav-item.active {
  background: var(--accent-soft-hover);
  color: var(--accent-1);
  border-color: var(--border-hover);
}
.side-nav-item.active i { color: var(--accent-1); }
.side-nav-item.active::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: var(--accent-gradient);
  border-radius: 0 3px 3px 0;
}
.side-nav-badge {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.sidebar-footer {
  position: relative;
  z-index: 1;
  padding: 0 4px;
}
.sidebar-storage {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-storage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.sidebar-storage-head i { margin-right: 4px; }
.sidebar-storage-value {
  color: #ffd66b;
  font-weight: 700;
  background: rgba(255, 200, 60, 0.15);
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12px;
  border: 1px solid rgba(255, 200, 60, 0.25);
}
.sidebar-storage-info {
  font-size: 10.5px;
  color: var(--text-muted);
  text-align: center;
}

/* Main */
.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--bg-base);
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-sidebar);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
  z-index: 5;
  height: 76px;
}
.topbar-search {
  flex: 1;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0 16px;
  height: 44px;
  transition: var(--transition);
}
.topbar-search:focus-within {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px var(--accent-soft-hover);
}
.topbar-search > i { color: var(--accent-1); font-size: 15px; flex-shrink: 0; }
.topbar-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  min-width: 0;
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search-clear {
  background: var(--bg-hover);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 10px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topbar-search-clear.visible { display: flex; }
.topbar-search-clear:hover { background: var(--danger-soft); color: var(--danger); }

.topbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.theme-btn-d {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 40px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}
.theme-btn-d i { font-size: 14px; color: var(--accent-1); transition: transform 0.4s ease; }
.theme-btn-d:hover {
  background: var(--accent-soft);
  border-color: var(--border-hover);
}
.theme-btn-d:hover i { transform: rotate(20deg); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding-left: 16px;
  border-left: 1px solid var(--border-subtle);
}
.topbar-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.topbar-user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}
.topbar-user-plan {
  font-size: 10.5px;
  font-weight: 600;
  color: #d4a02a;
}
[data-theme="dark"] .topbar-user-plan { color: #ffd66b; }
.topbar-user-plan i { font-size: 9px; margin-right: 2px; }
.topbar-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  box-shadow: var(--shadow-accent);
  cursor: pointer;
  transition: var(--transition);
}
.topbar-avatar:hover { transform: scale(1.05); }

/* Desktop search panel */
.desktop-search-panel {
  position: absolute;
  top: 84px;
  left: 32px;
  width: 520px;
  max-width: calc(100% - 64px);
  background: var(--bg-elevated);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-hover);
  border-radius: 16px;
  z-index: 20;
  padding: 12px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.24s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 480px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.desktop-search-panel.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.desktop-search-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.desktop-search-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.desktop-search-close:hover { background: var(--danger-soft); color: var(--danger); }
.desktop-search-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  padding-top: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}
.desktop-search-list::-webkit-scrollbar { width: 6px; }
.desktop-search-list::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 3px;
}

/* Main scroll */
.main-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
  position: relative;
}
.main-scroll::-webkit-scrollbar { width: 8px; }
.main-scroll::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 4px;
}
.main-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  padding-bottom: 0;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

.layout-desktop .tab-content {
  display: none;
  flex-direction: column;
  gap: 24px;
  animation: tabFade 0.3s ease;
}
.layout-desktop .tab-content.active { display: flex; }

/* Stats desktop */
.stats-grid-desktop {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.stats-grid-desktop .stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition);
  cursor: pointer;
}
.stats-grid-desktop .stat-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-elevated);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.stat-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stats-grid-desktop .stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 16px;
}
.stat-icon-total { background: var(--accent-soft); color: var(--accent-1); }
.stat-icon-files { background: rgba(90, 150, 255, 0.15); color: #5a9bff; }
.stat-icon-media { background: rgba(70, 200, 120, 0.15); color: #4ec88a; }
.stat-icon-chat  { background: rgba(255, 180, 60, 0.15); color: #ffa94d; }
.stats-grid-desktop .stat-label {
  font-size: 12.5px;
  font-weight: 500;
}
.stats-grid-desktop .stat-value {
  font-size: 24px;
  font-weight: 700;
}
.stats-grid-desktop .stat-value small {
  font-size: 13px;
  font-weight: 600;
  margin-left: 2px;
}

/* Desktop toolbar */
.desktop-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.segmented-control {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 4px;
}
.segment {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.segment i { font-size: 12px; }
.segment:hover { color: var(--text-primary); background: var(--bg-hover); }
.segment.active {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: var(--shadow-accent);
}
.desktop-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.btn-desktop {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}
.btn-desktop i { font-size: 13px; color: var(--accent-1); }
.btn-desktop:hover {
  background: var(--accent-soft);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}
.btn-desktop-primary {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-accent);
}
.btn-desktop-primary i { color: #fff; }
.btn-desktop-primary:hover {
  background: var(--accent-gradient);
  box-shadow: 0 6px 18px rgba(80, 100, 255, 0.45);
  color: #fff;
}

/* Desktop section */
.desktop-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.desktop-section .section-header {
  margin-bottom: 0;
}
.desktop-section .section-header h2 {
  font-size: 15px;
}
.section-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Desktop file list */
.desktop-file-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
  padding-bottom: 0;
}
.desktop-file-list .file-item { padding: 14px 16px; }
.desktop-file-list .file-icon { width: 42px; height: 42px; font-size: 18px; }
.desktop-file-list .file-name { font-size: 13.5px; }
.desktop-file-list .file-meta { font-size: 11px; }
.desktop-file-list .empty-state { grid-column: 1 / -1; }

/* Analytics desktop */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.analytics-grid .analytics-card { padding: 24px; }
.analytics-grid .analytics-card h3 { font-size: 15px; margin-bottom: 20px; }
.desktop-analytics-stats {
  grid-template-columns: repeat(4, 1fr);
}

/* Profile desktop */
.desktop-profile-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}
.desktop-profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.desktop-profile-menu {
  padding: 8px;
  background: var(--bg-card);
  border-radius: 16px;
}
.desktop-profile-menu .menu-item {
  border-radius: 10px;
  padding: 14px 16px;
  border-bottom: none;
}
.desktop-profile-menu .menu-item:hover { background: var(--bg-hover); }

/* ==========================================
   MODAL, PREVIEW, TOAST (shared)
   ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--bg-modal);
  width: 100%;
  max-width: 520px;
  border-radius: 28px 28px 0 0;
  padding: 12px 20px calc(env(safe-area-inset-bottom, 0px) + 24px);
  max-height: 85vh;
  overflow-y: auto;
  scrollbar-width: none;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  color: var(--text-primary);
}
.modal::-webkit-scrollbar { display: none; }
.modal-overlay.show .modal { transform: translateY(0); }
@media (min-width: 900px) {
  .modal-overlay { align-items: center; }
  .modal {
    border-radius: 20px;
    max-height: 80vh;
    max-width: 560px;
    transform: translateY(20px) scale(0.94);
    opacity: 0;
    border-bottom: 1px solid var(--border-subtle);
    padding: 24px 28px;
    box-shadow: var(--shadow-lg);
  }
  .modal-overlay.show .modal {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}
.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--bg-hover);
  border-radius: 4px;
  margin: 0 auto 12px;
}
@media (min-width: 900px) { .modal-handle { display: none; } }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--text-primary); }
@media (min-width: 900px) { .modal-header h3 { font-size: 18px; } }
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); }
.modal-body { font-size: 13.5px; line-height: 1.5; color: var(--text-primary); }
.file-preview { padding: 12px 0 20px; }
.option-list { display: flex; flex-direction: column; gap: 4px; }
.option-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  background: var(--bg-hover);
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: var(--transition);
}
.option-item i { color: var(--accent-1); font-size: 15px; width: 20px; text-align: center; }
.option-item:hover {
  background: var(--accent-soft);
  border-color: var(--border-hover);
}
.option-item.danger { color: var(--danger); }
.option-item.danger i { color: var(--danger); }
.option-item.danger:hover { background: var(--danger-soft); border-color: rgba(255, 90, 90, 0.3); }
.option-item.success { color: var(--success); }
.option-item.success i { color: var(--success); }
.option-item.success:hover { background: var(--success-soft); border-color: rgba(70, 200, 120, 0.3); }
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--text-secondary); }
.detail-row span:last-child { color: var(--text-primary); font-weight: 500; }
.share-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}
.share-btn i { font-size: 20px; color: var(--accent-1); }
.share-btn:hover { background: var(--accent-soft); border-color: var(--border-hover); transform: translateY(-2px); }
.settings-list { display: flex; flex-direction: column; gap: 2px; }
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border-subtle);
}
.setting-item:last-child { border-bottom: none; }
.setting-info { display: flex; align-items: center; gap: 12px; font-size: 13.5px; }
.setting-info i { color: var(--accent-1); font-size: 15px; width: 20px; text-align: center; }
.toggle {
  width: 42px;
  height: 24px;
  background: var(--bg-hover);
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
}
.toggle.active { background: var(--accent-gradient); border-color: transparent; }
.toggle-dot {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.toggle.active .toggle-dot { transform: translateX(18px); }
.modal-input {
  width: 100%;
  padding: 13px 15px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 18px;
  outline: none;
}
.modal-input:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px var(--accent-soft-hover);
}
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-primary, .btn-secondary, .btn-danger {
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
}
.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover { background: var(--accent-soft); }
.btn-danger {
  background: rgba(255, 90, 90, 0.9);
  color: #fff;
}
.btn-danger:hover { background: #ff5c5c; transform: translateY(-1px); }

/* Preview */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  z-index: 300;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.preview-overlay.show { opacity: 1; pointer-events: auto; }
.preview-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 14px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.preview-back, .preview-action {
  width: 40px;
  height: 40px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.preview-back:hover, .preview-action:hover {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #fff;
}
.preview-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}
.preview-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
}
.preview-content img,
.preview-content video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
.preview-content audio { width: 100%; max-width: 400px; }
.preview-content iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
  background: #fff;
}
.preview-content pre {
  background: var(--bg-card);
  padding: 20px;
  border-radius: 12px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
  font-family: 'Courier New', monospace;
  line-height: 1.6;
  color: var(--text-primary);
}
.preview-content .preview-placeholder {
  text-align: center;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.preview-content .preview-placeholder i {
  font-size: 72px;
  color: var(--accent-1);
  opacity: 0.6;
}
.preview-content .preview-placeholder p {
  font-size: 14px;
  max-width: 300px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 90px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-hover);
  border-radius: 14px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast i { color: var(--success); font-size: 16px; }
@media (min-width: 900px) {
  .toast {
    bottom: 32px;
    transform: translateX(-50%) translateY(20px) scale(0.96);
  }
  .toast.show { transform: translateX(-50%) translateY(0) scale(1); }
}

/* Responsive tweaks */
@media (max-width: 360px) {
  .stat-card { padding: 10px 9px; }
  .stat-value { font-size: 14px; }
  .filter-btn span { font-size: 9.5px; }
  .filter-btn i { font-size: 15px; }
  .file-meta { font-size: 10px; }
  .nav-item span { font-size: 9px; }
  .share-options { grid-template-columns: repeat(2, 1fr); }
  .profile-stats-4 { grid-template-columns: repeat(2, 1fr); }
  .fab-main { width: 54px; height: 54px; font-size: 20px; }
  .fab-main i { font-size: 20px; }
  .fab-sub-icon { width: 42px; height: 42px; font-size: 15px; }
  .fab-sub-label { font-size: 11px; padding: 6px 10px; }
}

@media (min-width: 600px) and (max-width: 899px) {
  .layout-mobile {
    max-width: 720px;
    max-height: 900px;
    border-radius: 28px;
    border: 1px solid var(--border-subtle);
    margin: auto;
  }
  body { padding: 20px; }
}

@media (min-width: 900px) and (max-width: 1200px) {
  .layout-desktop { grid-template-columns: 240px 1fr; }
  .stats-grid-desktop { grid-template-columns: repeat(2, 1fr); }
  .analytics-grid { grid-template-columns: 1fr; }
  .desktop-file-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .desktop-profile-grid { grid-template-columns: 1fr; }
  .theme-btn-label { display: none; }
}

@media (min-width: 1200px) {
  .desktop-file-list { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}

/* ==========================================
   FIX: FAB & FILE LIST SPACING
   ========================================== */
.layout-mobile .fab-container {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 100px) !important;
}

.file-list {
  padding-bottom: 130px !important;
}