/* 墨韵 AI · 全局样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg-1: #0f0c29;
  --bg-2: #302b63;
  --bg-3: #24243e;
  --fg: #e8e6f5;
  --muted: #9b97b8;
  --primary: #8b5cf6;
  --primary-2: #ec4899;
  --card: rgba(255,255,255,0.04);
  --card-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2) 50%, var(--bg-3));
  background-attachment: fixed;
  color: var(--fg);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  width: 100%; padding: 12px 14px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  font: inherit;
  outline: none;
  transition: border-color .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 100px; }

/* 顶栏 */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 32px; border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px); background: rgba(0,0,0,0.3);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 18px;
}
.brand-name { font-size: 18px; font-weight: 600; }
.brand-sub { color: var(--muted); font-size: 13px; }
.topnav { display: flex; align-items: center; gap: 18px; }
.topnav a { color: var(--muted); font-size: 14px; transition: color .2s; }
.topnav a:hover { color: var(--fg); }
.user-chip {
  padding: 2px 10px; border-radius: 999px; font-size: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.user-name { color: var(--fg) !important; font-weight: 500; }

/* 按钮 */
.btn-primary, .btn-ghost, .btn-danger {
  padding: 8px 16px; border-radius: 8px; font-size: 14px;
  transition: all .2s; display: inline-block; text-align: center;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white; font-weight: 500;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(139,92,246,0.4); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-ghost { border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--card-hover); }
.btn-danger { color: #f87171; border: 1px solid rgba(248,113,113,0.3); }
.btn-danger:hover { background: rgba(248,113,113,0.1); }
.lg { padding: 12px 24px; font-size: 16px; }
.block { display: block; width: 100%; }

/* 页面 */
.page { max-width: 1200px; margin: 0 auto; padding: 40px 32px; }
.section-title { font-size: 22px; margin-bottom: 24px; }
.muted { color: var(--muted); font-size: 14px; }
.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--card); border-radius: 12px; }

