* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.6; color: #1a1a1a; display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 260px; height: 100vh; background: #f5f5f5; border-right: 1px solid #ddd; padding: 24px 16px; position: fixed; top: 0; left: 0; overflow-y: auto; }
.sidebar .site-title { font-size: 16px; font-weight: 700; color: #1a1a1a; text-decoration: none; display: block; margin-bottom: 24px; }

/* Nav links */
.sidebar nav a { display: block; padding: 6px 8px; color: #1a1a1a; text-decoration: none; border-radius: 4px; font-size: 14px; margin-bottom: 2px; }
.sidebar nav a:hover { background: #e8e8e8; }
.sidebar nav a.active { background: #1a1a1a; color: #fff; }

/* Nav groups (details/summary) */
.sidebar nav details { margin-bottom: 2px; }
.sidebar nav details summary {
  padding: 6px 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  cursor: pointer;
  border-radius: 4px;
  list-style: none;
  user-select: none;
}
.sidebar nav details summary::-webkit-details-marker { display: none; }
.sidebar nav details summary::before { content: "▸ "; font-size: 10px; }
.sidebar nav details[open] summary::before { content: "▾ "; }
.sidebar nav details summary:hover { background: #e8e8e8; }
.sidebar nav details summary.active-group { color: #1a1a1a; }

/* Sub-nav */
.nav-sub { padding-left: 14px; margin-top: 2px; }
.nav-sub a { font-size: 13px; }

/* Divider */
.nav-divider { border-top: 1px solid #ddd; margin: 12px 0; }

/* Aux links */
.sidebar .aux-links { margin-top: 4px; }
.sidebar .aux-links a { font-size: 13px; color: #555; display: block; padding: 5px 8px; border-radius: 4px; text-decoration: none; margin-bottom: 2px; }
.sidebar .aux-links a:hover { background: #e8e8e8; }

/* Main content */
.main { margin-left: 260px; padding: 48px; max-width: 900px; width: 100%; }

/* Typography */
h1 { font-size: 2em; margin-bottom: 8px; }
h2 { font-size: 1.4em; margin-top: 40px; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid #eee; }
h3 { font-size: 1.1em; margin-top: 24px; margin-bottom: 8px; }
p { margin-bottom: 16px; }
ul, ol { margin: 0 0 16px 24px; }
li { margin-bottom: 4px; }
code { background: #f0f0f0; padding: 2px 5px; border-radius: 3px; font-size: 0.9em; }
pre { background: #f0f0f0; padding: 16px; border-radius: 4px; overflow-x: auto; margin-bottom: 16px; }
pre code { background: none; padding: 0; }
blockquote { border-left: 3px solid #ddd; padding-left: 16px; color: #555; margin-bottom: 16px; }
hr { border: none; border-top: 1px solid #eee; margin: 32px 0; }

/* Tables */
table { border-collapse: collapse; width: 100%; margin-bottom: 16px; display: table; }
th, td { border: 1px solid #ddd; padding: 8px 12px; text-align: left; }
th { background: #f5f5f5; font-weight: 600; }

/* Buttons */
.btn { display: inline-block; padding: 8px 16px; border-radius: 4px; text-decoration: none; font-size: 14px; margin-right: 8px; margin-bottom: 16px; border: 1px solid #ddd; color: #1a1a1a; }
.btn-primary { background: #1a1a1a; color: #fff !important; border-color: #1a1a1a; }
.btn-primary:hover { background: #333; }

/* Content accordions */
.main details { border: 1px solid #ddd; border-radius: 4px; margin-bottom: 8px; }
.main details summary { padding: 12px 16px; font-weight: 600; font-size: 15px; cursor: pointer; list-style: none; user-select: none; }
.main details summary::-webkit-details-marker { display: none; }
.main details summary::before { content: "▸ "; font-size: 11px; color: #888; }
.main details[open] summary::before { content: "▾ "; }
.main details summary:hover { background: #f9f9f9; }
.main details[open] summary { border-bottom: 1px solid #ddd; }
.main details > *:not(summary) { padding: 0 16px 16px; }

/* Edit link */
.edit-link { text-align: right; margin-bottom: 24px; }
.edit-link a { font-size: 12px; color: #999; text-decoration: none; border: 1px solid #ddd; padding: 4px 10px; border-radius: 4px; }
.edit-link a:hover { background: #f5f5f5; color: #555; }

/* Footer */
.footer { margin-top: 64px; padding-top: 16px; border-top: 1px solid #eee; font-size: 13px; color: #888; }

/* Sidebar search */
.sidebar-search-form { margin-bottom: 14px; }
.sidebar-search-input { width: 100%; padding: 6px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; background: #fff; color: #1a1a1a; }
.sidebar-search-input:focus { outline: none; border-color: #1a1a1a; }
.sidebar-search-input::placeholder { color: #aaa; }

/* Search page */
.search-page-box { margin-bottom: 32px; }
.search-page-input { width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 4px; font-size: 16px; background: #fff; color: #1a1a1a; }
.search-page-input:focus { outline: none; border-color: #1a1a1a; }
.search-count { font-size: 14px; color: #555; margin-bottom: 24px; }
.search-hint, .search-loading, .search-no-results { font-size: 14px; color: #888; }
.search-results { list-style: none; margin: 0; padding: 0; }
.search-result { padding: 18px 0; border-bottom: 1px solid #eee; }
.search-result:last-child { border-bottom: none; }
.search-result a { font-weight: 600; font-size: 16px; color: #1a1a1a; text-decoration: none; }
.search-result a:hover { text-decoration: underline; }
.search-result p { margin: 5px 0 0; font-size: 14px; color: #555; line-height: 1.5; }

/* ── Snapshot bar ── */
#snapshot-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 40px; padding-top: 16px; border-top: 1px solid #eee; }
.snap-bar-label { font-size: 10px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: #888; margin-right: 2px; flex-shrink: 0; }
.snap-btn { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; border: 1px solid #ddd; background: none; color: #888; font-size: 11px; cursor: pointer; transition: background 0.12s, border-color 0.12s, color 0.12s; font-family: inherit; }
.snap-btn:hover { background: #f5f5f5; border-color: #999; color: #555; }
.snap-btn.active { background: rgba(0,113,227,0.08); border-color: rgba(0,113,227,0.3); color: #0071e3; }

/* ── Snapshot overlay ── */
#snap-overlay { position: fixed; inset: 0; z-index: 1000; background: #fff; display: flex; flex-direction: column; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; font-size: 16px; }
#snap-overlay-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: #f5f5f5; border-bottom: 1px solid #ddd; flex-shrink: 0; gap: 16px; }
#snap-overlay-title { font-size: 13px; color: #555; }
#snap-overlay-actions { display: flex; gap: 8px; flex-shrink: 0; }
#snap-overlay-actions button { padding: 5px 12px; border-radius: 5px; font-size: 12px; cursor: pointer; font-family: inherit; }
#snap-overlay-restore-btn { background: rgba(0,113,227,0.08); border: 1px solid rgba(0,113,227,0.3); color: #0071e3; }
#snap-overlay-restore-btn:hover { background: rgba(0,113,227,0.16); }
#snap-overlay-close-btn { background: #fff; border: 1px solid #ddd; color: #1a1a1a; }
#snap-overlay-close-btn:hover { background: #f5f5f5; }
#snap-overlay-body { display: flex; flex: 1; overflow: hidden; }
#snap-overlay-nav { width: 220px; flex-shrink: 0; background: #f5f5f5; border-right: 1px solid #ddd; padding: 16px 12px; overflow-y: auto; }
.snap-nav-btn { display: block; width: 100%; text-align: left; padding: 6px 8px; font-size: 13px; background: none; border: none; border-radius: 4px; cursor: pointer; color: #1a1a1a; margin-bottom: 2px; font-family: inherit; }
.snap-nav-btn:hover { background: #e8e8e8; }
.snap-nav-btn.active { background: #1a1a1a; color: #fff; }
#snap-overlay-content { flex: 1; overflow-y: auto; padding: 48px; }
#snap-overlay-content-inner { max-width: 760px; }
#snap-overlay-content-inner h1 { font-size: 2em; margin-bottom: 8px; }
#snap-overlay-content-inner h2 { font-size: 1.4em; margin-top: 40px; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid #eee; }
#snap-overlay-content-inner h3 { font-size: 1.1em; margin-top: 24px; margin-bottom: 8px; }
#snap-overlay-content-inner p { margin-bottom: 16px; }
#snap-overlay-content-inner ul, #snap-overlay-content-inner ol { margin: 0 0 16px 24px; }
#snap-overlay-content-inner li { margin-bottom: 4px; }
#snap-overlay-content-inner code { background: #f0f0f0; padding: 2px 5px; border-radius: 3px; font-size: 0.9em; }
#snap-overlay-content-inner pre { background: #f0f0f0; padding: 16px; border-radius: 4px; overflow-x: auto; margin-bottom: 16px; }
#snap-overlay-content-inner pre code { background: none; padding: 0; }
#snap-overlay-content-inner table { border-collapse: collapse; width: 100%; margin-bottom: 16px; }
#snap-overlay-content-inner th, #snap-overlay-content-inner td { border: 1px solid #ddd; padding: 8px 12px; text-align: left; font-size: 14px; }
#snap-overlay-content-inner th { background: #f5f5f5; font-weight: 600; }
#snap-overlay-content-inner blockquote { border-left: 3px solid #ddd; padding-left: 16px; color: #555; margin-bottom: 16px; }

/* ── Restore modal ── */
#snap-restore-modal { display: none; position: fixed; inset: 0; z-index: 1100; align-items: center; justify-content: center; background: rgba(0,0,0,0.45); backdrop-filter: blur(4px); }
#snap-restore-modal.visible { display: flex; }
.srm-inner { background: #fff; border: 1px solid #ddd; border-radius: 10px; padding: 22px 24px; width: 400px; max-width: calc(100vw - 40px); box-shadow: 0 12px 40px rgba(0,0,0,0.18); }
.srm-title { font-size: 14px; font-weight: 600; color: #1a1a1a; margin-bottom: 10px; }
.srm-success { color: #16a34a; }
.srm-body { font-size: 12px; color: #555; margin-bottom: 14px; line-height: 1.55; }
.srm-body code { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 11px; background: #f0f0f0; padding: 1px 5px; border-radius: 3px; }
.srm-input { width: 100%; background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 8px 12px; color: #1a1a1a; font-size: 12px; letter-spacing: 0.15em; margin-bottom: 6px; outline: none; box-sizing: border-box; }
.srm-input:focus { border-color: #0071e3; }
.srm-error { font-size: 11.5px; color: #ef4444; min-height: 18px; margin-bottom: 10px; }
.srm-btns { display: flex; gap: 8px; }
.srm-confirm { background: rgba(0,113,227,0.1); border: 1px solid rgba(0,113,227,0.3); color: #0071e3; border-radius: 5px; padding: 6px 14px; font-size: 12px; cursor: pointer; font-family: inherit; }
.srm-confirm:hover { background: rgba(0,113,227,0.2); }
.srm-dismiss { background: none; border: 1px solid #ddd; color: #888; border-radius: 5px; padding: 6px 14px; font-size: 12px; cursor: pointer; font-family: inherit; }
.srm-dismiss:hover { border-color: #999; color: #555; }
@keyframes srm-shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)} 40%{transform:translateX(6px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)} }
.srm-shake { animation: srm-shake 0.35s ease; }
