/* ==========================================================================
   Clip Manager — black & graphite design system
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #09090b;
  --bg-raised: #0e0e11;
  --surface: #121215;
  --surface-2: #18181c;
  --surface-3: #202025;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .11);
  --line-3: rgba(255, 255, 255, .18);

  --text: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #6b6b74;

  --danger: #f2555a;
  --danger-soft: rgba(242, 85, 90, .12);
  --warn: #f5b041;
  --warn-soft: rgba(245, 176, 65, .12);
  --success: #3ecf8e;
  --success-soft: rgba(62, 207, 142, .12);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 12px 32px -12px rgba(0, 0, 0, .7);
  --shadow-lg: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 30px 80px -20px rgba(0, 0, 0, .85);

  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: "Geist", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* Soft light falling from the top of every page */
body::before {
  content: "";
  position: fixed; inset: 0 0 auto 0; height: 520px; z-index: -1; pointer-events: none;
  background: radial-gradient(60% 100% at 50% 0%, rgba(255, 255, 255, .055), transparent 70%);
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.icon { flex: none; display: block; }
::selection { background: rgba(255, 255, 255, .18); }
:focus-visible { outline: 2px solid rgba(255, 255, 255, .55); outline-offset: 2px; }

/* ---------- Buttons ---------- */

.btn {
  --h: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 14px;
  font-size: 13.5px; font-weight: 500; letter-spacing: -.01em; white-space: nowrap;
  text-decoration: none; cursor: pointer;
  border-radius: 10px; border: 1px solid transparent;
  transition: background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease),
              transform .18s var(--ease), box-shadow .18s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-lg { --h: 44px; padding: 0 20px; font-size: 14.5px; border-radius: 12px; }
.btn-block { width: 100%; }

.btn-primary {
  background: linear-gradient(180deg, #ffffff, #e7e7ea);
  color: #09090b;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -8px rgba(255, 255, 255, .25);
}
.btn-primary:hover:not(:disabled) { background: #fff; box-shadow: 0 1px 0 #fff inset, 0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px -8px rgba(255, 255, 255, .35); }

.btn-ghost {
  background: rgba(255, 255, 255, .03);
  border-color: var(--line-2);
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .06); border-color: var(--line-3); color: var(--text); }
.btn-danger-hover:hover:not(:disabled) { background: var(--danger-soft); border-color: rgba(242, 85, 90, .35); color: var(--danger); }

.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 1px 0 rgba(255, 255, 255, .2) inset, 0 8px 24px -10px rgba(242, 85, 90, .6); }
.btn-danger:hover { background: #ff6a6e; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  color: var(--text-3); text-decoration: none;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.icon-btn:hover { background: rgba(255, 255, 255, .06); color: var(--text); }

/* ---------- Brand ---------- */

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -.02em; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #d4d4d8);
  color: #09090b;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 4px 14px -4px rgba(255, 255, 255, .35);
}
.brand-mark .icon { transform: translateX(1px); }
.brand-mark.lg { width: 48px; height: 48px; border-radius: 14px; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(9, 9, 11, .72);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; height: 64px; padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions form { margin: 0; }
.topbar-sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 6px; }

/* ---------- Page ---------- */

.page { max-width: 1440px; margin: 0 auto; padding: 48px 32px 96px; }
.page-narrow { max-width: 820px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  margin-bottom: 32px;
}
.eyebrow {
  font: 500 11.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 12px;
}
.page-title { font-size: 34px; line-height: 1.1; font-weight: 600; letter-spacing: -.035em; }
.page-sub { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--text-3); font-size: 13.5px; }
.page-sub strong { color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); }

/* Search */
.search {
  position: relative; display: flex; align-items: center;
  width: 300px; height: 40px; padding: 0 10px 0 38px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 11px;
  transition: border-color .18s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease);
}
.search .icon { position: absolute; left: 12px; color: var(--text-3); }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none;
  color: var(--text); font: inherit; font-size: 13.5px;
}
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { display: none; }
.search:focus-within { border-color: var(--line-3); background: var(--surface-2); box-shadow: 0 0 0 4px rgba(255, 255, 255, .04); }
kbd {
  font: 500 11px/1 var(--mono); color: var(--text-3);
  padding: 4px 6px; border-radius: 5px;
  border: 1px solid var(--line-2); background: rgba(255, 255, 255, .03);
}
.search:focus-within kbd { opacity: 0; }

