/* ===== 寺院知识库 - 暗黑主题（匹配AI红楼读书会风格） ===== */
:root {
  --bg-main: #111111;
  --bg-section: #181818;
  --bg-card: #202020;
  --text-main: #f4f4f4;
  --text-secondary: #c7c7c7;
  --accent: #ffb347;
  --accent-blue: #2f80ff;
  --border-soft: #2b2b2b;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  display: flex;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

/* 金银闪烁粒子背景 */
#sparkleCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.2;
}

/* ===== 侧边栏 ===== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 220px;
  background: var(--bg-section);
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
  z-index: 10;
  padding-bottom: 2rem;
}

.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-soft);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  display: inline;
}

.sidebar-header .nav-count {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 6px;
}

.sidebar-nav {
  padding: 8px 0;
}

.nav-item {
  padding: 6px 16px 6px 24px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: rgba(255, 179, 71, 0.08);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(255, 179, 71, 0.12);
  color: var(--accent);
}

.nav-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.nav-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  font-size: 11px;
  color: #666;
  flex-shrink: 0;
}

.nav-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 6px 12px;
}

.nav-section {
  padding: 8px 16px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-main);
}

.nav-subgroup-header {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s;
}

.nav-subgroup-header:hover {
  color: var(--accent);
}

.nav-subgroup-header.open {
  color: var(--accent);
}

.nav-arrow {
  font-size: 10px;
  width: 14px;
}

.nav-subgroup .nav-item {
  padding-left: 32px;
}

.nav-group-header {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  transition: color 0.15s;
}

.nav-group-header:hover {
  color: var(--accent);
}

.nav-group-header.open {
  color: var(--accent);
}

.nav-group .nav-item {
  padding-left: 32px;
}

/* ===== 主内容区 ===== */
.main-area {
  margin-left: 220px;
  flex: 1;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 8px;
  z-index: 20;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 18px;
  cursor: pointer;
}

/* ===== Hero 封面 ===== */
.hero-cover {
  position: relative;
  width: 100%;
  height: 280px;
  overflow: hidden;
}

.hero-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  filter: brightness(0.6);
}

.hero-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 32px;
  background: linear-gradient(to top, rgba(17,17,17,0.9) 0%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hero-left {
  flex: 1;
}

.hero-title {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.hero-right {
  flex-shrink: 0;
}

.hero-back-link {
  display: inline-block;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(8px);
  color: #fff;
  text-decoration: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,0.2);
  transition: background 0.2s;
}

.hero-back-link:hover {
  background: rgba(255,255,255,0.2);
}

/* ===== 页面内容 ===== */
.page-content {
  padding: 24px 32px;
}

/* Intro section */
.intro-section { margin: 0 0 1.5rem 0; }

.intro-main {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.stat-highlight {
  flex-shrink: 0;
  text-align: center;
  padding: 0.8rem 1.2rem;
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-soft);
}

.stat-num-big {
  display: block;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.stat-label-big { font-size: 0.9rem; color: var(--text-secondary); }

.intro-text { flex: 1; }
.intro-text p {
  font-size: 15px;
  line-height: 2.04;
  color: var(--text-secondary);
  margin: 0 0 0.6rem 0;
}
.intro-credit { color: var(--text-secondary); font-style: italic; margin-top: 0.8rem !important; }
.intro-credit strong { color: var(--accent); }

/* Feedback section */
.feedback-section {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 1.2rem 1.5rem;
  margin-top: 1rem;
}
.feedback-title { font-size: 15px; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-main); }
.feedback-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin: 0 0 0.8rem 0; }
.feedback-btn {
  display: inline-block;
  background: linear-gradient(135deg, #ffb347, #ff9f43);
  color: #1a1a1a;
  text-decoration: none;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.2s;
}
.feedback-btn:hover { opacity: 0.9; }

/* ===== Notion 内容样式 (暗色版) ===== */
.notion-h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 24px 0 16px;
  color: var(--text-main);
}

.notion-h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-main);
}

.notion-h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--text-main);
}

.notion-text {
  font-size: 15px;
  line-height: 2.1;
  margin: 6px 0;
  color: var(--text-secondary);
}

.notion-text strong { color: var(--text-main); }

.notion-li {
  font-size: 14px;
  line-height: 2.04;
  margin: 4px 0 4px 20px;
  color: var(--text-secondary);
}

.notion-callout {
  display: flex;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 12px 0;
}

.callout-icon { font-size: 18px; flex-shrink: 0; }
.callout-text { flex: 1; font-size: 14px; line-height: 1.92; color: var(--text-secondary); }

