/**
 * MyNAS Design System
 * 
 * Dark theme with glassmorphism, smooth animations, and responsive layout.
 * Mobile-first design that scales up to desktop.
 * 
 * Color palette: Deep navy/slate background, cyan/teal accents, soft whites.
 */

/* ==================== CSS Custom Properties (Design Tokens) ==================== */
:root {
  /* Background colors — deep navy gradient */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2035;
  --bg-elevated: rgba(30, 41, 66, 0.7);

  /* Glass effect */
  --glass-bg: rgba(17, 24, 39, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-hover: rgba(255, 255, 255, 0.04);
  --glass-active: rgba(255, 255, 255, 0.08);
  --glass-blur: 20px;

  /* Text colors */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-inverse: #0a0e1a;

  /* Accent colors — cyan/teal */
  --accent: #06b6d4;
  --accent-hover: #22d3ee;
  --accent-glow: rgba(6, 182, 212, 0.3);
  --accent-bg: rgba(6, 182, 212, 0.1);

  /* Status colors */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.1);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-xs: 0.75rem;
  --font-sm: 0.8125rem;
  --font-base: 0.875rem;
  --font-md: 1rem;
  --font-lg: 1.25rem;
  --font-xl: 1.5rem;
  --font-2xl: 2rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  /* Layout */
  --header-height: 56px;
  --toolbar-height: 52px;
  --sidebar-width: 260px;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-elevated: rgba(255, 255, 255, 0.95);

  --glass-bg: rgba(255, 255, 255, 0.88);
  --glass-border: rgba(15, 23, 42, 0.08);
  --glass-hover: rgba(15, 23, 42, 0.04);
  --glass-active: rgba(15, 23, 42, 0.08);
  --glass-blur: 20px;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --text-inverse: #ffffff;

  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-glow: rgba(2, 132, 199, 0.25);
  --accent-bg: rgba(2, 132, 199, 0.08);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.2);
}

[data-theme="light"] .login-container {
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(2, 132, 199, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%),
    #f8fafc;
}

[data-theme="light"] .bg-orb {
  opacity: 0.15;
}

[data-theme="light"] .modal-backdrop {
  background: rgba(15, 23, 42, 0.4);
}

.login-theme-btn {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 10;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.login-theme-btn:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* ==================== Reset & Base ==================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ==================== Utility Classes ==================== */
.hidden {
  display: none !important;
}

.view {
  min-height: 100vh;
}

/* ==================== LOGIN VIEW ==================== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-md);
  position: relative;
  overflow: hidden;
  /* Gradient background */
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(6, 182, 212, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%),
    var(--bg-primary);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: var(--space-2xl) var(--space-xl);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: slideUp 0.6s ease-out;
}

.login-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glow);
  animation: pulse-glow 3s ease-in-out infinite;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: white;
}

.login-title {
  font-size: var(--font-2xl);
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  font-size: var(--font-base);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Floating background orbs */
.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 20s ease-in-out infinite;
}

.bg-orb-1 {
  width: 300px;
  height: 300px;
  background: var(--accent);
  top: -100px;
  right: -100px;
  animation-delay: 0s;
}

.bg-orb-2 {
  width: 250px;
  height: 250px;
  background: #6366f1;
  bottom: -80px;
  left: -80px;
  animation-delay: -7s;
}

.bg-orb-3 {
  width: 200px;
  height: 200px;
  background: #10b981;
  top: 50%;
  left: 60%;
  animation-delay: -14s;
}

/* ==================== Input Fields ==================== */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
  transition: color var(--transition-fast);
}

.input-field {
  width: 100%;
  padding: 12px 16px 12px 44px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--font-base);
  outline: none;
  transition: all var(--transition-fast);
}

.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-field:focus + .input-icon,
.input-field:focus ~ .input-icon {
  color: var(--accent);
}

.input-field::placeholder {
  color: var(--text-tertiary);
}

/* ==================== Buttons ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  outline: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #0891b2);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0) scale(0.97);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--text-tertiary);
}

.btn-accent {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.btn-accent:hover {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 7px 14px;
  font-size: var(--font-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ==================== Error Message ==================== */
