:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --border: #e3e6ee;
  --text: #1f2540;
  --muted: #6b7390;
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --danger: #e11d48;
  --ok: #16a34a;
  --shadow: 0 12px 32px rgba(36, 41, 70, 0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
button { font: inherit; }

/* Auth pages */
.auth-wrap { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card { background: var(--panel); width: 100%; max-width: 380px; padding: 32px 28px; border-radius: 16px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 6px; font-size: 22px; }
.auth-card .sub { color: var(--muted); margin-bottom: 22px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); }
.field input { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none; }
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 6px; background: var(--primary); color: #fff; border: none; padding: 10px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: background .15s; }
.btn:hover { background: var(--primary-2); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.msg { font-size: 13px; margin-top: 10px; padding: 10px 12px; border-radius: 8px; }
.msg.err { background: #ffe8ee; color: #9d1239; }
.msg.ok { background: #e6f9ee; color: #086c2c; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; text-align: center; }

/* App shell */
.app-shell { display: grid; grid-template-rows: 56px 1fr; height: 100vh; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 18px; gap: 18px; box-shadow: 0 2px 8px rgba(36,41,70,.04); }
.brand { font-weight: 800; color: var(--primary); letter-spacing: -.3px; }
.brand small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.spacer { flex: 1; }
.account { position: relative; }
.account-trigger { display: flex; gap: 10px; align-items: center; cursor: pointer; padding: 6px 10px; border-radius: 8px; border: 1px solid transparent; }
.account-trigger:hover { border-color: var(--border); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.account-name { font-size: 13px; font-weight: 600; }
.dropdown { position: absolute; right: 0; top: 44px; min-width: 240px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: none; z-index: 100; }
.dropdown.show { display: block; }
.dropdown .info { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dropdown .info .u { font-weight: 700; }
.dropdown .info .e { color: var(--muted); font-size: 12px; }
.dropdown .item { display: block; width: 100%; text-align: left; background: transparent; border: none; padding: 9px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.dropdown .item:hover { background: #f0f1f7; }
.dropdown .item.danger { color: var(--danger); }

.body { display: grid; grid-template-columns: 220px 1fr; min-height: 0; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 14px 10px; overflow-y: auto; }
.sidebar .nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text); font-weight: 500; }
.sidebar .nav-item:hover { background: #f0f1f7; }
.sidebar .nav-item.active { background: rgba(79,70,229,.12); color: var(--primary); font-weight: 700; }
.sidebar .nav-icon { width: 22px; text-align: center; }

.main { overflow-y: auto; padding: 24px 28px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-title { font-size: 22px; font-weight: 800; }
.page-actions { display: flex; gap: 8px; }

.note-list { display: flex; flex-direction: column; gap: 10px; }
.note-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: 0 2px 8px rgba(36,41,70,.04); }
.note-card .nt { font-weight: 700; }
.note-card .nc { color: var(--text); white-space: pre-wrap; margin-top: 4px; font-size: 14px; }
.note-card .meta { color: var(--muted); font-size: 12px; margin-top: 8px; display: flex; justify-content: space-between; align-items: center; }
.note-card .actions { display: flex; gap: 6px; }
.note-card .actions button { background: transparent; border: 1px solid var(--border); padding: 4px 10px; font-size: 12px; border-radius: 6px; cursor: pointer; color: var(--text); }
.note-card .actions button:hover { background: #f0f1f7; }
.note-card .actions button.del:hover { background: #ffe8ee; color: var(--danger); border-color: #f7c1ce; }

.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 18px; }
.pagination button { padding: 6px 10px; min-width: 32px; border: 1px solid var(--border); background: var(--panel); border-radius: 6px; cursor: pointer; font-size: 13px; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .5; cursor: not-allowed; }

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

.modal-mask { position: fixed; inset: 0; background: rgba(15,15,30,.55); display: none; align-items: center; justify-content: center; z-index: 200; }
.modal-mask.show { display: flex; }
.modal { background: var(--panel); width: 480px; max-width: 92vw; border-radius: 12px; box-shadow: var(--shadow); padding: 22px; }
.modal h3 { margin: 0 0 14px; }
.modal textarea { width: 100%; min-height: 110px; resize: vertical; border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-family: inherit; font-size: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.settings-row label { font-weight: 600; }
.settings-row input { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: #fff; padding: 12px 18px; border-radius: 8px; box-shadow: var(--shadow); z-index: 999; opacity: 0; transform: translateY(10px); transition: all .25s; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