/* ---------- Clip grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 28px 20px;
}

.clip {
  position: relative;
  animation: rise .6s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.clip-media {
  position: relative; display: block; overflow: hidden;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius-lg);
  text-decoration: none; color: inherit;
  background: #0b0b0d;
  box-shadow: 0 0 0 1px var(--line), var(--shadow);
  transition: box-shadow .35s var(--ease), transform .35s var(--ease);
  isolation: isolate;
}

/* Designed placeholder poster (no video is loaded until the card is clicked) */
.poster {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 255, 255, .07), transparent 60%),
    radial-gradient(90% 60% at 50% 110%, rgba(255, 255, 255, .035), transparent 70%),
    linear-gradient(180deg, #151518 0%, #0c0c0e 100%);
}
.poster-grid {
  position: absolute; inset: -1px;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: center;
  mask-image: radial-gradient(60% 50% at 50% 48%, #000 0%, transparent 100%);
  -webkit-mask-image: radial-gradient(60% 50% at 50% 48%, #000 0%, transparent 100%);
  transition: transform .8s var(--ease), opacity .4s var(--ease);
  opacity: .8;
}
.poster-glow {
  position: absolute; left: 50%; top: 48%; width: 70%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 255, 255, .10), transparent 65%);
  filter: blur(8px);
  transition: opacity .4s var(--ease), transform .6s var(--ease);
  opacity: .7;
}
.poster-top {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; align-items: center; gap: 8px;
}
.poster-chip {
  font: 600 10px/1 var(--mono); letter-spacing: .08em; color: var(--text-2);
  padding: 5px 7px; border-radius: 6px;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line-2);
}
.poster-res { font: 500 10.5px/1 var(--mono); letter-spacing: .02em; color: var(--text-3); }
.poster-mark {
  position: relative;
  display: grid; place-items: center;
  width: 60px; height: 60px; border-radius: 18px;
  color: #09090b;
  background: linear-gradient(180deg, #ffffff, #d6d6da);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .8) inset,
    0 0 0 1px rgba(255, 255, 255, .08),
    0 10px 30px -6px rgba(255, 255, 255, .28),
    0 20px 40px -12px rgba(0, 0, 0, .8);
  transition: transform .45s var(--ease), box-shadow .45s var(--ease);
}
.poster-mark .icon { transform: translateX(2px); }
.poster-label {
  position: relative; margin-top: 16px;
  font-size: 12.5px; font-weight: 500; letter-spacing: -.005em; color: var(--text-2);
  opacity: 0; transform: translateY(-4px);
  transition: opacity .3s var(--ease), transform .35s var(--ease);
}
.poster-title {
  position: absolute; left: 14px; bottom: 12px; right: 64px;
  font: 500 12px/1.2 var(--mono); color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left;
}

.clip-duration {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
  font: 500 11.5px/1 var(--mono); letter-spacing: .02em; color: var(--text);
  padding: 5px 7px; border-radius: 6px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line-2);
}