.error-message {
  color: var(--danger);
  font-size: var(--font-sm);
  text-align: center;
  min-height: 20px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.error-message.visible {
  opacity: 1;
}

/* ==================== App Header ==================== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
  z-index: 100;
  gap: var(--space-md);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-logo-icon {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.header-title {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.header-center {
  flex: 1;
  max-width: 480px;
  display: flex;
  justify-content: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

.header-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.header-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.header-btn:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

.header-btn svg {
  width: 18px;
  height: 18px;
}

/* ==================== Search Bar ==================== */
.search-bar {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 36px 8px 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--font-sm);
  outline: none;
  transition: all var(--transition-fast);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

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

.search-clear {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-clear:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

.search-clear svg {
  width: 14px;
  height: 14px;
}

/* Search match highlight */
.search-match {
  background: var(--accent-glow);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

/* ==================== Toolbar ==================== */
.toolbar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  height: var(--toolbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--glass-border);
  z-index: 99;
  gap: var(--space-md);
}

.trash-toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.trash-toolbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.trash-toolbar-title svg {
  width: 18px;
  height: 18px;
  color: var(--danger);
}

.trash-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.trash-btn-restore {
  padding: 4px 10px;
  font-size: var(--font-xs);
  border-radius: var(--radius-sm);
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.trash-btn-restore:hover {
  background: var(--accent);
  color: white;
}

.trash-btn-restore svg {
  width: 13px;
  height: 13px;
}

.trash-btn-delete {
  padding: 4px 8px;
  font-size: var(--font-xs);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.trash-btn-delete:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: var(--danger);
}

.trash-btn-delete svg {
  width: 13px;
  height: 13px;
}

.trash-meta-orig {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ==================== Breadcrumb ==================== */
.breadcrumb {
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.breadcrumb::-webkit-scrollbar {
  display: none;
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  list-style: none;
  gap: var(--space-xs);
  white-space: nowrap;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.breadcrumb-separator {
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

.breadcrumb-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--glass-card);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  cursor: pointer;
  margin-right: 4px;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.breadcrumb-back-btn:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

.breadcrumb-back-btn svg {
  width: 15px;
  height: 15px;
}

.breadcrumb-link {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 4px 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: var(--font-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.breadcrumb-link:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

.breadcrumb-link.active {
  color: var(--text-primary);
  font-weight: 500;
}

.breadcrumb-link svg {
  width: 14px;
  height: 14px;
}

/* ==================== Toolbar Actions ==================== */
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* ==================== Category Filter Bar ==================== */
.category-bar {
  position: fixed;
  top: calc(var(--header-height) + var(--toolbar-height));
  left: 0;
  right: 0;
  height: 46px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-md);
  z-index: 95;
  transition: all var(--transition-fast);
}

/* ==================== Drive Selector in Filter Bar ==================== */
.drive-toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(15, 23, 42, 0.7);
  padding: 2px 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.drive-pill {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  background: transparent !important;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--font-xs);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  user-select: none;
  flex-shrink: 0;
  outline: none;
}

.drive-pill:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06) !important;
}

.drive-pill.active {
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--text-primary);
  border-color: var(--glass-border);
}

.drive-pill[data-drive="all"].active {
  color: #38bdf8;
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.15) !important;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.2);
}

.drive-pill[data-drive="r2"].active {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.15) !important;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}

.drive-pill[data-drive="telegram"].active {
  color: #38bdf8;
  border-color: rgba(14, 165, 233, 0.4);
  background: rgba(14, 165, 233, 0.15) !important;
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.2);
}

.drive-pill svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.drive-tag {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  opacity: 0.9;
  line-height: 1.2;
}

.drive-tag.r2-tag {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.drive-tag.tg-tag {
  background: rgba(14, 165, 233, 0.2);
  color: #38bdf8;
}

.filter-divider {
  width: 1px;
  height: 18px;
  background: var(--glass-border);
  margin: 0 6px;
  flex-shrink: 0;
}

/* ==================== Upload Dropdown Group ==================== */
.upload-btn-group {
  position: relative;
  display: inline-flex;
}

.upload-btn-group .btn-chevron {
  width: 13px;
  height: 13px;
  margin-left: 2px;
  opacity: 0.8;
  transition: transform var(--transition-fast);
}

.upload-btn-group.open .btn-chevron {
  transform: rotate(180deg);
}

.upload-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 250px;
  background: var(--bg-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  padding: 6px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 4px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.upload-dropdown.hidden {
  display: none;
}

.upload-dropdown-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
  width: 100%;
}

.upload-dropdown-option:hover {
  background: var(--glass-hover);
  border-color: var(--glass-border);
}

.upload-dropdown-option .opt-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.upload-dropdown-option .opt-icon.r2 {
  color: #f59e0b;
}

.upload-dropdown-option .opt-icon.tg {
  color: #06b6d4;
}

.upload-dropdown-option .opt-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.upload-dropdown-option .opt-title {
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-primary);
}

