* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #09090b;
  --surface: #18181b;
  --surface-hover: #27272a;
  --border: #27272a;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --primary: #ffffff;
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 9, 11, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
}

.header-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.header-link:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--text-muted);
}

/* Main */
.main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  gap: 16px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.crumb {
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.crumb:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.toolbar-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--text-muted);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

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

.view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.view-btn.active {
  background: var(--primary);
  color: var(--bg);
}

.view-btn + .view-btn {
  border-left: 1px solid var(--border);
}

/* Content */
.content {
  min-height: 400px;
}

/* Items Grid */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

/* List View */
.items-grid.list-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.items-grid.list-view .item-card {
  flex-direction: row;
  padding: 14px 18px;
  text-align: left;
  gap: 16px;
}

.items-grid.list-view .item-icon {
  width: 44px;
  height: 44px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.items-grid.list-view .item-icon svg {
  width: 22px;
  height: 22px;
}

.items-grid.list-view .item-name {
  text-align: left;
}

.items-grid.list-view .item-meta {
  text-align: left;
}

.items-grid.list-view .item-card:hover {
  transform: none;
}

/* Item Card */
.item-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s ease;
  cursor: pointer;
}

.item-card:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.item-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.item-icon.folder {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.item-icon.file {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
}

/* PDF - Red */
.item-icon.file-pdf {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
}

/* Word - Blue */
.item-icon.file-word {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

/* Excel - Green */
.item-icon.file-excel {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

/* PowerPoint - Orange */
.item-icon.file-ppt {
  background: linear-gradient(135deg, #f97316, #ea580c);
}

/* Images - Pink/Purple */
.item-icon.file-image {
  background: linear-gradient(135deg, #ec4899, #db2777);
}

/* Videos - Red/Pink */
.item-icon.file-video {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
}

/* Audio - Indigo */
.item-icon.file-audio {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
}

/* Archives - Yellow/Amber */
.item-icon.file-archive {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* Code - Cyan */
.item-icon.file-code {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
}

/* Text - Gray */
.item-icon.file-text {
  background: linear-gradient(135deg, #6b7280, #4b5563);
}

/* Config/JSON - Teal */
.item-icon.file-config {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
}

.item-icon svg {
  color: white;
}

.item-name {
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
  margin-bottom: 4px;
  word-break: break-word;
  max-width: 100%;
}

.item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state span {
  font-size: 0.9rem;
}

.empty-state.hidden {
  display: none;
}

/* Error State */
.error-state {
  padding: 16px 20px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid #ef4444;
  border-radius: var(--radius);
  color: #ef4444;
  font-weight: 500;
  text-align: center;
}

.error-state.hidden {
  display: none;
}

/* Preview Modal */
.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-modal.hidden {
  display: none;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
}

.preview-container {
  position: relative;
  width: 90vw;
  max-width: 1200px;
  height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

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

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.preview-title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.preview-actions {
  display: flex;
  gap: 8px;
}

.preview-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.preview-btn:hover {
  background: var(--border);
}

.preview-btn.close {
  padding: 8px;
  background: transparent;
  border: none;
}

.preview-btn.close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.preview-content {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

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

.preview-content video {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
}

.preview-content audio {
  width: 100%;
  max-width: 500px;
}

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

.preview-content pre {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: auto;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-unsupported {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  color: var(--text-muted);
}

.preview-unsupported svg {
  opacity: 0.5;
}

.preview-unsupported p {
  font-size: 1rem;
  color: var(--text);
  font-weight: 500;
}

.preview-unsupported span {
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 640px) {
  .header {
    padding: 12px 16px;
  }

  .main {
    padding: 0 16px 32px;
  }

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

  .item-card {
    padding: 20px 12px;
  }

  .item-icon {
    width: 48px;
    height: 48px;
  }
}
