:root {
  --bg: #ffffff;
  --sidebar-bg: #f7f6f3;
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --border: #e6e4df;
  --accent: #6a5acd;
  --code-bg: #f2f1ee;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
}

.sidebar-header {
  padding: 0 16px 12px;
  font-weight: 600;
}
.sidebar-header a { color: var(--text); text-decoration: none; }

.tree { padding-bottom: 8px; }
.folder-name {
  padding: 4px 16px;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.folder-name::before {
  content: "▸";
  display: inline-block;
  font-size: 0.7em;
  transition: transform 0.1s ease;
}
.folder.expanded > .folder-name::before,
.folder.force-open > .folder-name::before {
  transform: rotate(90deg);
}
.folder-children { display: none; }
.folder.expanded > .folder-children,
.folder.force-open > .folder-children {
  display: block;
}
.folder .folder-children { padding-left: 12px; }

.search-box, .quick-filter {
  display: block;
  width: calc(100% - 32px);
  margin: 0 16px 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}
.search-box { margin-bottom: 6px; }
.quick-filter { margin-bottom: 14px; }

.search-results { list-style: none; padding: 0; }
.search-results li { margin-bottom: 16px; }
.search-snippet { color: var(--muted); font-size: 0.9rem; margin: 4px 0 0; }

.sidebar .note-link {
  display: block;
  padding: 4px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .note-link:hover { background: #ece9e3; }
.sidebar .note-link.active { background: var(--accent); color: #fff; }

.content {
  flex: 1;
  padding: 40px 48px;
  max-width: 800px;
}

.tags { margin-bottom: 12px; }
.tag {
  display: inline-block;
  background: var(--code-bg);
  color: var(--accent);
  border-radius: 4px;
  padding: 2px 8px;
  margin-right: 6px;
  font-size: 0.8rem;
}

article h1:first-child { margin-top: 0; }
article code {
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.9em;
}
article pre {
  background: var(--code-bg);
  padding: 12px 16px;
  border-radius: 6px;
  overflow-x: auto;
}
article pre code { background: none; padding: 0; }
article blockquote {
  margin: 0;
  padding-left: 16px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
article table { border-collapse: collapse; width: 100%; }
article th, article td { border: 1px solid var(--border); padding: 6px 10px; }
article img { max-width: 100%; }

.broken-link {
  color: #b23b3b;
  border-bottom: 1px dashed #b23b3b;
  cursor: help;
}

@media (max-width: 700px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .content { padding: 24px; }
}
