/* ============================================================
   Drive — hle-c0de.dev
   Tokyonight Dark Theme
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg-dark: #1a1b26;
  --bg-medium: #24283b;
  --bg-light: #414868;
  --bg-highlight: #292e42;
  --text-primary: #c0caf5;
  --text-secondary: #565f89;
  --text-muted: #414868;
  --accent: #7aa2f7;
  --accent-hover: #89b4fa;
  --green: #9ece6a;
  --red: #f7768e;
  --orange: #e0af68;
  --purple: #bb9af7;
  --cyan: #7dcfff;
  --border: #292e42;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: 0.15s ease;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --sidebar-width: 240px;
  --right-panel-width: 300px;
  --header-height: 56px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--bg-light);
  border-radius: 3px;
}

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

* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-light) transparent;
}

/* ---------- App Layout ---------- */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ---------- Left Sidebar ---------- */
.sidebar-left {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-medium);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition), min-width var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo svg {
  width: 16px;
  height: 16px;
  fill: var(--bg-dark);
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-subtitle {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.sidebar-tree {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
  flex-shrink: 0;
}

/* Folder tree */
.tree-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem 0.4rem 1rem;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 0.85rem;
  transition: background var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.tree-item:hover {
  background: var(--bg-highlight);
}

.tree-item.active {
  background: var(--bg-highlight);
  color: var(--accent);
}

.tree-item.active .tree-icon svg {
  fill: var(--accent);
}

.tree-item .tree-arrow {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.tree-item .tree-arrow svg {
  width: 10px;
  height: 10px;
  fill: var(--text-secondary);
}

.tree-item .tree-arrow.expanded {
  transform: rotate(90deg);
}

.tree-item .tree-arrow.empty {
  visibility: hidden;
}

.tree-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-icon svg {
  width: 18px;
  height: 18px;
  fill: var(--orange);
}

.tree-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-children {
  padding-left: 1rem;
}

.tree-children.collapsed {
  display: none;
}

/* Trash link */
.sidebar-trash {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  margin-top: 0.25rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
}

.sidebar-trash:hover {
  background: var(--bg-highlight);
  color: var(--red);
}

.sidebar-trash svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Hub shortcut link */
.sidebar-hub-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  margin: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition), background var(--transition);
}

.sidebar-hub-link:hover {
  background: var(--bg-highlight);
  color: var(--accent);
}

.sidebar-hub-link svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

/* Storage indicator */
.storage-indicator {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.storage-bar {
  height: 4px;
  background: var(--bg-dark);
  border-radius: 2px;
  margin-top: 0.4rem;
  overflow: hidden;
}

.storage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.storage-fill.warning {
  background: var(--orange);
}

.storage-fill.danger {
  background: var(--red);
}

.storage-text {
  margin-top: 0.3rem;
  display: flex;
  justify-content: space-between;
}

/* ---------- Main Content Area ---------- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ---------- Header Bar ---------- */
.header-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  height: var(--header-height);
  min-height: var(--header-height);
  border-bottom: 1px solid var(--border);
  background: var(--bg-medium);
  flex-shrink: 0;
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.breadcrumb-item:hover {
  color: var(--text-primary);
  background: var(--bg-highlight);
}

.breadcrumb-item.current {
  color: var(--text-primary);
  font-weight: 600;
  cursor: default;
}

.breadcrumb-item.current:hover {
  background: transparent;
}

.breadcrumb-sep {
  color: var(--text-muted);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.header-spacer {
  flex: 1;
}

/* Search bar */
.search-wrapper {
  position: relative;
  width: 240px;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  padding: 0.45rem 0.75rem 0.45rem 2rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition), width var(--transition);
}

.search-input:focus {
  border-color: var(--accent);
}

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

.search-icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  fill: var(--text-muted);
  pointer-events: none;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.search-results-dropdown.visible {
  display: block;
}

.search-result-group {
  padding: 0.3rem 0;
}

.search-result-group-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.3rem 0.75rem;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  transition: background var(--transition);
}

.search-result-item:hover {
  background: var(--bg-highlight);
}

.search-result-item .result-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.search-result-item .result-icon svg {
  width: 16px;
  height: 16px;
}

.search-result-item .result-name {
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-item .result-path {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: auto;
  flex-shrink: 0;
}

.search-no-results {
  padding: 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* View toggle */
.view-toggle {
  display: flex;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.view-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background var(--transition);
}

.view-toggle-btn svg {
  width: 16px;
  height: 16px;
  fill: var(--text-secondary);
  transition: fill var(--transition);
}

.view-toggle-btn:hover {
  background: var(--bg-highlight);
}

.view-toggle-btn.active {
  background: var(--bg-highlight);
}

.view-toggle-btn.active svg {
  fill: var(--accent);
}

/* User menu */
.user-menu {
  position: relative;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--purple);
  color: var(--bg-dark);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity var(--transition);
}

.user-avatar:hover {
  opacity: 0.85;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: 200;
  display: none;
  overflow: hidden;
}

.user-dropdown.visible {
  display: block;
}

.user-dropdown-header {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.user-dropdown-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.user-dropdown-role {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition);
}

.user-dropdown-item:hover {
  background: var(--bg-highlight);
}

.user-dropdown-item svg {
  width: 16px;
  height: 16px;
  fill: var(--text-secondary);
}

.user-dropdown-item.danger {
  color: var(--red);
}

.user-dropdown-item.danger svg {
  fill: var(--red);
}

.user-dropdown-sep {
  height: 1px;
  background: var(--border);
}

/* ---------- Content Area ---------- */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  position: relative;
}

/* ---------- File Grid ---------- */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.file-card {
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 0.85rem 0.75rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  user-select: none;
  position: relative;
}

.file-card:hover {
  background: var(--bg-highlight);
  border-color: var(--bg-light);
}

.file-card.selected {
  border-color: var(--accent);
  background: rgba(122, 162, 247, 0.08);
  box-shadow: 0 0 0 1px var(--accent);
}

.file-card.drag-over {
  border-color: var(--green);
  background: rgba(158, 206, 106, 0.08);
}

.file-card-checkbox {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 2;
}

.file-card:hover .file-card-checkbox,
.file-card.selected .file-card-checkbox {
  opacity: 1;
}

.file-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  margin-bottom: 0.6rem;
}