.upload-dropdown-option .opt-desc {
  font-size: 10px;
  color: var(--text-tertiary);
}

/* ==================== Storage Provider Badges on Files ==================== */
.storage-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.storage-badge.r2 {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.storage-badge.tg {
  background: rgba(6, 182, 212, 0.12);
  color: #06b6d4;
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.storage-badge svg {
  width: 9px;
  height: 9px;
}

.category-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  width: 100%;
  padding: 4px 0;
}

.category-scroll::-webkit-scrollbar {
  display: none;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
  font-size: var(--font-xs);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  user-select: none;
  flex-shrink: 0;
}

.category-pill:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

.category-pill.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.category-pill svg {
  width: 14px;
  height: 14px;
}

.category-count {
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
}

.category-pill.active .category-count {
  background: rgba(255, 255, 255, 0.3);
  color: white;
}

/* ==================== File Area ==================== */
.file-area {
  padding-top: calc(var(--header-height) + var(--toolbar-height) + 48px + var(--space-md));
  padding-left: var(--space-md);
  padding-right: var(--space-md);
  padding-bottom: var(--space-xl);
  min-height: 100vh;
}

.file-area.no-category-bar {
  padding-top: calc(var(--header-height) + var(--toolbar-height) + var(--space-md));
}

/* ==================== States (Loading, Empty, Error) ==================== */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  gap: var(--space-md);
  min-height: 300px;
}

.state-icon {
  width: 56px;
  height: 56px;
  color: var(--text-tertiary);
  opacity: 0.5;
}

.state-icon-error {
  color: var(--warning);
  opacity: 0.7;
}

.state-text {
  font-size: var(--font-md);
  color: var(--text-secondary);
}

.state-subtext {
  font-size: var(--font-sm);
  color: var(--text-tertiary);
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ==================== File Grid ==================== */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-md);
  animation: fadeIn 0.3s ease;
}

.file-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md);
  gap: var(--space-sm);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  text-decoration: none;
  color: inherit;
}

