/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ===== CSS Variables ===== */
:root {
  --bg: #fafcfa;
  --bg-secondary: #eef3ee;
  --text: #1a1a1a;
  --text-muted: #6b7b6b;
  --text-faint: #a8bda8;
  --border: #d0dfd0;
  --accent: #4a9e5c;
  --accent-secondary: #2d7a3e;
  --accent-tertiary: #7bc47b;
  --pink: #e8729a;
  --pink-soft: #f0a0bb;
  --link: #4a9e5c;
  --code-bg: #eef3ee;
  --status-active: #4a9e5c;
  --status-idle: #ffca7f;
  --status-away: #e8729a;
  --sidebar-width: 280px;
  --header-mark: #2d7a3e;
}

[data-theme="dark"] {
  --bg: #0c160c;
  --bg-secondary: #132013;
  --text: #c8dcc8;
  --text-muted: #6b8a6b;
  --text-faint: #3a5a3a;
  --border: #1e3a1e;
  --accent: #5cbf6e;
  --accent-secondary: #8ed69e;
  --accent-tertiary: #3da64f;
  --pink: #f0859f;
  --pink-soft: #c46b88;
  --link: #5cbf6e;
  --code-bg: #0a150a;
  --header-mark: #8ed69e;
}

/* ===== Base ===== */
body {
  padding: 40px;
  max-width: 1000px;
  margin: 0 auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 20px;
  color: var(--text);
  background: var(--bg);
  transition: background 0.3s, color 0.3s;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6, p { margin: 14px 0; }
h1, h2, h3, h4, h5, h6 { font-weight: 600; }

h1 a, h2 a, h3 a { color: inherit; }
h1 a:hover, h2 a:hover, h3 a:hover { text-decoration: underline; }

h1 { color: var(--accent); }
h1::before { content: "# "; color: var(--pink); opacity: 0.4; }

h2 { color: var(--accent-secondary); }
h2::before { content: "## "; color: var(--pink-soft); opacity: 0.35; }

h3 { color: var(--accent-tertiary); }
h3::before { content: "### "; color: var(--pink-soft); opacity: 0.3; }

a { color: var(--link); }
a:hover { text-decoration: underline; }

hr { margin: 24px 0; border: none; border-bottom: 1px solid var(--border); }

/* ===== Layout ===== */
.site-wrapper { display: flex; gap: 0; }

aside {
  position: sticky;
  top: 40px;
  align-self: flex-start;
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  padding-right: 32px;
  border-right: 1px solid var(--border);
  margin-right: 32px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

aside::-webkit-scrollbar { width: 4px; }
aside::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.content-area { flex: 1; min-width: 0; }

@media (max-width: 767px) {
  body { padding: 20px; }
  .site-wrapper { flex-direction: column; }
  aside {
    position: static;
    max-width: 100%;
    min-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 20px;
    margin-right: 0;
    margin-bottom: 24px;
    max-height: none;
  }
}

/* ===== User Card ===== */
.user { margin-bottom: 20px; }
.user .name { margin: 0; font-size: 14px; }
.user .name::before { content: ""; }
.user .name a { color: var(--text); }
.user .name a:hover { color: var(--accent); }
.user .status {
  margin: 2px 0 0 0;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user .status::before { content: ""; }
.user .status .active::before { content: "● "; color: var(--status-active); }
.user .status .idle::before { content: "● "; color: var(--status-idle); }
.user .status .away::before { content: "● "; color: var(--status-away); }

/* ===== Theme Toggle ===== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  transition: all 0.2s;
  margin-bottom: 16px;
}
.theme-toggle:hover {
  border-color: var(--pink);
  color: var(--pink);
}

/* ===== Tree (Sidebar) ===== */
.tree { }
.entry { padding: 3px 0; }
summary { cursor: pointer; list-style: none; user-select: none; }
summary::-webkit-details-marker { display: none; }
details .tree { padding-left: 18px; border-left: 1px solid var(--border); margin-left: 9px; }

.entry .name { text-decoration: none; color: var(--text); font-size: 12px; }
.entry .name:hover { color: var(--accent); text-decoration: underline; }
.entry .name.active { color: var(--pink); font-weight: 600; }

.filename { display: flex; align-items: center; column-gap: 6px; }

.tree-count {
  font-size: 10px;
  color: var(--text-faint);
  margin-left: auto;
  padding: 0 5px;
  background: var(--bg-secondary);
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}

.icon {
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  opacity: 0.7;
}

/* ===== Content Headers ===== */
.headers {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  opacity: 0.5;
  font-size: 12px;
}
.headers li { padding: 1px 0; }

/* ===== Markdown Content ===== */
.markdown p { white-space: pre-wrap; }
.markdown hr { max-width: 60px; }
.markdown ul, .markdown ol { margin: 12px 0; }
.markdown li { padding: 2px 0; }
.markdown li::before { content: "- "; opacity: 0.25; }
.markdown ol li::before { content: none; }
.markdown ol { list-style: decimal; padding-left: 24px; }

.markdown a { color: var(--link); }
.markdown a:hover { text-decoration: underline; }

.markdown code {
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.markdown pre {
  background: var(--code-bg);
  padding: 14px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 14px 0;
  border: 1px solid var(--border);
}
.markdown pre code { background: none; padding: 0; border-radius: 0; }

.markdown blockquote {
  border-left: 3px solid var(--pink);
  padding-left: 14px;
  color: var(--text-muted);
  margin: 14px 0;
}

.markdown img { border-radius: 6px; margin: 14px 0; }

.markdown table {
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 12px;
}
.markdown th, .markdown td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.markdown th { background: var(--bg-secondary); font-weight: 600; }

/* Task list */
.markdown .task-list-item { display: flex; align-items: center; gap: 6px; }
.markdown .task-list-item::before { content: none; }
.markdown input[type="checkbox"] { margin: 0; }

/* ===== Page Title ===== */
.page-title {
  margin-bottom: 8px;
}
.page-title::before { content: ""; }

/* ===== Home ===== */
.home-intro { color: var(--text-muted); margin-bottom: 24px; }
.recent-notes h2::before { content: ""; }

.note-list { margin-top: 12px; }
.note-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.note-item:last-child { border-bottom: none; }
.note-item .note-title { color: var(--text); }
.note-item .note-title:hover { color: var(--accent); }
.note-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: 12px; }
.note-item .note-date { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.note-section { font-size: 10px; color: var(--text-faint); padding: 1px 5px; background: var(--bg-secondary); border-radius: 3px; }

/* ===== Empty ===== */
.empty-state { color: var(--text-muted); padding: 40px 0; }

/* ===== Git Graph Timeline ===== */
.timeline-page .page-title { margin-bottom: 4px; }

.git-subtitle {
  color: var(--text-faint);
  margin-bottom: 24px;
  font-size: 12px;
}

/* Legend */
.gg-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.gg-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}
.gg-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* Graph wrapper */
.gg-wrapper {
  display: flex;
  position: relative;
  overflow-x: auto;
}

.gg-svg {
  flex-shrink: 0;
}

.gg-info {
  flex: 1;
  min-width: 0;
}

/* Each row */
.gg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  border-radius: 3px;
  cursor: default;
}
.gg-row:hover { background: var(--bg-secondary); }

/* Branch label row */
.gg-branch {
  font-weight: 600;
  font-size: 12px;
  color: var(--accent-secondary);
}

/* Commit info */
.gg-hash {
  color: var(--accent);
  font-size: 11px;
  min-width: 32px;
  opacity: 0.7;
  flex-shrink: 0;
}

.gg-title {
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
a.gg-title:hover { color: var(--accent); text-decoration: underline; }

.gg-ref {
  font-size: 11px;
  flex-shrink: 0;
  margin-left: 4px;
}

.gg-folder {
  font-size: 10px;
  flex-shrink: 0;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-secondary);
  font-weight: 600;
}

.gg-legend-date {
  font-size: 10px;
  opacity: 0.6;
}

/* SVG dots */
.gg-dot { transition: r 0.15s; cursor: pointer; }

/* ===== Footer ===== */
.site-footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
}
.site-footer p { margin: 8px 0 0 0; }
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }

.footer-icons {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 4px;
}
.footer-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--text-faint);
  transition: color 0.2s, transform 0.2s;
}
.footer-icon svg { width: 18px; height: 18px; }
.footer-icon:hover { color: var(--accent); transform: scale(1.15); text-decoration: none; }
