:root {
  --bg: #0f1117;
  --bg-elevated: #161b26;
  --bg-hover: #1e2533;
  --border: #2a3142;
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 80px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Disk usage panel */
.disk-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.disk-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.disk-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.disk-panel-title svg { color: var(--success); }

.disk-panel-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.disk-graph-track {
  height: 14px;
  background: rgba(34, 197, 94, 0.12);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.disk-graph-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 7px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0;
}

.disk-graph-system {
  background: linear-gradient(90deg, #15803d, #22c55e);
  z-index: 1;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.35);
}

.disk-graph-anon {
  background: linear-gradient(90deg, #4ade80, #86efac);
  z-index: 2;
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.15);
}

.disk-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-item strong {
  color: var(--text);
  font-weight: 600;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-anon { background: #4ade80; box-shadow: 0 0 6px rgba(74, 222, 128, 0.6); }
.legend-free { background: rgba(34, 197, 94, 0.25); border: 1px solid rgba(34, 197, 94, 0.4); }
.legend-session { background: #86efac; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.session-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
  font-family: ui-monospace, monospace;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background var(--transition), transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--bg-hover); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 6px 10px;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.btn-icon:hover { color: var(--text); background: var(--bg-hover); }

.upload-label { cursor: pointer; }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.breadcrumb button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: inherit;
}

.breadcrumb button:hover { color: var(--accent); background: var(--bg-hover); }

.breadcrumb button.active { color: var(--text); font-weight: 500; cursor: default; }

.breadcrumb .sep { color: var(--border); user-select: none; }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.view-toggle {
  display: flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.view-btn:hover { color: var(--text); }

.view-btn.active {
  background: var(--bg-hover);
  color: var(--accent);
}

.toolbar-info {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Main / Drop zone */
.main { flex: 1; }

.drop-zone {
  background: var(--bg-elevated);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  min-height: 400px;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}

/* File list */
.file-list {
  padding: 8px;
}

.file-list.view-list .file-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: default;
  transition: background var(--transition);
}

.file-list.view-list .file-item:hover { background: var(--bg-hover); }

.file-list.view-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 12px;
}

.file-list.view-grid .file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: default;
  transition: border-color var(--transition), transform 0.15s;
  text-align: center;
}

.file-list.view-grid .file-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.file-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.view-grid .file-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
}

.view-grid .file-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.file-name {
  font-size: 0.875rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.view-grid .file-name {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.file-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.view-list .file-meta { text-align: right; min-width: 80px; }

.file-actions {
  display: flex;
  gap: 4px;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.file-item:hover .file-actions { opacity: 1; }

.view-grid .file-actions {
  margin-top: 8px;
  opacity: 1;
}

.action-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), border-color var(--transition);
}

.action-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.file-item[data-type="directory"] { cursor: pointer; }

.file-item[data-type="directory"] .file-name { color: var(--accent); }

/* Empty state */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  pointer-events: none;
}

.empty-icon { color: var(--border); margin-bottom: 16px; }

.empty-state h2 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 320px;
}

/* Footer */
.footer {
  margin-top: 32px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Upload panel */
.upload-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
  overflow: hidden;
}

.upload-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.upload-panel-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
}

.upload-list {
  max-height: 280px;
  overflow-y: auto;
  padding: 8px;
}

.upload-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.upload-item:last-child { margin-bottom: 0; }

.upload-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.upload-item-name {
  font-size: 0.8rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.upload-item-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.upload-item-status.done { color: var(--success); }
.upload-item-status.error { color: var(--danger); }

/* Custom progress bar */
.progress-track {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #6366f1);
  width: 0%;
  transition: width 0.15s ease-out;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.25) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

.progress-fill.complete {
  background: linear-gradient(90deg, var(--success), #16a34a);
}

.progress-fill.complete::after { display: none; }

.progress-fill.error { background: var(--danger); }

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.modal-editor { max-width: 800px; height: 70vh; }
.modal-preview { max-width: 900px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#editorText {
  flex: 1;
  margin: 0;
  padding: 16px 20px;
  background: var(--bg);
  border: none;
  color: var(--text);
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  resize: none;
  outline: none;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.preview-body {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  max-height: 60vh;
  overflow: auto;
}

.preview-body img,
.preview-body video {
  max-width: 100%;
  max-height: 55vh;
  border-radius: var(--radius-sm);
}

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 320px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 640px) {
  .header { flex-direction: column; align-items: flex-start; }
  .file-list.view-list .file-item {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }
  .file-list.view-list .file-meta { display: none; }
  .upload-panel { bottom: 10px; right: 10px; left: 10px; width: auto; }
}
