/* ============================================================
   藏书阁 —— 全局样式表
   极简几何科技风，深色底配浅色字
   ============================================================ */

/* --- CSS 变量 --- */
:root {
  --bg-deep: #0a0a0a;
  --bg-page: #0f0f0f;
  --bg-card: #1a1a1a;
  --bg-card-hover: #222222;
  --bg-surface: #141414;
  --bg-input: #1a1a1a;
  --border: #2a2a2a;
  --border-light: #333;
  --text-primary: #e0e0e0;
  --text-secondary: #999;
  --text-muted: #666;
  --accent: #ffffff;
  --accent-dim: #aaa;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
  --radius: 6px;
  --radius-lg: 10px;
  --transition-fast: 0.15s ease;
  --transition: 0.25s ease;
  --transition-slow: 0.4s ease;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --max-read: 700px;
}

/* --- Reset --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent);
}

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

/* --- 公告条 --- */
.announcement-bar {
  position: sticky;
  top: 0;
  z-index: 101;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 24px;
  background: linear-gradient(90deg, rgba(255, 180, 80, 0.15), rgba(255, 140, 60, 0.12));
  border-bottom: 1px solid rgba(255, 180, 80, 0.3);
  color: #ffd591;
  font-size: 0.875rem;
  text-align: center;
  justify-content: center;
  flex-wrap: wrap;
}
.announcement-bar .announcement-icon {
  font-size: 1rem;
}
.announcement-bar .announcement-text {
  flex: 1;
  min-width: 0;
}
.announcement-bar .announcement-close {
  background: none;
  border: none;
  color: #ffd591;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.announcement-bar .announcement-close:hover {
  opacity: 1;
}

/* --- 导航栏 --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.navbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--accent);
}

.navbar-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.navbar-links a {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
}

/* 移动端导航 */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
}

@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }
  .navbar-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: rgba(10, 10, 10, 0.98);
    backdrop-filter: blur(12px);
    flex-direction: column;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    gap: 2px;
  }
  .navbar-links.open {
    display: flex;
  }
  .navbar-links a {
    padding: 10px 14px;
    font-size: 0.9rem;
  }
}

/* --- 主容器 --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* --- 搜索栏 --- */
.search-bar {
  position: relative;
  margin-bottom: 24px;
}

.search-bar input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast);
  outline: none;
}

