:root {
  --bg: #f6f7fb;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --line: rgba(17, 24, 39, 0.07);
  --text: #14161f;
  --muted: #6b7280;
  --brand: #5b5bd6;
  --brand-2: #a855f7;
  --danger: #ef4444;
  --radius: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 8px 30px rgba(16, 24, 40, 0.09);
  --shadow-lg: 0 24px 70px rgba(16, 24, 40, 0.16);
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- ambient background ---------- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora i {
  position: absolute; display: block; border-radius: 50%; filter: blur(90px); opacity: .5;
  animation: drift 22s ease-in-out infinite alternate;
  will-change: transform;
}
.aurora i:nth-child(1) { width: 46vw; height: 46vw; left: -8vw; top: -12vw; background: radial-gradient(circle, #c7d2fe, transparent 70%); }
.aurora i:nth-child(2) { width: 40vw; height: 40vw; right: -10vw; top: 6vw; background: radial-gradient(circle, #e9d5ff, transparent 70%); animation-delay: -7s; }
.aurora i:nth-child(3) { width: 38vw; height: 38vw; left: 28vw; bottom: -18vw; background: radial-gradient(circle, #bae6fd, transparent 70%); animation-delay: -14s; }
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(4vw, 3vw, 0) scale(1.12); }
}

.hidden { display: none !important; }

/* ---------- shared ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: 0; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 500; padding: 9px 16px; border-radius: 12px;
  color: var(--text); background: transparent; transition: transform .16s, background .2s, box-shadow .2s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 18px rgba(91, 91, 214, .28);
}
.btn.primary:hover { box-shadow: 0 10px 24px rgba(91, 91, 214, .36); }
.btn.ghost { background: rgba(255, 255, 255, .7); border: 1px solid var(--line); }
.btn.ghost:hover { background: #fff; box-shadow: var(--shadow-sm); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; justify-content: center; padding: 12px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); backdrop-filter: blur(22px);
  border: 1px solid rgba(255, 255, 255, .7); border-radius: 26px; padding: 34px 30px 26px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 15px;
  animation: rise .5s cubic-bezier(.2, .8, .2, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  font-weight: 700; font-size: 20px; color: #fff; letter-spacing: -1px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 20px rgba(91, 91, 214, .3);
}
.brand h1 { font-size: 19px; font-weight: 650; letter-spacing: -.3px; }
.brand p { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.brand.small .brand-mark { width: 38px; height: 38px; border-radius: 12px; font-size: 17px; }
.brand.small h1 { font-size: 16px; }

.login-card label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--muted); }
.login-card input {
  font: inherit; font-size: 15px; padding: 12px 14px; border-radius: 13px; color: var(--text);
  border: 1px solid var(--line); background: rgba(255, 255, 255, .85); outline: none;
  transition: border .2s, box-shadow .2s;
}
.login-card input:focus { border-color: rgba(91, 91, 214, .55); box-shadow: 0 0 0 4px rgba(91, 91, 214, .1); }
.err { color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; }

/* ---------- app shell ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; padding: 16px clamp(14px, 3vw, 34px) 40px; }

.topbar {
  position: sticky; top: 10px; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 10px 14px; border-radius: 20px; background: rgba(255, 255, 255, 0.9);
  /* 吸顶条滚动时每帧都要重新做背景模糊，模糊半径越小越省，165Hz 下差别明显 */
  backdrop-filter: blur(12px) saturate(1.4); -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .8); box-shadow: var(--shadow-sm);
}
.search {
  flex: 1; display: flex; align-items: center; gap: 9px; padding: 9px 14px;
  background: rgba(17, 24, 39, .04); border-radius: 13px; color: var(--muted);
  transition: background .2s, box-shadow .2s; max-width: 460px;
}
.search:focus-within { background: #fff; box-shadow: 0 0 0 3px rgba(91, 91, 214, .1); }
.search input { flex: 1; border: 0; background: none; outline: none; font: inherit; font-size: 14px; color: var(--text); }
.actions { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line); cursor: pointer;
  background: linear-gradient(135deg, #eef2ff, #f5f3ff); color: var(--brand);
  font: inherit; font-weight: 650; font-size: 14px; transition: transform .16s, box-shadow .2s;
}
.avatar:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.stage { flex: 1; margin-top: 22px; }

/* ---------- grid ---------- */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
}
.card {
  position: relative; display: flex; flex-direction: column; cursor: pointer;
  background: var(--surface-solid); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  /* hover 只动 transform / opacity，全部走合成层，165Hz 下不产生逐帧重绘 */
  transition: transform .18s cubic-bezier(.2, .8, .2, 1);
  animation: cardIn .3s ease backwards;
}
/* 阴影单独一层，用 opacity 淡入，避免 box-shadow 过渡触发整卡重绘 */
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: var(--shadow-md); opacity: 0; transition: opacity .18s ease;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.card:hover { transform: translateY(-3px); }
.card:hover::after { opacity: 1; }
.card .thumb {
  aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(135deg, #f8fafc, #eef2ff); position: relative;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .thumb .play {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-size: 15px; pointer-events: none;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .55);
}
.card .thumb .play::before {
  content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(12, 14, 22, .45); backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, .35);
}
.card .thumb .play { z-index: 1; }
.card .thumb .glyph { font-size: 34px; opacity: .55; filter: saturate(.9); }
.card .meta { padding: 11px 13px 13px; }
.card .name {
  font-size: 13.5px; font-weight: 550; line-height: 1.35; word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .sub { margin-top: 5px; font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }
.tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 6px; background: rgba(91, 91, 214, .1);
  color: var(--brand); font-weight: 500;
}
.card .ops {
  position: absolute; top: 8px; right: 8px; display: flex; gap: 5px; opacity: 0;
  transition: opacity .18s; transform: translateY(-3px);
}
.card:hover .ops { opacity: 1; transform: none; }
.opbtn {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .8); background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(8px); box-shadow: 0 2px 8px rgba(16, 24, 40, .1); color: var(--muted);
  transition: color .15s, transform .15s;
}
.opbtn:hover { color: var(--brand); transform: scale(1.06); }
.opbtn.danger:hover { color: var(--danger); }
.opbtn svg { width: 15px; height: 15px; }

/* ---------- empty ---------- */
.empty { display: grid; place-items: center; text-align: center; padding: 12vh 20px; gap: 8px; }
.empty-orb {
  width: 92px; height: 92px; border-radius: 30px; margin-bottom: 12px;
  background: linear-gradient(135deg, #e0e7ff, #f3e8ff);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .8), 0 18px 40px rgba(91, 91, 214, .16);
  animation: float 5s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-8px) rotate(4deg); } }
.empty h2 { font-size: 19px; font-weight: 620; }
.empty p { font-size: 13.5px; color: var(--muted); }

/* ---------- dropzone ---------- */
.dropzone {
  position: fixed; inset: 0; z-index: 60; display: none; place-items: center;
  background: rgba(91, 91, 214, .08); backdrop-filter: blur(6px);
}
.dropzone.on { display: grid; }
.dz-inner {
  padding: 34px 56px; border-radius: 24px; font-size: 17px; font-weight: 600; color: var(--brand);
  border: 2px dashed rgba(91, 91, 214, .45); background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow-lg);
}

