/* ============================================
   ADoc — Clean document site theme
   VitePress / Stripe Docs inspired
   ============================================ */

/* ===== Local Inter font ===== */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 300; font-display: swap; src: url('/docs/static/fonts/Inter-Light.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/docs/static/fonts/Inter-Regular.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/docs/static/fonts/Inter-Medium.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/docs/static/fonts/Inter-SemiBold.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/docs/static/fonts/Inter-Bold.woff2') format('woff2'); }
@font-face { font-family: 'Instrument Serif'; font-style: italic; font-weight: 400; font-display: swap; src: url('/docs/static/fonts/InstrumentSerif-Italic.woff2') format('woff2'); }

:root {
  --sidebar-w: 270px;
  --toc-w: 220px;
  --content-max: 760px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Noto Sans SC', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', Menlo, Consolas, monospace;
  --font-serif: 'Instrument Serif', Georgia, serif;
  --c-title: #1c1917;
  --c-body: #57534e;
  --c-link: #44403c;
  --c-link-hover: #1c1917;
  --c-muted: #78716c;
  --c-faint: #a8a29e;
  --c-border: #e7e5e4;
  --c-border-light: #e7e5e4;
  --c-bg: #fefefe;
  --c-sidebar-bg: #f5f5f3;
  --c-code-bg: #1b1b1f;
  --c-hover-bg: rgba(28,25,23,0.04);
  --navbar-h: 0px;
  --transition: 0.2s ease;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--c-body);
  background: var(--c-bg);
  line-height: 1.7;
}

/* ===== Layout ===== */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Top Navbar (removed) ===== */

