:root {
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --nav-bg: #1e293b;
  --nav-text: #e2e8f0;
  --page-bg: #f1f5f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --shadow: 0 1px 4px rgba(0, 0, 0, .08);
}
[data-theme="dark"] {
  --page-bg: #0f172a;
  --card-bg: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  background: var(--nav-bg);
  color: var(--nav-text);
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { font-weight: 700; font-size: 1.15rem; }
.topbar .brand i { color: var(--brand); margin-right: .4rem; }

.app-layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 260px;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 1rem;
  flex-shrink: 0;
}
.sidebar-list { list-style: none; margin: 0; padding: 0; }
.sidebar-list li { margin-bottom: 2px; }
.sidebar-list a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .6rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.sidebar-list a:hover, .sidebar-list a.active { background: rgba(37, 99, 235, .1); color: var(--brand); }

.main-area { flex: 1; display: flex; min-width: 0; }
.notes-list { width: 320px; border-right: 1px solid var(--border); overflow-y: auto; background: var(--card-bg); }
.note-item { padding: .85rem 1rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.note-item:hover { background: rgba(37, 99, 235, .06); }
.note-item.active { background: rgba(37, 99, 235, .12); border-left: 3px solid var(--brand); }
.note-item .note-title { font-weight: 600; margin-bottom: 2px; }
.note-item .note-snippet { font-size: .8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.editor-area { flex: 1; padding: 1.25rem 1.5rem; display: flex; flex-direction: column; min-width: 0; }
.editor-title { border: none; background: transparent; font-size: 1.5rem; font-weight: 700; width: 100%; outline: none; color: var(--text); margin-bottom: .5rem; }
.editor-content { flex: 1; border: 1px solid var(--border); border-radius: 10px; padding: 1rem; background: var(--card-bg); outline: none; overflow-y: auto; min-height: 300px; line-height: 1.6; }
.editor-toolbar { display: flex; gap: .35rem; margin-bottom: .5rem; flex-wrap: wrap; }
.editor-toolbar button { border: 1px solid var(--border); background: var(--card-bg); border-radius: 6px; padding: .3rem .55rem; cursor: pointer; }
.editor-toolbar button:hover { background: rgba(37, 99, 235, .1); }

.btn-brand { background: var(--brand); border-color: var(--brand); }
.btn-brand:hover { background: var(--brand-hover); border-color: var(--brand-hover); }

.empty-state { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); flex-direction: column; gap: .5rem; }
.attachment-chip { display: inline-flex; align-items: center; gap: .35rem; background: rgba(37,99,235,.08); border-radius: 20px; padding: .25rem .7rem; font-size: .82rem; margin: .25rem .25rem 0 0; }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--page-bg); }
.auth-card { background: var(--card-bg); border-radius: 14px; box-shadow: var(--shadow); padding: 2rem; width: 100%; max-width: 380px; }

.toast-msg { position: fixed; bottom: 1rem; right: 1rem; z-index: 2000; }

@media (max-width: 900px) {
  .notes-list { position: fixed; left: 0; top: 56px; bottom: 0; z-index: 15; transform: translateX(-100%); transition: transform .2s; }
  .notes-list.open { transform: translateX(0); }
  .sidebar { display: none; }
}