.file-card-icon svg {
  width: 40px;
  height: 40px;
}

.file-card-icon img {
  max-width: 100%;
  max-height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.file-card-name {
  font-size: 0.82rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.file-card-meta {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Folder cards */
.file-card.folder .file-card-icon svg {
  width: 44px;
  height: 44px;
}

/* ---------- File List ---------- */
.file-list {
  width: 100%;
}

.file-list-header {
  display: flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.file-list-row {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
}

.file-list-row:hover {
  background: var(--bg-highlight);
}

.file-list-row.selected {
  background: rgba(122, 162, 247, 0.08);
}

.file-list-row.selected .file-list-name {
  color: var(--accent);
}

.file-list-check {
  width: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.file-list-icon {
  width: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.file-list-name {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 0.5rem;
}

.file-list-size {
  width: 90px;
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: right;
}

.file-list-date {
  width: 140px;
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: right;
}

.file-list-uploader {
  width: 120px;
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Empty State ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  fill: var(--text-muted);
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 0.85rem;
}

.empty-state .btn {
  margin-top: 1rem;
}

/* ---------- Right Sidebar (Activity) ---------- */
.sidebar-right {
  width: var(--right-panel-width);
  min-width: var(--right-panel-width);
  background: var(--bg-medium);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition), min-width var(--transition), opacity var(--transition);
}

.sidebar-right.collapsed {
  width: 0;
  min-width: 0;
  border-left: none;
  opacity: 0;
  pointer-events: none;
}

.activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.activity-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
}

.activity-toggle-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.activity-toggle-btn:hover {
  background: var(--bg-highlight);
}

.activity-toggle-btn svg {
  width: 14px;
  height: 14px;
  fill: var(--text-secondary);
}

.activity-feed {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.activity-item {
  display: flex;
  gap: 0.6rem;
  padding: 0.5rem 0;
}

.activity-item + .activity-item {
  border-top: 1px solid var(--border);
}

.activity-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-light);
  color: var(--text-primary);
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-body {
  flex: 1;
  min-width: 0;
}

.activity-text {
  font-size: 0.8rem;
  line-height: 1.4;
}

.activity-text strong {
  font-weight: 600;
  color: var(--text-primary);
}

.activity-text .file-name {
  color: var(--accent);
}

.activity-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Chat bubble */
.activity-item.chat-message {
  flex-direction: column;
  gap: 0.3rem;
}

.activity-item.chat-message .chat-bubble {
  background: var(--bg-highlight);
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
  line-height: 1.45;
  margin-left: 2.1rem;
}

.activity-item.chat-message .chat-sender {
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.activity-item.chat-message .chat-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Chat input */
.activity-chat-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.activity-chat-input {
  flex: 1;
  padding: 0.45rem 0.65rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  transition: border-color var(--transition);
}

.activity-chat-input:focus {
  border-color: var(--accent);
}

.activity-chat-input::placeholder {
  color: var(--text-muted);
}

.activity-chat-send {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}

.activity-chat-send:hover {
  background: var(--accent-hover);
}

.activity-chat-send svg {
  width: 14px;
  height: 14px;
  fill: var(--bg-dark);
}

/* External toggle button (visible when panel collapsed) */
.activity-panel-toggle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 48px;
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: background var(--transition);
}

.activity-panel-toggle:hover {
  background: var(--bg-highlight);
}

.activity-panel-toggle svg {
  width: 12px;
  height: 12px;
  fill: var(--text-secondary);
}

.activity-panel-toggle.visible {
  display: flex;
}

/* ---------- Upload Panel ---------- */
.upload-panel {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 340px;
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  overflow: hidden;
  display: none;
}

.upload-panel.visible {
  display: block;
}

.upload-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: var(--bg-highlight);
  cursor: pointer;
}

.upload-panel-title {
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.upload-panel-title .count {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.upload-panel-actions {
  display: flex;
  gap: 0.25rem;
}

.upload-panel-actions button {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.upload-panel-actions button:hover {
  background: var(--bg-light);
}

.upload-panel-actions button svg {
  width: 12px;
  height: 12px;
  fill: var(--text-secondary);
}

.upload-panel-body {
  max-height: 240px;
  overflow-y: auto;
}

.upload-panel.minimized .upload-panel-body {
  display: none;
}

.upload-overall {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.upload-overall-bar {
  height: 3px;
  background: var(--bg-dark);
  border-radius: 2px;
  overflow: hidden;
}

.upload-overall-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.2s ease;
}

.upload-overall-fill.complete {
  background: var(--green);
}

.upload-file-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.upload-file-item:last-child {
  border-bottom: none;
}

.upload-file-icon svg {
  width: 16px;
  height: 16px;
}

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

.upload-file-name {
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-file-progress {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.upload-file-bar {
  height: 2px;
  background: var(--bg-dark);
  border-radius: 1px;
  margin-top: 0.2rem;
  overflow: hidden;
}

.upload-file-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 0.15s ease;
}

.upload-file-status {
  flex-shrink: 0;
}

.upload-file-status svg {
  width: 14px;
  height: 14px;
}

.upload-file-cancel {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}

.upload-file-cancel:hover {
  background: rgba(247, 118, 142, 0.15);
}

.upload-file-cancel svg {
  width: 10px;
  height: 10px;
  fill: var(--text-secondary);
}

/* Drag overlay */
.drag-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 27, 38, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.drag-overlay.visible {
  display: flex;
}

.drag-overlay-inner {
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  padding: 3rem 4rem;
  text-align: center;
  pointer-events: none;
}

.drag-overlay-inner svg {
  width: 48px;
  height: 48px;
  fill: var(--accent);
  margin-bottom: 0.75rem;
}

.drag-overlay-inner p {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

.drag-overlay-inner .sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-top: 0.25rem;
}

/* ---------- Context Menu ---------- */
.context-menu {
  position: fixed;
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 1000;
  padding: 0.3rem 0;
  display: none;
}

.context-menu.visible {
  display: block;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.83rem;
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition);
}

.context-menu-item:hover {
  background: var(--bg-highlight);
}

.context-menu-item svg {
  width: 15px;
  height: 15px;
  fill: var(--text-secondary);
  flex-shrink: 0;
}

.context-menu-item.danger {
  color: var(--red);
}

.context-menu-item.danger svg {
  fill: var(--red);
}

.context-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

.modal-card {
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.15s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

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

.modal-close:hover {
  background: var(--bg-highlight);
}

.modal-close svg {
  width: 14px;
  height: 14px;
  fill: var(--text-secondary);
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

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

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-highlight);
  color: var(--text-primary);
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-light);
}

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

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-dark);
  border-color: var(--accent);
}

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

.btn-primary svg {
  fill: var(--bg-dark);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: rgba(247, 118, 142, 0.3);
}

.btn-danger:hover {
  background: rgba(247, 118, 142, 0.1);
  border-color: var(--red);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-highlight);
  color: var(--text-primary);
}

.btn-icon {
  padding: 0.4rem;
  width: 32px;
  height: 32px;
  justify-content: center;
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
}

/* ---------- Form Inputs ---------- */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--transition);
}

