/* ==========================================================
   Ichigo CDN — dark, quiet, minimal
   ========================================================== */

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg: #0d0e10;
  --surface: #131417;
  --surface-2: #181a1e;
  --surface-3: #1f2227;
  --line: #24272d;
  --line-strong: #30343b;
  --line-hover: #3d424a;

  /* Text */
  --text: #ecedef;
  --text-2: #a4a8b0;
  --text-3: #7d828b;

  /* One accent, used sparingly: activity, focus, drag */
  --accent: #ff8a3d;
  --accent-soft: rgba(255, 138, 61, 0.1);

  /* Semantic */
  --ok: #4cc38a;
  --ok-soft: rgba(76, 195, 138, 0.12);
  --err: #f26d6d;
  --err-soft: rgba(242, 109, 109, 0.12);

  /* Radii — larger for containers, smaller for controls */
  --r-xl: 18px;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 10px;
  --r-xs: 8px;

  --font: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body.no-scroll { overflow: hidden; }

main { flex: 1; outline: none; }

[hidden] { display: none !important; }

a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
input[type="file"] { display: none; }

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

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

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 300;
  padding: 8px 14px; border-radius: var(--r-xs);
  background: var(--text); color: var(--bg); font-size: 13px; font-weight: 500; text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.15s var(--ease);
}
.skip-link:focus { transform: none; }

.container {
  width: 100%;
  max-width: 1152px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Icons ---------- */
.ic {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.ic-fill { fill: currentColor; stroke: none; }

/* ==========================================================
   Buttons
   ========================================================== */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; line-height: 1; letter-spacing: -0.005em;
  text-decoration: none; white-space: nowrap; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s var(--ease), opacity 0.15s;
}
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-xs); gap: 6px; }