/* ===== Search Modal ===== */
.search-modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}
.search-modal-overlay.active { display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.search-modal {
  width: 560px; max-width: calc(100vw - 32px);
  background: #fff; border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.05);
  overflow: hidden;
  animation: modalSlideIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn { from { opacity: 0; transform: translateY(-12px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.search-modal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
}
.search-modal-header svg { flex-shrink: 0; color: var(--c-faint); }
.search-modal-input {
  flex: 1; border: none; outline: none;
  font-size: 16px; font-family: var(--font-sans);
  color: var(--c-title); background: transparent;
}
.search-modal-input::placeholder { color: var(--c-faint); }
.search-modal-esc {
  font-size: 11px; color: var(--c-faint);
  border: 1px solid var(--c-border); border-radius: 4px;
  padding: 2px 8px; background: var(--c-hover-bg);
}
.search-modal-body {
  max-height: 400px; overflow-y: auto;
  padding: 8px;
}
.search-modal-body:empty { display: none; }
.search-modal-empty {
  padding: 40px 20px; text-align: center;
  color: var(--c-faint); font-size: 14px;
}
.search-modal-item {
  display: block; padding: 10px 14px;
  text-decoration: none; border-radius: 2px;
  transition: background 0.1s;
}
.search-modal-item:hover, .search-modal-item.active { background: var(--c-hover-bg); }
.search-modal-item-title {
  font-size: 14px; font-weight: 500; color: var(--c-title);
  line-height: 1.4;
}
.search-modal-item-excerpt {
  font-size: 12px; color: var(--c-muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-modal-item mark {
  background: #fef08a; color: inherit; border-radius: 2px; padding: 0 1px;
}
.search-modal-footer {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  border-top: 1px solid var(--c-border);
  font-size: 12px; color: var(--c-faint);
}
.search-modal-footer kbd {
  font-family: var(--font-sans); font-size: 11px;
  border: 1px solid var(--c-border); border-radius: 3px;
  padding: 1px 5px; background: var(--c-hover-bg);
  margin-right: 2px;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--c-sidebar-bg);
  border-right: 1px solid var(--c-border-light);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar header */
.sidebar-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--c-border);
}
.sidebar-logo-link {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; transition: opacity var(--transition);
}
.sidebar-logo-link:hover { opacity: 0.8; }
.sidebar-logo {
  width: 30px; height: 30px; border-radius: 2px;
  background: linear-gradient(135deg, var(--c-title) 0%, #374151 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.site-title {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic; font-size: 22px; font-weight: 700; color: #1c1917;
}
.sidebar-logo-img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }

/* Sidebar search button */
.sidebar-search-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid var(--c-border); border-radius: 2px;
  background: var(--c-hover-bg); color: var(--c-faint);
  font-size: 13px; font-family: var(--font-sans);
  cursor: pointer; transition: border-color var(--transition), box-shadow var(--transition);
}
.sidebar-search-btn:hover { border-color: #a8a29e; box-shadow: 0 0 0 3px rgba(28,25,23,0.06); }
.sidebar-search-btn kbd {
  font-size: 11px; font-family: var(--font-sans);
  border: 1px solid var(--c-border); border-radius: 4px;
  padding: 1px 6px; background: #fff; color: var(--c-faint);
  margin-left: auto;
}

/* Sidebar nav */
.sidebar-nav {
  flex: 1; padding: 4px 10px 20px;
  overflow-y: auto; overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; }
.sidebar-nav:hover::-webkit-scrollbar-thumb { background: #d1d5db; }

.nav-group { margin-bottom: 8px; }
.nav-group-title {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 10px;
  margin: 0; background: none; border: none;
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: #333333; cursor: pointer; user-select: none;
  transition: color var(--transition);
}
.nav-group:not(:first-child) .nav-group-title { padding-top: 20px; }
.nav-group-title:hover { color: var(--c-title); }

.nav-chevron {
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
  opacity: 0.4;
}
.nav-group.collapsed .nav-chevron { transform: rotate(-90deg); }
.nav-group.collapsed .nav-pages {
  max-height: 0; overflow: hidden; opacity: 0; margin: 0;
}
.nav-pages {
  margin: 0; padding: 0; margin-left: 8px; border-left: 1px solid var(--c-border);
  max-height: 2000px; opacity: 1;
  transition: max-height 0.35s cubic-bezier(0.25, 0.1, 0.25, 1), opacity 0.3s ease;
}
.nav-link {
  display: block;
  padding: 7px 14px;
  font-size: 13px; font-weight: 400; color: #333333;
  line-height: 1.5; text-decoration: none;
  border-left: 2px solid transparent;
  margin: 1px 8px 1px 0;
  border-radius: 0;
  transition: all 0.15s ease;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-link:hover {
  color: #1c1917;
  background: rgba(0,0,0,0.04);
}
.nav-link.active {
  color: #1c1917;
  font-weight: 500;
  border-left: 2px solid #1c1917;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--c-border-light);
  font-size: 11px; color: var(--c-faint); opacity: 0.7;
}

/* ===== Main Wrapper ===== */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex; flex-direction: column;
  margin-top: var(--navbar-h);
}

/* ===== Content Header / Breadcrumb ===== */
.content-header {
  position: sticky; top: var(--navbar-h);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: 10px 40px;
  z-index: 50;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition);
}
.content-header.scrolled { border-bottom-color: var(--c-border); }

.menu-toggle {
  display: none; background: none; border: none;
  cursor: pointer; padding: 4px; color: var(--c-muted); border-radius: 6px;
}
.menu-toggle:hover { background: var(--c-hover-bg); }

.breadcrumb { font-size: 13px; color: var(--c-faint); }
.breadcrumb a { color: var(--c-muted); text-decoration: none; transition: color var(--transition); }
.breadcrumb a:hover { color: var(--c-title); }
.breadcrumb .sep { margin: 0 8px; color: #d1d5db; }
.breadcrumb-current { color: var(--c-body); }

/* ===== Content Body ===== */
.content-body {
  display: flex; flex: 1;
}

/* ===== Article ===== */
.article-wrapper { flex: 1; min-width: 0; }
.article {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 40px 48px 4rem;
}

/* Page title */
.page-category {
  font-size: 12px;
  color: #a8a29e;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.page-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 2.4rem;
  font-weight: 400;
  color: var(--c-title);
  margin: 0 0 0.5rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.page-description {
  font-size: 16px;
  color: var(--c-muted);
  margin-top: 0.5em;
  margin-bottom: 2em;
  line-height: 1.6;
}

/* ===== Markdown content — github-markdown-css overrides ===== */
.markdown-body {
  font-family: var(--font-sans);
  color: var(--c-body);
  line-height: 1.8;
  background: transparent;
  font-size: 14.5px;
}

/* Headings */
.markdown-body h1 {
  font-size: 2.4rem; font-weight: 400;
  color: var(--c-title); letter-spacing: -0.02em;
  margin-top: 0; padding-bottom: 0; border-bottom: none;
}
.markdown-body h2 {
  font-size: 1.5rem; font-weight: 600;
  color: var(--c-title); letter-spacing: 0.01em;
  margin-top: 2em; padding-top: 24px;
  border-top: 1px solid var(--c-border); border-bottom: none !important; padding-bottom: 0 !important;
}
.markdown-body h3 {
  font-size: 1.2rem; font-weight: 600;
  color: var(--c-title); letter-spacing: -0.005em;
  margin-top: 1.5em; margin-bottom: 0.5em;
}
.markdown-body h4 {
  font-size: 1rem; font-weight: 600;
  color: var(--c-title); margin-top: 24px;
}

/* Paragraphs */
.markdown-body p { margin: 0 0 1em; }

/* Lists */
.markdown-body ul, .markdown-body ol { padding-left: 1.5em; margin: 16px 0; }
.markdown-body li { font-size: 16px; line-height: 1.7; margin-bottom: 0.3em; }
.markdown-body li + li { margin-top: 6px; }
.markdown-body li > p { margin: 4px 0; }
.markdown-body li::marker { color: var(--c-faint); }

/* Links */
.markdown-body a {
  color: var(--c-link); font-weight: 500;
  text-decoration: underline; text-decoration-color: rgba(68,64,60,0.3);
  text-underline-offset: 2px;
  transition: color var(--transition), text-decoration-color var(--transition);
}
.markdown-body a:hover { color: var(--c-link-hover); text-decoration-color: var(--c-link-hover); }

/* Images */
.markdown-body img {
  max-width: 375px; width: 100%; height: auto;
  border-radius: 12px; margin: 16px 0;
  display: block; cursor: zoom-in;
}

/* Blockquote */
.markdown-body blockquote {
  border-left: 3px solid #d6d3d1;
  padding: 0.5em 1em; margin: 20px 0;
  background: rgba(28,25,23,0.03);
  border-radius: 0 2px 2px 0;
  color: var(--c-muted);
}
.markdown-body blockquote p { margin: 4px 0; }

/* Inline code */
.markdown-body :not(pre) > code {
  font-size: 0.88em; color: #44403c;
  background: rgba(142,150,170,0.12);
  border-radius: 2px; padding: 0.15em 0.4em;
  font-family: var(--font-mono);
}

/* Code blocks */
.markdown-body pre {
  background: var(--c-code-bg) !important;
  color: #dfdfd6 !important;
  border-radius: 2px; padding: 1em 1.2em;
  overflow-x: auto; line-height: 1.7;
  margin: 20px 0;
}
.markdown-body pre code {
  background: transparent !important; color: inherit !important;
  font-size: 12.5px; font-family: var(--font-mono);
}

/* Tables */
.markdown-body table { border-collapse: collapse; width: 100%; margin: 20px 0; }
.markdown-body tr { border-top: 1px solid var(--c-border); }
.markdown-body tr:nth-child(2n) { background: #f9fafb; }
.markdown-body th, .markdown-body td { border: 1px solid var(--c-border); padding: 0.5em 0.8em; font-size: 0.9em; }
.markdown-body th { font-size: 13px; font-weight: 600; color: var(--c-muted); background: var(--c-hover-bg); text-align: left; }

/* Horizontal rule */
.markdown-body hr {
  display: none !important;
}

/* Header anchors */
.markdown-body .header-anchor {
  color: var(--c-faint); text-decoration: none;
  margin-left: 0.25em; opacity: 0;
  transition: opacity 0.15s;
}
.markdown-body h2:hover .header-anchor,
.markdown-body h3:hover .header-anchor { opacity: 1; }

/* ===== Pager (VitePress style) ===== */
.pager { display: flex; gap: 16px; margin-top: 40px; padding-top: 24px; }
.pager-link { flex: 1; display: block; border: 1px solid #e2e2e3; border-radius: 2px; padding: 12px 16px; text-decoration: none; transition: border-color 0.25s; }
.pager-link:hover { border-color: #1c1917; }
.pager-prev { text-align: left; }
.pager-next { text-align: right; margin-left: auto; }
.pager-label { display: block; font-size: 12px; color: #78716c; font-weight: 500; margin-bottom: 4px; }
.pager-title { display: block; font-size: 14px; color: #1c1917; font-weight: 500; }

/* ===== TOC (right sidebar) ===== */
.toc {
  width: var(--toc-w); flex-shrink: 0;
  position: sticky; top: calc(var(--navbar-h) + 48px);
  align-self: flex-start;
  padding: 0 16px 32px 0;
  max-height: calc(100vh - var(--navbar-h) - 80px);
  overflow-y: auto;
}
.toc::-webkit-scrollbar { width: 3px; }
.toc::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.toc:hover::-webkit-scrollbar-thumb { background: #d1d5db; }

.toc-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--c-faint); margin-bottom: 12px;
  padding-left: 12px;
}
.toc-nav { display: flex; flex-direction: column; gap: 1px; }
.toc-link {
  display: block;
  padding: 4px 0 4px 12px;
  font-size: 12.5px; color: var(--c-faint);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
  line-height: 1.5;
}
.toc-link:hover { color: var(--c-body); border-left-color: #d1d5db; }
.toc-link.active {
  color: #1c1917; font-weight: 500;
  border-left-color: #1c1917;
}
.toc-h3 { padding-left: 24px; }
.toc-h3.active { padding-left: 22px; }

/* ===== Footer ===== */
.footer {
  padding: 24px 40px;
  text-align: center;
  font-size: 12px; color: var(--c-faint);
}

/* ===== Mobile Overlay ===== */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; top: var(--navbar-h);
  background: rgba(0,0,0,0.3);
  z-index: 99;
  transition: opacity 0.3s ease;
}
body.sidebar-open .sidebar-overlay { display: block; }

/* ===== Old search dropdown (sidebar, kept for fallback) ===== */
.search-dropdown {
  display: none;
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff; border: 1px solid var(--c-border); border-radius: 2px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  max-height: 340px; overflow-y: auto; z-index: 200; margin-top: 4px;
}
.search-dropdown-item {
  display: block; padding: 10px 14px;
  text-decoration: none; transition: background 0.1s;
}
.search-dropdown-item:hover { background: var(--c-hover-bg); }
.search-dropdown-title { font-size: 14px; font-weight: 600; color: var(--c-title); }
.search-dropdown-excerpt { font-size: 12px; color: var(--c-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-dropdown-empty { padding: 16px; text-align: center; color: var(--c-faint); font-size: 14px; }
.search-dropdown mark { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 1px; }

/* ===== Homepage / Sites ===== */
.sites-page { max-width: 800px; margin: 0 auto; padding: 100px 24px 60px; }
.sites-header { text-align: center; margin-bottom: 48px; }
.sites-header h1 {
  font-size: 2.5rem; font-weight: 700; color: var(--c-title);
  margin: 0 0 12px; letter-spacing: -0.02em; line-height: 1.2;
}
.sites-header p { color: #666; font-size: 1.1rem; margin: 0; }

.sites-search { max-width: 480px; margin: 32px auto 48px; }
.sites-search-wrapper { position: relative; }
.sites-search-icon {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  color: var(--c-faint); pointer-events: none;
}
.sites-search input {
  width: 100%; padding: 12px 20px 12px 48px;
  border: 1px solid var(--c-border); border-radius: 100px;
  font-size: 15px; font-family: var(--font-sans);
  background: #fff; color: var(--c-title); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.sites-search input::placeholder { color: var(--c-faint); }
.sites-search input:focus { border-color: #a8a29e; box-shadow: 0 0 0 3px rgba(28,25,23,0.06); }
.search-dropdown-home { border-radius: 12px; }

.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.site-card {
  display: block; padding: 24px; background: #fff;
  border: 1px solid var(--c-border); border-radius: 10px;
  text-decoration: none;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.site-card:hover {
  border-color: #d1d5db;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  transform: translateY(-2px);
}
.site-card h2 { margin: 0 0 4px; font-size: 1rem; font-weight: 600; color: var(--c-title); }
.site-card .site-id { margin: 0; font-size: 12px; color: var(--c-faint); }
.no-sites { text-align: center; color: var(--c-faint); padding: 60px 20px; grid-column: 1 / -1; }

/* ===== Error Page ===== */
.error-page {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100vh; text-align: center; padding: 24px;
}
.error-page h1 { font-size: 6rem; font-weight: 800; color: var(--c-border); margin: 0; }
.error-page p { color: var(--c-muted); font-size: 1.1rem; margin: 8px 0 32px; }
.error-page a {
  color: var(--c-title); text-decoration: none;
  padding: 10px 24px; border: 1px solid var(--c-border);
  border-radius: 100px; font-size: 14px;
  transition: all 0.15s;
}
.error-page a:hover { background: var(--c-title); color: #fff; border-color: var(--c-title); }

/* ===== Search Page ===== */
.search-form { display: flex; gap: 8px; margin: 24px 0; }
.search-form input {
  flex: 1; padding: 10px 16px;
  border: 1px solid var(--c-border); border-radius: 2px;
  font-size: 15px; font-family: var(--font-sans); outline: none;
}
.search-form input:focus { border-color: #a8a29e; box-shadow: 0 0 0 3px rgba(28,25,23,0.06); }
.search-form button {
  padding: 10px 24px; background: var(--c-title); color: #fff;
  border: none; border-radius: 2px;
  font-size: 14px; font-family: var(--font-sans); cursor: pointer;
  transition: background var(--transition);
}
.search-form button:hover { background: #000; }
.search-results { margin-top: 24px; }
.search-result { padding: 16px 0; }
.search-result h3 { margin: 0 0 4px; font-size: 1rem; }
.search-result h3 a { color: var(--c-title); text-decoration: none; }
.search-result h3 a:hover { text-decoration: underline; }
.search-result p { margin: 4px 0 0; color: var(--c-muted); font-size: 14px; }
.result-slug { font-size: 12px; color: var(--c-faint); font-family: var(--font-mono); }
.no-results { color: var(--c-faint); margin-top: 16px; }

/* ===== Highlight.js ===== */
.hljs { background: var(--c-code-bg) !important; }
.hljs-keyword { color: #f97583; }
.hljs-string { color: #9ecbff; }
.hljs-number { color: #79b8ff; }
.hljs-comment { color: #6a737d; }
.hljs-function .hljs-title { color: #b392f0; }
.hljs-built_in { color: #79b8ff; }
.hljs-attr { color: #9ecbff; }
.hljs-tag { color: #85e89d; }
.hljs-variable { color: #ffab70; }
.hljs-title { color: #b392f0; }
.hljs-params { color: #e1e4e8; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ===== Selection ===== */
::selection { background: rgba(87,83,78,0.15); color: #1c1917; }

/* ===== Print ===== */
@media print {
  .sidebar, .toc, .content-header, .footer, .menu-toggle,
  .sidebar-overlay, .top-navbar, .search-modal-overlay,
  .pager, .navbar-hamburger { display: none !important; }
  .main-wrapper { margin-left: 0 !important; margin-top: 0 !important; }
  .article { max-width: 100%; padding: 0; }
  .markdown-body a { color: inherit; text-decoration: underline; }
  .markdown-body a::after { content: " (" attr(href) ")"; font-size: 0.85em; color: #666; }
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .toc { display: none; }
}

@media (max-width: 768px) {
  .navbar-hamburger { display: flex; align-items: center; }
  .navbar-search-btn span { display: none; }
  .navbar-search-btn { min-width: auto; }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.sidebar-open,
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.1);
  }
  .main-wrapper { margin-left: 0 !important; }
  .menu-toggle { display: flex; }
  .content-header { padding: 10px 16px; }
  .article { padding: 1.5rem 16px !important; }
  .page-title, .markdown-body h1 { font-size: 1.5rem !important; }
  .markdown-body h2 { font-size: 1.25rem !important; }
  .markdown-body img { max-width: 100% !important; border-radius: 12px !important; }
  .footer { padding: 20px 16px; }
  .sites-page { padding: 48px 16px; }
  .sites-header h1 { font-size: 2rem; }
  .sites-grid { grid-template-columns: 1fr; }
  .pager { flex-direction: column; }
  .pager-link { max-width: 100%; }
  .pager-next { margin-left: 0; }
  .search-modal { width: calc(100vw - 16px); }
}

/* Tome h2 # decoration */
/* h2 # 装饰已移除 */

/* Tome h1 — italic serif */
.tome-content h1, .markdown-body h1 {
  font-family: var(--font-serif) !important;
  font-style: italic !important;
  font-weight: 400 !important;
  font-size: 2.4rem !important;
}
/* h1 不要 # 装饰 */
.tome-content h1::before, .markdown-body h1::before { content: none !important; }

/* ===== Lightbox ===== */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.85);
  cursor: zoom-out;
  justify-content: center;
  align-items: center;
}
.lightbox-overlay.active {
  display: flex;
}
.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

/* ===== Grain texture overlay ===== */
.grain-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px;
}
