/* =============================================================================
   后台管理样式
   设计语言沿用参考平台 video.scsedu.cn/admin 的深色金色调，但更紧凑：
   顶部导航 + 卡片列表 + 表单分组，全部原生 CSS，无框架依赖。
   ========================================================================== */

:root {
  --ink: #0b0e14;
  --ink-2: #121722;
  --ink-3: #1a2130;
  --paper: #eef2f8;
  --dim: #98a2b8;
  --gold: #d4a445;
  --gold-lt: #f0d494;
  --brand: #5d89f7;
  --danger: #e2574c;
  --ok: #3fb950;
  --line: rgba(148, 168, 210, .16);
  --radius: 12px;
  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

/* 兜底：组件样式里的 display 会盖掉 hidden 属性自带的 display:none，
   导致「隐藏」的进度条/表单照样显示。这条必须保留。 */
[hidden] { display: none !important; }

body {
  background: var(--ink); color: var(--paper); font-family: var(--sans);
  font-size: 14px; line-height: 1.6; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
code { font-family: var(--mono); font-size: 12.5px; }

/* ---------------------------------------------------------------- 登录页 */

.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background:
    radial-gradient(900px 520px at 20% 0%, rgba(212, 164, 69, .12), transparent 60%),
    radial-gradient(800px 500px at 90% 100%, rgba(93, 137, 247, .12), transparent 60%),
    var(--ink);
  padding: 24px;
}
.login-shell { width: 100%; max-width: 400px; }
.login-panel {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 34px 30px; box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.brand-mark {
  width: 46px; height: 46px; border-radius: 12px; margin-bottom: 18px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; letter-spacing: .04em; color: #1a1205;
  background: linear-gradient(135deg, var(--gold-lt), var(--gold));
}
.eyebrow { font-size: 11px; letter-spacing: .3em; color: var(--gold); margin-bottom: 6px; }
.login-panel h1 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.muted { color: var(--dim); font-size: 13px; }
.login-panel .muted { margin-bottom: 22px; }

/* ---------------------------------------------------------------- 表单 */

.form-stack { display: flex; flex-direction: column; gap: 16px; }
label { display: block; }
label > span { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="url"], input[type="number"], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 9px;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--line); outline: 0; font: inherit;
  transition: border-color .18s ease, box-shadow .18s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(93, 137, 247, .7); box-shadow: 0 0 0 3px rgba(93, 137, 247, .16);
}
textarea { min-height: 92px; resize: vertical; line-height: 1.7; }
.hint { font-size: 12px; color: var(--dim); margin-top: 5px; }
.field-error { color: var(--danger); font-size: 12.5px; min-height: 18px; }