.file-item:hover {
  background: var(--glass-hover);
  border-color: var(--text-tertiary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.file-item.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.file-item-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.file-item-icon svg {
  width: 28px;
  height: 28px;
}

/* File type icon colors */
.file-icon-folder { color: #fbbf24; background: rgba(251, 191, 36, 0.1); }
.file-icon-image { color: #a78bfa; background: rgba(167, 139, 250, 0.1); }
.file-icon-video { color: #f472b6; background: rgba(244, 114, 182, 0.1); }
.file-icon-audio { color: #34d399; background: rgba(52, 211, 153, 0.1); }
.file-icon-pdf { color: #ef4444; background: rgba(239, 68, 68, 0.1); }
.file-icon-doc { color: #60a5fa; background: rgba(96, 165, 250, 0.1); }
.file-icon-code { color: #06b6d4; background: rgba(6, 182, 212, 0.1); }
.file-icon-archive { color: #f59e0b; background: rgba(245, 158, 11, 0.1); }
.file-icon-text { color: #94a3b8; background: rgba(148, 163, 184, 0.1); }
.file-icon-default { color: #64748b; background: rgba(100, 116, 139, 0.1); }

.file-item-name {
  font-size: var(--font-sm);
  color: var(--text-primary);
  text-align: center;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  max-width: 100%;
}

.file-item-meta {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
}

.file-item-menu-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  z-index: 5;
  transition: all var(--transition-fast);
  opacity: 0.85;
}

.file-item-menu-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  opacity: 1;
  transform: scale(1.05);
}

.file-item-menu-btn svg {
  width: 16px;
  height: 16px;
}

.file-list-view .file-item {
  padding-right: 48px;
}

.file-list-view .file-item-menu-btn {
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
}

.file-list-view .file-item-menu-btn:hover {
  transform: translateY(-50%) scale(1.05);
}

/* ==================== File List View ==================== */
.file-list-view {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-list-view .file-item {
  flex-direction: row;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  gap: var(--space-md);
}

.file-list-view .file-item:hover {
  transform: none;
}

.file-list-view .file-item-icon {
  width: 36px;
  height: 36px;
}

.file-list-view .file-item-icon svg {
  width: 20px;
  height: 20px;
}

.file-list-view .file-item-name {
  text-align: left;
  flex: 1;
  -webkit-line-clamp: 1;
}

.file-list-view .file-item-meta {
  white-space: nowrap;
}

.file-item-info {
  display: none;
}

.file-list-view .file-item-info {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex-shrink: 0;
}

.file-item-info span {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  min-width: 70px;
  text-align: right;
}

/* ==================== Batch Selection & Multi-Select ==================== */
.file-item-checkbox {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--glass-border);
  background: var(--bg-card);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 6;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.file-item-checkbox svg {
  width: 13px;
  height: 13px;
  color: white;
  display: none;
}

.select-mode .file-item-checkbox {
  display: flex;
}

.file-item:hover .file-item-checkbox {
  display: flex;
}

.file-item.selected-batch {
  border-color: var(--accent);
  background: var(--accent-bg);
  box-shadow: 0 0 0 1px var(--accent);
}

.file-item.selected-batch .file-item-checkbox {
  display: flex;
  background: var(--accent);
  border-color: var(--accent);
}

.file-item.selected-batch .file-item-checkbox svg {
  display: block;
}

/* List view checkbox position */
.file-list-view .file-item-checkbox {
  position: static;
  margin-right: 8px;
  flex-shrink: 0;
}

.btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Floating Batch Action Bar */
.batch-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 550;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 90vw;
}

.batch-bar.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(120%);
  pointer-events: none;
}

.batch-bar-content {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg), 0 8px 30px rgba(0, 0, 0, 0.35);
}

.batch-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 12px;
  border-right: 1px solid var(--glass-border);
}

.batch-count {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.batch-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon-only {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon-only:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.btn-icon-only svg {
  width: 16px;
  height: 16px;
}

.batch-close-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

@media (max-width: 768px) {
  .batch-bar {
    bottom: 16px;
    width: calc(100% - 24px);
    max-width: 100%;
  }

  .batch-bar-content {
    border-radius: var(--radius-lg);
    justify-content: space-between;
    padding: 8px 12px;
    gap: 8px;
  }

  .batch-bar-actions {
    gap: 6px;
  }

  .batch-bar-actions .btn-label {
    display: none;
  }

  .batch-bar-actions .btn {
    padding: 8px 10px;
  }
}


/* ==================== Drag & Drop Overlay ==================== */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 182, 212, 0.08);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  border: 3px dashed var(--accent);
  animation: fadeIn 0.2s ease;
}

.drop-content {
  text-align: center;
  padding: var(--space-2xl);
}

.drop-icon {
  width: 64px;
  height: 64px;
  color: var(--accent);
  margin-bottom: var(--space-md);
  animation: bounce 2s ease-in-out infinite;
}

.drop-text {
  font-size: var(--font-lg);
  color: var(--accent);
  font-weight: 600;
}

/* ==================== Upload Progress ==================== */
.upload-progress {
  position: fixed;
  bottom: var(--space-md);
  right: var(--space-md);
  width: 300px;
  padding: var(--space-md);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 150;
  animation: slideUp 0.3s ease;
}

.upload-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
  font-size: var(--font-sm);
  font-weight: 500;
}

.upload-progress-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.upload-progress-close:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

.upload-progress-close svg {
  width: 14px;
  height: 14px;
}

.upload-progress-bar-container {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.upload-progress-text {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
  display: block;
}

/* ==================== Modal ==================== */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
  padding: var(--space-md);
  animation: fadeIn 0.2s ease;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 600;
}

.modal-content {
  position: relative;
  z-index: 601;
  max-width: 90vw;
  max-height: 90vh;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: scaleIn 0.2s ease;
}

.dialog-content {
  width: 100%;
  max-width: 400px;
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.storage-modal-content {
  width: 100%;
  max-width: 520px;
  max-height: min(88vh, 680px);
  max-height: min(88dvh, 680px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 0;
}

.details-dialog-content,
.move-dialog-content {
  padding: 0;
  overflow: hidden;
  max-width: 440px;
  max-height: min(88vh, 620px);
  max-height: min(88dvh, 620px);
  display: flex;
  flex-direction: column;
}

.details-dialog-content .modal-header,
.move-dialog-content .modal-header {
  flex-shrink: 0;
}

.details-dialog-content .details-list {
  margin: var(--space-md) var(--space-lg);
  overflow-y: auto;
}

.move-dialog-content .dialog-message {
  margin: var(--space-md) var(--space-lg) 0 var(--space-lg);
}

.move-dialog-content .move-folder-options {
  margin: var(--space-xs) var(--space-lg) 0 var(--space-lg);
  flex: 1 1 auto;
  max-height: 180px;
}

.move-dialog-content .input-group {
  margin: var(--space-md) var(--space-lg) 0 var(--space-lg);
}

.details-dialog-content .dialog-actions,
.move-dialog-content .dialog-actions {
  flex-shrink: 0;
  padding: 14px var(--space-lg);
  border-top: 1px solid var(--glass-border);
  background: var(--bg-secondary);
  margin-top: var(--space-md);
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.modal-header-icon {
  width: 22px;
  height: 22px;
  color: var(--accent);
  flex-shrink: 0;
}

.modal-subtitle {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  font-weight: 500;
  display: block;
}

/* ==================== Upload Destination Dialog ==================== */
.upload-dialog-content {
  max-width: 540px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: var(--bg-secondary);
}

.upload-dialog-content .modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.upload-drives-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 24px;
}

.upload-drive-card {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  width: 100%;
}

.upload-drive-card:hover {
  background: rgba(255, 255, 255, 0.07);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

#upload-choice-r2:hover,
#upload-choice-r2.selected-drive {
  border-color: rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.08);
}

#upload-choice-tg:hover,
#upload-choice-tg.selected-drive {
  border-color: rgba(14, 165, 233, 0.6);
  background: rgba(14, 165, 233, 0.08);
}

.upload-drive-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.upload-drive-icon svg {
  width: 24px;
  height: 24px;
}

.upload-drive-icon.r2 {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.upload-drive-icon.tg {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
}

.upload-drive-info {
  flex: 1;
  min-width: 0;
}

.upload-drive-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.upload-drive-name {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.upload-drive-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.upload-drive-tag.r2 {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}

.upload-drive-tag.tg {
  background: rgba(14, 165, 233, 0.18);
  color: #38bdf8;
}

.upload-drive-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 6px 0;
  line-height: 1.4;
}

.upload-drive-meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.upload-drive-meta svg {
  width: 12px;
  height: 12px;
}

.upload-drive-action {
  color: var(--text-tertiary);
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.upload-drive-card:hover .upload-drive-action {
  color: var(--text-primary);
  transform: translateX(4px);
}

.storage-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  -webkit-overflow-scrolling: touch;
}

.storage-usage-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.storage-usage-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.storage-usage-label {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.storage-usage-badge {
  font-size: var(--font-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--accent-bg);
  color: var(--accent);
}

.storage-meter {
  width: 100%;
  height: 10px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.storage-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #10b981);
  border-radius: var(--radius-full);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.storage-usage-bottom {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-xs);
}

.storage-used-value {
  color: var(--text-secondary);
  font-weight: 500;
}

.storage-free-value {
  color: var(--success);
  font-weight: 600;
}

.storage-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

.storage-metric-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
}

.metric-icon-wrap {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--glass-hover);
  color: var(--text-secondary);
}

.metric-icon-wrap svg {
  width: 17px;
  height: 17px;
}

.metric-icon-wrap.accent {
  background: var(--accent-bg);
  color: var(--accent);
}

.metric-icon-wrap.success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}

.metric-icon-wrap.info {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
}

.metric-icon-wrap.warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}

.metric-info {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: var(--font-xs);
  color: var(--text-secondary);
  font-weight: 500;
}

.metric-val {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--text-primary);
  margin: 2px 0 1px 0;
}

.metric-hint {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.storage-info-note {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-xs);
  color: var(--success);
}

.storage-info-note svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--glass-border);
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.modal-title {
  font-size: var(--font-md);
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.dialog-message {
  font-size: var(--font-base);
  color: var(--text-secondary);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-sm);
}

/* ==================== Delete & Confirmation Dialogs (Desktop & Mobile) ==================== */
#delete-dialog .dialog-content,
#empty-trash-dialog .dialog-content {
  width: 100%;
  max-width: 440px;
  padding: 24px 26px 26px;
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
}

#delete-dialog .modal-header,
#empty-trash-dialog .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--glass-border);
}