.notion-quote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 12px 0;
  font-style: italic;
  color: var(--text-secondary);
}

.notion-divider {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 20px 0;
}

.notion-img {
  margin: 16px 0;
  border-radius: 8px;
  overflow: hidden;
}

.notion-img img {
  max-width: 640px;
  width: 100%;
  border-radius: 8px;
  margin: 0 auto;
  display: block;
}

.notion-img {
  text-align: center;
}

.notion-img figcaption {
  font-size: 12px;
  color: #666;
  text-align: center;
  margin-top: 6px;
}

.notion-toggle {
  margin: 8px 0;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  overflow: hidden;
}

.notion-toggle summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  background: var(--bg-card);
}

.notion-toggle > *:not(summary) {
  padding: 0 14px 10px;
}

.notion-bookmark {
  display: block;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 13px;
  color: var(--accent-blue);
  margin: 8px 0;
}

.notion-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
}

.notion-table th, .notion-table td {
  padding: 8px 12px;
  border: 1px solid var(--border-soft);
  text-align: left;
  color: var(--text-secondary);
}

.notion-table th {
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 600;
}

/* ===== Card Grid (首页) ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin: 16px 0 32px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 179, 71, 0.3);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.card-cover {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.cover-placeholder {
  height: 120px;
  background: linear-gradient(135deg, var(--bg-section), var(--bg-card));
}

.card-body {
  padding: 10px 12px;
}

.card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.card-meta {
  font-size: 11px;
  color: #888;
  line-height: 1.4;
}

/* ===== Feedback form ===== */
.feedback-form { max-width: 640px; margin: 2rem auto; padding: 0 1rem; }
.feedback-form h2 { font-size: 1.5rem; margin-bottom: 1rem; color: var(--text-main); }
.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.4rem; color: var(--text-main); font-size: 14px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 0.6rem 0.8rem; border: 1px solid var(--border-soft); border-radius: 6px;
  font-size: 14px; font-family: inherit; box-sizing: border-box;
  background: var(--bg-card); color: var(--text-main);
}
.form-group textarea { min-height: 120px; resize: vertical; }
.form-group input:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,179,71,0.2);
}
.submit-btn {
  background: linear-gradient(135deg, #ffb347, #ff9f43);
  color: #1a1a1a; border: none; padding: 0.7rem 2rem;
  border-radius: 6px; font-size: 15px; cursor: pointer; font-weight: 600;
}
.submit-btn:hover { opacity: 0.9; }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.success-msg { display:none; background: rgba(46,204,113,0.15); color: #2ecc71; padding: 1rem; border-radius: 6px; margin-top: 1rem; border: 1px solid rgba(46,204,113,0.3); }
.back-link { display:inline-block; margin-bottom:1rem; color:var(--accent); text-decoration:none; }
.back-link:hover { text-decoration:underline; }

/* ===== Mobile ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
    z-index: 100;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-area {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: block;
  }
  .intro-main {
    flex-direction: column;
    gap: 1rem;
  }
  .stat-highlight {
    align-self: flex-start;
  }
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
  .page-content {
    padding: 16px;
  }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-main); }
::-webkit-scrollbar-thumb { background: var(--border-soft); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* ========== Image Editor Toolbar ========== */
.img-edit-wrap { position: relative; }

.img-toolbar {
  position: absolute; top: 8px; right: 8px; z-index: 100;
  opacity: 1; transition: opacity .2s;
  display: flex; gap: 6px; background: rgba(0,0,0,.85); border-radius: 10px; padding: 6px 8px;
}
.img-toolbar button {
  background: none; border: none; color: #ffb347; cursor: pointer; font-size: 22px; padding: 6px 10px; border-radius: 6px;
}
.img-toolbar button:hover { background: rgba(255,179,71,.2); }
.img-toolbar input[type=range] { width: 80px; accent-color: #ffb347; margin: 4px 0; }
.hero-cover .img-toolbar { top: 8px; right: 8px; }
.img-pos-label { color: #ccc; font-size: 11px; line-height: 28px; white-space: nowrap; }
.img-replace-input { display: none; }

/* ===== 原生标题样式（内容区域） ===== */
.page-content h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 24px 0 16px;
  color: var(--text-main);
}

.page-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-main);
}

.page-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 10px;
  color: var(--text-main);
}

/* h2后面紧跟h3时，加大间距 */
.page-content h2 + h3 {
  margin-top: 20px;
}

/* strong标签在内容区域中的样式 */
.callout-text strong, .notion-li strong, .notion-text strong {
  color: var(--text-main);
  font-weight: 600;
}
