/* ---------------------------------------------------------------------- */
/* Tokens                                                                  */
/* ---------------------------------------------------------------------- */
:root {
  --bg: #f4f5fb;
  --bg-2: #eceefb;
  --surface: #ffffffcc;
  --surface-solid: #ffffff;
  --surface-2: #f7f8fdcc;
  --border: #e2e4f3;
  --text: #191b2e;
  --text-dim: #6b6e8c;
  --text-faint: #9497b3;
  --accent: #6d5efc;
  --accent-2: #a259ff;
  --accent-3: #35d0ba;
  --accent-grad: linear-gradient(135deg, #6d5efc 0%, #a259ff 55%, #ff6fd8 100%);
  --danger: #ef4565;
  --success: #24c98d;
  --shadow-sm: 0 1px 2px rgba(24, 20, 60, 0.06);
  --shadow-md: 0 8px 24px rgba(24, 20, 60, 0.08);
  --shadow-lg: 0 20px 60px rgba(24, 20, 60, 0.16);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e0e18;
  --bg-2: #14152a;
  --surface: #1a1b30cc;
  --surface-solid: #1a1b30;
  --surface-2: #20213acc;
  --border: #2d2f4d;
  --text: #f1f1fb;
  --text-dim: #a6a8c9;
  --text-faint: #6c6e93;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e18;
    --bg-2: #14152a;
    --surface: #1a1b30cc;
    --surface-solid: #1a1b30;
    --surface-2: #20213acc;
    --border: #2d2f4d;
    --text: #f1f1fb;
    --text-dim: #a6a8c9;
    --text-faint: #6c6e93;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------------- */
/* Reset & base                                                            */
/* ---------------------------------------------------------------------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}
h1, h2, p { margin: 0; }
button { font: inherit; }
kbd {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.1em 0.45em;
}

/* Animated background orbs */
.bg-orbs { position: fixed; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.35; }
.orb-1 { width: 420px; height: 420px; background: #6d5efc; top: -120px; left: -100px; animation: float1 22s ease-in-out infinite; }
.orb-2 { width: 380px; height: 380px; background: #ff6fd8; bottom: -140px; right: -80px; animation: float2 26s ease-in-out infinite; }
.orb-3 { width: 300px; height: 300px; background: #35d0ba; top: 40%; right: 15%; animation: float3 20s ease-in-out infinite; }
:root[data-theme="dark"] .orb, @media (prefers-color-scheme: dark) { }
:root[data-theme="dark"] .orb { opacity: 0.22; }

@keyframes float1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(60px, 40px); } }
@keyframes float2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-50px, -30px); } }
@keyframes float3 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-30px, 50px) scale(1.1); } }

/* ---------------------------------------------------------------------- */
/* Topbar                                                                  */
/* ---------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(16px, 5vw, 48px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em; }
.brand-mark { font-size: 1.4rem; filter: drop-shadow(0 2px 6px rgba(109,94,252,0.4)); }
.brand-name { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.storage-summary { font-size: 0.85rem; color: var(--text-faint); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0) scale(0.95); }

#themeToggle .icon-moon { display: none; }
:root[data-theme="dark"] #themeToggle .icon-sun { display: none; }
:root[data-theme="dark"] #themeToggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #themeToggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) #themeToggle .icon-moon { display: block; }
}

/* ---------------------------------------------------------------------- */
/* Layout                                                                  */
/* ---------------------------------------------------------------------- */
.page { max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 5vw, 48px) 60px; }

.hero { text-align: center; padding: 24px 0 36px; }
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.hero p { margin-top: 12px; color: var(--text-dim); font-size: 1.05rem; }