#delete-dialog .modal-title,
#empty-trash-dialog .modal-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
}

#delete-dialog .dialog-message,
#empty-trash-dialog .dialog-message {
  font-size: var(--font-base);
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 16px 0 6px 0;
  word-break: break-word;
}

#delete-dialog .dialog-actions,
#empty-trash-dialog .dialog-actions {
  display: flex;
  flex-direction: column-reverse;
  width: 100%;
  gap: 10px;
  margin-top: 18px;
}

#delete-dialog .dialog-actions .btn,
#empty-trash-dialog .dialog-actions .btn {
  width: 100%;
  height: 44px;
  justify-content: center;
  font-size: var(--font-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  margin: 0;
}

#delete-dialog #delete-confirm,
#empty-trash-dialog #empty-trash-confirm {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#delete-dialog #delete-confirm:hover,
#empty-trash-dialog #empty-trash-confirm:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.7);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25);
}

#delete-dialog #delete-perm-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

#delete-dialog #delete-perm-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  transform: translateY(-1px);
}

#delete-dialog #delete-cancel,
#empty-trash-dialog #empty-trash-cancel {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-tertiary);
}

#delete-dialog #delete-cancel:hover,
#empty-trash-dialog #empty-trash-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
}

.modal-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: 14px var(--space-lg);
  border-top: 1px solid var(--glass-border);
  background: var(--bg-secondary);
}

