:root {
  --bg: #16161e;
  --bg-soft: #1e1e2a;
  --bg-card: #232332;
  --border: #33334a;
  --text: #e4e4ef;
  --text-muted: #8c8ca6;
  --accent: #a78bfa;
  --accent-soft: #2c2544;
  --danger: #f87171;
  --ok: #4ade80;
}

* { box-sizing: border-box; }

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

main { max-width: 860px; margin: 0 auto; padding: 16px; }

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

.topnav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.nav-links { display: flex; gap: 14px; align-items: center; }

.btn {
  display: inline-block; padding: 7px 14px; border-radius: 8px;
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); cursor: pointer;
  font-size: 0.92rem; font-family: inherit;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-accent { background: var(--accent); color: #16161e; border-color: var(--accent); font-weight: 600; }
.btn-danger { color: var(--danger); }
.btn-small { padding: 3px 9px; font-size: 0.82rem; }
.btn-block { width: 100%; }

.muted { color: var(--text-muted); font-size: 0.88rem; }
.error { color: var(--danger); }
.empty { color: var(--text-muted); text-align: center; padding: 40px 0; }

.login-box { max-width: 320px; margin: 18vh auto; text-align: center; }
.login-box input {
  width: 100%; padding: 11px; margin: 12px 0; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  font-size: 1rem;
}

.nav-left { display: flex; align-items: center; gap: 6px; }
.hamburger {
  background: none; border: none; color: var(--text); font-size: 1.35rem;
  cursor: pointer; padding: 2px 10px; line-height: 1;
}

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 250px; z-index: 30;
  background: var(--bg-soft); border-right: 1px solid var(--border);
  padding: 14px; padding-top: max(14px, env(safe-area-inset-top));
  transform: translateX(-105%); transition: transform 0.2s ease;
  overflow-y: auto;
}
.sidebar.open { transform: none; }
.sidebar-title {
  color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.08em; padding: 6px 10px;
}
.sidebar-sep { border-top: 1px solid var(--border); margin: 10px 0; }
.sb-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 10px; border-radius: 8px; color: var(--text); font-size: 0.95rem;
}
.sb-item:hover { background: var(--bg-card); text-decoration: none; }
.sb-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sb-count { color: var(--text-muted); font-size: 0.8rem; }

.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: none; z-index: 25; }
.overlay.show { display: block; }

.nb-heading { margin: 4px 0 14px; font-size: 1.3rem; }

@media (min-width: 1100px) {
  .sidebar { transform: none; }
  .hamburger { display: none; }
  .overlay { display: none !important; }
  .topnav { padding-left: 266px; }
  main { margin-left: 250px; }
}

.editmeta { display: flex; gap: 10px; }
.nb-input { max-width: 180px; }

.searchbar { display: flex; gap: 8px; margin-bottom: 14px; }
.searchbar input {
  flex: 1; padding: 10px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  font-size: 1rem;
}

.tagcloud { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tag {
  background: var(--accent-soft); color: var(--accent);
  padding: 3px 10px; border-radius: 999px; font-size: 0.85rem;
}
.tag:hover { text-decoration: none; filter: brightness(1.25); }
.tag-active { outline: 1px solid var(--accent); }
.tag-small { padding: 1px 8px; font-size: 0.78rem; }
.tag-clear { background: var(--bg-card); color: var(--text-muted); }

.notelist { display: flex; flex-direction: column; gap: 10px; }
.notecard {
  display: block; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; color: var(--text);
}
.notecard:hover { border-color: var(--accent); text-decoration: none; }
.notecard h2 { margin: 0 0 6px; font-size: 1.05rem; }
.snippet { margin: 0 0 8px; color: var(--text-muted); font-size: 0.88rem; overflow-wrap: anywhere; }
.notemeta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.note header { border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 16px; }
.note h1 { margin: 0 0 8px; }
.actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.actions form { display: inline; margin: 0; }

.content { font-size: 1rem; overflow-wrap: anywhere; }
.content h1, .content h2, .content h3 { color: var(--accent); margin-top: 1.4em; }
.content a { text-decoration: underline; }
.content blockquote {
  border-left: 3px solid var(--accent); margin-left: 0; padding-left: 14px;
  color: var(--text-muted);
}
.content code {
  background: var(--bg-soft); padding: 1px 6px; border-radius: 5px; font-size: 0.9em;
}
.content pre { background: var(--bg-soft); padding: 12px; border-radius: 8px; overflow-x: auto; }
.content pre code { background: none; padding: 0; }
.content table { border-collapse: collapse; }
.content td, .content th { border: 1px solid var(--border); padding: 5px 10px; }
.boxed { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 4px 18px; }

.banner {
  background: var(--accent-soft); border: 1px solid var(--accent);
  padding: 10px 14px; border-radius: 8px; margin-bottom: 14px;
}

.editform { display: flex; flex-direction: column; gap: 10px; }
.title-input, .tags-input {
  padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); font-size: 1rem;
}
.title-input { font-size: 1.25rem; font-weight: 600; }
.editform textarea {
  min-height: 50vh; padding: 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  font-family: ui-monospace, Consolas, monospace; font-size: 0.95rem;
}

/* EasyMDE — dopasowanie do ciemnego motywu */
.EasyMDEContainer .CodeMirror {
  background: var(--bg-card); color: var(--text); border-color: var(--border);
}
.EasyMDEContainer .CodeMirror-cursor { border-color: var(--text); }
.editor-toolbar { background: var(--bg-soft); border-color: var(--border); }
.editor-toolbar button { color: var(--text) !important; }
.editor-toolbar button:hover, .editor-toolbar button.active { background: var(--bg-card); }
.editor-preview { background: var(--bg); color: var(--text); }

.versions { width: 100%; border-collapse: collapse; }
.versions th { text-align: left; color: var(--text-muted); font-weight: 500; font-size: 0.85rem; }
.versions td, .versions th { padding: 8px 10px; border-bottom: 1px solid var(--border); }

.badge { padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; white-space: nowrap; }
.badge-created, .badge-imported { background: #16341f; color: var(--ok); }
.badge-edited { background: var(--accent-soft); color: var(--accent); }
.badge-deleted { background: #3a1d1d; color: var(--danger); }
.badge-restored { background: #1d303a; color: #7dd3fc; }

.diff {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; overflow-x: auto; font-size: 0.85rem; line-height: 1.45;
}
.diff-add { color: var(--ok); }
.diff-del { color: var(--danger); }
.diff-hunk { color: var(--accent); }

.statusbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  padding: 7px 16px; padding-bottom: max(7px, env(safe-area-inset-bottom));
  font-size: 0.82rem; text-align: center;
  background: var(--bg-soft); border-top: 1px solid var(--border);
}
.statusbar a { color: inherit; text-decoration: none; }
.sb-ok { color: var(--ok); }
.sb-warn { color: #fbbf24; }
.sb-err { color: var(--danger); }
main { padding-bottom: 56px; }

@media (min-width: 1100px) {
  .statusbar { padding-left: 266px; }
}

@media (max-width: 600px) {
  main { padding: 12px; padding-bottom: 56px; }
  .versions th:nth-child(4), .versions td:nth-child(4) { display: none; }
}