/* Floating tools (top-right of the thumbnail) */
.clip-tools {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  display: flex; gap: 6px;
  opacity: 0; transform: translateY(-4px);
  transition: opacity .25s var(--ease), transform .3s var(--ease);
}
.clip-tools form { margin: 0; }
.tool {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px; cursor: pointer;
  color: #fff;
  background: rgba(16, 16, 20, .55);
  border: 1px solid rgba(255, 255, 255, .16);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.tool:hover { background: rgba(40, 40, 46, .75); border-color: rgba(255, 255, 255, .3); }
.tool:active { transform: scale(.94); }
.tool-danger:hover { background: var(--danger); border-color: var(--danger); }
.tool.copied { background: var(--success); border-color: var(--success); }

/* Hover state */
.clip:hover .clip-media { box-shadow: 0 0 0 1px var(--line-3), var(--shadow-lg); transform: translateY(-3px); }
.clip:hover .poster-mark { transform: scale(1.07); box-shadow: 0 1px 0 #fff inset, 0 0 0 1px rgba(255, 255, 255, .12), 0 14px 44px -6px rgba(255, 255, 255, .4), 0 20px 40px -12px rgba(0, 0, 0, .8); }
.clip:hover .poster-glow { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
.clip:hover .poster-grid { transform: scale(1.06); opacity: 1; }
.clip:hover .poster-label { opacity: 1; transform: none; }
.clip:hover .clip-tools, .clip:focus-within .clip-tools { opacity: 1; transform: none; }

/* Info row under the thumbnail */
.clip-info { display: flex; align-items: center; gap: 12px; padding: 14px 2px 0; }
.clip-text { flex: 1; min-width: 0; }
.clip-name {
  font-size: 14px; font-weight: 500; letter-spacing: -.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.clip-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.copy-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px; cursor: pointer;
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line-2); border-radius: 999px;
  transition: all .18s var(--ease);
}
.copy-chip:hover { color: var(--text); border-color: var(--line-3); background: rgba(255, 255, 255, .07); }
.copy-chip.copied { color: var(--success); border-color: rgba(62, 207, 142, .4); background: var(--success-soft); }

/* Touch devices: no hover, so always show tools */
@media (hover: none) {
  .clip-tools { opacity: 1; transform: none; }
}

.no-results { padding: 64px 0; text-align: center; color: var(--text-3); }
.no-results span { color: var(--text-2); }

/* Search clear button */
.search-clear {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px;
  color: var(--text-3); text-decoration: none;
}
.search-clear:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
.search-clear .icon { position: static; }
.no-results a { color: var(--text); text-underline-offset: 3px; text-decoration-color: var(--line-3); }

/* Results bar + pagination */
.results-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: -8px 0 20px; font-size: 13px; color: var(--text-3);
}
.results-bar strong { color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.results-page { font: 500 12px var(--mono); }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--line);
}
.pager-pages { display: flex; align-items: center; gap: 4px; }
.pager-btn, .pager-num {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; border-radius: 10px; text-decoration: none;
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
  transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.pager-btn { padding: 0 14px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, .03); }
