:root {
  /* Dark Theme (Default) */
  --bg: #0a0a0a;
  --bg-elevated: #111111;
  --bg-sidebar: #0d0d0d;
  --border: #2a2a2a;
  --text: #e8e6e3;
  --text-muted: #888888;
  --text-dim: #555555;
  --accent: #c9a96e;
  --accent-dim: #8a7a52;
  --radius: 8px;
  --font: "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code", monospace;
}

/* Automatically detect browser/OS theme preferences */
@media (prefers-color-scheme: light) {
  :root {
    /* Light Theme Overrides */
    --bg: #fdfdfd;
    --bg-elevated: #f4f4f4;
    --bg-sidebar: #f9f9f9;
    --border: #e0e0e0;
    --text: #1a1a1a;
    --text-muted: #555555;
    --text-dim: #888888;
    --accent: #9a762e;
    --accent-dim: #c7b693;
  }
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
}

.archive-root {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* LEFT SIDEBAR */
.left-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.left-head {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  margin-bottom: 10px;
}

.left-head .logo-mark {
  padding: 4px 12px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 16px; /* Changed to a pill shape to fit words */
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.left-head h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  font-weight: 600;
}

.section-list {
  list-style: none;
  padding: 8px 0;
  flex: 1;
}

.section-list li {
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: all 0.15s ease;
  border-left: 2px solid transparent;
}

.section-list li:hover {
  color: var(--text);
  background: rgba(150,150,150,0.05);
}

.section-list li.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(201,169,110,0.05);
}

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 16px 16px 6px;
  font-weight: 600;
}

/* MAIN CONTENT */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.main-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 50px 60px;
}

.article-meta {
  margin-bottom: 32px;
}

.article-meta h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.byline {
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

.divider {
  margin: 24px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 12px;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.article-body {
  max-width: 100%;
  font-size: 17px;
  line-height: 1.8;
  padding-right: 20px;
}

.article-body p {
  margin-bottom: 1.4em;
  text-align: justify;
  hyphens: auto;
}

.article-body .annot {
  border-bottom: 1px dashed var(--accent-dim);
  cursor: pointer;
  color: var(--accent);
  transition: all 0.2s ease;
  padding: 0 2px;
}

.article-body .annot:hover {
  background: rgba(201,169,110,0.1);
  border-bottom-style: solid;
}

.article-body .annot.active {
  background: rgba(201,169,110,0.15);
  border-bottom: 1px solid var(--accent);
}

.article-body em, .article-body i { color: var(--text-muted); font-style: italic; }
.article-body strong { color: var(--text); font-weight: 600; }
.article-body blockquote {
  border-left: 2px solid var(--accent-dim);
  padding-left: 16px;
  margin: 1.5em 0;
  color: var(--text-muted);
}

.article-body h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 2em 0 0.8em;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.article-body h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 1.5em 0 0.6em;
  color: var(--text-muted);
}

/* RIGHT SIDEBAR */
.right-sidebar {
  width: 360px;
  min-width: 360px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), background 0.3s ease, border-color 0.3s ease;
}

.right-sidebar.collapsed {
  transform: translateX(100%);
  margin-left: -360px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  font-weight: 600;
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.sidebar-close:hover {
  background: rgba(150,150,150,0.1);
  color: var(--text);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.sidebar-quote {
  font-style: italic;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.7;
  padding: 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  border-left: 2px solid var(--accent-dim);
  margin-bottom: 24px;
}

.sidebar-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
}

/* Sidebar reopen handle */
.sidebar-handle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 60px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 6px 0 0 6px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 14px;
  z-index: 10;
}
