:root {
  --bg: #071018; --bg2: #0b1520; --bg3: #0e1a2a;
  --border: #1e3a5a; --border2: #162030;
  --accent: #7ab3e0; --text: #d0e4f4; --text2: #9ab8d4;
  --muted: #4a7a9a; --muted2: #4a6a8a;
  --green: #4caf50; --gold: #d0a060; --red: #f44336;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }

.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 260px; flex-shrink: 0; background: var(--bg2);
  border-right: 1px solid var(--border); padding: 16px 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar .logo {
  padding: 0 16px 16px; color: var(--accent); font-weight: 700; font-size: 15px;
  border-bottom: 1px solid var(--border); margin-bottom: 10px;
}
.folder-tree { padding: 0 8px; flex: 1; overflow-y: auto; }
.folder-block { margin-bottom: 2px; }
.folder-row {
  display: flex; align-items: center; gap: 6px; padding: 7px 8px; cursor: pointer;
  border-radius: 5px; font-size: 13px; font-weight: 600; color: var(--text); user-select: none;
}
.folder-row:hover { background: rgba(122,179,224,0.08); }
.chevron { font-size: 10px; color: var(--muted); width: 10px; }
.page-list { padding-left: 20px; }
.page-link {
  display: block; padding: 6px 8px; font-size: 12.5px; color: var(--text2);
  text-decoration: none; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.page-link:hover { background: rgba(122,179,224,0.08); color: var(--accent); text-decoration: none; }
.page-link.active { background: rgba(122,179,224,0.15); color: var(--accent); font-weight: 600; }
.add-page-input, .add-folder-input {
  width: 100%; background: none; border: none; color: var(--muted);
  font-size: 12.5px; padding: 6px 8px; outline: none; font-family: inherit;
}
.add-page-input::placeholder, .add-folder-input::placeholder { color: var(--muted); }
.add-page-input:focus, .add-folder-input:focus { color: var(--text); }
.add-folder-form { padding: 10px 16px 0; border-top: 1px solid var(--border); margin-top: 10px; }

/* ── Main / editor ────────────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#editor-pane { flex: 1; display: flex; flex-direction: column; padding: 32px 40px 80px; max-width: 800px; margin: 0 auto; width: 100%; }
.editor-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.page-title-input {
  flex: 1; background: none; border: none; color: var(--text); font-size: 26px; font-weight: 700;
  outline: none; padding: 4px 0; font-family: inherit;
}
.save-status { font-size: 11.5px; color: var(--muted); min-width: 80px; text-align: right; white-space: nowrap; }
.delete-btn { background: none; border: none; color: var(--muted); font-size: 15px; cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.delete-btn:hover { color: var(--red); background: rgba(244,67,54,0.1); }
.move-select {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 5px;
  color: var(--text2); font-size: 12px; padding: 5px 8px; cursor: pointer; font-family: inherit;
}
.move-select:hover { border-color: var(--accent); color: var(--accent); }

.page-content {
  flex: 1; width: 100%; min-height: 60vh; outline: none;
  color: var(--text); font-size: 15px; line-height: 1.7;
}
.page-content:empty:before { content: attr(data-placeholder); color: var(--muted); }
.page-content img { max-width: 100%; border-radius: 6px; margin: 8px 0; display: block; }
.page-content table { border-collapse: collapse; margin: 10px 0; }
.page-content td, .page-content th { border: 1px solid var(--border); padding: 4px 8px; }
.page-content p { margin: 0 0 10px; }
.page-content ul, .page-content ol { padding-left: 22px; margin: 0 0 10px; }
.page-content pre { background: var(--bg3); padding: 10px 12px; border-radius: 6px; overflow-x: auto; }
.page-content code { background: var(--bg3); padding: 1px 5px; border-radius: 3px; font-size: 0.9em; }

.editor-empty { color: var(--muted); font-size: 14px; padding: 40px 0; text-align: center; }

/* ── Mobile sidebar toggle ────────────────────────────────────────────────── */
.sidebar-toggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 200;
  width: 40px; height: 40px; border-radius: 8px; background: var(--bg2);
  border: 1px solid var(--border); color: var(--text); font-size: 18px; cursor: pointer;
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90; }
.sidebar-overlay.open { display: block; }
@media (max-width: 768px) {
  .sidebar-toggle { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
    transform: translateX(-100%); transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  #editor-pane { padding: 70px 20px 60px; }
}

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 32px; width: 300px; text-align: center; }
.login-logo { font-size: 20px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.login-sub { font-size: 12px; color: var(--muted); margin-bottom: 20px; }
.login-box input {
  width: 100%; padding: 10px 12px; margin-bottom: 12px; background: var(--bg3);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 14px;
}
.login-box button {
  width: 100%; padding: 10px; background: var(--accent); border: none; border-radius: 6px;
  color: var(--bg); font-weight: 700; cursor: pointer;
}
.err { color: var(--red); font-size: 12px; margin-top: 8px; }
