:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e2e2e2;
  --hover: #f2f2f2;
  --active: #ebebeb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --text: #ececec;
    --muted: #949494;
    --border: #2b2b2b;
    --hover: #1d1d1d;
    --active: #232323;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Mono', monospace;
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
#sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 24px 12px;
  overflow-y: auto;
  transition: margin-left 0.2s ease;
}

body.collapsed #sidebar {
  margin-left: -260px;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 20px 12px;
}

#sidebar h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
}

#collapse-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  width: 26px;
  height: 26px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 12px;
}

#collapse-btn:hover {
  background: var(--hover);
}

#expand-btn {
  display: none;
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 10;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  width: 30px;
  height: 30px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

#expand-btn:hover {
  background: var(--hover);
}

body.collapsed #expand-btn {
  display: block;
}

.tree, .tree ul {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.tree ul {
  padding-left: 16px;
}

.tree li {
  margin: 1px 0;
}

.node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  user-select: none;
  white-space: nowrap;
}

.node:hover {
  background: var(--hover);
}

.node.active {
  background: var(--active);
  font-weight: 700;
}

.folder .node::before {
  content: "▸";
  display: inline-block;
  font-size: 0.7rem;
  color: var(--muted);
  width: 10px;
  transition: transform 0.15s ease;
}

.folder.open > .node::before {
  transform: rotate(90deg);
}

.file .node::before {
  content: "";
  width: 10px;
}

.folder > ul {
  display: none;
}

.folder.open > ul {
  display: block;
}

/* Main content */
#main {
  flex: 1;
  padding: 60px 48px;
  max-width: 720px;
}

#page-title {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-weight: 700;
  font-size: 2.4rem;
  margin: 0 0 8px 0;
  line-height: 1.15;
}

#page-date {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 32px;
}

#page-body p {
  font-size: 0.95rem;
  line-height: 1.8;
  margin: 0 0 20px 0;
}

@media (max-width: 700px) {
  #main { padding: 32px 24px 32px 56px; }
  #page-title { font-size: 1.8rem; }
}