.btn-primary { background: var(--text); color: #0d0e10; --spin: #0d0e10; --spin-track: rgba(13, 14, 16, 0.2); }
.btn-primary:hover:not(:disabled) { background: #fff; }
.btn-primary:active:not(:disabled) { background: #d6d8dc; transform: scale(0.98); }

.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-hover); }
.btn-secondary:active:not(:disabled) { background: var(--surface-2); transform: scale(0.98); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.btn-ghost:active:not(:disabled) { background: rgba(255, 255, 255, 0.08); transform: scale(0.98); }

.btn-danger { background: var(--err); color: #1c0c0c; --spin: #1c0c0c; --spin-track: rgba(28, 12, 12, 0.2); }
.btn-danger:hover:not(:disabled) { background: #f68282; }
.btn-danger:active:not(:disabled) { background: #dd5c5c; transform: scale(0.98); }

/* Disabled */
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Loading */
.btn[aria-busy="true"] { color: transparent; pointer-events: none; }
.btn[aria-busy="true"] .ic { opacity: 0; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--spin-track, rgba(255, 255, 255, 0.18));
  border-top-color: var(--spin, var(--text));
  animation: spin 0.7s linear infinite;
}

/* Success (copy feedback) */
.i-done { display: none; }
.is-success .i-copy { display: none; }
.is-success .i-done { display: inline-block; }
.btn.is-success { color: var(--ok); border-color: rgba(76, 195, 138, 0.35); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--text-2);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s var(--ease);
}
.icon-btn-sm { width: 28px; height: 28px; border-radius: 7px; }
.icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.icon-btn:active:not(:disabled) { background: rgba(255, 255, 255, 0.1); transform: scale(0.94); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn.is-success { color: var(--ok); }
.icon-btn.icon-danger:hover:not(:disabled) { background: var(--err-soft); color: var(--err); }
.icon-btn .lbl { display: none; }

.text-link {
  font-size: 13.5px; color: var(--text-2); text-decoration: none;
  border-radius: 6px; transition: color 0.15s;
}
.text-link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* ==========================================================
   Navbar
   ========================================================== */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13, 14, 16, 0.82);
  -webkit-backdrop-filter: saturate(1.3) blur(14px);
  backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
  border-radius: 8px;
}
.brand-mark {
  position: relative; width: 24px; height: 24px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  display: grid; place-items: center;
}
.brand-mark::after {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  transition: transform 0.25s var(--ease);
}
.brand:hover .brand-mark::after { transform: scale(1.25); }
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.brand-tag { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: -4px; }

.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  padding: 7px 12px; border-radius: var(--r-xs);
  color: var(--text-2); font-size: 14px; font-weight: 500; text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.nav-links a:active { background: rgba(255, 255, 255, 0.08); }
.nav-links a[aria-current="page"] {
  color: var(--text); background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}

.nav-toggle {
  display: none;
  width: 40px; height: 40px; margin-right: -8px;
  align-items: center; justify-content: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--text);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.nav-toggle:hover { background: rgba(255, 255, 255, 0.06); }
.nav-toggle:active { background: rgba(255, 255, 255, 0.1); }
.nav-toggle-bars { position: relative; width: 18px; height: 12px; display: block; }
.nav-toggle-bars i {
  position: absolute; left: 0; right: 0; height: 1.5px; border-radius: 2px; background: currentColor;
  transition: transform 0.22s var(--ease), top 0.22s var(--ease);
}
.nav-toggle-bars i:nth-child(1) { top: 2px; }
.nav-toggle-bars i:nth-child(2) { top: 9px; }
.nav.open .nav-toggle-bars i:nth-child(1) { top: 5.5px; transform: rotate(45deg); }
.nav.open .nav-toggle-bars i:nth-child(2) { top: 5.5px; transform: rotate(-45deg); }

@media (max-width: 760px) {
  .nav-inner { height: 56px; }
  .nav-toggle { display: inline-flex; }
  .nav-links {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    padding: 8px 16px 14px;
    background: rgba(13, 14, 16, 0.97);
    border-bottom: 1px solid var(--line);
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.22s var(--ease), visibility 0s linear 0.22s;
  }
  .nav.open .nav-links {
    opacity: 1; visibility: visible; transform: none;
    transition-delay: 0s;
  }
  .nav-links a { padding: 14px 12px; font-size: 16px; border-radius: var(--r-sm); }
}

/* ==========================================================
   Pages
   ========================================================== */
.page { animation: page-in 0.24s ease; }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 40px; align-items: end;
  padding: 52px 0 32px;
}
.hero-title {
  margin: 0;
  font-size: clamp(34px, 4.6vw, 54px); font-weight: 600;
  line-height: 1.04; letter-spacing: -0.035em;
}
.hero-title span { display: block; }
.hero-side { display: flex; flex-direction: column; gap: 20px; padding-bottom: 4px; }
.hero-sub { margin: 0; max-width: 40ch; color: var(--text-2); font-size: 16px; line-height: 1.55; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 820px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 32px 0 24px; }
  .hero-title { font-size: clamp(30px, 9.4vw, 42px); }
  .hero-sub { font-size: 15px; }
}

/* ---------- Page header (Uploader / Admin) ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 44px 0 24px;
}
.page-title { margin: 0; font-size: clamp(28px, 4vw, 36px); font-weight: 600; line-height: 1.1; letter-spacing: -0.03em; }
.page-sub { margin: 8px 0 0; max-width: 54ch; color: var(--text-2); }

@media (max-width: 640px) {
  .page-head { padding: 28px 0 18px; flex-direction: column; align-items: stretch; }
  .page-head .btn { align-self: flex-start; }
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 44px 0 12px; }
.section-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025), 0 14px 34px -20px rgba(0, 0, 0, 0.75);
}

/* ==========================================================
   Uploader
   ========================================================== */