.pager-btn:hover { color: var(--text); border-color: var(--line-3); background: rgba(255, 255, 255, .06); }
.pager-btn.disabled { opacity: .35; pointer-events: none; }
.pager-num { min-width: 36px; padding: 0 6px; font-variant-numeric: tabular-nums; }
.pager-num:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.pager-num.current {
  color: #09090b; font-weight: 600;
  background: linear-gradient(180deg, #ffffff, #e4e4e7);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 6px 18px -6px rgba(255, 255, 255, .3);
}
.pager-gap { width: 24px; text-align: center; color: var(--text-3); }

/* Empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 88px 24px; margin-top: 8px;
  border: 1px dashed var(--line-2); border-radius: var(--radius-xl);
  background: radial-gradient(50% 80% at 50% 0%, rgba(255, 255, 255, .035), transparent);
}
.empty-icon {
  display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 20px;
  border-radius: 18px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: var(--shadow);
}
.empty h2 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.empty p { margin: 8px 0 24px; color: var(--text-3); max-width: 340px; }

/* ---------- Modal ---------- */

.modal {
  width: min(420px, calc(100% - 32px));
  padding: 0; border: 0; border-radius: var(--radius-xl);
  background: var(--surface); color: var(--text);
  box-shadow: 0 0 0 1px var(--line-2), var(--shadow-lg);
}
.modal[open] { animation: pop .28s var(--ease); }
.modal::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.modal form { padding: 28px; }
.modal-icon {
  display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 18px;
  border-radius: 12px; color: var(--danger);
  background: var(--danger-soft); border: 1px solid rgba(242, 85, 90, .22);
}
.modal h2 { font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.modal p { margin-top: 8px; color: var(--text-2); line-height: 1.55; word-break: break-word; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed; left: 50%; bottom: 28px; z-index: 50;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transform: translateX(-50%); pointer-events: none;
}
.toast {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 11px 16px 11px 13px; border-radius: 12px;
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  background: rgba(28, 28, 33, .88); border: 1px solid var(--line-2);
  backdrop-filter: blur(16px) saturate(160%); -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(12px) scale(.98);
  transition: opacity .3s var(--ease), transform .35s var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast.ok .icon { color: var(--success); }
.toast.err .icon { color: var(--danger); }

/* ---------- Alerts & fields ---------- */

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius);
  font-size: 13.5px; color: #ffb4b6;
  background: var(--danger-soft); border: 1px solid rgba(242, 85, 90, .25);
}
.alert .icon { margin-top: 2px; color: var(--danger); }

/* ---------- Login ---------- */

.auth-page { display: grid; place-items: center; padding: 24px 16px; overflow: hidden; }
.auth-page::before { display: none; }
.auth-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 50% at 50% 30%, rgba(255, 255, 255, .07), transparent 70%),
    radial-gradient(80% 60% at 50% 120%, rgba(255, 255, 255, .03), transparent 70%);
}
.auth-glow::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(45% 45% at 50% 40%, #000, transparent);
  -webkit-mask-image: radial-gradient(45% 45% at 50% 40%, #000, transparent);
  opacity: .5;
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card {
  display: flex; flex-direction: column;
  padding: 40px 36px 32px;
  background: linear-gradient(180deg, rgba(24, 24, 28, .9), rgba(16, 16, 19, .9));
  border: 1px solid var(--line-2); border-radius: 24px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  animation: pop .5s var(--ease);
}
.auth-card .brand-mark { margin-bottom: 24px; }
.auth-card h1 { font-size: 24px; font-weight: 600; letter-spacing: -.03em; }
.auth-sub { margin: 6px 0 24px; color: var(--text-3); }
.auth-card .alert { margin-bottom: 18px; }

.field-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 8px; }
.field {
  position: relative; display: flex; align-items: center;
  height: 46px;
  background: var(--bg-raised); border: 1px solid var(--line-2); border-radius: 12px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.field:focus-within { border-color: var(--line-3); box-shadow: 0 0 0 4px rgba(255, 255, 255, .05); }
.field-icon { position: absolute; left: 14px; color: var(--text-3); }
.field input {
  flex: 1; min-width: 0; height: 100%; padding: 0 44px 0 40px;
  background: none; border: 0; outline: 0; color: var(--text);
  font: 500 14px var(--mono); letter-spacing: .04em;
}
.field input::placeholder { font-family: var(--font); letter-spacing: 0; color: var(--text-3); font-weight: 400; }
.field-toggle {
  position: absolute; right: 6px;
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: 8px; background: none; color: var(--text-3); cursor: pointer;
}
.field-toggle:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.field-meta { display: flex; justify-content: flex-end; margin: 8px 0 22px; }
.counter { font: 500 11.5px var(--mono); color: var(--text-3); transition: color .2s; }
.counter.complete { color: var(--success); }
.auth-foot {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 22px; font-size: 12px; color: var(--text-3);
}

/* ---------- Upload ---------- */

.dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 64px 24px 56px; cursor: pointer;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(60% 90% at 50% 0%, rgba(255, 255, 255, .04), transparent),
    var(--bg-raised);
  border: 1.5px dashed var(--line-3);
  transition: border-color .25s var(--ease), background .25s var(--ease), transform .25s var(--ease);
}
.dropzone:hover { border-color: rgba(255, 255, 255, .3); }
.dropzone.over {
  border-color: #fff; border-style: solid;
  background: radial-gradient(60% 90% at 50% 0%, rgba(255, 255, 255, .09), transparent), var(--surface);
  transform: scale(1.005);
}
.dropzone-icon {
  display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 20px;
  border-radius: 18px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  transition: transform .35s var(--ease);
}
.dropzone:hover .dropzone-icon, .dropzone.over .dropzone-icon { transform: translateY(-3px); }
.dropzone-title { font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.dropzone-sub { margin-top: 6px; color: var(--text-3); }
.dropzone-sub .link { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-3); text-underline-offset: 3px; }
.dropzone-formats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 22px; }
.chip {
  font: 500 10.5px/1 var(--mono); letter-spacing: .06em; color: var(--text-3);
  padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line-2);
}

