:root {
  --bg: #fbfaf7;
  --panel: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e5e2da;
  --accent: #6d4aff;
  --sidebar: 320px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1c1f; --panel: #222327; --text: #e8e6e3; --muted: #9aa0a6; --border: #34363b; --accent: #a48bff; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; }

#sidebar {
  width: var(--sidebar); height: 100%; display: flex; flex-direction: column; gap: .6rem;
  padding: 1rem; background: var(--panel); border-right: 1px solid var(--border); z-index: 2;
}
#sidebar header h1 { margin: .3rem 0 .1rem; font-size: 1.35rem; }
.home { color: var(--muted); text-decoration: none; font-size: .85rem; }
.home:hover { color: var(--accent); }
.muted { color: var(--muted); margin: 0; font-size: .85rem; }

#search {
  width: 100%; padding: .55rem .7rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: .95rem;
}
#categories { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); border-radius: 999px; padding: .2rem .6rem;
  font-size: .8rem; cursor: pointer;
}
.chip.off { opacity: .4; }
.dot { width: .65rem; height: .65rem; border-radius: 50%; display: inline-block; flex: none; }

#list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#list li { padding: .55rem .4rem; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 6px; }
#list li:hover { background: var(--bg); }
#list li strong { display: flex; align-items: center; gap: .4rem; font-size: .95rem; }
#list li span { color: var(--muted); font-size: .8rem; }

#map { flex: 1; height: 100%; }

.leaflet-popup-content { font-size: .9rem; line-height: 1.4; }
.popup h3 { margin: 0 0 .25rem; font-size: 1rem; }
.popup .cat { color: #6b7280; font-size: .8rem; margin-bottom: .4rem; }
.popup .actions { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.popup button, .popup a.btn {
  border: 0; border-radius: 6px; padding: .35rem .6rem; font-size: .8rem; cursor: pointer;
  background: #6d4aff; color: #fff !important; text-decoration: none;
}
.popup a.btn.secondary { background: #eeeaff; color: #4b2fd1 !important; }

#reader {
  position: fixed; top: 0; right: 0; width: min(480px, 100%); height: 100%; overflow-y: auto;
  background: var(--panel); border-left: 1px solid var(--border); z-index: 1000;
  box-shadow: -8px 0 24px rgba(0,0,0,.12);
}
.reader-bar {
  position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center;
  padding: .7rem 1rem; background: var(--panel); border-bottom: 1px solid var(--border);
}
.reader-bar button { border: 0; background: none; font-size: 1.1rem; cursor: pointer; color: var(--text); }
.reader-bar a { color: var(--accent); font-weight: 600; text-decoration: none; }
#reader-body { padding: 1rem 1.4rem 3rem; line-height: 1.6; }
#reader-body img { max-width: 100%; }
#reader-body a { color: var(--accent); }
#reader-body blockquote { border-left: 3px solid var(--accent); margin: 0; padding-left: 1rem; color: var(--muted); }

#toggle-sidebar {
  display: none; position: fixed; top: .8rem; left: .8rem; z-index: 1001; width: 2.6rem; height: 2.6rem;
  border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 1.2rem;
}
@media (max-width: 760px) {
  #toggle-sidebar { display: block; }
  #sidebar { position: fixed; inset: 0 auto 0 0; width: 85%; max-width: 360px; transform: translateX(-100%); transition: transform .2s; z-index: 1002; padding-top: 3.8rem; }
  body.show-sidebar #sidebar { transform: none; }
}
