:root {
  --bg: #111418;
  --panel: #171b21;
  --panel2: #1d232b;
  --border: #2a2f36;
  --text: #e8e8e8;
  --muted: #9aa4b2;
  --accent: #4c9aff;
  --danger: #ff6b6b;
  --ok: #5fd08a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, sans-serif;
}
.hidden { display: none !important; }

.login { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-box h1 { margin: 0 0 8px; font-size: 20px; }
.err { color: var(--danger); min-height: 18px; font-size: 12px; }

input, textarea, button {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}
input:focus, textarea:focus { outline: 1px solid var(--accent); }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }

#app { display: grid; grid-template-columns: 300px 1fr; height: 100vh; }
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
  overflow: hidden;
}
.brand { display: flex; align-items: center; justify-content: space-between; }
.brand h1 { font-size: 18px; margin: 0; }
.list { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.list .item {
  padding: 7px 9px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  border: 1px solid transparent;
  display: flex; justify-content: space-between; gap: 8px;
}
.list .item:hover { background: var(--panel2); color: var(--text); }
.list .item .kind { font-size: 11px; color: var(--muted); opacity: .7; }
#search-hits { border-bottom: 1px solid var(--border); padding-bottom: 8px; }

main { overflow-y: auto; padding: 20px 26px; }
.note-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.note-head .title { flex: 1; font-size: 22px; font-weight: 600; border: 1px solid transparent; background: transparent; }
.note-head .title:focus { border-color: var(--border); }
.note-actions { display: flex; gap: 8px; }
.tags { margin: 8px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 10px; font-size: 12px; color: var(--muted);
}
.preview {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  min-height: 200px;
  overflow-x: auto;
}
.preview h1 { font-size: 20px; } .preview h2 { font-size: 17px; } .preview h3 { font-size: 15px; }
.preview a { color: var(--accent); text-decoration: none; }
.preview a:hover { text-decoration: underline; }
.preview code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.preview pre { background: var(--panel2); padding: 10px; border-radius: 6px; overflow-x: auto; }
.preview blockquote { border-left: 3px solid var(--accent); margin: 0; padding-left: 12px; color: var(--muted); }
.preview table { border-collapse: collapse; } .preview td, .preview th { border: 1px solid var(--border); padding: 4px 8px; }
#note-body { width: 100%; min-height: 320px; font-family: ui-monospace, monospace; font-size: 13px; }

.note-meta { display: grid; grid-template-columns: 220px 1fr; gap: 18px; margin-top: 16px; }
.note-meta h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
#note-links, #note-backlinks { display: flex; flex-direction: column; gap: 4px; }
.link-item { color: var(--accent); cursor: pointer; font-size: 13px; }
.link-item:hover { text-decoration: underline; }
.hint { font-weight: 400; text-transform: none; letter-spacing: 0; }

#graph { width: 100%; height: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }

.review-head { display: flex; justify-content: space-between; align-items: center; }
.q-item { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; margin-bottom: 12px; }
.q-question { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.q-answer { color: var(--muted); white-space: pre-wrap; }
.q-btns { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.q-btns button { font-size: 13px; }
.q-meta { font-size: 11px; color: var(--muted); margin-top: 8px; }