.uploader { padding: 10px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; min-height: 292px; padding: 40px 24px; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, min-height 0.25s var(--ease), padding 0.25s var(--ease);
}
.dropzone:hover { border-color: var(--line-hover); background: #1b1d22; }

.dz-title { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
.dz-title-drag { display: none; }

.dz-info { margin: 4px 0 0; color: var(--text-3); font-size: 13px; line-height: 1.6; transition: opacity 0.2s; }
.dz-info p { margin: 0; }

/* Dragging */
.dropzone.drag {
  border-style: solid; border-color: var(--accent);
  background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface-2);
}
.dropzone.drag .dz-title-idle { display: none; }
.dropzone.drag .dz-title-drag { display: inline; }
.dropzone.drag .dz-btn,
.dropzone.drag .dz-info { opacity: 0.35; pointer-events: none; }

/* Compact once files are queued */
.uploader.has-items .dropzone { min-height: 176px; padding: 28px 24px; gap: 14px; }
.uploader.has-items .dz-info { display: none; }

/* ---------- Queue ---------- */
.queue { padding: 16px 6px 6px; }
.queue-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 6px 12px; }
.queue-title { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.queue-count {
  min-width: 22px; padding: 1px 7px; border-radius: 99px;
  background: var(--surface-3); color: var(--text-2);
  font-size: 12px; font-weight: 500; text-align: center; font-variant-numeric: tabular-nums;
}
.queue-count:empty { display: none; }
.queue-actions { display: flex; gap: 4px; }
.queue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.qi {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start;
  padding: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color 0.2s, background 0.2s;
}
.qi.is-new { animation: item-in 0.24s var(--ease); }
.qi[data-state="failed"] { border-color: rgba(242, 109, 109, 0.32); }

.qi-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-sm);
  background: var(--surface-3); border: 1px solid var(--line-strong);
  color: var(--text-2); font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
}
.qi-main { min-width: 0; }
.qi-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qi-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qi-size { flex: none; font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.qi-progress { height: 4px; margin: 10px 0 9px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.qi-bar { height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width 0.25s ease, background 0.2s; }

.qi-meta { min-height: 24px; }
.qi-status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); min-width: 0; }
.qi-status-icon { display: inline-grid; place-items: center; width: 14px; height: 14px; flex: none; }
.qi-status-icon .ic { width: 14px; height: 14px; stroke-width: 2; }
.qi-pct { margin-left: auto; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.spin {
  display: block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--surface-3); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.i-ok, .i-err { display: none; }

.qi-reason { margin: 6px 0 0; font-size: 13px; color: var(--err); line-height: 1.45; }

.qi-url { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.qi-url-box {
  flex: 1; min-width: 0; height: 32px; display: flex; align-items: center; padding: 0 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-xs);
}
.qi-url-text { font: 400 12.5px var(--mono); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Queue item states */
.qi[data-state="uploading"] .qi-pct { display: inline; }
.qi[data-state="completed"] .qi-progress,
.qi[data-state="completed"] .qi-pct,
.qi[data-state="failed"] .qi-pct { display: none; }
.qi[data-state="completed"] .qi-meta { margin-top: 6px; }
.qi[data-state="completed"] .spin,
.qi[data-state="failed"] .spin { display: none; }
.qi[data-state="completed"] .i-ok { display: block; color: var(--ok); }
.qi[data-state="completed"] .qi-status { color: var(--ok); }
.qi[data-state="failed"] .i-err { display: block; color: var(--err); }
.qi[data-state="failed"] .qi-status { color: var(--err); }
.qi[data-state="failed"] .qi-bar { background: var(--err); }
.qi[data-state="failed"] .qi-meta { justify-content: space-between; }

@media (max-width: 560px) {
  .queue-actions .btn-sm { height: 36px; }
  .qi { grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; padding: 12px; }
  .qi-icon { width: 36px; height: 36px; }
  .qi-url { flex-wrap: wrap; }
  .qi-url-box { flex: 1 1 100%; height: 38px; }
  .qi-url .btn { flex: 1; height: 40px; }
  .qi-retry { height: 36px; }
  .qi-remove { width: 40px; height: 40px; margin: -6px -6px 0 0; }
  .dropzone { min-height: 264px; padding: 32px 18px; }
  .dz-btn { height: 46px; padding: 0 26px; }
}

/* ==========================================================
   Stats & features
   ========================================================== */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 28px; }
.stats-admin { margin-top: 0; }

.stat {
  padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.stat-label { margin: 0; font-size: 13px; color: var(--text-2); }
.stat-value {
  display: flex; align-items: center; margin: 10px 0 3px; min-height: 31px;
  font-size: 28px; font-weight: 600; line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.stat-hint { margin: 0; font-size: 12.5px; color: var(--text-3); }

.stat[data-state="loading"] .stat-text {
  display: inline-block; min-width: 64px; border-radius: 6px; color: transparent;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.stat[data-state="error"] .stat-text { color: var(--text-3); }

.status-dot { width: 8px; height: 8px; margin-right: 10px; border-radius: 50%; background: var(--text-3); flex: none; }
.stat[data-status="online"] .status-dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.stat[data-status="offline"] .status-dot { background: var(--err); box-shadow: 0 0 0 4px var(--err-soft); }
.stat[data-state="loading"] .status-dot { display: none; }

.features { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 56px; }
.feature { padding: 20px; border: 1px solid var(--line); border-radius: 14px; }
.feature-icon {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text);
}
.feature-icon .ic { width: 18px; height: 18px; stroke-width: 1.5; }
.feature h3 { margin: 16px 0 6px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.feature p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-2); }

@media (max-width: 960px) {
  .stats, .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .stats { gap: 10px; margin-top: 20px; }
  .stats-admin { margin-top: 0; }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 24px; min-height: 26px; margin-top: 8px; }
  .features { grid-template-columns: minmax(0, 1fr); margin-top: 40px; }
  .feature { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 14px; padding: 16px; }
  .feature h3 { margin: 0 0 4px; }
}

/* ==========================================================
   Recent uploads (Uploader page)
   ========================================================== */
.recent-card { padding: 6px; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px; border-radius: var(--r-sm);
  transition: background 0.15s;
}
.recent-item:hover { background: rgba(255, 255, 255, 0.03); }
.r-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.r-meta { display: flex; gap: 12px; font-size: 12.5px; color: var(--text-3); }
.recent-empty { margin: 0; padding: 36px 16px; text-align: center; color: var(--text-3); font-size: 14px; }

/* ==========================================================
   Thumbs (shared)
   ========================================================== */
.thumb {
  position: relative; flex: none; display: grid; place-items: center;
  width: 36px; height: 36px; overflow: hidden; border-radius: var(--r-xs);
  background: var(--surface-3); border: 1px solid var(--line-strong);
  color: var(--text-2); font-size: 10px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
  transition: border-color 0.15s;
}
.thumb img, .thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.32); color: #fff;
}
.thumb .play .ic { width: 14px; height: 14px; }
.thumb.is-clickable { cursor: zoom-in; }
.thumb.is-clickable:hover { border-color: var(--line-hover); }

