:root,
[data-theme="dark"] {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-raised: #111111;
  --border: #222222;
  --border-hover: #333333;
  --text: #ededed;
  --text-muted: #a0a0a0;
  --text-faint: #666666;
  --primary: #ffffff;
  --primary-hover: #cccccc;
  --danger: #ff4444;
  --danger-hover: #ff6666;
  --success: #00cc88;
  --warning: #ffaa00;
  --radius: 8px;
  --font: 'Mona Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] {
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-raised: #f5f5f5;
  --border: #eaeaea;
  --border-hover: #999999;
  --text: #171717;
  --text-muted: #555555;
  --text-faint: #777777;
  --primary: #000000;
  --primary-hover: #333333;
  --danger: #ee0000;
  --danger-hover: #cc0000;
  --success: #00aa66;
  --warning: #f5a623;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

/* ── Utility ── */
.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;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.header-logo svg { flex-shrink: 0; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.header-user-btn:hover {
  background: var(--surface-raised);
  border-color: var(--border);
}

.header-username { color: var(--text); font-weight: 500; }

.header-chevron {
  color: var(--text-faint);
  flex-shrink: 0;
}

.header-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

/* ── User Menu ── */
.user-menu {
  min-width: 220px;
}

.user-menu-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.user-menu-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.user-menu-login {
  font-size: 12px;
  color: var(--text-muted);
}

.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.user-menu-section-label {
  padding: 6px 12px 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-menu-cdn-item {
  font-size: 12px;
  padding: 6px 12px;
}

.user-menu-danger {
  color: var(--danger);
}

.user-menu-danger:hover {
  background: rgba(255, 68, 68, 0.08);
}

.user-menu-compress {
  padding: 4px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-menu-compress-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.user-menu-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.user-menu-inline-label {
  color: var(--text-muted);
  min-width: 48px;
}

.user-menu-select {
  flex: 1;
  padding: 2px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
}

.user-menu-range {
  flex: 1;
  accent-color: var(--primary);
  height: 4px;
}

.user-menu-range-val {
  min-width: 32px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}

.btn:hover { background: var(--surface-raised); border-color: var(--border-hover); text-decoration: none; text-decoration-thickness: 1px; }

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

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

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

.btn-sm { padding: 4px 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }

.btn-icon {
  padding: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
}

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

/* ── Login Screen ── */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 61px);
  text-align: center;
  padding: 24px;
}

.login-screen h1 {
  font-size: 40px;
  font-weight: 700;
  margin-bottom: 12px;
}

.login-screen p {
  color: var(--text-muted);
  font-size: 18px;
  margin-bottom: 32px;
  max-width: 480px;
}

.btn-github {
  padding: 12px 24px;
  font-size: 16px;
  background: var(--primary);
  color: var(--bg);
  border: none;
  font-weight: 600;
}

.btn-github:hover { background: var(--primary-hover); }

.btn-github svg { width: 20px; height: 20px; }

/* ── Setup Wizard ── */
.setup-screen {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.setup-screen h2 {
  margin-bottom: 8px;
}

.setup-screen p {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 14px;
}

.setup-detecting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  padding: 40px;
}

.setup-repo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.setup-repo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
  font-size: 14px;
}

.setup-repo-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}