/* Layout: centred drop zone when empty; sidebar + wide queue grid once files are added */
.upload-layout { max-width: 820px; margin: 0 auto; }
.upload-page:not(.has-queue) .page-head { max-width: 820px; margin-left: auto; margin-right: auto; }
.upload-side > .alert { margin-top: 16px; }

.has-queue .upload-layout {
  max-width: none;
  display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start;
}
.has-queue .upload-side { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 12px; }
.has-queue .upload-side > .alert { margin-top: 0; }

/* Compact drop zone in the sidebar */
.has-queue .dropzone {
  display: grid; grid-template-columns: 40px 1fr; column-gap: 14px; row-gap: 1px;
  align-items: center; text-align: left; padding: 16px 18px;
}
.has-queue .dropzone-icon { grid-row: 1 / span 2; width: 40px; height: 40px; margin: 0; border-radius: 11px; }
.has-queue .dropzone-icon .icon { width: 20px; height: 20px; }
.has-queue .dropzone-title { font-size: 14px; }
.has-queue .dropzone-sub { margin: 0; font-size: 12.5px; }
.has-queue .dropzone .dropzone-formats { display: none; }
.has-queue .dropzone:hover .dropzone-icon, .has-queue .dropzone.over .dropzone-icon { transform: none; }

/* Compact page header once files are queued, so the grid gets the room */
.has-queue.page { padding-top: 28px; padding-bottom: 28px; }
.has-queue .eyebrow { display: none; }
.has-queue .page-title { font-size: 22px; }
.has-queue .page-sub { margin-top: 6px; }
.has-queue .page-head { margin-bottom: 20px; }