/* ==========================================================
   Admin — toolbar, table
   ========================================================== */
.files-card { margin-top: 16px; overflow: hidden; }

.toolbar {
  display: grid; grid-template-columns: minmax(0, 1fr) 160px 172px; gap: 10px;
  padding: 14px; border-bottom: 1px solid var(--line);
}

.field {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  color: var(--text); font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.field::placeholder { color: var(--text-3); }
.field:hover { border-color: var(--line-hover); }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field:disabled { opacity: 0.5; cursor: not-allowed; }

select.field {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d828b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 15px;
}

.search { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 13px; color: var(--text-3); pointer-events: none; }
.search .field { padding-left: 38px; padding-right: 40px; }
.search .field::-webkit-search-cancel-button { display: none; }
.search-clear { position: absolute; right: 5px; }

.table-wrap { overflow: hidden; }
.files-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.col-type { width: 100px; }
.col-size { width: 92px; }
.col-date { width: 118px; }
.col-url { width: 208px; }
.col-actions { width: 148px; }

.files-table th {
  padding: 12px 16px; text-align: left;
  font-size: 12.5px; font-weight: 500; color: var(--text-3);
  border-bottom: 1px solid var(--line);
}
.files-table td {
  padding: 11px 16px; vertical-align: middle;
  font-size: 14px; color: var(--text-2);
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
.files-table tbody tr:last-child td { border-bottom: 0; }
.files-table tbody tr:hover td { background: rgba(255, 255, 255, 0.022); }
.files-table .c-size, .files-table .c-date { font-variant-numeric: tabular-nums; }

.cell-file { display: flex; align-items: center; gap: 12px; min-width: 0; }
.f-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 500; font-size: 14px; }

.url-chip {
  display: flex; align-items: center; gap: 4px; height: 32px; padding: 0 3px 0 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-xs);
  transition: border-color 0.15s;
}
.frow:hover .url-chip { border-color: var(--line-strong); }
.url-text { flex: 1; min-width: 0; font: 400 12px var(--mono); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row-actions { display: flex; justify-content: flex-end; gap: 2px; }

.frow[aria-busy="true"] { opacity: 0.55; pointer-events: none; }

/* Empty */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 68px 24px; }
.empty-icon {
  display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 14px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text-2);
}
.empty-icon .ic { width: 20px; height: 20px; stroke-width: 1.5; }
.empty h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.empty p { margin: 0 0 18px; max-width: 38ch; font-size: 14px; color: var(--text-2); }