.setup-repo-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.setup-repo-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.setup-repo-desc {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-repo-meta {
  font-size: 11px;
  color: var(--text-faint);
}

.setup-repo-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.setup-repo-item:hover { border-color: var(--text-muted); }
.setup-repo-item.selected { border-color: var(--text); background: var(--surface-raised); }

.setup-search-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.setup-search {
  flex: 1;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}

.setup-search::placeholder { color: var(--text-muted); }
.setup-search:focus { outline: none; border-color: var(--primary); }

/* ── Dashboard ── */
.dashboard {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.toolbar-left { display: flex; align-items: center; min-width: 0; }

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.toolbar-repo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.toolbar-repo:hover { border-color: var(--border-hover); }
.toolbar-repo-name { white-space: nowrap; }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.storage-bar {
  position: relative;
  width: 80px;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.storage-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.storage-ok .storage-bar-fill { background: var(--success); }
.storage-warn .storage-bar-fill { background: var(--warning); }
.storage-danger .storage-bar-fill { background: var(--danger); }

.storage-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  pointer-events: none;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

.breadcrumbs a:hover { text-decoration: underline; text-decoration-thickness: 1px; }

.breadcrumbs .sep { color: var(--text-muted); margin: 0 2px; }

/* ── Action Bar ── */
.action-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-bar {
  display: flex;
  gap: 8px;
}

.filter-search {
  flex: 1;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
}

.filter-search::placeholder { color: var(--text-muted); }
.filter-search:focus { outline: none; border-color: var(--primary); }

.filter-sort {
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.filter-sort:focus { outline: none; border-color: var(--primary); }

/* ── Drop Zone ── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 24px;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.dropzone.active {
  border-color: var(--text-muted);
  background: var(--surface-raised);
  color: var(--text);
}

.dropzone-text { font-size: 14px; }
.dropzone-hint { font-size: 12px; margin-top: 4px; }

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

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}

.file-card:hover { border-color: var(--border-hover); }
.file-card.selected { border-color: var(--text-muted); background: var(--surface-raised); }
.file-card.drag-over { border-color: var(--success); background: rgba(0, 204, 136, 0.06); }

.rubber-band {
  position: absolute;
  border: 1px solid var(--text-muted);
  background: rgba(136, 136, 136, 0.08);
  pointer-events: none;
  z-index: 1000;
}

.file-thumb,
video.file-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: repeating-conic-gradient(var(--surface-raised) 0% 25%, var(--bg) 0% 50%) 0 0 / 16px 16px;
  display: block;
}

.file-thumb-placeholder {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-muted);
}

.folder-icon { display: flex; align-items: center; justify-content: center; color: var(--text-muted); }

.folder-preview-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.folder-icon-front {
  position: relative;
  z-index: 1;
}

.folder-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  padding: 20%;
  gap: 4px;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
  z-index: 0;
}

.folder-grid ~ .folder-icon-front { opacity: 0.85; }
.folder-grid { opacity: 0; animation: fadeToHalf 0.3s ease forwards; }
@keyframes fadeToHalf { from { opacity: 0; } to { opacity: 0.4; } }

.folder-grid-cell {
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg);
}

.folder-grid-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 4px;
}

.folder-grid-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.folder-grid-icon svg { width: 14px; height: 14px; }

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

/* Hover preview */
.file-card:has(.file-thumb):hover .hover-preview {
  display: block;
}

.hover-preview {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  max-width: 320px;
  max-height: 320px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  background: var(--surface);
  pointer-events: none;
}

.hover-preview img {
  display: block;
  max-width: 320px;
  max-height: 320px;
  border-radius: var(--radius);
}

.file-info {
  padding: 8px 10px;
}

.file-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pin-icon { display: inline-flex; vertical-align: middle; color: var(--text-muted); }

.file-size {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.file-card { position: relative; }

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rename-input {
  width: 100%;
  padding: 2px 4px;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--primary);
  border-radius: 4px;
  color: var(--text);
  outline: none;
}

.file-actions {
  display: flex;
  gap: 2px;
  padding: 4px 6px;
  border-top: 1px solid var(--border);
}

/* ── Staging Area ── */
.staging-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.staging-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.staging-header h3 { font-size: 14px; font-weight: 600; }
.staging-size { font-size: 12px; color: var(--text-muted); }

.staging-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.staging-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 240px;
  min-width: 0;
  overflow: hidden;
}

.staging-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.staging-thumb-placeholder {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.staging-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.staging-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.staging-name:hover { text-decoration: underline; text-decoration-thickness: 1px; }

.staging-rename-input {
  font-size: 13px;
  padding: 1px 4px;
  background: var(--bg);
  border: 1px solid var(--primary);
  border-radius: 4px;
  color: var(--text);
  width: 100%;
  outline: none;
}

.staging-file-size { font-size: 11px; color: var(--text-muted); }
.staging-savings { color: var(--success); font-weight: 500; }

.staging-remove { flex-shrink: 0; }

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

.staging-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}

.staging-input::placeholder { color: var(--text-muted); }
.staging-input:focus { outline: none; border-color: var(--primary); }

.staging-actions { display: flex; gap: 8px; }
.staging-card-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* ── Compress Modal ── */
.compress-modal { max-width: 600px; width: 94%; }

.compress-preview { margin: 12px 0; }

.compress-zoom-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.compress-zoom-btn {
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.compress-zoom-btn:hover { border-color: var(--border-hover); }

.compress-zoom-level {
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.compress-compare-wrapper {
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.compress-dims {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.compress-compare {
  position: relative;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  transition: transform 0.15s ease;
  transform-origin: center center;
}

.compress-img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: repeating-conic-gradient(var(--surface-raised) 0% 25%, var(--bg) 0% 50%) 0 0 / 12px 12px;
}

.compress-img-original {
  position: relative;
}

.compress-img-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  overflow: hidden;
}

.compress-img-wrapper .compress-img {
  width: auto;
  min-width: var(--compare-width, 100%);
  max-height: 320px;
  object-fit: contain;
}

.compress-slider-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 3px;
  height: 100%;
  background: var(--primary);
  cursor: ew-resize;
  z-index: 2;
  transform: translateX(-50%);
}

.compress-slider-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg);
  box-shadow: var(--shadow-md);
}

.compress-label {
  position: absolute;
  bottom: 8px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  pointer-events: none;
}
.compress-label-left { left: 8px; }
.compress-label-right { right: 8px; }

.compress-sizes {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.compress-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.compress-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compress-control label {
  font-size: 13px;
  color: var(--text-muted);
}

.compress-control select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: var(--font);
}

.compress-control input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Context Menu ── */
.context-menu {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  z-index: 1003;
  min-width: 180px;
  box-shadow: var(--shadow-lg);
}

.context-item {
  display: block;
  width: 100%;
  padding: 7px 12px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}

.context-item:hover { background: var(--surface-raised); }
.context-item-danger { color: var(--danger); }
.context-item-danger:hover { background: rgba(255, 68, 68, 0.08); }

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

/* ── CDN Menu ── */
.cdn-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  z-index: 1002;
  min-width: 140px;
  box-shadow: var(--shadow-lg);
}

.cdn-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}

