:root {
  --bg: #f6f1e8;
  --bg-sidebar: #efe8db;
  --bg-content: #fffdf8;
  --text: #2d2a26;
  --text-dim: #7a7266;
  --accent: #1a7f6b;
  --accent-soft: #e2efe9;
  --border: #e4dccd;
  --code-bg: #f0eadd;
  --shadow: 0 1px 2px rgba(0,0,0,.05);
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #121417;
  --bg-sidebar: #191c21;
  --bg-content: #1d2127;
  --text: #e8e4dc;
  --text-dim: #9a938a;
  --accent: #4db39a;
  --accent-soft: #243b34;
  --border: #2a2e35;
  --code-bg: #262b31;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 300px; min-width: 300px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 10px;
  font-weight: 700; font-size: 20px; letter-spacing: -0.02em;
}
.brand-mark { color: var(--accent); font-size: 22px; }
.search {
  margin: 6px 14px 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-content); color: var(--text);
  font-size: 14px; outline: none;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.note-list { flex: 1; overflow-y: auto; padding: 0 10px 10px; }
.note-item {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%; text-align: left; padding: 10px 12px; margin: 2px 0;
  border: none; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--text); font-size: 14px;
}
.note-item:hover { background: var(--accent-soft); }
.note-item.active { background: var(--accent); color: #fff; }
.note-item.active .note-date { color: rgba(255,255,255,.75); }
.note-title { font-weight: 600; line-height: 1.3; }
.note-date { font-size: 11.5px; color: var(--text-dim); }

.sidebar-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim);
}
.ghost-btn {
  border: 1px solid var(--border); background: var(--bg-content);
  color: var(--text); border-radius: 8px; padding: 6px 9px; cursor: pointer;
  font-size: 14px; line-height: 1;
}

/* ---------- Content ---------- */
.content {
  flex: 1; overflow-y: auto; background: var(--bg-content);
  padding: 48px clamp(24px, 8vw, 96px) 96px;
}
.empty { color: var(--text-dim); text-align: center; margin-top: 18vh; }
.empty-mark { font-size: 48px; color: var(--border); margin-bottom: 8px; }

.note-head { margin-bottom: 28px; border-bottom: 1px solid var(--border); padding-bottom: 16px; }
.note-head h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -0.02em; }
.note-meta { color: var(--text-dim); font-size: 13px; }
.tags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}

.article { font-family: var(--serif); font-size: 17.5px; line-height: 1.75; max-width: 720px; }
.article h2 { font-family: var(--sans); font-size: 22px; margin: 1.6em 0 .5em; letter-spacing: -0.01em; }
.article h3 { font-family: var(--sans); font-size: 18px; margin: 1.4em 0 .4em; }
.article p { margin: .9em 0; }
.article a { color: var(--accent); }
.article ul, .article ol { padding-left: 1.4em; margin: .8em 0; }
.article li { margin: .3em 0; }
.article blockquote {
  margin: 1.1em 0; padding: 2px 0 2px 18px;
  border-left: 3px solid var(--accent); color: var(--text-dim);
}
.article code {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: .85em; background: var(--code-bg); padding: 2px 6px; border-radius: 6px;
}
.article pre {
  background: var(--code-bg); padding: 14px 16px; border-radius: 10px;
  overflow-x: auto; font-size: 14px; line-height: 1.5;
}
.article pre code { background: transparent; padding: 0; font-size: 13.5px; }
.article hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

/* ---------- Mobile ---------- */
.hamburger, .scrim { display: none; }
@media (max-width: 720px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 30;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .hamburger {
    display: block; position: fixed; top: 12px; left: 12px; z-index: 40;
    background: var(--bg-content); border: 1px solid var(--border);
    border-radius: 9px; padding: 8px 11px; cursor: pointer; color: var(--text);
  }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 20;
    background: rgba(0,0,0,.35);
  }
  .content { padding: 64px 20px 80px; }
}
