/* ============ 全局 深色主题 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0b0c10;
  --bg2: #121319;
  --card: #16171e;
  --card2: #1c1e27;
  --line: #262833;
  --text: #e8e9ee;
  --text2: #9a9db0;
  --text3: #6b6e80;
  --gold: #d4a852;
  --gold2: #f0cd7e;
  --teal: #37d0c0;
  --red: #f06a6a;
  --radius: 12px;
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; cursor: pointer; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2e303c; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 按钮/表单 ============ */
.btn-primary {
  background: linear-gradient(135deg, var(--gold), #b8862f);
  color: #1a1405; border: none; border-radius: 10px;
  padding: 11px 22px; font-size: 14px; font-weight: 600;
  transition: .15s;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 18px; font-size: 14px;
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold2); }
.btn-block { width: 100%; margin-top: 14px; }
.btn-ghost {
  background: var(--card2); color: var(--text2);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; font-size: 13px;
}
.btn-ghost:hover { color: var(--text); border-color: #3a3d4d; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
textarea, select {
  width: 100%; background: #101116; border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px; color: var(--text);
  font-size: 14px; outline: none; transition: .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); }
textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
label { display: block; margin: 14px 0 7px; color: var(--text2); font-size: 13px; }

/* ============ 登录页 ============ */
.auth-page {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1000px 600px at 70% -10%, #1d1a10, var(--bg) 60%);
}
.auth-card {
  width: 400px; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 34px 34px 28px;
}
.auth-logo { text-align: center; font-size: 24px; font-weight: 700; color: var(--gold2); margin-bottom: 22px; letter-spacing: 1px; }
.auth-tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.auth-tab { background: none; border: none; color: var(--text3); font-size: 16px; padding: 8px 2px; position: relative; }
.auth-tab.active { color: var(--text); font-weight: 600; }
.auth-tab.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--gold); border-radius: 2px; }
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-img { width: 118px; height: 42px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; background: #fff; }
.btn-code { white-space: nowrap; padding: 10px 14px; }
.btn-code:disabled { opacity: .5; cursor: not-allowed; }
.auth-forgot { text-align: right; margin-top: 12px; font-size: 13px; }
.auth-forgot a, .auth-tip a { color: var(--gold2); }
.auth-tip { text-align: center; margin-top: 14px; color: var(--text3); font-size: 13px; }

/* ============ 主框架 ============ */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 200px; flex-shrink: 0; background: var(--bg2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.sidebar-logo {
  width: 42px; height: 42px; border-radius: 12px; margin: 4px 0 22px 6px;
  background: linear-gradient(135deg, #2a2e3d, #171923);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold2); font-size: 20px;
}
.nav-menu { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px; color: var(--text2);
  font-size: 14px; position: relative;
}
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--card2); color: var(--text); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; background: var(--gold); border-radius: 3px; }
.nav-ico { width: 18px; text-align: center; opacity: .8; }
.nav-arrow { margin-left: auto; color: var(--text3); }
.nav-soon { margin-left: auto; font-size: 11px; color: var(--text3); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.nav-item.disabled { opacity: .55; cursor: not-allowed; }
.sidebar-foot { display: flex; gap: 18px; padding: 12px 10px 2px; color: var(--text3); font-size: 16px; }
.sidebar-foot span { cursor: pointer; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; flex-shrink: 0; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; background: rgba(18,19,25,.85);
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 18px; color: var(--text2); font-size: 13px; }
.top-link { cursor: pointer; }
.top-link:hover { color: var(--text); }
.credits-badge {
  background: linear-gradient(135deg, rgba(212,168,82,.18), rgba(212,168,82,.06));
  border: 1px solid rgba(212,168,82,.4); color: var(--gold2);
  padding: 6px 14px; border-radius: 20px; font-size: 13px;
}
.view { flex: 1; overflow-y: auto; padding: 26px; }

/* ============ 通用卡片/网格 ============ */
.page-head { margin-bottom: 20px; }
.page-head h2 { font-size: 20px; margin-bottom: 6px; }
.page-head p { color: var(--text3); font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.tool-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: .18s;
}
.tool-card:hover { border-color: rgba(212,168,82,.5); transform: translateY(-2px); }
.tool-cover { height: 150px; background: var(--card2); position: relative; overflow: hidden; }
.tool-cover img { width: 100%; height: 100%; object-fit: cover; }
.tool-body { padding: 14px 16px; }
.tool-name { font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.tool-desc { color: var(--text3); font-size: 12.5px; line-height: 1.5; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: rgba(55,208,192,.15); color: var(--teal); }
.tag-gold { background: rgba(212,168,82,.16); color: var(--gold2); }
.tag-gray { background: #262833; color: var(--text3); }

/* ============ 首页 ============ */
.hero {
  background: linear-gradient(120deg, #1a1c26, #13141b 60%);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 34px 34px 28px; margin-bottom: 22px; position: relative; overflow: hidden;
}
.hero h1 { font-size: 26px; margin-bottom: 8px; }
.hero h1 .hl { color: var(--gold2); }
.hero p { color: var(--text2); margin-bottom: 20px; }
.hero-tabs { display: flex; gap: 10px; margin-bottom: 18px; }
.hero-tab { padding: 8px 22px; border-radius: 20px; border: 1px solid var(--line); background: transparent; color: var(--text2); }
.hero-tab.active { background: var(--text); color: #111; font-weight: 600; border-color: var(--text); }
.section-title { font-size: 15px; font-weight: 600; margin: 26px 0 14px; display: flex; align-items: center; gap: 10px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ============ 创作表单 ============ */
.create-wrap { max-width: 860px; margin: 0 auto; }
.upload-slots { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 4px; }
.upload-slot {
  width: 96px; height: 96px; border-radius: 10px; border: 1.5px dashed var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text3); cursor: pointer; position: relative; overflow: hidden; background: #101116;
}
.upload-slot:hover { border-color: var(--gold); color: var(--gold2); }
.upload-slot img { width: 100%; height: 100%; object-fit: cover; }
.upload-slot video { width: 100%; height: 100%; object-fit: cover; }
.upload-slot .rm { position: absolute; right: 3px; top: 3px; background: rgba(0,0,0,.6); border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; z-index: 2; }
.upload-slot .plus { font-size: 26px; line-height: 1; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.form-row > div { flex: 1; min-width: 140px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  background: #101116; border: 1px solid var(--line); color: var(--text2);
  border-radius: 8px; padding: 8px 16px; font-size: 13px;
}
.seg button.active { border-color: var(--gold); color: var(--gold2); background: rgba(212,168,82,.08); }
.cost-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
}
.cost { color: var(--gold2); font-weight: 600; }
.result-box { margin-top: 22px; }
.result-video { width: 100%; max-height: 520px; border-radius: 12px; background: #000; }
.ai-btn { color: var(--teal); background: none; border: none; font-size: 13px; }
.ai-btn:hover { text-decoration: underline; }
.progress-bar { height: 6px; background: var(--card2); border-radius: 4px; overflow: hidden; margin: 10px 0; }
.progress-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: .4s; }
.script-out { background: #101116; border: 1px solid var(--line); border-radius: 10px; padding: 14px; line-height: 1.9; white-space: pre-wrap; color: var(--text); font-size: 13.5px; }

/* ============ 作品/资产/模板 卡片 ============ */
.media-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; position: relative;
}
.media-card .thumb { display: block; width: 100%; aspect-ratio: 9/14; object-fit: cover; background: #0e0f14; }
.media-card video.thumb { width: 100%; aspect-ratio: 9/14; object-fit: cover; }
.media-card .mb { padding: 8px 10px; }
.media-card .mb .t1 { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-card .mb .t2 { font-size: 11px; color: var(--text3); margin-top: 2px; }
.media-card .ops { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.media-card .ops a { background: rgba(0,0,0,.6); border-radius: 6px; padding: 3px 8px; font-size: 12px; color: #fff; }
.media-card .st { position: absolute; left: 8px; top: 8px; font-size: 11px; padding: 2px 8px; border-radius: 6px; background: rgba(0,0,0,.65); }
.st-run { color: var(--teal); }
.st-fail { color: var(--red); }
.st-ok { color: #7ee2a8; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  padding: 7px 16px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--card); color: var(--text2); font-size: 13px;
}
.chip.active { background: var(--text); color: #111; border-color: var(--text); font-weight: 600; }
.tpl-price { position: absolute; top: 8px; left: 8px; font-size: 11px; padding: 2px 8px; border-radius: 6px; background: rgba(212,168,82,.9); color: #1a1405; font-weight: 600; }
.tpl-free { background: rgba(55,208,192,.85); color: #04302b; }

/* ============ 积分页 ============ */
.pkg-card { text-align: center; padding: 26px 16px; }
.pkg-card .pkg-name { font-size: 16px; font-weight: 600; }
.pkg-card .pkg-credits { font-size: 30px; color: var(--gold2); font-weight: 700; margin: 12px 0 4px; }
.pkg-card .pkg-price { color: var(--text2); margin-bottom: 16px; }
.pkg-card .pkg-price b { color: var(--red); font-size: 20px; }

/* ============ 无限画布编辑器 ============ */
.canvas-page { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: #0a0b0e; }
.canvas-topbar {
  height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 14px;
  padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--bg2);
}
.canvas-topbar .back { cursor: pointer; color: var(--text2); }
.canvas-topbar .back:hover { color: var(--text); }
.canvas-title { background: transparent; border: none; color: var(--text); font-size: 15px; font-weight: 600; width: 200px; outline: none; }
.canvas-title:focus { border-bottom: 1px solid var(--gold); }
.canvas-body { flex: 1; position: relative; overflow: hidden; }
.canvas-world {
  position: absolute; left: 0; top: 0; transform-origin: 0 0;
  width: 4000px; height: 3000px;
  background-image: radial-gradient(circle, #1e2029 1px, transparent 1px);
  background-size: 24px 24px;
}
.cv-node {
  position: absolute; width: 230px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px;
  user-select: none;
}
.cv-node.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(212,168,82,.25); }
.cv-node.running { border-color: var(--teal); }
.cv-node.failed { border-color: var(--red); }
.cv-node .nv-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 8px; cursor: move; }
.cv-node .nv-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); flex-shrink: 0; }
.cv-node .nv-head .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-node .nv-del { color: var(--text3); }
.cv-node .nv-del:hover { color: var(--red); }
.cv-mat-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: #0e0f14; }
.cv-mat-add {
  width: 100%; aspect-ratio: 1; border: 1.5px dashed var(--line); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text3); cursor: pointer; gap: 4px;
}
.cv-mat-add:hover { border-color: var(--gold); color: var(--gold2); }
.cv-port {
  position: absolute; width: 20px; height: 20px; border-radius: 50%;
  background: var(--card2); border: 3px solid var(--teal); cursor: crosshair; z-index: 5;
  box-shadow: 0 0 6px rgba(55,208,192,.5);
}
.cv-port.in { left: -8px; top: 50%; transform: translateY(-50%); }
.cv-port.out { right: -8px; top: 50%; transform: translateY(-50%); }
.cv-gen-body { font-size: 12.5px; }
.cv-gen-body textarea { min-height: 70px; font-size: 12.5px; padding: 8px; margin-bottom: 8px; }
.cv-gen-body .mini-label { color: var(--text3); font-size: 11.5px; margin: 6px 0 4px; }
.cv-gen-body select { padding: 7px 9px; font-size: 12.5px; margin-bottom: 6px; }
.cv-seg { display: flex; gap: 4px; flex-wrap: wrap; }
.cv-seg button { flex: 1; min-width: 44px; padding: 5px 0; font-size: 12px; background: #101116; border: 1px solid var(--line); color: var(--text2); border-radius: 6px; }
.cv-seg button.active { border-color: var(--gold); color: var(--gold2); }
.cv-run-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.cv-run {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--gold), #b8862f); border: none; color: #1a1405; font-size: 16px;
}
.cv-run:disabled { opacity: .5; }
.cv-cost { font-size: 11.5px; color: var(--gold2); }
.cv-result { margin-top: 8px; border-radius: 8px; overflow: hidden; }
.cv-result video { width: 100%; display: block; background: #000; }
.cv-err { color: var(--red); font-size: 11.5px; margin-top: 6px; }
.cv-spin { display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(55,208,192,.3); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.cv-toolbar-left {
  position: absolute; left: 14px; top: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 20;
}
.cv-tool {
  width: 40px; height: 40px; border-radius: 10px; background: var(--card); border: 1px solid var(--line);
  color: var(--text2); font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.cv-tool:hover { color: var(--gold2); border-color: var(--gold); }
.cv-zoombar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: 20px; padding: 6px 14px; z-index: 20;
}
.cv-zoombar button { background: none; border: none; color: var(--text2); font-size: 16px; }
.cv-zoombar span { font-size: 12.5px; color: var(--text2); min-width: 42px; text-align: center; }
.cv-svg { position: absolute; left: 0; top: 0; width: 4000px; height: 3000px; pointer-events: none; z-index: 3; overflow: visible; }
.cv-svg path, .cv-svg g { pointer-events: none; }
.cv-addmenu { position: absolute; z-index: 30; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-width: 130px; }
.cv-addmenu a { display: block; padding: 9px 12px; border-radius: 7px; font-size: 13px; color: var(--text2); }
.cv-addmenu a:hover { background: var(--card); color: var(--gold2); }
.cv-log {
  position: absolute; right: 14px; top: 14px; width: 300px; max-height: 70%;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; z-index: 20;
  display: flex; flex-direction: column;
}
.cv-log .lh { padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; }
.cv-log .lb { overflow-y: auto; padding: 8px 14px; font-size: 12px; color: var(--text2); line-height: 1.9; }

/* ============ toast / modal ============ */
.toast {
  position: fixed; left: 50%; top: 70px; transform: translateX(-50%);
  background: #23262f; color: var(--text); border: 1px solid var(--line);
  padding: 11px 22px; border-radius: 10px; z-index: 999; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.err { border-color: rgba(240,106,106,.5); color: #ffb3b3; }
.toast.ok { border-color: rgba(126,226,168,.4); color: #b9f2cf; }
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 500;
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 26px; min-width: 360px; max-width: 90vw; max-height: 86vh; overflow-y: auto;
}
.modal-box h3 { margin-bottom: 16px; font-size: 17px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

/* ============ 管理后台 ============ */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.admin-table th { color: var(--text3); font-weight: 500; }
.stat-cards { display: flex; gap: 16px; margin-bottom: 22px; }
.stat-card { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.stat-card .v { font-size: 28px; font-weight: 700; color: var(--gold2); }
.stat-card .k { color: var(--text3); font-size: 13px; margin-top: 4px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