.search-bar input:focus {
  border-color: #555;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.search-bar .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

/* --- 筛选器 --- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.filter-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: #555;
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
  font-weight: 600;
}

/* --- 分类选择器（geometric tabs） --- */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.category-tab {
  padding: 10px 20px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.category-tab:hover {
  color: var(--text-primary);
}

.category-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- 文本卡片列表 --- */
.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card:hover::before {
  opacity: 1;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
  line-height: 1.4;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.card-tag {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.card-excerpt {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 0.95rem;
}

/* --- 搜索高亮 --- */
mark {
  background: rgba(255, 255, 255, 0.2);
  color: var(--accent);
  padding: 0 2px;
  border-radius: 2px;
}

/* --- 阅读页 --- */
.reading-container {
  max-width: var(--max-read);
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.reading-header {
  margin-bottom: 36px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.reading-title {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 12px;
}

.reading-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.reading-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.reading-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.reading-tag {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.reading-content {
  font-size: var(--reading-font-size, 1.05rem);
  line-height: 1.9;
  color: var(--text-primary);
  word-break: break-word;
}

.reading-content p {
  margin-bottom: 1.2em;
}

/* 阅读背景变体 */
body.reading-bg-pure { background: #000000; }
body.reading-bg-dark { background: #0f0f0f; }
body.reading-bg-deeper { background: #050505; }

/* 阅读背景图覆盖层 */
.reading-bg-image {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--bg-img-opacity, 0.15);
  filter: blur(var(--bg-img-blur, 0px));
  pointer-events: none;
}

/* --- 浮动工具栏 --- */
.toolbar-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}

.toolbar-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: scale(1.05);
}

.toolbar-panel {
  position: fixed;
  bottom: 88px;
  right: 28px;
  width: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  z-index: 199;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transition: all var(--transition);
}

.toolbar-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.toolbar-panel h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.toolbar-row label {
  flex-shrink: 0;
}

.toolbar-row .value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  min-width: 40px;
  text-align: right;
}

/* 滑块 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  margin: 4px 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-card);
  cursor: pointer;
}

/* 预设按钮组 */
.preset-group {
  display: flex;
  gap: 6px;
  margin: 8px 0;
}

.preset-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.preset-btn:hover {
  border-color: #555;
  color: var(--text-primary);
}

.preset-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
}

.preset-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--border);
}

/* 文件上传 */
.file-upload-label {
  display: block;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin: 8px 0;
}

.file-upload-label:hover {
  border-color: #555;
  color: var(--text-secondary);
}

.file-upload-label input {
  display: none;
}

/* --- 管理页 --- */
.admin-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 24px;
}

.admin-container h1 {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.admin-container .subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.form-section {
  margin-bottom: 28px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.form-section h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: #555;
}

.form-group textarea {
  min-height: 200px;
  resize: vertical;
  line-height: 1.7;
}

/* 分类勾选网格 */
.category-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.category-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: background var(--transition-fast);
}

.category-check-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.category-check-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 500;
}

.btn:hover {
  border-color: #555;
  background: var(--bg-card-hover);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover {
  background: #e0e0e0;
  border-color: #e0e0e0;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

.btn-danger {
  background: transparent;
  border-color: #5a2d2d;
  color: #df8f8f;
}

.btn-danger:hover {
  background: rgba(223, 143, 143, 0.08);
  border-color: #8f4f4f;
  color: #ffaaaa;
}

/* 上传行 */
.upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

/* 文本列表（删除区） */
.text-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.text-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.text-item:hover {
  border-color: var(--border-light);
}

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

.text-item-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 消息提示 */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  z-index: 999;
  animation: toastIn 0.3s ease;
  font-family: var(--font-sans);
}

.toast-success {
  background: #1a3a1a;
  border: 1px solid #2d5a2d;
  color: #8fdf8f;
}

.toast-error {
  background: #3a1a1a;
  border: 1px solid #5a2d2d;
  color: #df8f8f;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- 开场页 --- */
.landing {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  background: transparent;
}

.landing > * {
  pointer-events: auto;
}

#particle-canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: block;
  background: #ffffff;
}

.landing-title {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-align: center;
  color: #000000;
  margin-bottom: 48px;
  text-shadow: 0 0 24px rgba(255,255,255,0.8);
}

.landing-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  margin-bottom: 40px;
  text-align: center;
}

.btn-enter {
  padding: 14px 48px;
  border: 1px solid rgba(0,0,0,0.4);
  border-radius: 2px;
  background: rgba(255,255,255,0.6);
  color: #000000;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  letter-spacing: 0.15em;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.landing-notice {
  color: rgba(255, 213, 145, 0.9);
  font-size: 0.85rem;
  margin: 0 0 24px 0;
  text-align: center;
  letter-spacing: 0.05em;
}

.btn-enter:hover {
  background: #000000;
  color: #ffffff;
  border-color: #000000;
}

.btn-enter:active {
  transform: translateY(1px);
}

/* 响应式 */
@media (max-width: 600px) {
  .landing-title {
    font-size: 1.8rem;
  }
  .container {
    padding: 16px;
  }
  .card-list {
    grid-template-columns: 1fr;
  }
  .reading-container {
    padding: 24px 16px 80px;
  }
  .toolbar-panel {
    width: calc(100vw - 40px);
    right: 20px;
    bottom: 80px;
  }
  .reading-title {
    font-size: 1.4rem;
  }
}

/* --- 通用工具类 --- */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
