:root {
  --primary: #7c3aed;
  --primary-dark: #5b21b6;
  --primary-light: #ede9fe;
  --text: #1e1b2e;
  --text-2: #6b7280;
  --bg: #faf9ff;
  --card: #ffffff;
  --border: #ece9f6;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(30, 27, 46, 0.06), 0 8px 24px rgba(30, 27, 46, 0.05);
  --danger: #ef4444;
  --success: #10b981;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--primary), #d946ef);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  gap: 18px;
  align-items: center;
}

.site-nav a {
  color: var(--text-2);
  font-size: 15px;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f3f0fe;
  border-radius: 999px;
  padding: 6px 14px;
}

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  width: 140px;
  color: var(--text);
}

.search-box input::placeholder {
  color: #a0a0b8;
}

.search-box button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: var(--primary);
}

/* ---------- 主内容 ---------- */
.main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: auto;
  background: #ffffff;
  border-top: 1px solid var(--border);
  padding: 28px 20px 20px;
  font-size: 13px;
  color: var(--text-2);
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.footer-line .sep {
  color: #d8d5ea;
}

.footer-line a {
  color: inherit;
}

.footer-line a:hover {
  color: var(--primary);
}

.police-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.police-badge svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #475569;
}

.footer-brand {
  color: #a6a3bd;
  font-size: 12px;
}

/* ---------- 卡片与按钮 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: #fee2e2;
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
}

/* ---------- 首页 ---------- */
.hero {
  text-align: center;
  padding: 28px 0 34px;
}

.hero h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 10px;
}

.hero p {
  color: var(--text-2);
  max-width: 560px;
  margin: 0 auto;
}

.category-tabs {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 18px 0 26px;
}

.category-tabs a {
  padding: 7px 18px;
  border-radius: 999px;
  background: #f1eefe;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
}

.category-tabs a:hover,
.category-tabs a.active {
  background: var(--primary);
  color: #fff;
}

.novel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.novel-card {
  display: flex;
  gap: 16px;
  padding: 18px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.novel-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 6px rgba(30, 27, 46, 0.06), 0 16px 40px rgba(30, 27, 46, 0.1);
}

.novel-cover {
  width: 72px;
  height: 100px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #d946ef);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  padding: 6px;
  flex-shrink: 0;
  overflow: hidden;
}

.novel-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.novel-info {
  min-width: 0;
  flex: 1;
}

.novel-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.novel-title a:hover {
  color: var(--primary);
}

.novel-meta {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
}

.tag-green {
  background: #d1fae5;
  color: #047857;
}

.novel-intro {
  font-size: 13px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-tip {
  text-align: center;
  padding: 60px 0;
  color: var(--text-2);
}

.empty-tip .big {
  font-size: 42px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ---------- 详情页 ---------- */
.detail-wrap {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 28px;
  padding: 28px;
}

.detail-cover {
  width: 200px;
  height: 278px;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--primary), #d946ef);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  text-align: center;
  padding: 12px;
}

.detail-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-info h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 12px;
}

.detail-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 16px;
}

.detail-intro {
  font-size: 15px;
  color: #4b4759;
  margin-bottom: 22px;
  background: #f7f4ff;
  padding: 16px 18px;
  border-radius: 10px;
  border-left: 3px solid var(--primary);
}

.detail-actions {
  display: flex;
  gap: 12px;
}

.chapter-list-wrap {
  padding: 24px 28px;
}

.chapter-list-wrap h2 {
  font-size: 18px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chapter-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.chapter-list a {
  display: block;
  font-size: 14px;
  padding: 8px 12px;
  background: #f6f4fd;
  border-radius: 8px;
  color: #4b4759;
  transition: all 0.2s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-list a:hover {
  background: var(--primary);
  color: #fff;
}

/* ---------- 阅读页 ---------- */
.reader-top {
  text-align: center;
  padding: 10px 0 6px;
}

.reader-top .novel-name {
  font-size: 13px;
  color: var(--text-2);
}

.reader-top .novel-name a:hover {
  color: var(--primary);
}

.reader-title {
  font-size: 24px;
  font-weight: 800;
  margin: 10px 0 6px;
}

.reader-body {
  max-width: 760px;
  margin: 24px auto 0;
  padding: 34px 40px;
  font-size: 17px;
  letter-spacing: 0.5px;
  color: #2b2838;
}

.reader-body p {
  margin-bottom: 18px;
  text-indent: 2em;
}

.reader-body::selection {
  background: #ddd6fe;
}

.reader-nav {
  max-width: 760px;
  margin: 24px auto 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.reader-nav a {
  padding: 10px 20px;
  border-radius: 8px;
  background: #f1eefe;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
}

.reader-nav a:hover {
  background: var(--primary);
  color: #fff;
}

.reader-nav a.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- 后台页面 ---------- */
.admin-body {
  background: #f4f2fb;
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.admin-sidebar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  height: fit-content;
  position: sticky;
  top: 84px;
}

.admin-sidebar .side-title {
  font-size: 13px;
  color: var(--text-2);
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.admin-sidebar a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: #4b4759;
  margin-bottom: 4px;
}

.admin-sidebar a:hover,
.admin-sidebar a.active {
  background: var(--primary-light);
  color: var(--primary);
}

.admin-main {
  min-width: 0;
}

.admin-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-page-head h2 {
  font-size: 22px;
  font-weight: 800;
}

.admin-card {
  padding: 22px;
  margin-bottom: 20px;
}

.admin-card h3 {
  font-size: 16px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* 表单 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #4b4759;
}

.form-group label .opt {
  font-weight: 400;
  color: #a6a3bd;
}

.form-group input,
.form-group textarea,
.form-group select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.form-actions {
  margin-top: 18px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 18px;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
}

/* 表格 */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  color: var(--text-2);
  font-weight: 600;
  font-size: 13px;
  background: #faf9ff;
}

.admin-table tr:hover td {
  background: #faf9ff;
}

.admin-table .row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* 登录页 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 36px 34px;
}

.login-card .logo {
  font-size: 26px;
  text-align: center;
  margin-bottom: 8px;
  display: block;
}

.login-sub {
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 24px;
}

.login-card .form-group {
  margin-bottom: 16px;
}

.login-hint {
  margin-top: 16px;
  font-size: 12px;
  color: #a6a3bd;
  text-align: center;
}

/* 备案设置页脚预览 */
.footer-preview {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-top: 16px;
  background: #faf9ff;
}

.footer-preview-title {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 10px;
}

.footer-preview .footer-line {
  font-size: 13px;
}

/* 徽章 */
.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
}

.badge-blue {
  background: #e0e7ff;
  color: #3730a3;
}

.badge-green {
  background: #d1fae5;
  color: #047857;
}

.badge-gray {
  background: #f1f5f9;
  color: #475569;
}

/* 响应式 */
@media (max-width: 820px) {
  .detail-wrap {
    grid-template-columns: 1fr;
  }
  .detail-cover {
    width: 140px;
    height: 195px;
    margin: 0 auto;
  }
  .detail-info {
    text-align: center;
  }
  .detail-actions {
    justify-content: center;
  }
  .admin-layout {
    grid-template-columns: 1fr;
  }
  .admin-sidebar {
    position: static;
    display: flex;
    overflow-x: auto;
    gap: 4px;
  }
  .admin-sidebar .side-title {
    display: none;
  }
  .admin-sidebar a {
    white-space: nowrap;
    margin: 0;
  }
  .search-box input {
    width: 90px;
  }
  .reader-body {
    padding: 24px 20px;
  }
}