.cdn-menu-item:hover { background: var(--surface-raised); }

.repo-menu { min-width: 200px; }
.repo-menu-active { color: var(--primary); font-weight: 500; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 1000;
  animation: slideIn 0.2s ease-out;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

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

/* ── Upload Progress ── */
.upload-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  font-size: 14px;
  display: none;
  align-items: center;
  gap: 12px;
  z-index: 999;
}

.upload-bar.visible { display: flex; }

.upload-bar-progress {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.upload-bar-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.2s;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state p { margin-top: 8px; font-size: 14px; }

/* ── Loading ── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 90%;
}

.modal h3 { margin-bottom: 12px; }

.modal-warn {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-actions-stack {
  flex-direction: column;
}

.modal-actions-stack .btn { text-align: center; }

/* ── Stats ── */
.stats-grid { display: flex; flex-direction: column; gap: 12px; }
.stats-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.stats-card.small { flex: 1; text-align: center; }
.stats-row { display: flex; gap: 8px; }
.stats-value { font-size: 24px; font-weight: 700; }
.stats-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stats-sublabel { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stats-bar { height: 8px; background: var(--border); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.stats-bar-fill { height: 100%; border-radius: 4px; transition: width 0.4s; }
.stats-bar-fill.ok { background: var(--success); }
.stats-bar-fill.warn { background: var(--warning); }
.stats-bar-fill.danger { background: var(--danger); }
.stats-types { display: flex; flex-wrap: wrap; gap: 6px; }
.stats-type { font-size: 12px; padding: 3px 8px; background: var(--surface); border-radius: 4px; color: var(--text-muted); }
.stats-type strong { color: var(--text); }

/* ── Recent Uploads ── */
.recent-uploads {
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.recent-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.recent-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.recent-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }

.recent-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.recent-item:hover { border-color: var(--primary); }

.recent-thumb { width: 24px; height: 24px; object-fit: cover; border-radius: 3px; }
.recent-icon { display: flex; align-items: center; color: var(--text-muted); }
.recent-name { font-size: 12px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-time { font-size: 10px; color: var(--text-muted); }

/* ── URL Panel ── */
.url-panel { max-width: 600px; width: 95%; }

.url-panel-preview {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 16px;
}

.url-panel-text-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin: 8px 0 16px;
  max-height: 240px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-muted);
}

.url-panel-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.url-panel-item {}

.url-panel-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
}

.url-panel-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.url-panel-url {
  flex: 1;
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg);
  padding: 6px 8px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.url-panel-copy { flex-shrink: 0; }

.url-panel-alt {
  margin-top: 4px;
}

.url-panel-alt summary {
  font-size: 12px;
  color: var(--text-faint);
  cursor: pointer;
  padding: 6px 0;
}

.url-panel-alt summary:hover { color: var(--text-muted); }

.url-panel-alt .url-panel-item {
  margin-top: 8px;
}

/* ── S3 Panel ── */
.s3-panel { max-width: 520px; width: 95%; }

.s3-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.s3-field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.s3-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.s3-field-value {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.s3-field-secret {
  color: var(--text-faint);
}

.s3-details {
  margin-top: 16px;
}

.s3-details summary {
  font-size: 12px;
  color: var(--text-faint);
  cursor: pointer;
  padding: 6px 0;
}

.s3-details summary:hover { color: var(--text-muted); }

.s3-snippet {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Toast Undo ── */
.toast-undo {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 12px;
  padding: 0;
  font-family: var(--font);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── History ── */
.history-modal {
  max-width: 600px;
  width: 95%;
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.history-header .btn-icon { font-size: 20px; }

.history-content {
  overflow-y: auto;
  flex: 1;
}

.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-entry {
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.history-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.history-message {
  font-size: 14px;
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.history-file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.history-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  background: var(--surface);
  font-size: 13px;
}

.history-file.deleted { border-left: 3px solid var(--danger); }
.history-file.added { border-left: 3px solid var(--success); }
.history-file.modified { border-left: 3px solid var(--primary); }

.history-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg);
}

.history-file-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.history-filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-status {
  font-size: 11px;
  font-weight: 500;
}

.history-status-deleted { color: var(--danger); }
.history-status-added { color: var(--success); }
.history-status-modified { color: var(--primary); }

/* ── Walkthrough ── */
.walkthrough-highlight {
  position: relative;
  z-index: 100;
  box-shadow: 0 0 0 2px var(--text), 0 0 20px rgba(136, 136, 136, 0.2);
  border-radius: var(--radius);
}

.walkthrough-tooltip {
  position: absolute;
  z-index: 1010;
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 12px 16px;
  max-width: 280px;
  box-shadow: var(--shadow-lg);
}

.walkthrough-text { font-size: 13px; margin-bottom: 10px; }

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

.walkthrough-counter { font-size: 11px; color: var(--text-muted); flex: 1; }

/* ── Landing Page ── */
.landing {
  min-height: 100dvh;
}

/* CTA Button (shared with app) */
.btn-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
  font-family: var(--font);
}

.btn-cta:hover { background: var(--primary-hover); }
.btn-cta:active { transform: scale(0.98); }
.btn-cta svg { width: 18px; height: 18px; }

.btn-cta-sm { padding: 7px 14px; font-size: 13px; }
.btn-cta-sm svg { width: 16px; height: 16px; }

.btn-cta-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-cta-outline:hover {
  background: var(--surface-raised);
  border-color: var(--border-hover);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .header { padding: 12px 16px; }
  .dashboard { padding: 16px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
  .dropzone { padding: 24px 16px; }
  .modal { padding: 16px; max-width: calc(100vw - 32px); }
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .toolbar-right { flex-wrap: wrap; }
  .breadcrumbs { font-size: 13px; flex-wrap: wrap; }
  .login-screen h1 { font-size: 28px; }
  .login-screen p { font-size: 16px; }
  .context-menu { max-width: calc(100vw - 16px); }
  .url-panel { max-width: calc(100vw - 32px); }
  .url-panel-url { font-size: 11px; word-break: break-all; }
}