/* ---------------------------------------------------------------------- */
/* Dropzone                                                                */
/* ---------------------------------------------------------------------- */
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(16px);
  padding: clamp(36px, 6vw, 64px) 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  outline: none;
}
.dropzone:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.dropzone:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(109,94,252,0.2); }
.dropzone.drag-active {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(109,94,252,0.12), rgba(255,111,216,0.10));
  transform: scale(1.01);
  box-shadow: var(--shadow-lg);
}
.dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dropzone-icon {
  width: 52px; height: 52px;
  color: var(--accent);
  margin-bottom: 8px;
  animation: bob 3s ease-in-out infinite;
}
.dropzone.drag-active .dropzone-icon { animation: bounce 0.5s ease infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.dropzone-title { font-size: 1.25rem; font-weight: 700; }
.dropzone-sub { color: var(--text-dim); font-size: 0.95rem; }
.link-like { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.dropzone-tiny { color: var(--text-faint); font-size: 0.8rem; margin-top: 10px; }

/* ---------------------------------------------------------------------- */
/* Upload queue                                                            */
/* ---------------------------------------------------------------------- */
.queue { margin-top: 28px; }
.queue-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.queue-header h2 { font-size: 1rem; font-weight: 700; color: var(--text-dim); }
.text-btn {
  background: none; border: none; color: var(--accent);
  font-weight: 600; font-size: 0.85rem; cursor: pointer;
  padding: 4px 8px; border-radius: 6px;
}
.text-btn:hover { background: var(--surface-2); }

.queue-list { display: flex; flex-direction: column; gap: 10px; }
.queue-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  animation: slideIn 0.25s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.queue-item-icon {
  width: 38px; height: 38px; flex: none; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); font-size: 1.2rem;
}
.queue-item-body { flex: 1; min-width: 0; }
.queue-item-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.queue-item-name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item-status { font-size: 0.78rem; color: var(--text-faint); flex: none; }
.queue-item-status.status-done { color: var(--success); }
.queue-item-status.status-error { color: var(--danger); }
.queue-item-sub { font-size: 0.75rem; color: var(--text-faint); margin-top: 4px; }

.progress-track { height: 6px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  background: var(--accent-grad);
  border-radius: 4px;
  transition: width 0.2s ease;
  position: relative;
}
.queue-item.state-done .progress-fill { background: var(--success); }
.queue-item.state-error .progress-fill { background: var(--danger); }
.queue-item-cancel { width: 30px; height: 30px; flex: none; }
.queue-item.state-done .queue-item-cancel,
.queue-item.state-error .queue-item-cancel { display: none; }

/* ---------------------------------------------------------------------- */
/* Library                                                                  */
/* ---------------------------------------------------------------------- */
.library { margin-top: 48px; }
.library-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.library-header h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; }
.library-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px;
  min-width: 200px;
}
.search-box svg { width: 15px; height: 15px; color: var(--text-faint); flex: none; }
.search-box input { border: none; background: none; outline: none; color: var(--text); font-size: 0.88rem; width: 100%; }
.search-box input::placeholder { color: var(--text-faint); }

#sortSelect {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-size: 0.85rem; cursor: pointer; outline: none;
}

.view-toggle { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.view-btn {
  border: none; background: none; color: var(--text-faint);
  width: 32px; height: 32px; border-radius: 999px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.view-btn svg { width: 15px; height: 15px; }
.view-btn.active { background: var(--accent-grad); color: #fff; }

/* Grid of file cards */
.file-grid[hidden] { display: none; }
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.file-grid.view-list { grid-template-columns: 1fr; gap: 10px; }

.file-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  animation: cardIn 0.3s ease;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.file-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent); }

.file-thumb {
  height: 110px; border-radius: 12px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem;
  overflow: hidden;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb svg { width: 34px; height: 34px; }

.file-info { min-width: 0; }
.file-name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 0.78rem; color: var(--text-faint); margin-top: 2px; }
.file-actions { display: flex; gap: 6px; }
.file-actions .icon-btn { width: 32px; height: 32px; }
.file-actions .icon-btn svg { width: 14px; height: 14px; }

/* List view layout overrides */
.file-grid.view-list .file-card {
  flex-direction: row; align-items: center; padding: 10px 14px;
}
.file-grid.view-list .file-thumb { height: 44px; width: 44px; flex: none; font-size: 1.3rem; border-radius: 9px; }
.file-grid.view-list .file-thumb svg { width: 20px; height: 20px; }
.file-grid.view-list .file-info { flex: 1; }
.file-grid.view-list .file-actions { flex: none; }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-faint);
}
.empty-state svg { width: 56px; height: 56px; margin-bottom: 14px; opacity: 0.6; }
.empty-state p { font-size: 1.05rem; font-weight: 700; color: var(--text-dim); }
.empty-state span { font-size: 0.85rem; }