/* 带固定前缀的输入行：前缀做成不可编辑的胶囊，视觉上明确「这个改不了」 */
.field-label { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 6px; }
.slug-row {
  display: flex; align-items: center; gap: 0;
  border: 1px solid var(--line); border-radius: 9px; overflow: hidden;
  background: var(--ink);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.slug-row:focus-within { border-color: rgba(93, 137, 247, .7); box-shadow: 0 0 0 3px rgba(93, 137, 247, .16); }
.slug-prefix {
  flex: none; padding: 10px 12px; font-family: var(--mono); font-size: 12.5px;
  color: var(--gold-lt); background: var(--ink-3); border-right: 1px solid var(--line);
  user-select: none;
}
.slug-row input {
  border: 0; border-radius: 0; background: transparent;
}
.slug-row input:focus { box-shadow: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 9px; font-size: 13.5px;
  border: 1px solid var(--line); background: var(--ink-3); color: var(--paper);
  transition: background .18s ease, border-color .18s ease, transform .12s ease;
  white-space: nowrap;
}
.btn:hover { background: #222b3d; border-color: rgba(148, 168, 210, .3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), #3f6fe0); border-color: transparent; color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, #6d95f8, #4a79e8); }
.btn-gold { background: linear-gradient(135deg, var(--gold-lt), var(--gold)); border-color: transparent; color: #1a1205; font-weight: 600; }
.btn-gold:hover { filter: brightness(1.06); }
.btn-danger { color: #ffb4ad; border-color: rgba(226, 87, 76, .4); }
.btn-danger:hover { background: rgba(226, 87, 76, .16); }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- 布局 */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 clamp(16px, 3vw, 32px); height: 60px;
  background: rgba(11, 14, 20, .92); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--paper); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand .brand-mark { width: 30px; height: 30px; border-radius: 8px; margin: 0; font-size: 12px; }
.brand small { display: block; font-size: 11px; color: var(--dim); font-weight: 400; letter-spacing: .14em; }
.topbar nav { display: flex; align-items: center; gap: 4px; }
.topbar nav a {
  padding: 7px 13px; border-radius: 8px; font-size: 13.5px; color: var(--dim);
}
.topbar nav a:hover { background: var(--ink-3); color: var(--paper); text-decoration: none; }
.topbar nav a.is-active { background: rgba(93, 137, 247, .18); color: #cfe0ff; }

main { max-width: 1220px; margin: 0 auto; padding: clamp(20px, 3vw, 34px) clamp(16px, 3vw, 32px) 80px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 18px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 { font-size: 24px; font-weight: 600; }
.page-head .eyebrow { margin-bottom: 4px; }
.page-head .muted { margin-top: 6px; }
.head-actions { display: flex; gap: 10px; align-items: center; }

/* ---------------------------------------------------------------- 卡片 */

.card {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.card h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.card > .muted { margin-bottom: 16px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.project-card {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 14px;
  transition: border-color .2s ease, transform .2s ease;
}
.project-card:hover { border-color: rgba(148, 168, 210, .32); transform: translateY(-2px); }
.project-card.is-disabled { opacity: .62; }

.pc-head { display: flex; align-items: flex-start; gap: 12px; }
.pc-avatar {
  flex: none; width: 42px; height: 42px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600; color: #1a1205;
  background: linear-gradient(135deg, var(--gold-lt), var(--gold));
  overflow: hidden;
}
.pc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pc-title { flex: 1; min-width: 0; }
.pc-title h2 { font-size: 15.5px; margin-bottom: 6px; word-break: break-word; }
.pc-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.badge {
  display: inline-flex; align-items: center; height: 21px; padding: 0 9px;
  border-radius: 999px; font-size: 11.5px; letter-spacing: .04em;
  background: var(--ink-3); color: var(--dim); border: 1px solid var(--line);
}
.badge-ok { background: rgba(63, 185, 80, .14); color: #7ee787; border-color: rgba(63, 185, 80, .3); }
.badge-off { background: rgba(226, 87, 76, .14); color: #ff9d94; border-color: rgba(226, 87, 76, .3); }
.badge-gold { background: rgba(212, 164, 69, .16); color: var(--gold-lt); border-color: rgba(212, 164, 69, .34); }
.badge-brand { background: rgba(93, 137, 247, .16); color: #cfe0ff; border-color: rgba(93, 137, 247, .34); }

.entry-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--ink); border: 1px solid var(--line); border-radius: 9px; padding: 7px 8px 7px 12px;
}
.entry-row input { border: 0; background: transparent; padding: 0; font-size: 12.5px; font-family: var(--mono); }
.entry-row input:focus { box-shadow: none; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------------------------------------- 表格 */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; color: var(--dim); font-weight: 500; letter-spacing: .06em; }
.table td { font-size: 13.5px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }

/* ---------------------------------------------------------------- 开关 */

.switch-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.switch-row:last-child { border-bottom: 0; }
.switch-row strong { display: block; font-size: 13.5px; font-weight: 500; }
.switch-row p { font-size: 12.5px; color: var(--dim); margin-top: 3px; }
.switch { flex: none; position: relative; width: 44px; height: 25px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; pointer-events: none;
  background: var(--ink-3); border: 1px solid var(--line); transition: background .2s ease;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px;
  border-radius: 50%; background: var(--dim); transition: transform .2s ease, background .2s ease;
}
.switch input:checked + span { background: rgba(93, 137, 247, .35); border-color: rgba(93, 137, 247, .6); }
.switch input:checked + span::after { transform: translateX(19px); background: #fff; }

/* ---------------------------------------------------------------- 可视化编辑（岛屿按钮） */

.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 980px) { .editor-layout { grid-template-columns: 1fr; } }

.stage-preview {
  position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--radius); border: 1px solid var(--line); background: #05070d;
}
.stage-preview video, .stage-preview .pv-image {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
/* 预览用的蒙版：必须跟前台 .stage__veil 同样按 --veil 缩放 alpha，
   否则拖「背景蒙版」滑杆时预览毫无反应。 */
.stage-preview .pv-veil {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(1200px 620px at 50% -10%,
      rgba(10, 22, 48, calc(.10 * var(--veil, 1))),
      rgba(3, 6, 15, calc(.55 * var(--veil, 1))) 70%),
    linear-gradient(180deg,
      rgba(3, 6, 15, calc(.55 * var(--veil, 1))) 0%,
      rgba(3, 6, 15, calc(.12 * var(--veil, 1))) 32%,
      rgba(3, 6, 15, calc(.62 * var(--veil, 1))) 100%);
}
.pv-title {
  position: absolute; top: 14px; left: 18px; z-index: 3;
  font-size: 15px; letter-spacing: .28em; text-shadow: 0 2px 12px rgba(0, 0, 0, .9);
}
.pv-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 13px; text-align: center; padding: 20px;
}
.pv-sound {
  position: absolute; top: 12px; right: 14px; z-index: 4;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(9, 16, 32, .6); border: 1px solid var(--line); color: #fff;
  display: flex; align-items: center; justify-content: center;
}

.pv-btn {
  position: absolute; transform: translate(-50%, -50%); z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: grab; user-select: none; touch-action: none;
}
.pv-btn.is-dragging { cursor: grabbing; z-index: 9; }
.pv-btn__icon {
  /* 尺寸必须跟前台 .island__icon 用同一套算法（基准 clamp × --icon-scale），
     否则拖「岛屿图标大小」滑杆时预览不动、前台却在变 —— 预览就失去意义了。
     基准值取 68px 是因为后台预览窗口比实际视口小，clamp 会稳定落在上限。 */
  width: calc(clamp(44px, 5vw, 68px) * var(--icon-scale, 1));
  height: calc(clamp(44px, 5vw, 68px) * var(--icon-scale, 1));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: var(--gold);
  border-radius: 50%; border: 1px solid rgba(244, 213, 141, .45);
  background: radial-gradient(circle at 40% 32%, rgba(244, 213, 141, .26), rgba(9, 16, 32, .72));
  box-shadow: 0 0 20px rgba(244, 213, 141, .2);
}
.pv-btn__icon img { width: 100%; height: 100%; object-fit: contain; }
.pv-btn__label {
  font-size: 11px; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  background: rgba(5, 10, 22, .7); border: 1px solid rgba(244, 213, 141, .3);
  text-shadow: 0 1px 6px #000;
}
.pv-btn.is-selected .pv-btn__icon { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(93, 137, 247, .35), 0 0 22px rgba(93, 137, 247, .5); }

.btn-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.btn-list-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: 9px; border: 1px solid var(--line); background: var(--ink-3); cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}
.btn-list-item:hover { border-color: rgba(148, 168, 210, .34); }
.btn-list-item.is-active { border-color: rgba(93, 137, 247, .6); background: rgba(93, 137, 247, .14); }
.btn-list-item .num {
  flex: none; width: 22px; height: 22px; border-radius: 6px; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink); border: 1px solid var(--line); color: var(--dim);
}
.btn-list-item .name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- 上传 */

.upload-box {
  border: 1px dashed rgba(148, 168, 210, .3); border-radius: var(--radius);
  padding: 18px; text-align: center; background: var(--ink);
  transition: border-color .2s ease, background .2s ease;
}
.upload-box.is-over { border-color: var(--brand); background: rgba(93, 137, 247, .1); }
.upload-box p { font-size: 12.5px; color: var(--dim); margin-top: 8px; }
.progress { height: 5px; border-radius: 3px; background: var(--ink-3); overflow: hidden; margin-top: 12px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .15s linear; }

.asset-preview { display: flex; align-items: center; gap: 12px; }
.asset-thumb {
  width: 92px; height: 60px; border-radius: 8px; overflow: hidden; flex: none;
  background: var(--ink-3); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 11px;
}
.asset-thumb img, .asset-thumb video { width: 100%; height: 100%; object-fit: cover; }

/* ---------------------------------------------------------------- 滑杆设置 */

.slider-row { margin-top: 16px; }
.slider-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  margin-bottom: 9px;
}
.slider-head strong { display: block; font-size: 13.5px; font-weight: 500; }
.slider-head p { font-size: 12.5px; color: var(--dim); margin-top: 3px; }
.slider-head output {
  flex: none; min-width: 52px; text-align: right;
  font-size: 13px; font-family: var(--mono); color: var(--gold-lt);
}
.slider-scale {
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: var(--dim); margin-top: 5px;
}

/* 原生 range 的样式在各浏览器差异很大，这里统一成细轨 + 圆钮 */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 20px; background: transparent; cursor: pointer; padding: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px; background: var(--ink-3); border: 1px solid var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin-top: -7px;
  border-radius: 50%; background: linear-gradient(135deg, var(--gold-lt), var(--gold));
  border: 0; box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
input[type="range"]::-moz-range-track {
  height: 4px; border-radius: 2px; background: var(--ink-3); border: 1px solid var(--line);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; border: 0;
  background: linear-gradient(135deg, var(--gold-lt), var(--gold));
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(93, 137, 247, .45); }

/* ---------------------------------------------------------------- 资源列表 */

.asset-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--ink-3);
}
.asset-row:last-child { margin-bottom: 0; }
.asset-info { flex: 1; min-width: 0; }
.asset-name {
  font-size: 13px; word-break: break-all; margin-bottom: 3px;
}
.asset-meta { font-size: 12px; color: var(--dim); }
.asset-meta a { font-size: 12px; }
.asset-roles { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }

/* ---------------------------------------------------------------- 徽标提示 */

.toast-host { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 11px 16px; border-radius: 10px; font-size: 13px;
  background: var(--ink-3); border: 1px solid var(--line); color: var(--paper);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
  animation: toastIn .22s ease;
}
.toast.is-ok { border-color: rgba(63, 185, 80, .45); }
.toast.is-err { border-color: rgba(226, 87, 76, .5); color: #ffb4ad; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.empty {
  padding: 40px 20px; text-align: center; color: var(--dim); font-size: 13.5px;
  border: 1px dashed var(--line); border-radius: var(--radius);
}

.kv { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv > span { color: var(--dim); font-size: 12.5px; }
.kv > strong { font-weight: 500; font-size: 13.5px; }

.qr-box { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.qr-box img { width: 168px; height: 168px; border-radius: 10px; background: #fff; padding: 8px; }
