* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #6b7385;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --line: #e4e7f0;
  --danger: #dc2626;
  --ok: #16a34a;
}
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); min-height: 100vh;
}
a { color: var(--brand); text-decoration: none; }

/* 顶部导航 */
.nav {
  background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.nav-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 16px; height: 56px;
  display: flex; align-items: center; gap: 14px;
}
.logo { font-size: 19px; font-weight: 800; color: var(--ink); white-space: nowrap; flex-shrink: 0; }
.logo span { color: var(--brand); }
.nav-links {
  display: flex; gap: 14px; font-size: 14px; flex: 1;
  white-space: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a { color: var(--muted); flex-shrink: 0; }
.nav-links a.active, .nav-links a:hover { color: var(--brand); }
.nav-user {
  font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px;
  white-space: nowrap; flex-shrink: 0;
}
@media (max-width: 480px) {
  .nav-user .nick { display: none; }
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 16px 60px; }
.wrap.narrow { max-width: 720px; }

h2.page-title { font-size: 22px; margin-bottom: 18px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; cursor: pointer; font-size: 15px; font-weight: 600;
  padding: 10px 22px; border-radius: 10px; color: #fff;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .92; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.plain { background: #eef0f7; color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 14px; font-size: 13px; border-radius: 8px; }

/* 卡片与表单 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: 10px 12px; font-size: 15px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink); font-family: inherit;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: 2px solid #c7d2fe; border-color: var(--brand); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }

.tag { display: inline-block; background: #eef0f7; color: var(--muted); font-size: 12px; padding: 2px 8px; border-radius: 6px; margin-right: 4px; }

/* 小红书式瀑布流 */
.masonry { display: flex; align-items: flex-start; gap: 10px; }
.masonry-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.xhs-card {
  display: block; background: #fff; border-radius: 12px; overflow: hidden; color: inherit;
  box-shadow: 0 1px 3px rgba(29,36,51,.06); transition: box-shadow .15s, transform .12s;
}
.xhs-card:hover { box-shadow: 0 8px 22px rgba(29,36,51,.12); transform: translateY(-2px); }
.xhs-cover { display: block; width: 100%; height: auto; }
.xhs-body { padding: 8px 10px 10px; }
.xhs-title {
  font-size: 14px; line-height: 1.4; font-weight: 600; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.xhs-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }
.xhs-author { display: flex; align-items: center; gap: 5px; min-width: 0; font-size: 12px; color: var(--muted); }
.xhs-author .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xhs-avatar {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 600;
}
.xhs-like { display: flex; align-items: center; gap: 3px; flex-shrink: 0; font-size: 12px; color: var(--muted); }
.xhs-like svg { display: block; }

/* 工具条 */
.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=text] { max-width: 260px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: none; background: #fff; padding: 8px 16px; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--brand); color: #fff; }

/* 创建器步骤 */
.steps { display: flex; gap: 8px; margin-bottom: 20px; font-size: 13px; flex-wrap: wrap; }
.step { padding: 6px 14px; border-radius: 999px; background: #eef0f7; color: var(--muted); }
.step.active { background: var(--brand); color: #fff; }
.step.done { background: #dcfce7; color: var(--ok); }

.tpl-option {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 2px solid var(--line);
  border-radius: 12px; cursor: pointer; margin-bottom: 10px; background: #fff; transition: border-color .15s;
}
.tpl-option:hover { border-color: #c7d2fe; }
.tpl-option.selected { border-color: var(--brand); background: #f5f6ff; }
.tpl-option .tpl-icon { font-size: 26px; }
.tpl-option .tpl-name { font-weight: 700; font-size: 15px; }
.tpl-option .tpl-desc { font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.recommend-badge { display: inline-block; background: #fef3c7; color: #b45309; font-size: 12px; padding: 2px 8px; border-radius: 6px; margin-left: 8px; }

/* 知识点编辑器 */
.k-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fff; }
.k-item .k-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.k-item .k-index { font-size: 13px; font-weight: 700; color: var(--muted); }
.k-item input, .k-item textarea { margin-bottom: 8px; font-size: 14px; padding: 8px 10px; }
.k-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.k-row input { margin-bottom: 0; }
.k-row .radio { flex-shrink: 0; }

/* 预览 iframe */
.preview-frame {
  width: 100%; height: 560px; border: 1px solid var(--line); border-radius: 14px;
  background: #111; display: block;
}
@media (max-width: 640px) { .preview-frame { height: 480px; } }

/* 播放页为独立全屏布局，样式内联于 play.html */

/* 表格（管理后台） */
table.admin { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; border-radius: 12px; overflow: hidden; }
table.admin th, table.admin td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
table.admin th { background: #f8f9fd; color: var(--muted); font-weight: 600; }
.stats-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; }
.stat-card .num { font-size: 26px; font-weight: 800; color: var(--brand); }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 4px; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14px; }
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #1d2433; color: #fff; font-size: 14px; padding: 10px 20px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 99;
}
.toast.show { opacity: 1; }
.status-pill { font-size: 12px; padding: 2px 10px; border-radius: 999px; }
.status-draft { background: #fef3c7; color: #b45309; }
.status-published { background: #dcfce7; color: var(--ok); }
.status-removed { background: #fee2e2; color: var(--danger); }

/* 首页 AI 输入框 */
.ai-hero { padding: 10px 0 30px; text-align: center; }
.ai-hero h1 { font-size: 26px; margin-bottom: 18px; line-height: 1.35; }
.ai-box {
  position: relative; max-width: 720px; margin: 0 auto; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 10px 30px rgba(29,36,51,.07); padding: 18px 18px 62px;
  transition: box-shadow .15s, border-color .15s;
}
.ai-box:focus-within { border-color: var(--brand); box-shadow: 0 12px 34px rgba(79,70,229,.15); }
.ai-box textarea {
  width: 100%; border: none; outline: none; resize: none; background: transparent;
  font-family: inherit; font-size: 16px; line-height: 1.65; color: var(--ink); min-height: 92px;
}
.ai-send {
  position: absolute; right: 14px; bottom: 14px;
  display: inline-flex; align-items: center; gap: 7px; border: none; cursor: pointer;
  font-size: 15px; font-weight: 700; color: #fff; padding: 10px 20px; border-radius: 12px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2)); box-shadow: 0 4px 12px rgba(79,70,229,.3);
  transition: opacity .15s, transform .1s;
}
.ai-send:hover { opacity: .93; }
.ai-send:active { transform: scale(.97); }
.ai-send:disabled { opacity: .5; cursor: not-allowed; }
.ai-hint2 { max-width: 720px; margin: 12px auto 0; padding-left: 6px; font-size: 12.5px; color: var(--muted); text-align: left; }

/* 加载转圈 */
.spinner {
  width: 40px; height: 40px; margin: 0 auto; border-radius: 50%;
  border: 4px solid #e4e7f0; border-top-color: var(--brand); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.autopilot-mask {
  position: fixed; inset: 0; z-index: 60; display: none;
  align-items: center; justify-content: center; background: rgba(244,246,251,.92);
}