/* ---------------------------------------------------------------------- */
/* Lightbox                                                                 */
/* ---------------------------------------------------------------------- */
.lightbox[hidden] { display: none; }
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 8, 16, 0.82);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.lightbox-content { max-width: min(90vw, 900px); max-height: 85vh; display: flex; }
.lightbox-content img, .lightbox-content video { max-width: 100%; max-height: 85vh; border-radius: 12px; box-shadow: var(--shadow-lg); }
.lightbox-content audio { width: min(90vw, 480px); }
.lightbox-content iframe { width: min(90vw, 800px); height: 85vh; border: none; border-radius: 12px; background: #fff; }
.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08); color: #fff;
  font-size: 1.6rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.18); }

/* ---------------------------------------------------------------------- */
/* Rename / customize-link modal                                           */
/* ---------------------------------------------------------------------- */
.modal-overlay[hidden] { display: none; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(8, 8, 16, 0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal-box {
  width: min(420px, 100%);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: cardIn 0.2s ease;
}
.modal-box h3 { font-size: 1.1rem; font-weight: 800; }
.modal-sub { color: var(--text-dim); font-size: 0.85rem; margin-top: 6px; }
.modal-input-row {
  display: flex; align-items: center;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}
.modal-prefix {
  padding: 10px 0 10px 12px;
  color: var(--text-faint);
  font-size: 0.85rem;
  white-space: nowrap;
}
.modal-input-row input {
  flex: 1; min-width: 0;
  border: none; background: none; outline: none;
  color: var(--text); font-size: 0.9rem;
  padding: 10px 12px 10px 2px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.modal-error {
  color: var(--danger); font-size: 0.8rem; margin-top: 10px;
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 20px;
}
.primary-btn {
  border: none; border-radius: 999px;
  background: var(--accent-grad); color: #fff;
  font-weight: 700; font-size: 0.85rem;
  padding: 9px 20px; cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.primary-btn:hover { box-shadow: 0 6px 18px rgba(109,94,252,0.35); transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }
.primary-btn:disabled { opacity: 0.6; cursor: default; transform: none; box-shadow: none; }

/* Short-link pill shown on each file card */
.file-link {
  display: inline-flex; align-items: center;
  margin-top: 6px;
  border: none; background: var(--surface-2);
  color: var(--accent);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-link:hover { background: var(--border); }
.file-link:empty { display: none; }

/* ---------------------------------------------------------------------- */
/* Toasts                                                                   */
/* ---------------------------------------------------------------------- */
.toast-stack {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 200;
  align-items: center;
}
.toast {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.toast-success { color: var(--success); }
.toast.toast-error { color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.toast.toast-out { animation: toastOut 0.2s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ---------------------------------------------------------------------- */
/* Footer                                                                   */
/* ---------------------------------------------------------------------- */
.site-footer {
  text-align: center;
  padding: 30px 20px 40px;
  color: var(--text-faint);
  font-size: 0.85rem;
}
.site-footer a { color: var(--accent); text-decoration: none; font-weight: 600; }
.site-footer a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------- */
/* Responsive                                                               */
/* ---------------------------------------------------------------------- */
@media (max-width: 560px) {
  .library-controls { width: 100%; }
  .search-box { flex: 1; min-width: 0; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .storage-summary { display: none; }
}