/* ==================== Preview Modal ==================== */
.preview-modal-content {
  width: 90vw;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.preview-body {
  flex: 1;
  overflow: auto;
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-body img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.preview-body video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--radius-sm);
}

.preview-body pre {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  overflow: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: var(--font-sm);
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-body iframe {
  width: 100%;
  height: 70vh;
  border: none;
  border-radius: var(--radius-sm);
  background: white;
}

.preview-editor-textarea {
  width: 100%;
  height: 65vh;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;
  font-size: var(--font-sm);
  line-height: 1.6;
  resize: none;
  outline: none;
}

.preview-editor-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}

/* ==================== In-Browser Code/Text Editor ==================== */
.editor-modal-content {
  width: 92vw;
  max-width: 1050px;
  height: 85vh;
  max-height: 850px;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: #0d1117;
  border: 1px solid #30363d;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  border-radius: var(--radius-lg);
  transition: all var(--transition-normal);
}

.editor-modal-content.fullscreen {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  border: none;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
}

.editor-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.editor-header-icon {
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex-shrink: 0;
}

.editor-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.editor-filename {
  font-size: var(--font-sm);
  font-weight: 600;
  color: #c9d1d9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-dirty-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: #d29922;
  color: #0d1117;
}

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

.editor-workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  background: #0d1117;
  position: relative;
  overflow: hidden;
}

.editor-gutter {
  width: 50px;
  background: #161b22;
  border-right: 1px solid #21262d;
  color: #484f58;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 20px;
  padding: 14px 8px 14px 0;
  text-align: right;
  user-select: none;
  overflow: hidden;
  flex-shrink: 0;
  white-space: pre;
}

.editor-textarea {
  flex: 1;
  width: 100%;
  height: 100%;
  padding: 14px 16px;
  background: transparent;
  color: #e6edf3;
  border: none;
  outline: none;
  resize: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 20px;
  tab-size: 2;
  -moz-tab-size: 2;
  white-space: pre;
  overflow: auto;
  word-break: normal;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #161b22;
  border-top: 1px solid #21262d;
  font-size: 11px;
  color: #8b949e;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  flex-shrink: 0;
}

.editor-footer-left,
.editor-footer-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.editor-footer-dot {
  opacity: 0.5;
}