.form-input:focus {
  border-color: var(--accent);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23565f89'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 18px;
  padding-right: 2rem;
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
  font-family: var(--font-sans);
}

/* Checkbox */
.checkbox {
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

.checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 8px;
  border: solid var(--bg-dark);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Badges / Tags / Pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-info {
  background: rgba(125, 207, 255, 0.12);
  color: var(--cyan);
}

.badge-success {
  background: rgba(158, 206, 106, 0.12);
  color: var(--green);
}

.badge-warning {
  background: rgba(224, 175, 104, 0.12);
  color: var(--orange);
}

.badge-danger {
  background: rgba(247, 118, 142, 0.12);
  color: var(--red);
}

.badge-purple {
  background: rgba(187, 154, 247, 0.12);
  color: var(--purple);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  background: var(--bg-highlight);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  pointer-events: auto;
  animation: toastIn 0.2s ease;
  max-width: 360px;
}

.toast.removing {
  animation: toastOut 0.2s ease forwards;
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toast-icon svg {
  width: 18px;
  height: 18px;
}

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

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

.toast.error { border-left: 3px solid var(--red); }
.toast.error .toast-icon svg { fill: var(--red); }

.toast.warning { border-left: 3px solid var(--orange); }
.toast.warning .toast-icon svg { fill: var(--orange); }

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

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

/* ---------- Bulk Action Bar ---------- */
.bulk-bar {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  z-index: 600;
  animation: bulkBarIn 0.2s ease;
}

.bulk-bar.hidden {
  display: none;
}

.bulk-bar-count {
  font-size: 0.85rem;
  font-weight: 600;
  padding-right: 0.5rem;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.bulk-bar .btn {
  border: none;
}

@keyframes bulkBarIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- Admin Panel ---------- */
.admin-container {
  max-width: 960px;
  margin: 0 auto;
}

.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.admin-tab {
  padding: 0.65rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.admin-tab:hover {
  color: var(--text-primary);
}

.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.admin-table tr:hover td {
  background: var(--bg-highlight);
}

.admin-table .actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}

/* Storage bar in admin */
.admin-storage-bar {
  height: 8px;
  background: var(--bg-dark);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.admin-storage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

.admin-storage-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

/* ---------- Share Modal ---------- */
.share-link-display {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.share-link-input {
  flex: 1;
  padding: 0.5rem 0.65rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--accent);
  font-size: 0.82rem;
  font-family: var(--font-mono);
  outline: none;
}

.share-link-copy {
  flex-shrink: 0;
}

/* Active share list */
.share-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.share-list-item:last-child {
  border-bottom: none;
}

.share-list-info {
  flex: 1;
  min-width: 0;
}

.share-list-name {
  font-size: 0.85rem;
  font-weight: 500;
}

.share-list-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  gap: 0.75rem;
  margin-top: 0.15rem;
}

/* ---------- Trash View ---------- */
.trash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.trash-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.trash-header h2 svg {
  width: 20px;
  height: 20px;
  fill: var(--red);
}

/* ---------- Loading & Spinners ---------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

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

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  :root {
    --right-panel-width: 260px;
  }

  .search-wrapper {
    width: 180px;
  }

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

  .file-list-uploader {
    display: none;
  }
}

@media (max-width: 768px) {
  .sidebar-left {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 800;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar-left.open {
    transform: translateX(0);
  }

  .sidebar-right {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 800;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar-right.open {
    transform: translateX(0);
    width: var(--right-panel-width);
    min-width: var(--right-panel-width);
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 799;
    display: none;
  }

  .mobile-overlay.visible {
    display: block;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius-sm);
  }

  .mobile-menu-btn svg {
    width: 20px;
    height: 20px;
    fill: var(--text-primary);
  }

  .header-bar {
    padding: 0 0.75rem;
  }

  .search-wrapper {
    width: 100%;
    flex-shrink: 1;
  }

  .breadcrumbs {
    display: none;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
  }

  .file-card {
    padding: 0.75rem 0.65rem 0.6rem;
  }

  .file-list-date {
    display: none;
  }

  .content-area {
    padding: 0.75rem;
  }

  .upload-panel {
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
  }

  .bulk-bar {
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    transform: none;
  }

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

  .modal-card {
    max-width: none;
    margin: 0.5rem;
  }
}

/* ---------- Focus & Accessibility ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- File Type Icon Colors ---------- */
.icon-pdf svg { fill: var(--red); }
.icon-doc svg { fill: var(--accent); }
.icon-xls svg { fill: var(--green); }
.icon-ppt svg { fill: var(--orange); }
.icon-image svg { fill: var(--purple); }
.icon-video svg { fill: #ff79c6; }
.icon-audio svg { fill: var(--cyan); }
.icon-archive svg { fill: var(--orange); }
.icon-code svg { fill: var(--green); }
.icon-text svg { fill: var(--text-secondary); }
.icon-folder svg { fill: var(--orange); }
.icon-generic svg { fill: var(--text-secondary); }

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--red); }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
