/* ====================================================================
   晚安中国 · 全站公共样式 (Notion 简约文档风)
   主色 #2563eb / 辅助 #64748b / 背景 #F7F6F3 / 文字 #1A1F36
   ==================================================================== */

:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1e56d8;
  --color-primary-soft: rgba(37, 99, 235, 0.06);
  --color-secondary: #64748b;
  --color-bg: #F7F6F3;
  --color-card: #ffffff;
  --color-text: #1A1F36;
  --color-text-soft: #4b5563;
  --color-muted: #9ca3af;
  --color-border: #e9e6e1;
  --color-border-soft: #f1efec;
  --color-success: #059669;
  --color-warn: #d97706;
  --color-danger: #dc2626;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.05);
  --shadow-hover: 0 8px 24px rgba(15, 23, 42, 0.08);
  --font-sans: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

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

html, body { height: 100%; }

::selection { background: rgba(37, 99, 235, 0.14); }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  letter-spacing: 0.005em;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ---------- 布局 ---------- */
.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}
.page-wide {
  max-width: 1140px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}

/* ---------- 顶部导航 ---------- */
.topbar {
  width: 100%;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  color: var(--color-text);
}
.brand .dot {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.topbar nav a {
  color: var(--color-secondary);
  font-size: 14px;
  margin-left: 22px;
}
.topbar nav a:hover { color: var(--color-primary); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card + .card { margin-top: 18px; }
.card-hover { transition: box-shadow .25s ease, transform .25s ease; }
.card-hover:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease,
              box-shadow .18s ease, transform .18s ease;
  line-height: 1.35;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover { background: var(--color-primary-hover); box-shadow: 0 4px 10px rgba(37, 99, 235, 0.22); }
.btn-ghost {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-soft);
}
.btn-ghost:hover { background: var(--color-primary-soft); color: var(--color-primary); border-color: rgba(37,99,235,.25); }
.btn-soft {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.btn-soft:hover { background: rgba(37, 99, 235, 0.12); }
.btn-danger {
  background: transparent;
  color: var(--color-danger);
  border-color: rgba(220, 38, 38, 0.25);
}
.btn-danger:hover { background: rgba(220, 38, 38, 0.06); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.label {
  display: block;
  font-size: 13px;
  color: var(--color-secondary);
  margin-bottom: 7px;
  font-weight: 500;
}
.input, .textarea, .select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .18s ease, box-shadow .18s ease;
  line-height: 1.5;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
.input::placeholder { color: var(--color-muted); }
.textarea { resize: vertical; min-height: 90px; }

/* ---------- 标题 ---------- */
.h1 { font-size: 30px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 8px; line-height: 1.3; }
.h2 { font-size: 22px; font-weight: 700; letter-spacing: -.005em; margin-bottom: 6px; line-height: 1.35; }
.h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; line-height: 1.4; }
.subtle { color: var(--color-secondary); font-size: 14px; }
.link { color: var(--color-primary); font-size: 14px; text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .15s ease; }
.link:hover { border-bottom-color: var(--color-primary); }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.section-title h2 { font-size: 18px; font-weight: 600; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--color-border-soft);
  color: var(--color-secondary);
}
.tag-green { background: rgba(5,150,105,.1); color: #047857; }
.tag-red { background: rgba(220,38,38,.08); color: #b91c1c; }
.tag-blue { background: var(--color-primary-soft); color: var(--color-primary); }
.tag-muted { background: rgba(100,116,139,.1); color: var(--color-secondary); }

/* ---------- 提示条 ---------- */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error { background: rgba(239,68,68,.07); border-color: rgba(239,68,68,.2); color: #b91c1c; }
.alert-success { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.22); color: #047857; }
.alert-info { background: var(--color-primary-soft); border-color: rgba(37,99,235,.18); color: var(--color-primary); }
.alert[hidden] { display: none; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--color-border); background: #fff; }
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th, .table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border-soft);
  vertical-align: middle;
}
.table th {
  background: #fbfbfa;
  font-weight: 600;
  color: var(--color-secondary);
  font-size: 12px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fcfbf9; }

/* ---------- 统计卡片 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
  font-size: 13px;
  color: var(--color-secondary);
  margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.stat-card .stat-value.text-primary { color: var(--color-primary); }
.stat-card .stat-value.text-green { color: var(--color-success); }
.stat-card .stat-value.text-muted { color: var(--color-muted); }

/* ---------- 杂志卡片网格 ---------- */
.mag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.mag-item {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .25s ease, transform .25s ease;
}
.mag-item:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.mag-cover {
  aspect-ratio: 3/4;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  font-weight: 700;
  font-size: 15px;
  padding: 18px;
  text-align: center;
  position: relative;
}
.mag-cover::before {
  content: "PDF";
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(37,99,235,.12);
  color: var(--color-primary);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.mag-meta { padding: 14px; }
.mag-meta .t { font-weight: 600; font-size: 14px; margin-bottom: 4px; line-height: 1.4; }
.mag-meta .d { color: var(--color-secondary); font-size: 12.5px; line-height: 1.5; }
.mag-action-btn {
  display: flex;
  width: 100%;
  justify-content: center;
  margin-top: 12px;
  text-decoration: none;
}

/* ---------- 阅读器 ---------- */
.reader-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #e8e6e2;
}
.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  z-index: 10;
}
.reader-title { font-weight: 600; font-size: 15px; }
.reader-controls { display: flex; align-items: center; gap: 6px; }
.reader-canvas-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 16px 56px;
}
.pdf-page-canvas {
  background: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.08);
  border-radius: 3px;
  margin-bottom: 14px;
  max-width: 100%;
  height: auto;
}
.reader-loading {
  padding: 40px;
  text-align: center;
  color: var(--color-secondary);
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--color-secondary);
}
.empty .icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: .5;
}