#editor-modal {
  z-index: 2000;
  position: fixed;
  inset: 0;
}

@media (max-width: 768px) {
  .editor-modal-content {
    width: 100vw;
    height: 100dvh;
    height: 100vh;
    max-width: 100vw;
    max-height: 100dvh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  .editor-header {
    padding: 8px 12px;
  }
  .editor-header-actions {
    gap: 6px;
  }
  .editor-header-actions .btn {
    padding: 4px 8px;
    font-size: 12px;
    height: 30px;
  }
  .editor-gutter {
    width: 36px;
    font-size: 11px;
    padding: 10px 4px 10px 0;
  }
  .editor-textarea {
    font-size: 12px;
    padding: 10px 12px;
  }
  .editor-footer-right {
    display: none;
  }
}

/* Terminal / ANSI escape color rendering in Preview */
.ansi-cyan { color: #56d4dd; }
.ansi-green { color: #7ee787; font-weight: 500; }
.ansi-blue { color: #79c0ff; }
.ansi-red { color: #ff7b72; font-weight: 500; }
.ansi-yellow { color: #e3b341; }
.ansi-magenta { color: #d2a8ff; }
.ansi-bold { font-weight: 600; }
.ansi-dim { opacity: 0.6; }

/* ==================== Context Menu ==================== */
.context-menu {
  position: fixed;
  min-width: 180px;
  padding: var(--space-xs);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 400;
  animation: scaleIn 0.15s ease;
}

.context-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--font-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
}

.context-item:hover {
  background: var(--glass-hover);
}

.context-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.context-item-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.context-item-danger:hover svg {
  color: var(--danger);
}

.context-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 380;
}

.context-sheet-handle {
  display: none;
}

.context-sheet-header {
  display: none;
}

.context-cancel-item {
  display: none;
}

.context-divider {
  height: 1px;
  margin: var(--space-xs) 0;
  background: var(--glass-border);
}

.move-folder-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  max-height: 160px;
  overflow-y: auto;
  padding: 4px 0;
}

.move-folder-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: var(--font-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.move-folder-pill svg {
  width: 14px;
  height: 14px;
}

.move-folder-pill:hover,
.move-folder-pill.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.details-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.details-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-xs);
  gap: var(--space-md);
}

.details-label {
  color: var(--text-tertiary);
  font-weight: 500;
  flex-shrink: 0;
}

.details-val {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

.details-val.path-val {
  font-family: monospace;
  color: var(--accent);
}

/* ==================== Toast Notifications ==================== */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--space-md));
  right: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  z-index: 700;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-sm);
  color: var(--text-primary);
  pointer-events: all;
  animation: slideInRight 0.3s ease;
  max-width: 340px;
}

.toast svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-success svg { color: var(--success); }

.toast-error { border-left: 3px solid var(--danger); }
.toast-error svg { color: var(--danger); }

.toast-info { border-left: 3px solid var(--accent); }
.toast-info svg { color: var(--accent); }

.toast-exit {
  animation: slideOutRight 0.3s ease forwards;
}

/* ==================== Animations ==================== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(10px, -10px) scale(1.02); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(6, 182, 212, 0.3); }
  50% { box-shadow: 0 0 30px rgba(6, 182, 212, 0.5), 0 0 60px rgba(6, 182, 212, 0.15); }
}

/* ==================== Responsive Design ==================== */

/* Tablet and up */
@media (min-width: 640px) {
  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .file-area {
    padding-left: var(--space-xl);
    padding-right: var(--space-xl);
  }
}

/* Mobile & Tablet boundary */
@media (max-width: 640px) {
  .header-title {
    display: none;
  }

  .header-center {
    max-width: none;
  }

  .breadcrumb {
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .breadcrumb::-webkit-scrollbar {
    display: none;
  }

  .storage-grid {
    grid-template-columns: 1fr;
  }

  .file-list-header .file-list-type,
  .file-list-header .file-list-date,
  .file-list-item .file-list-type,
  .file-list-item .file-list-date {
    display: none;
  }

  /* Mobile Bottom Action Sheet */
  .context-menu {
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 16px)) !important;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
  }

  .context-sheet-handle {
    display: block;
    width: 36px;
    height: 4px;
    border-radius: var(--radius-full);
    background: var(--text-tertiary);
    margin: 0 auto 12px auto;
    opacity: 0.5;
  }

  .context-sheet-header {
    display: block;
    padding: 0 4px 10px 4px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 6px;
  }

  .context-sheet-title {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-secondary);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .context-item {
    padding: 12px 14px;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
  }

  .context-item svg {
    width: 18px;
    height: 18px;
  }

  .context-cancel-item {
    display: flex;
    justify-content: center;
    margin-top: 8px;
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
  }
}