/* ---------- progress ---------- */
.progress-wrap {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 70;
  display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 40px));
}
.pitem {
  background: rgba(20, 22, 31, .9); color: #fff; padding: 11px 15px; border-radius: 14px;
  font-size: 12.5px; box-shadow: var(--shadow-lg); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; gap: 7px; animation: rise .25s ease;
}
.pbar { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .18); overflow: hidden; }
.pbar i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, #818cf8, #c084fc); transition: width .25s; }

/* ---------- viewer ---------- */
.viewer, .panel { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; }
.viewer-bg, .panel-bg { position: absolute; inset: 0; background: rgba(10, 12, 20, .55); backdrop-filter: blur(10px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.viewer-body {
  position: relative; width: min(1080px, 94vw); height: min(86vh, 900px); display: flex; flex-direction: column;
  background: var(--surface-solid); border-radius: 22px; overflow: hidden; box-shadow: var(--shadow-lg);
  animation: rise .26s cubic-bezier(.2, .8, .2, 1);
}
.viewer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.viewer-title { font-size: 14px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-tools { display: flex; gap: 7px; flex-shrink: 0; }
.viewer-content { flex: 1; overflow: auto; display: grid; place-items: center; background: #0b0d14; }
.viewer-content img, .viewer-content video { max-width: 100%; max-height: 100%; display: block; }
.viewer-content pre {
  width: 100%; height: 100%; margin: 0; padding: 20px; overflow: auto; background: #0b0d14; color: #d7dae3;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.65; white-space: pre-wrap;
  word-break: break-word;
}
.viewer-content iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-content .nopreview { color: #8b90a0; font-size: 14px; text-align: center; padding: 30px; }

/* ---------- panel ---------- */
.panel-body {
  position: relative; margin-left: auto; height: 100%; width: min(480px, 100%); overflow-y: auto;
  background: var(--surface-solid); padding: 22px 22px 34px; box-shadow: var(--shadow-lg);
  animation: slideIn .28s cubic-bezier(.2, .8, .2, 1);
}
@keyframes slideIn { from { transform: translateX(30px); opacity: .4; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h3 { font-size: 17px; font-weight: 620; }
.hint { font-size: 13px; line-height: 1.65; color: var(--muted); margin-bottom: 20px; }
.field { margin-bottom: 17px; }
.field label { display: block; font-size: 12px; font-weight: 550; color: var(--muted); margin-bottom: 7px; letter-spacing: .2px; }
.copyrow {
  display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 12px;
  background: rgba(17, 24, 39, .04); border: 1px solid var(--line);
}
.copyrow code {
  flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px;
  color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 14px); z-index: 90;
  padding: 11px 18px; border-radius: 13px; font-size: 13px; color: #fff;
  background: rgba(20, 22, 31, .92); box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s; backdrop-filter: blur(8px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .app { padding: 10px 12px 30px; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px; border-radius: 18px; top: 6px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .brand.small p { display: none; }
  .btn.ghost span, .btn.primary span { display: none; }
  .btn.primary, .btn.ghost { padding: 9px 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(142px, 1fr)); gap: 11px; }
  .viewer-body { width: 100vw; height: 100dvh; border-radius: 0; }
  .panel-body { width: 100%; }
}
