/* ============================================================
   Asset Manager — design system
   ============================================================ */
:root {
  --bg: #0b0d10;
  --bg-soft: #11141a;
  --panel: #151922;
  --panel-2: #1b202b;
  --border: #262c39;
  --border-soft: #1e242f;
  --text: #e7eaf0;
  --muted: #8b93a5;
  --faint: #5d6579;
  --brand: #5b8cff;
  --brand-ink: #ffffff;
  --brand-soft: rgba(91, 140, 255, 0.14);
  --green: #35c98a;
  --amber: #f0b429;
  --red: #f4595b;
  --violet: #a678ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.42);
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

html[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-soft: #eceef2;
  --panel: #ffffff;
  --panel-2: #f4f6f9;
  --border: #dde1e8;
  --border-soft: #e8ebf0;
  --text: #161a21;
  --muted: #5f6879;
  --faint: #8b93a3;
  --brand-soft: rgba(91, 140, 255, 0.1);
  --shadow: 0 8px 24px rgba(20, 26, 40, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
::selection { background: var(--brand); color: #fff; }

/* ---------------------------------------------------- scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ---------------------------------------------------- top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 56px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--bg-soft) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -0.01em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), var(--violet));
  display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 800;
}
.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a {
  padding: 7px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2);
  border: 1px solid var(--border); display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--text);
}

/* ---------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .13s, border-color .13s, transform .06s;
}
.btn:hover { background: var(--panel-2); border-color: var(--faint); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: #4b7cf0; border-color: #4b7cf0; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: rgba(244, 89, 91, .12); border-color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel); color: var(--text); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn-block { width: 100%; height: 40px; }
.icon-btn {
  width: 34px; height: 34px; padding: 0; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); }

/* ---------------------------------------------------- forms */
.field { margin-bottom: 14px; }
.label { display: block; margin-bottom: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 11px;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: border-color .13s, box-shadow .13s;
}
.textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 72px; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.input::placeholder { color: var(--faint); }
.select { appearance: none; cursor: pointer; padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238b93a5' stroke-width='2'><path d='M2 4l4 4 4-4'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center; }
.hint { margin-top: 5px; font-size: 12px; color: var(--faint); }

/* ---------------------------------------------------- login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 480px at 12% -10%, rgba(91,140,255,.16), transparent 62%),
    radial-gradient(760px 420px at 92% 108%, rgba(166,120,255,.14), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 396px; padding: 30px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
}
.auth-logo { width: 46px; height: 46px; border-radius: 13px; margin-bottom: 18px;
  background: linear-gradient(135deg, var(--brand), var(--violet));
  display: grid; place-items: center; color: #fff; font-size: 22px; }
.auth-card h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: -0.02em; }
.auth-card .sub { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }
.alert { padding: 10px 12px; margin-bottom: 16px; border-radius: var(--radius-sm); font-size: 13px; }
.alert-error { background: rgba(244,89,91,.11); border: 1px solid rgba(244,89,91,.32); color: #ff9a9b; }
html[data-theme="light"] .alert-error { color: #b3282a; }

/* ---------------------------------------------------- layout */
.page { padding: 22px; max-width: 1680px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.page-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 18px; }

/* ---------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { padding: 13px 15px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.stat .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 600; }
.stat .v { font-size: 20px; font-weight: 680; letter-spacing: -0.02em; margin-top: 3px; }

/* ---------------------------------------------------- dropzone */
.dropzone {
  position: relative; padding: 46px 24px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: 14px; background: var(--panel);
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--brand); background: var(--panel-2); }
.dropzone.dragging { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .dz-icon { font-size: 34px; margin-bottom: 10px; }
.dropzone h3 { margin: 0 0 5px; font-size: 16px; }
.dropzone p { margin: 0; color: var(--muted); font-size: 13px; }
.dz-badges { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.dz-badge { padding: 3px 9px; font-size: 11.5px; border-radius: 20px; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--muted); }

/* ---------------------------------------------------- upload queue */
.queue { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.q-item { display: flex; align-items: center; gap: 12px; padding: 10px 13px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.q-thumb { width: 40px; height: 40px; border-radius: 7px; flex: none; object-fit: cover;
  background: var(--panel-2); display: grid; place-items: center; font-size: 17px; }
.q-body { flex: 1; min-width: 0; }
.q-name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.q-bar { height: 4px; margin-top: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.q-fill { height: 100%; width: 0; background: var(--brand); transition: width .18s ease; }
.q-item.done .q-fill { background: var(--green); }
.q-item.error .q-fill { background: var(--red); }
.q-url { font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------- toolbar */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 420px; }
.search-box .input { padding-left: 34px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.seg { display: flex; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 5px 11px; border-radius: 6px;
  cursor: pointer; font-weight: 550; font-size: 13px; }
.seg button.active { background: var(--panel-2); color: var(--text); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { padding: 5px 11px; border-radius: 20px; font-size: 12.5px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted); user-select: none; }
.chip:hover { border-color: var(--faint); color: var(--text); }
.chip.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.chip .n { opacity: .65; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------- bulk bar */
.bulkbar { display: none; align-items: center; gap: 8px; padding: 9px 13px; margin-bottom: 12px;
  background: var(--brand-soft); border: 1px solid var(--brand); border-radius: var(--radius-sm); }
.bulkbar.show { display: flex; }
.bulkbar .count { font-weight: 620; color: var(--brand); margin-right: 4px; }

/* ---------------------------------------------------- grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 12px; }
.tile { position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: border-color .13s, transform .13s, box-shadow .13s; }
.tile:hover { border-color: var(--faint); transform: translateY(-2px); box-shadow: var(--shadow); }
.tile.selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.tile-media { position: relative; aspect-ratio: 4 / 3; background: var(--panel-2);
  display: grid; place-items: center; overflow: hidden; }
.tile-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-media .ficon { font-size: 34px; opacity: .82; }
.tile-body { padding: 9px 11px 11px; }
.tile-name { font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta { font-size: 11.5px; color: var(--faint); display: flex; gap: 6px; margin-top: 2px; }
.tile-check { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; border-radius: 5px;
  border: 1.5px solid rgba(255,255,255,.6); background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
  display: grid; place-items: center; opacity: 0; transition: opacity .12s; z-index: 2; }
.tile:hover .tile-check, .tile.selected .tile-check { opacity: 1; }
.tile.selected .tile-check { background: var(--brand); border-color: var(--brand); }
.tile-check svg { opacity: 0; }
.tile.selected .tile-check svg { opacity: 1; }
.tile-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .12s; z-index: 2; }
.tile:hover .tile-actions { opacity: 1; }
.mini {
  width: 26px; height: 26px; border-radius: 6px; border: 0; cursor: pointer;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px); color: #fff;
  display: grid; place-items: center;
}
.mini:hover { background: var(--brand); }
.badge-kind { position: absolute; bottom: 7px; right: 7px; padding: 2px 7px; border-radius: 5px;
  font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  background: rgba(0,0,0,.6); color: #fff; backdrop-filter: blur(4px); }
.star-dot { position: absolute; bottom: 7px; left: 7px; font-size: 13px; }

/* ---------------------------------------------------- list view */
.table { width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; padding: 10px 12px; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--faint); background: var(--panel-2);
  border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; }
.table th:hover { color: var(--text); }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border-soft); font-size: 13px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--panel-2); }
.table tr.selected { background: var(--brand-soft); }
.row-thumb { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; background: var(--panel-2);
  display: grid; place-items: center; font-size: 15px; flex: none; }
.cell-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-scroll { overflow-x: auto; }

/* ---------------------------------------------------- drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 92vw; z-index: 60;
  background: var(--panel); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  transform: translateX(101%); transition: transform .2s ease; overflow-y: auto; }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--panel); z-index: 2; }
.drawer-head h3 { margin: 0; font-size: 15px; }
.drawer-body { padding: 16px; }
.preview-box { border-radius: var(--radius); overflow: hidden; background: var(--panel-2);
  display: grid; place-items: center; min-height: 170px; margin-bottom: 16px; }
.preview-box img, .preview-box video { max-width: 100%; max-height: 300px; display: block; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 12.5px; margin-bottom: 16px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; word-break: break-word; }
.copy-row { display: flex; gap: 6px; margin-bottom: 8px; }
.copy-row .input { font-family: var(--mono); font-size: 11.5px; height: 34px; }
.sep { height: 1px; background: var(--border); margin: 16px 0; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; opacity: 0;
  pointer-events: none; transition: opacity .18s; }
.overlay.show { opacity: 1; pointer-events: auto; }

/* ---------------------------------------------------- lightbox */
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(6,8,12,.94);
  display: none; align-items: center; justify-content: center; padding: 40px; }
.lightbox.show { display: flex; }
.lightbox img, .lightbox video, .lightbox iframe { max-width: 92vw; max-height: 86vh;
  border-radius: 10px; background: #000; border: 0; }
.lightbox iframe { width: 92vw; height: 86vh; }
.lb-close { position: absolute; top: 18px; right: 20px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px;
  border-radius: 50%; background: rgba(255,255,255,.1); border: 0; color: #fff; cursor: pointer;
  display: grid; place-items: center; font-size: 20px; }
.lb-nav:hover { background: rgba(255,255,255,.2); }
.lb-prev { left: 18px; } .lb-next { right: 18px; }
.lb-caption { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  color: #cfd5e2; font-size: 13px; background: rgba(0,0,0,.5); padding: 6px 14px; border-radius: 20px; }

/* ---------------------------------------------------- misc */
.empty { padding: 64px 20px; text-align: center; color: var(--muted); }
.empty .e-icon { font-size: 40px; margin-bottom: 10px; opacity: .55; }
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; }
.pager .pinfo { color: var(--muted); font-size: 13px; }
.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90;
  display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { padding: 9px 16px; border-radius: 20px; font-size: 13px; font-weight: 550;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: toastin .2s ease; }
.toast.good { border-color: var(--green); color: var(--green); }
.toast.bad { border-color: var(--red); color: var(--red); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }
.skeleton { background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 50%, var(--panel) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }
code, pre { font-family: var(--mono); }
pre { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px; overflow-x: auto; font-size: 12.5px; }
code.inline { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 5px;
  padding: 1px 5px; font-size: 12.5px; }
.kbd { padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; font-size: 11.5px; font-family: var(--mono); color: var(--muted); background: var(--panel-2); }

@media (max-width: 720px) {
  .page { padding: 14px; }
  .nav a { padding: 7px 9px; }
  .user-chip span { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 9px; }
}