/* ---------- 工具类 ---------- */
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--color-secondary); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }
.hidden { display: none !important; }
.break-all { word-break: break-all; }
.cursor-pointer { cursor: pointer; }

/* ---------- 进度/加载 ---------- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 分隔 ---------- */
.divider { height: 1px; background: var(--color-border); margin: 20px 0; }
.hr-soft { height: 1px; background: var(--color-border-soft); margin: 14px 0; }

/* ---------- 移动端 ---------- */
@media (max-width: 768px) {
  .page { padding: 36px 16px 60px; }
  .page-wide { padding: 28px 14px 60px; }
  .h1 { font-size: 24px; }
  .h2 { font-size: 19px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .topbar-inner { padding: 0 14px; }
  .topbar nav a { margin-left: 14px; font-size: 13px; }
  .reader-header { padding: 10px 14px; }
  .reader-title { font-size: 14px; }
  .mag-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .table th, .table td { padding: 9px 10px; font-size: 12.5px; }
  .pdf-page-canvas { max-width: 100% !important; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .reader-controls .btn-text { display: none; }
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(26, 31, 54, 0.32);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.16);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
}
.modal-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border-soft);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-foot { padding: 14px 24px; border-top: 1px solid var(--color-border-soft); display: flex; justify-content: flex-end; gap: 10px; }
.close-btn {
  background: none; border: none;
  width: 30px; height: 30px; border-radius: 6px;
  font-size: 20px; color: var(--color-secondary);
  cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.close-btn:hover { background: var(--color-border-soft); color: var(--color-text); }

/* ---------- 封面缩略图 ---------- */
.mag-thumb {
  width: 40px;
  height: 54px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  flex-shrink: 0;
}
.mag-thumb-placeholder {
  width: 40px;
  height: 54px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  color: var(--color-primary);
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* 封面上传预览（弹窗内） */
.cover-preview {
  width: 90px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
}
.cover-preview-placeholder {
  width: 90px;
  height: 120px;
  border-radius: 6px;
  border: 1px dashed var(--color-border);
  background: #faf9f7;
  color: var(--color-muted);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* ---------- 拖拽排序 ---------- */
.drag-handle {
  cursor: grab;
  color: var(--color-muted);
  font-size: 16px;
  user-select: none;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }
tr.dragging { opacity: .4; background: #faf9f7 !important; }
tr.drag-over { border-top: 2px solid var(--color-primary); }

/* 分类卡片拖拽 */
.cat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.cat-item.dragging { opacity: .4; }
.cat-item.drag-over { border-color: var(--color-primary); border-top: 2px solid var(--color-primary); }
.cat-item:hover { box-shadow: var(--shadow-sm); }
.cat-item .cat-name { flex: 1; font-weight: 500; font-size: 14px; }
.cat-item .cat-count { font-size: 12px; color: var(--color-muted); }

/* 会员侧封面图（替代旧文字封面） */
.mag-item .mag-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.mag-item .mag-cover.has-cover::before { display: none; }
.mag-item .mag-cover.has-cover { background: #f3f1ed; }