/* Mobile - small */
@media (max-width: 480px) {
  .app-header {
    padding: 0 var(--space-sm);
    gap: var(--space-xs);
  }

  .header-btn {
    width: 32px;
    height: 32px;
  }

  .btn-label {
    display: none;
  }

  .toolbar {
    padding: 6px 10px;
    gap: 6px;
    min-height: 48px;
  }

  .toolbar-actions {
    gap: 4px;
    flex-shrink: 0;
  }

  .toolbar-actions .btn {
    padding: 0;
    width: 34px;
    height: 34px;
    min-width: 34px;
    justify-content: center;
    border-radius: var(--radius-md);
  }

  .toolbar-actions .btn-icon {
    margin: 0;
  }

  .breadcrumb {
    min-width: 0;
    flex: 1;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, transparent, black 8px, black calc(100% - 10px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent, black 8px, black calc(100% - 10px), transparent 100%);
  }

  .breadcrumb::-webkit-scrollbar {
    display: none;
  }

  .breadcrumb-list {
    gap: 3px;
  }

  .breadcrumb-link {
    padding: 4px 6px;
    font-size: 13px;
    border-radius: var(--radius-sm);
  }

  .breadcrumb-link.active {
    font-weight: 600;
    color: var(--accent);
    background: var(--glass-card);
  }

  .category-bar {
    z-index: 90;
    background: var(--bg-primary);
  }

  .file-area {
    padding-top: 172px !important;
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
    padding-bottom: var(--space-xl);
  }

  .file-area.no-category-bar {
    padding-top: 116px !important;
  }

  .file-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .file-item {
    padding: var(--space-sm);
  }

  .upload-progress {
    left: var(--space-sm);
    right: var(--space-sm);
    width: auto;
  }

  .preview-modal-content {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .dialog-content {
    max-width: min(400px, calc(100vw - 28px));
    padding: var(--space-lg) var(--space-md) var(--space-md);
    border-radius: var(--radius-lg);
  }

  #delete-dialog .dialog-actions,
  #empty-trash-dialog .dialog-actions,
  .dialog-content .dialog-actions {
    display: flex;
    flex-direction: column-reverse;
    width: 100%;
    gap: 8px;
    margin-top: var(--space-md);
  }

  #delete-dialog .dialog-actions .btn,
  #empty-trash-dialog .dialog-actions .btn,
  .dialog-content .dialog-actions .btn {
    width: 100%;
    justify-content: center;
    height: 42px;
    font-size: var(--font-sm);
    font-weight: 500;
  }

  .storage-modal-content {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 28px);
    max-height: calc(100vh - 28px);
    padding: 0 !important;
    border-radius: var(--radius-lg);
  }

  .details-dialog-content,
  .move-dialog-content {
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 28px);
    max-height: calc(100vh - 28px);
    padding: 0 !important;
  }

  .storage-modal-content .modal-header,
  .details-dialog-content .modal-header,
  .move-dialog-content .modal-header {
    padding: 12px 16px;
  }

  .storage-body {
    padding: 12px 16px;
  }

  .modal-footer,
  .details-dialog-content .dialog-actions,
  .move-dialog-content .dialog-actions {
    padding: 12px 16px;
    margin-top: 0;
  }

  .toast {
    max-width: calc(100vw - 32px);
  }

  .login-theme-btn {
    top: var(--space-md);
    right: var(--space-md);
  }
}

/* Mobile - extra small */
@media (max-width: 360px) {
  .search-input {
    font-size: var(--font-xs);
  }

  .file-grid {
    grid-template-columns: 1fr;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--text-tertiary) transparent;
}

/* Selection color */
::selection {
  background: var(--accent-glow);
  color: var(--text-primary);
}
