:root {
  --bg: #ffffff;
  --bg-side: #fafafa;
  --fg: #18181b;
  --muted: #71717a;
  --border: #e7e7ea;
  --accent: #5e6ad2;
  --accent-weak: #eef0fb;
  --danger: #dc2626;
  --radius: 10px;
  --topbar: 48px;
  --sidebar: 290px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--fg); font-size: 15px; line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.spacer { flex: 1; }

/* ---------- topbar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar); z-index: 50;
  display: flex; align-items: center; gap: 8px; padding: 0 14px;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.logo .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
#hamburger { display: none; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--fg); padding: 4px 8px; border-radius: 6px; }
button {
  font: inherit; border-radius: 8px; border: 1px solid var(--border); background: #fff;
  padding: 6px 14px; cursor: pointer; color: var(--fg); transition: background 0.15s, border-color 0.15s;
}
button:hover { background: var(--bg-side); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: #4c56c0; }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--accent-weak); }

/* ---------- layout ---------- */
#layout { display: flex; height: 100vh; padding-top: var(--topbar); }
#sidebar {
  width: var(--sidebar); flex-shrink: 0; background: var(--bg-side);
  border-right: 1px solid var(--border); overflow-y: auto; padding: 12px;
}
#main { flex: 1; overflow-y: auto; min-width: 0; }

/* ---------- sidebar içerik ---------- */
#search {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; background: #fff; margin-bottom: 10px; outline: none;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.tsec { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 14px 4px 6px; }
#tree details { margin-bottom: 2px; }
#tree summary { cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; font-weight: 600; font-size: 13.5px; user-select: none; }
#tree summary:hover { background: #f0f0f2; }
#tree summary .fi { font-size: 9px; color: var(--muted); transition: transform 0.12s; }
#tree details[open] summary .fi { transform: rotate(90deg); }
#tree .cnt { margin-left: auto; font-size: 11px; color: var(--muted); background: #ececef; border-radius: 20px; padding: 0 7px; }
#tree .note { display: flex; align-items: center; gap: 7px; padding: 4px 6px 4px 18px; border-radius: 6px; color: var(--fg); font-size: 13.5px; }
#tree .note:hover { background: #f0f0f2; text-decoration: none; }
#tree .note .fi { font-size: 8px; color: #b8b8c0; }
#tree .note .p { margin-left: auto; font-size: 11px; color: var(--muted); }
#tree .empty { color: var(--muted); font-size: 13px; padding: 10px 4px; }

/* ---------- ana içerik ---------- */
.loading { padding: 60px; text-align: center; color: var(--muted); }
.empty { padding: 60px; text-align: center; color: var(--muted); }
.home { max-width: 720px; margin: 0 auto; padding: 48px 32px 80px; }
.home h1 { font-size: 32px; letter-spacing: -0.03em; margin-bottom: 4px; }
.muted { color: var(--muted); font-size: 14px; }
.home h2 { font-size: 15px; margin: 36px 0 12px; letter-spacing: -0.01em; }
.stats { display: flex; gap: 12px; margin: 24px 0; }
.card { flex: 1; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.card b { font-size: 26px; letter-spacing: -0.02em; }
.card span { color: var(--muted); font-size: 13px; }
.big-link { display: inline-block; margin-top: 8px; font-weight: 600; }
.recent { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rrow { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--fg); }
.rrow:last-child { border-bottom: none; }
.rrow:hover { background: var(--bg-side); text-decoration: none; }
.rrow .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.rrow .rt { font-weight: 600; }
.rrow .p { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px; color: var(--fg); font-size: 13px; }
.chip:hover { background: var(--bg-side); text-decoration: none; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.chip b { color: var(--muted); font-weight: 600; }

/* ---------- not görünümü ---------- */
.note-wrap { max-width: 760px; margin: 0 auto; padding: 32px 36px 90px; }
.note-top { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.crumb { font-size: 13px; color: var(--muted); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tag { font-size: 12px; background: var(--accent-weak); color: var(--accent); padding: 2px 10px; border-radius: 20px; font-weight: 600; }
.md { font-size: 15.5px; }
.md h1 { font-size: 27px; letter-spacing: -0.02em; margin: 6px 0 18px; }
.md h2 { font-size: 20px; margin: 30px 0 10px; letter-spacing: -0.01em; }
.md h3 { font-size: 17px; margin: 24px 0 8px; }
.md p { margin: 10px 0; }
.md ul, .md ol { margin: 10px 0; padding-left: 24px; }
.md li { margin: 4px 0; }
.md code { background: #f4f4f5; border-radius: 5px; padding: 1.5px 6px; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.md pre { background: #f4f4f5; border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; margin: 14px 0; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--accent); padding-left: 14px; color: var(--muted); margin: 12px 0; }
.md table { border-collapse: collapse; margin: 14px 0; width: 100%; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.md th { background: var(--bg-side); font-weight: 600; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.meta { margin-top: 26px; font-size: 12.5px; }

/* ---------- editör ---------- */
.fields { display: flex; flex-direction: column; gap: 10px; }
.fields input, .fields select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; outline: none; background: #fff;
}
.fields input:focus, .fields select:focus, .fields textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.fields input[disabled] { background: var(--bg-side); color: var(--muted); }
.frow { display: flex; gap: 10px; }
.frow input { flex: 1; }
.frow select { width: 150px; }
.fields textarea {
  min-height: 55vh; padding: 14px; border: 1px solid var(--border); border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.6; outline: none; resize: vertical;
}

/* ---------- graph ---------- */
#graph { height: calc(100vh - var(--topbar)); position: relative; background: #fff; }
#graph-canvas { width: 100%; height: 100%; }
#legend {
  position: absolute; bottom: 16px; left: 16px; display: flex; gap: 8px; flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.9); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
}
.lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.lg .dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- login ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg-side); padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--border);
  border-radius: 14px; padding: 36px 34px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 40px rgba(0, 0, 0, 0.05);
}
.login-logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; margin-bottom: 22px; }
.login-logo .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.login-card h1 { font-size: 22px; letter-spacing: -0.02em; margin-bottom: 4px; }
.login-card .muted { margin-bottom: 22px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; outline: none; background: #fff;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.login-card button {
  width: 100%; margin-top: 22px; padding: 10px; border-radius: 8px; font-weight: 600;
  background: var(--accent); border: 1px solid var(--accent); color: #fff; font: inherit; cursor: pointer;
}
.login-card button:hover { background: #4c56c0; }
.login-card button:disabled { opacity: 0.6; cursor: default; }
.login-err { margin-top: 14px; font-size: 13px; color: var(--danger); }

/* ---------- mobil ---------- */
@media (max-width: 768px) {
  #hamburger { display: block; }
  #sidebar {
    position: fixed; top: var(--topbar); bottom: 0; left: 0; z-index: 40;
    transform: translateX(-100%); transition: transform 0.18s ease; box-shadow: 0 10px 40px rgba(0,0,0,0.12);
  }
  body.nav-open #sidebar { transform: translateX(0); }
  .note-wrap { padding: 24px 18px 70px; }
  .home { padding: 32px 18px 70px; }
  .stats { flex-direction: column; }
}