/* Summary card */
.summary {
  padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.summary-top { display: flex; align-items: flex-end; justify-content: space-between; }
.summary-label { font-size: 12.5px; color: var(--text-3); }
.summary-big { margin-top: 4px; font-size: 28px; font-weight: 600; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.summary-of { color: var(--text-3); font-weight: 500; font-size: 20px; }
.summary-pct { font: 500 13px var(--mono); color: var(--text-2); }
.summary-bar { height: 6px; margin-top: 14px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.summary-fill { height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, #d4d4d8, #fff); transition: width .3s var(--ease); }
.summary-fill.complete { background: var(--success); }
.summary-bytes { margin-top: 8px; font: 500 11.5px var(--mono); color: var(--text-3); min-height: 1em; }

.summary-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 14px 0 0;
  background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.summary-stats > div { padding: 8px 12px; background: var(--bg-raised); }
.summary-stats dt { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-3); }
.summary-stats dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sdot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.sdot.uploading { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .12); }
.sdot.done { background: var(--success); }
.sdot.failed { background: var(--danger); }

.summary-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.btn-danger-soft { background: var(--danger-soft); border-color: rgba(242, 85, 90, .3); color: #ff9a9d; }
.btn-danger-soft:hover { background: rgba(242, 85, 90, .2); color: #fff; }

/* Queue panel */
.queue-panel {
  min-width: 0; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.queue-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.queue-title { display: flex; align-items: baseline; gap: 10px; }
.queue-title h2 { font-size: 15px; font-weight: 600; letter-spacing: -.015em; }
.queue-count { font: 500 12px var(--mono); color: var(--text-3); }
.seg-sm span { height: 26px; padding: 0 11px; font-size: 12.5px; gap: 6px; }
.seg-sm b { font: 600 10.5px/1 var(--mono); color: var(--danger); }

/* Dense tile grid — one line per file, background fills with progress */
.qgrid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 5px;
}
.qt {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 5px 0 8px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 9px;
  font-size: 12.5px;
  animation: rise .3s var(--ease) both;
}
.qt-fill {
  position: absolute; inset: 0 auto 0 0; width: 0; z-index: 0;
  background: rgba(255, 255, 255, .07);
  transition: width .25s var(--ease);
}
.qt > :not(.qt-fill) { position: relative; z-index: 1; }
.qt-icon { flex: none; display: grid; place-items: center; color: var(--text-3); }
.qt-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.qt-status { flex: none; font: 500 11px var(--mono); color: var(--text-3); font-variant-numeric: tabular-nums; padding-right: 3px; }
.qt-btn {
  flex: none; display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  height: 22px; padding: 0 5px; border-radius: 6px; border: 0;
  background: none; color: var(--text-3); font-size: 11.5px; font-weight: 500;
}
.qt-btn.remove { width: 22px; justify-content: center; padding: 0; opacity: 0; }
.qt:hover .qt-btn.remove { opacity: 1; }
.qt-btn.remove:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.qt-btn.retry { padding: 0 8px; color: #fff; background: var(--danger); }
.qt-btn.retry:hover { background: #ff6a6e; }

.qt.uploading { border-color: var(--line-3); }
.qt.uploading .qt-icon, .qt.uploading .qt-name, .qt.uploading .qt-status { color: var(--text); }
.qt.done { border-color: rgba(62, 207, 142, .22); }
.qt.done .qt-fill { background: var(--success-soft); }
.qt.done .qt-icon { color: var(--success); }
.qt.done .qt-name { color: var(--text); }
.qt.failed, .qt.invalid { border-color: rgba(242, 85, 90, .35); background: rgba(242, 85, 90, .06); }
.qt.failed .qt-icon, .qt.invalid .qt-icon, .qt.invalid .qt-status { color: var(--danger); }
.qt.failed .qt-status { display: none; }
.qt.invalid .qt-status { font-family: var(--font); font-size: 11.5px; }
/* Duplicates */
.qt.checking .qt-icon, .qt.checking .qt-status { color: var(--text-2); }
.qt.checking .qt-icon { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.qt.duplicate { border-color: rgba(245, 176, 65, .38); background: rgba(245, 176, 65, .06); }
.qt.duplicate .qt-icon, .qt.duplicate .qt-status { color: var(--warn); }
.qt.duplicate .qt-name { color: var(--text-2); text-decoration: line-through; text-decoration-color: rgba(245, 176, 65, .5); }
.qt.duplicate .qt-status { display: none; }
.qt-btn.remove-dup { padding: 0 8px 0 6px; color: #1a1204; background: var(--warn); }
.qt-btn.remove-dup:hover { background: #ffc766; }
.seg-sm b.warn { color: var(--warn); }

.dup-alert {
  padding: 14px; border-radius: var(--radius);
  background: var(--warn-soft); border: 1px solid rgba(245, 176, 65, .3);
  animation: rise .3s var(--ease) both;
}
.dup-alert-text { display: flex; gap: 10px; font-size: 13px; line-height: 1.5; color: #ffd89a; }
.dup-alert-text .icon { flex: none; margin-top: 2px; color: var(--warn); }
.dup-alert-text strong { color: #fff; font-weight: 600; }
.dup-alert .btn { margin-top: 12px; }
.btn-warn { background: rgba(245, 176, 65, .14); border-color: rgba(245, 176, 65, .4); color: #ffd89a; }
.btn-warn:hover { background: var(--warn); border-color: var(--warn); color: #1a1204; }
.btn-warn-solid { background: var(--warn); color: #1a1204; box-shadow: 0 1px 0 rgba(255, 255, 255, .3) inset, 0 8px 24px -10px rgba(245, 176, 65, .6); }
.btn-warn-solid:hover { background: #ffc766; }
.modal-icon.warn { color: var(--warn); background: var(--warn-soft); border-color: rgba(245, 176, 65, .25); }
.dup-list {
  list-style: none; margin: 16px 0 0; padding: 0;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.dup-list li { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; background: var(--bg-raised); }
.dup-list li + li { border-top: 1px solid var(--line); }
.dup-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dup-of { font: 11.5px var(--mono); color: var(--warn); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dup-more { color: var(--text-3); font-size: 12.5px; }

.qgrid-empty { padding: 32px 0; text-align: center; color: var(--text-3); font-size: 13px; }


/* ---------- Links page ---------- */

.links-page .page-sub { display: block; max-width: 640px; }
.links-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 11px;
}
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: inline-flex; align-items: center; height: 30px; padding: 0 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--text-3);
  transition: background .18s var(--ease), color .18s var(--ease);
}
.seg label:hover span { color: var(--text-2); }
.seg input:checked + span { color: var(--text); background: var(--surface-3); box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, var(--shadow-sm); }
.seg input:focus-visible + span { outline: 2px solid rgba(255, 255, 255, .55); }

.range { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); }
.range input {
  width: 64px; height: 36px; padding: 0 10px; text-align: center;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
  color: var(--text); font: 500 13px var(--mono); outline: 0;
  -moz-appearance: textfield;
}
.range input::-webkit-inner-spin-button, .range input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.range input:focus { border-color: var(--line-3); box-shadow: 0 0 0 4px rgba(255, 255, 255, .04); }

.fmt-hint { margin: 14px 0 20px; font-size: 13px; color: var(--text-3); }
.fmt-hint strong, .links-tip strong { font: 500 12.5px var(--mono); color: var(--text-2); }

.links-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden;
}
.links-head {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px 12px 16px;
  background: rgba(18, 18, 21, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.links-selected { flex: 1; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.links-actions { display: flex; gap: 8px; }

.links-list { list-style: none; margin: 0; padding: 0; max-height: 62vh; overflow-y: auto; }
.link-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px 10px 16px; cursor: pointer; user-select: none;
  transition: background .12s;
}
.link-row + .link-row { border-top: 1px solid var(--line); }
.link-row:hover { background: rgba(255, 255, 255, .025); }
.link-row.selected { background: rgba(255, 255, 255, .05); }
.link-num { flex: none; width: 28px; text-align: right; font: 500 12px var(--mono); color: var(--text-3); }
.link-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.link-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-url { font: 12px var(--mono); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: text; }
.link-copy {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; cursor: pointer;
  border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text-3);
  transition: all .15s var(--ease);
}
.link-row:hover .link-copy { border-color: var(--line-2); }
.link-copy:hover { color: var(--text); background: rgba(255, 255, 255, .06); }

/* Custom checkbox */
.check { position: relative; display: inline-grid; flex: none; cursor: pointer; }
.check input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.check span {
  width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--line-3); background: var(--bg-raised);
  transition: background .15s, border-color .15s;
}
.check input:checked + span, .check input:indeterminate + span { background: #fafafa; border-color: #fafafa; }
.check input:checked + span {
  background: #fafafa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2309090b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.check input:indeterminate + span {
  background: #fafafa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%2309090b' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.check input:focus-visible + span { outline: 2px solid rgba(255, 255, 255, .55); outline-offset: 2px; }

.links-tip { margin-top: 16px; font-size: 12.5px; color: var(--text-3); line-height: 1.7; }

/* ---------- Missing page ---------- */

.miss-controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.miss-field { display: flex; flex-direction: column; gap: 6px; }
.miss-field > span { font-size: 12px; font-weight: 500; color: var(--text-3); }
.miss-field input, .miss-field select {
  height: 36px; padding: 0 12px; min-width: 120px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
  color: var(--text); font: 500 13.5px var(--mono); outline: 0;
}
.miss-field select { font-family: var(--font); min-width: 180px; cursor: pointer; }
.miss-field input:focus, .miss-field select:focus { border-color: var(--line-3); box-shadow: 0 0 0 4px rgba(255, 255, 255, .04); }

.miss-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.miss-stat {
  display: flex; flex-direction: column; gap: 4px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.miss-stat-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-3); }
.miss-stat-value { font-size: 32px; font-weight: 600; letter-spacing: -.035em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.miss-stat-sub { font: 500 12px var(--mono); color: var(--text-3); }
.miss-stat.is-bad { border-color: rgba(242, 85, 90, .3); background: linear-gradient(180deg, rgba(242, 85, 90, .07), var(--surface) 70%); }
.miss-stat.is-bad .miss-stat-value { color: #ff8a8e; }
.miss-stat.is-good .miss-stat-value { color: var(--success); }

.miss-card {
  margin-bottom: 16px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.miss-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.miss-card-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -.015em; }
.miss-card-actions { display: flex; gap: 8px; }

.miss-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.miss-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px; border-radius: 8px;
  font: 500 12.5px var(--mono); color: #ffb4b6;
  background: var(--danger-soft); border: 1px solid rgba(242, 85, 90, .28);
}
.miss-dash { color: rgba(255, 180, 182, .5); }
.miss-count {
  font-size: 10.5px; padding: 2px 6px; border-radius: 5px; margin-left: 2px;
  background: rgba(242, 85, 90, .22); color: #fff;
}

.miss-allgood {
  display: flex; align-items: center; gap: 16px; margin-bottom: 16px; padding: 18px 20px;
  background: linear-gradient(180deg, var(--success-soft), var(--surface) 80%);
  border: 1px solid rgba(62, 207, 142, .28); border-radius: var(--radius-lg);
}
.miss-allgood-icon {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px;
  color: var(--success); background: var(--success-soft); border: 1px solid rgba(62, 207, 142, .3);
}
.miss-allgood h2 { font-size: 16px; font-weight: 600; }
.miss-allgood p { margin-top: 2px; color: var(--text-3); font-size: 13px; }

.miss-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-3); }
.miss-legend span { display: inline-flex; align-items: center; gap: 6px; }
.miss-legend i { width: 10px; height: 10px; border-radius: 3px; }
.lg-have { background: var(--surface-3); border: 1px solid var(--line-2); }
.lg-miss { background: var(--danger); }
.lg-extra { background: var(--warn); }

.miss-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
.cell {
  display: grid; place-items: center; height: 26px; border-radius: 6px;
  font: 500 10.5px var(--mono); font-variant-numeric: tabular-nums; text-decoration: none;
}
.cell.have { color: var(--text-3); background: var(--bg-raised); border: 1px solid var(--line); transition: background .15s, color .15s; }
.cell.have:hover { color: var(--text); background: var(--surface-3); border-color: var(--line-3); }
.cell.extra { color: #1a1204; background: var(--warn); border-color: var(--warn); }
.cell.miss { color: #fff; font-weight: 600; background: var(--danger); box-shadow: 0 0 0 1px rgba(242, 85, 90, .5), 0 4px 14px -4px rgba(242, 85, 90, .6); }

.miss-notes { display: flex; flex-direction: column; gap: 8px; }
.miss-notes p { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--text-3); }
.miss-notes .icon { margin-top: 2px; color: var(--warn); }
.miss-note-item { font: 12px var(--mono); color: var(--text-2); padding: 1px 6px; border-radius: 5px; background: var(--surface-2); }

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .topbar-inner { padding: 0 16px; height: 58px; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { width: 36px; padding: 0; }
  .topbar-sep { margin: 0 2px; }
  .page { padding: 28px 16px 72px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 20px; margin-bottom: 24px; }
  .page-title { font-size: 28px; }
  .search { width: 100%; }
  .search kbd { display: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
  .clip-media { border-radius: 12px; }
  .copy-chip span { display: none; }
  .copy-chip { width: 30px; padding: 0; justify-content: center; }
  .clip-info { gap: 8px; padding-top: 10px; }
  .clip-name { font-size: 13px; }
  .clip-tools { top: 8px; right: 8px; }
  .poster-mark { width: 48px; height: 48px; border-radius: 14px; }
  .poster-res { display: none; }
  .auth-card { padding: 32px 22px 26px; }
  .pager { margin-top: 40px; gap: 8px; }
  .pager-btn span { display: none; }
  .pager-btn { width: 36px; padding: 0; }
  .results-page { display: none; }
  .links-actions .btn span { display: none; }
  .links-actions .btn { width: 36px; padding: 0; }
  .range { width: 100%; }
  .link-num { display: none; }
  .miss-stats { grid-template-columns: 1fr; }
  .miss-stat { flex-direction: row; align-items: baseline; flex-wrap: wrap; column-gap: 12px; padding: 14px 16px; }
  .miss-stat-value { font-size: 24px; }
  .miss-card { padding: 16px; }
  .miss-card-actions .btn span { display: none; }
  .miss-card-actions .btn { width: 36px; padding: 0; }
  .miss-map { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); }
  .dropzone { padding: 44px 18px 40px; }
  .has-queue .upload-layout { grid-template-columns: 1fr; }
  .has-queue .upload-side { position: static; }
  .qgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .qt-btn.remove { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