.table-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--text-3);
}

/* Table → card list */
@media (max-width: 960px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar .search { grid-column: 1 / -1; }

  .files-table, .files-table tbody { display: block; }
  .files-table colgroup { display: none; }
  .files-table thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  }
  .frow {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
    padding: 16px; border-bottom: 1px solid var(--line);
  }
  .files-table tbody tr:last-child { border-bottom: 0; }
  .files-table td, .files-table tbody tr:hover td { display: block; padding: 0; border: 0; background: none; }
  .frow td.c-file { width: 100%; }
  .frow .c-type, .frow .c-size, .frow .c-date { margin-top: -2px; font-size: 13px; color: var(--text-3); }
  .frow .c-type { margin-left: 48px; color: var(--text-2); }
  .frow td.c-url, .frow td.c-actions { width: 100%; }
  .url-chip { height: 42px; padding-left: 12px; }
  .url-chip .icon-btn { width: 36px; height: 36px; }
  .row-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .row-actions .icon-btn {
    width: auto; height: 42px; gap: 7px; grid-auto-flow: column; justify-content: center;
    border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
    font-size: 13.5px; font-weight: 500;
  }
  .row-actions .icon-btn:hover:not(:disabled) { background: var(--surface-3); }
  .row-actions .icon-btn .lbl { display: inline; }
  .row-actions .icon-danger { color: var(--err); }
  .frow[aria-busy="true"] { opacity: 0.55; }
}

@media (max-width: 420px) {
  .toolbar { grid-template-columns: minmax(0, 1fr); }
  .thumb { width: 38px; height: 38px; }
}

/* ==========================================================
   Footer
   ========================================================== */
.footer { margin-top: 72px; padding: 24px 0 32px; border-top: 1px solid var(--line); }
.footer p { margin: 0; font-size: 13px; color: var(--text-3); }

/* ==========================================================
   Dialogs
   ========================================================== */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
  background: rgba(6, 7, 8, 0.72);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fade 0.18s ease;
}
.dialog {
  position: relative; width: min(420px, 100%);
  padding: 22px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-xl);
  box-shadow: 0 28px 64px -24px rgba(0, 0, 0, 0.85);
  animation: pop 0.22s var(--ease);
}
.dialog-title { margin: 0 0 8px; font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.dialog-text { margin: 0 0 22px; color: var(--text-2); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.dialog-media { width: min(900px, 100%); max-height: 92vh; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.media { display: grid; place-items: center; min-height: 0; overflow: hidden; border-radius: var(--r-md); background: #000; }
.media img, .media video { display: block; max-width: 100%; max-height: 72vh; }
.dialog-meta { display: flex; gap: 14px; padding: 2px 8px 4px; font-size: 13px; color: var(--text-3); }
.dialog-meta .pm-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.dialog-close {
  position: absolute; top: 18px; right: 18px; z-index: 1;
  background: rgba(13, 14, 16, 0.7); border-color: var(--line-strong); color: var(--text);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

@media (max-width: 560px) {
  .overlay { padding: 14px; align-items: end; }
  .dialog-confirm { border-radius: var(--r-xl); }
  .dialog-actions .btn { flex: 1; height: 44px; }
}

/* ==========================================================
   Toasts
   ========================================================== */
.toasts {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  width: min(380px, calc(100vw - 28px)); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: 0 16px 36px -16px rgba(0, 0, 0, 0.8);
  font-size: 13.5px; pointer-events: auto;
  animation: toast-in 0.26s var(--ease);
}
.toast .ic { width: 16px; height: 16px; stroke-width: 2; }
.toast.ok .ic { color: var(--ok); }
.toast.err .ic { color: var(--err); }
.toast.leaving { animation: toast-out 0.18s ease forwards; }

/* ==========================================================
   Keyframes
   ========================================================== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes page-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes item-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
@keyframes dz-float { 0%, 100% { transform: translateY(-2px); } 50% { transform: translateY(-7px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .spin, .btn[aria-busy="true"]::after, .stat[data-state="loading"] .stat-text {
    animation-duration: 1.2s !important;
    animation-iteration-count: infinite !important;
  }
}
