/* Sunlife 视频生成平台 — 公共样式 */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #f97316;
  --primary-dark: #ea580c;
  --danger: #dc2626;
  --ok: #16a34a;
  --border: #e5e7eb;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 头部 */
.topbar {
  background: linear-gradient(90deg, #ff7a45, #ffb84d);
  color: #fff; padding: 12px 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.brand small { font-size: 12px; font-weight: 400; opacity: .85; margin-left: 8px; }
.topbar .spacer { flex: 1; }
.topbar .userbox { text-align: right; font-size: 13px; }
.btn {
  display: inline-block; border: none; border-radius: 6px; cursor: pointer;
  padding: 8px 16px; font-size: 14px; background: #fff; color: var(--text);
  border: 1px solid var(--border); transition: all .15s;
}
.btn:hover { border-color: #d1d5db; background: #f9fafb; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: #fff; border-color: #fca5a5; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 布局 */
.wrap { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
.grid2 { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card h2 { font-size: 16px; margin-bottom: 14px; }
.card h3 { font-size: 14px; margin-bottom: 8px; color: var(--muted); }

/* 表单 */
.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #fdba74; border-color: var(--primary); }
textarea { resize: vertical; min-height: 90px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* 密码可见性开关 */
.pwd-wrap { position: relative; display: block; }
.pwd-wrap input { padding-right: 42px; }
.pwd-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: none; background: transparent;
  cursor: pointer; color: var(--muted); display: flex;
  align-items: center; justify-content: center; border-radius: 6px;
}
.pwd-eye:hover { color: var(--text); background: #f3f4f6; }
.pwd-eye svg { width: 18px; height: 18px; }
.pwd-eye .eye-off { display: none; }
.pwd-eye.showing .eye-on { display: none; }
.pwd-eye.showing .eye-off { display: block; }

/* 徽章 */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; white-space: nowrap;
}
.badge-gray { background: #f3f4f6; color: #4b5563; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-brown { background: #fef3c7; color: #92400e; }

/* 表格 */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
tr:hover td { background: #fafafa; }
.tbl-scroll { overflow-x: auto; }
.prompt-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-cell { max-width: 220px; color: var(--danger); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

/* 提示条 */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert-red { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-yellow { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

/* 页签 */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 8px 18px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 14px; color: var(--muted);
}
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; padding: 24px; width: 420px;
  max-width: 92vw; max-height: 86vh; overflow: auto;
}
.modal h3 { margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* 登录/注册页 */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { width: 380px; max-width: 92vw; }
.auth-card .brand { color: var(--primary-dark); display: block; text-align: center; margin-bottom: 6px; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 22px; font-size: 13px; }
.auth-card .switch { text-align: center; margin-top: 14px; font-size: 13px; color: var(--muted); }

/* 音频附件列表 */
.file-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 6px; padding: 6px 10px;
  background: #f9fafb; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px;
}
.file-item .x {
  flex: none; width: 18px; height: 18px;
  background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 50%;
  cursor: pointer; font-size: 11px; line-height: 18px;
}

/* 图片预览 */
.previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.preview {
  position: relative; width: 72px; height: 72px; border-radius: 8px;
  border: 1px solid var(--border); overflow: hidden;
}
.preview img { width: 100%; height: 100%; object-fit: cover; }
.preview .x {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
  background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 50%;
  cursor: pointer; font-size: 11px; line-height: 18px;
}

/* 对话式创作页（app 页） */
.app-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.app-page .chat-wrap {
  flex: 1; min-height: 0; width: 100%; max-width: 1400px; margin: 0 auto;
  display: flex; flex-direction: column;
}
.main { display: flex; flex: 1; min-height: 0; padding: 0 12px 0 8px; }
.chat-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.chat-head b { font-size: 15px; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 4px; }
.chat-empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* 右侧视频库（可拖拽调宽） */
.splitter {
  width: 6px; flex: none; cursor: col-resize; border-radius: 3px;
  margin: 0 4px; background: transparent; transition: background .15s;
}
.splitter:hover, .splitter.drag { background: #fed7aa; }
.right-panel {
  flex: none; width: 300px; min-height: 0; display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.rp-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.rp-body {
  flex: 1; overflow-y: auto; padding: 10px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px; align-content: start;
}
.rp-card {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  cursor: pointer; background: #fff; transition: border-color .15s;
}
.rp-card:hover { border-color: #fdba74; }
.rp-card video { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: #000; }
.rp-meta { padding: 6px 8px; font-size: 12px; color: var(--muted); }
@media (max-width: 900px) {
  .main { flex-direction: column; }
  .splitter { display: none; }
  .right-panel { width: 100% !important; max-height: 300px; margin-top: 8px; }
}

/* 气泡 */
.msg { display: flex; flex-direction: column; margin-bottom: 16px; }
.msg-user { align-items: flex-end; }
.msg-sys { align-items: flex-start; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 12px; }
.bubble-user { background: #fff7ed; border: 1px solid #fed7aa; border-bottom-right-radius: 4px; }
.bubble-sys { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble-prompt { white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.bubble-prompt.clamped {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; cursor: pointer;
}
.bubble-prompt.clamped:hover { background: rgba(0,0,0,.04); border-radius: 4px; }
.bubble-video {
  display: block; width: 100%; max-width: 340px; aspect-ratio: 16/9;
  object-fit: cover; background: #000; border-radius: 8px; margin-top: 8px;
}
#img-zoom {
  position: fixed; display: none; z-index: 999; max-width: 320px; max-height: 320px;
  object-fit: contain; border-radius: 10px; border: 2px solid #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,.35); background: #fff; pointer-events: none;
}
.modal-video { width: 720px; }
.modal-video video {
  width: 100%; aspect-ratio: 16/9; object-fit: contain;
  background: #000; border-radius: 10px;
}
.modal-img { width: 640px; }
.modal-img img {
  display: block; width: 100%; max-height: 72vh; object-fit: contain;
  background: #111; border-radius: 10px;
}
.bubble-media { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.bubble-img {
  width: 64px; height: 64px; object-fit: cover; display: block;
  border-radius: 8px; border: 1px solid var(--border);
}
.bubble-params { margin-top: 6px; }
.bubble-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.bubble-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 底部提交栏 */
.composer { padding: 0 4px 16px; }
.composer-grip {
  height: 12px; cursor: ns-resize; display: flex;
  align-items: center; justify-content: center;
}
.composer-grip i { width: 40px; height: 4px; border-radius: 2px; background: #d1d5db; }
.composer-grip:hover i, .composer-grip.drag i { background: var(--primary); }
.composer-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.08); padding: 12px 14px;
}
.attach-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.attach-thumb {
  position: relative; width: 56px; height: 56px; border-radius: 8px;
  border: 1px solid var(--border); cursor: pointer; overflow: hidden; flex: none;
}
.attach-thumb:hover { outline: 2px solid #fdba74; }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-x {
  position: absolute; top: 2px; right: 2px; width: 16px; height: 16px;
  background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 50%;
  cursor: pointer; font-size: 10px; line-height: 16px; padding: 0;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f9fafb; border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 10px; font-size: 12px;
}
.chip-x {
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 14px; padding: 0; line-height: 1;
}
.chip-x:hover { color: var(--danger); }
.chip-click { cursor: pointer; }
.chip-click:hover { border-color: #fdba74; }
.composer-input { position: relative; }
.composer-input textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-family: inherit;
  resize: none; min-height: 64px; background: #fff;
}
.composer-input textarea:focus { outline: 2px solid #fdba74; border-color: var(--primary); }

/* @ 引用菜单 */
.at-menu {
  position: absolute; bottom: calc(100% + 6px); left: 0;
  min-width: 220px; max-width: 320px; max-height: 200px; overflow: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 30; padding: 4px;
}
.at-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.at-item:hover { background: #f3f4f6; }
.at-item img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.at-icon {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: #f9fafb; border: 1px solid var(--border); border-radius: 6px; font-size: 16px; flex: none;
}
.at-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }

.composer-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.composer-row select { width: auto; min-width: 92px; padding: 7px 10px; }
.composer-row input[type=number] { width: 72px; padding: 7px 10px; }
.edit-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 10px; padding: 8px 12px; background: #fff7ed;
  border: 1px solid #fed7aa; color: #c2410c; border-radius: 8px; font-size: 13px;
}

/* 统计卡片 */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.stat { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; background: #fff; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 22px; font-weight: 700; margin: 4px 0; }
.stat .d { font-size: 12px; color: var(--muted); }

.quota-bar { background: #f3f4f6; border-radius: 999px; height: 10px; overflow: hidden; }
.quota-bar > div { background: linear-gradient(90deg, #ff7a45, #ffb84d); height: 100%; }
.code-list { font-family: Consolas, monospace; background: #f9fafb; border: 1px dashed var(--border); border-radius: 8px; padding: 12px; margin: 10px 0; }
.code-list div { padding: 3px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.mt { margin-top: 10px; }