/* Hero */
.hero { text-align: center; padding: 60px 0 40px; }
.hero h1 {
  font-size: 48px; font-weight: 700; line-height: 1.2;
  background: linear-gradient(135deg, #fff 30%, var(--primary) 70%, var(--primary-2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
}
.hero p { font-size: 18px; color: var(--muted); max-width: 640px; margin: 0 auto 32px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; margin-bottom: 48px; }
.hero-stats { display: flex; gap: 48px; justify-content: center; }
.hero-stats div { text-align: center; }
.hero-stats b { display: block; font-size: 28px; color: var(--fg); }
.hero-stats span { color: var(--muted); font-size: 13px; }

/* 卡片网格 */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.novel-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; cursor: pointer;
  transition: all .25s;
}
.novel-card:hover { transform: translateY(-3px); background: var(--card-hover); }
.cover {
  height: 140px; display: flex; align-items: flex-end; padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.cover-genre {
  padding: 4px 10px; background: rgba(0,0,0,0.4); border-radius: 6px;
  font-size: 12px; backdrop-filter: blur(10px);
}
.novel-body { padding: 16px; }
.novel-body h3 { font-size: 16px; margin-bottom: 6px; }
.novel-body p {
  font-size: 13px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 12px;
}
.meta { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }

/* 认证 */
.auth-box { max-width: 380px; margin: 60px auto; }
.auth-box h2 { text-align: center; margin-bottom: 24px; }
.auth-box input, .auth-box button { margin-bottom: 12px; }

/* 创作中心 */
.studio { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.create-form, .my-novels { background: var(--card); padding: 24px; border-radius: 14px; border: 1px solid var(--border); }
.create-form h3, .my-novels h3 { margin-bottom: 16px; }
.create-form input, .create-form select, .create-form textarea { margin-bottom: 12px; }
.my-novel-item {
  padding: 14px; background: rgba(0,0,0,0.2); border-radius: 10px;
  margin-bottom: 8px; cursor: pointer; transition: all .2s;
}
.my-novel-item:hover { background: rgba(0,0,0,0.3); }
.my-novel-item b { margin-right: 8px; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  background: rgba(139,92,246,0.2); font-size: 11px; margin-right: 4px;
}
.status { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; }
.status.s0 { background: rgba(251,191,36,0.2); color: #fbbf24; }
.status.s1 { background: rgba(74,222,128,0.2); color: #4ade80; }
.status.s2 { background: rgba(96,165,250,0.2); color: #60a5fa; }
.status.s3 { background: rgba(248,113,113,0.2); color: #f87171; }

/* 小说详情 */
.novel-detail { background: var(--card); padding: 32px; border-radius: 14px; border: 1px solid var(--border); }
.nd-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 32px; }
.nd-head h1 { font-size: 28px; margin-bottom: 8px; }
.nd-head p { margin-bottom: 12px; }
.meta-tags { display: flex; gap: 8px; }
.nd-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chapter-list { margin-top: 16px; }
.chapter-item {
  padding: 14px 18px; background: rgba(0,0,0,0.2); border-radius: 10px;
  margin-bottom: 8px; cursor: pointer; transition: all .2s;
  display: flex; justify-content: space-between; align-items: center;
}
.chapter-item:hover { background: rgba(0,0,0,0.3); }
.chapter-item b { margin-right: 8px; }

.generating {
  display: flex; gap: 16px; padding: 20px; margin: 20px 0;
  background: linear-gradient(135deg, rgba(139,92,246,0.1), rgba(236,72,153,0.1));
  border: 1px solid rgba(139,92,246,0.3); border-radius: 12px;
}
.spinner {
  width: 32px; height: 32px; border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 1s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.stream {
  margin-top: 8px; padding: 12px; background: rgba(0,0,0,0.3);
  border-radius: 8px; font-size: 12px; color: var(--muted);
  max-height: 200px; overflow: auto; white-space: pre-wrap;
}

/* 阅读器 */
.reader { max-width: 800px; margin: 0 auto; }
.reader h1 { font-size: 28px; margin: 16px 0 8px; }
.reader article {
  margin: 24px 0; padding: 32px; background: var(--card);
  border-radius: 12px; line-height: 1.9; font-size: 16px;
}
.reader article p { margin-bottom: 16px; }
.reader-actions { display: flex; gap: 12px; justify-content: center; padding: 20px 0; }

/* 我的资料 */
.me-box { background: var(--card); padding: 32px; border-radius: 14px; }
.me-box p { padding: 10px 0; border-bottom: 1px solid var(--border); }
.upgrade { margin-top: 32px; }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 16px 0; }
.plan {
  padding: 20px; background: rgba(0,0,0,0.3); border-radius: 12px;
  text-align: center; border: 1px solid var(--border);
}
.plan b { display: block; font-size: 18px; margin-bottom: 8px; }
.plan span { display: block; font-size: 28px; color: var(--primary); margin: 12px 0 0; }
.plan em { display: block; font-size: 12px; color: var(--muted); font-style: normal; margin-bottom: 12px; }

.redeem-box { display: flex; gap: 8px; margin: 16px 0; }
.redeem-box input { flex: 1; font-family: monospace; letter-spacing: 1px; font-size: 15px; }
.card-tips { padding: 16px; background: rgba(0,0,0,0.2); border-radius: 10px; margin-top: 16px; font-size: 14px; }
.card-tips p { margin-bottom: 6px; color: var(--muted); }
.card-tips b { color: var(--fg); }
.plan.highlight { border-color: var(--primary); background: rgba(139,92,246,0.1); }

/* 后台 */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat {
  padding: 24px; background: var(--card); border-radius: 12px;
  text-align: center; border: 1px solid var(--border);
}
.stat b { display: block; font-size: 28px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat b.good { background: linear-gradient(135deg, #4ade80, #22d3ee); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat b.bad { background: linear-gradient(135deg, #f87171, #fb923c); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat b.warn { background: linear-gradient(135deg, #fbbf24, #f59e0b); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat span { color: var(--muted); font-size: 13px; display: block; margin-top: 4px; }
.stat small { color: var(--muted); font-size: 11px; display: block; margin-top: 4px; opacity: 0.7; }
.stat.warn { border-color: rgba(251,191,36,0.3); }
.stat.good { border-color: rgba(74,222,128,0.3); }

/* 表格 */
.data-table {
  width: 100%; border-collapse: collapse; margin-top: 12px;
  background: var(--card); border-radius: 8px; overflow: hidden;
}
.data-table th, .data-table td {
  padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.data-table th { color: var(--muted); font-weight: 500; font-size: 12px; background: rgba(0,0,0,0.2); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* 柱状图 */
.trend {
  display: flex; align-items: flex-end; gap: 4px;
  height: 180px; padding: 16px;
  background: var(--card); border-radius: 12px;
  border: 1px solid var(--border);
}
.trend-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.trend-fill {
  width: 100%; min-height: 2px;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  border-radius: 4px 4px 0 0;
  transition: height .3s;
}
.trend-bar small { color: var(--muted); font-size: 10px; transform: rotate(-45deg); margin-top: 8px; white-space: nowrap; }

/* 后台 tabs */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.admin-tabs a {
  padding: 10px 20px; color: var(--muted); border-bottom: 2px solid transparent;
  transition: all .2s; margin-bottom: -1px;
}
.admin-tabs a:hover { color: var(--fg); }
.admin-tabs a.active { color: var(--fg); border-bottom-color: var(--primary); }

/* 生成卡密表单 */
.gen-card {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px;
  padding: 20px; background: var(--card); border-radius: 12px;
  border: 1px solid var(--border); align-items: end;
}
.gen-card > div { display: flex; flex-direction: column; gap: 6px; }
.gen-card label { font-size: 12px; color: var(--muted); }

/* 生成的卡密 */
.generated { padding: 20px; background: linear-gradient(135deg, rgba(74,222,128,0.05), rgba(34,211,238,0.05)); border: 1px solid rgba(74,222,128,0.3); border-radius: 12px; margin-top: 16px; }
.generated h4 { color: #4ade80; margin-bottom: 8px; }
.codes { display: flex; flex-wrap: wrap; gap: 8px; max-height: 200px; overflow-y: auto; padding: 12px; background: rgba(0,0,0,0.3); border-radius: 8px; }
.codes code { padding: 6px 10px; background: rgba(0,0,0,0.4); border-radius: 4px; cursor: pointer; font-size: 13px; transition: background .2s; }
.codes code:hover { background: var(--primary); color: white; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 页脚 */
.footer { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); margin-top: 60px; }

/* 通知 */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  padding: 12px 24px; background: rgba(0,0,0,0.85); backdrop-filter: blur(10px);
  border-radius: 10px; z-index: 1000; animation: slideIn .3s;
  border: 1px solid var(--border);
}
.toast.error { border-color: rgba(248,113,113,0.5); }
.toast.success { border-color: rgba(74,222,128,0.5); }
@keyframes slideIn { from { opacity: 0; transform: translate(-50%, -20px); } }

@media (max-width: 768px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
  .topnav { gap: 10px; font-size: 13px; }
  .page { padding: 24px 16px; }
  .hero h1 { font-size: 32px; }
  .hero p { font-size: 15px; }
  .hero-stats { gap: 24px; }
  .studio { grid-template-columns: 1fr; }
  .nd-head { flex-direction: column; gap: 16px; }
  .plans { grid-template-columns: 1fr; }
}
