/* ═══════════════════════════════════════════════════════════
   E2EE Notes — Styles
   Aesthetic: Deep space minimal, refined obsidian
═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Crimson+Pro:ital,wght@0,300;0,400;0,600;1,300;1,400&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg-base:       #0d0d12;
  --bg-surface:    #12121a;
  --bg-elevated:   #18181f;
  --bg-hover:      #1e1e28;
  --bg-active:     #22223a;
  --border:        rgba(255,255,255,0.06);
  --border-mid:    rgba(255,255,255,0.10);
  --border-bright: rgba(255,255,255,0.18);

  --text-primary:  #e8e8f0;
  --text-secondary:#9898b0;
  --text-muted:    #5a5a72;
  --text-disabled: #3a3a50;

  --accent:        #7c6af7;
  --accent-soft:   rgba(124,106,247,0.15);
  --accent-glow:   rgba(124,106,247,0.35);
  --accent-2:      #a78bfa;
  --accent-3:      #818cf8;

  --green:         #4ade80;
  --red:           #f87171;
  --amber:         #fbbf24;
  --teal:          #2dd4bf;

  --sidebar-w:     260px;
  --topbar-h:      48px;
  --panel-w:       320px;

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;

  --font-ui:       'Sora', sans-serif;
  --font-mono:     'JetBrains Mono', monospace;
  --font-editor:   'Crimson Pro', Georgia, serif;

  --shadow-sm:     0 2px 8px rgba(0,0,0,0.4);
  --shadow:        0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.7);

  --transition:    0.15s ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ══════════════════════════════════════════════════════════
   AUTH SCREEN
══════════════════════════════════════════════════════════ */
#auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-base);
  z-index: 1000;
}

#auth-screen::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 30%, rgba(124,106,247,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 500px 600px at 80% 70%, rgba(45,212,191,0.04) 0%, transparent 70%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(124,106,247,0.1);
}

.auth-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 32px;
}
.auth-logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 0 20px var(--accent-glow);
}
.auth-logo h1 {
  font-size: 20px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--text-primary);
}
.auth-logo span {
  font-size: 11px; color: var(--text-muted);
  display: block; font-weight: 400;
  letter-spacing: 0.05em; text-transform: uppercase;
}

.auth-tabs {
  display: flex; gap: 4px;
  background: var(--bg-base);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 28px;
}
.auth-tab {
  flex: 1; padding: 8px 0;
  text-align: center;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
}
.auth-tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 12px; color: var(--text-secondary);
  font-weight: 500; letter-spacing: 0.02em;
}
.form-group input {
  background: var(--bg-base);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-group input::placeholder { color: var(--text-disabled); }

.key-hint {
  font-size: 11px; color: var(--text-muted);
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.6;
  margin-top: 2px;
}
.key-hint strong { color: var(--amber); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-3) 100%);
  color: white;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.01em;
  transition: all var(--transition);
  position: relative; overflow: hidden;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-google {
  background: var(--bg-base);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 14px; font-weight: 500;
  color: var(--text-primary);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: all var(--transition);
}
.btn-google:hover {
  border-color: var(--border-bright);
  background: var(--bg-elevated);
}

.auth-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-disabled); font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.auth-error {
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px; color: var(--red);
  display: none;
}
.auth-error.show { display: block; }

/* ══════════════════════════════════════════════════════════
   SETUP ENCRYPTION KEY MODAL
══════════════════════════════════════════════════════════ */
#key-setup-modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 900;
}
.key-setup-card {
  width: 480px;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.key-setup-card h2 {
  font-size: 20px; font-weight: 600; margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px;
}
.key-setup-card p { color: var(--text-secondary); font-size: 13px; margin-bottom: 24px; line-height: 1.7; }
.key-warning {
  background: rgba(251,191,36,0.08);
  border: 1px solid rgba(251,191,36,0.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 12px; color: var(--amber);
  margin-bottom: 24px; line-height: 1.7;
}

/* ══════════════════════════════════════════════════════════
   STORAGE CHOICE MODAL
══════════════════════════════════════════════════════════ */
#storage-choice-modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 900;
}
.storage-choice-card {
  width: 520px;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.storage-choice-card h2 {
  font-size: 20px; font-weight: 600; margin-bottom: 8px;
}
.storage-choice-card > p {
  color: var(--text-secondary); font-size: 13px; margin-bottom: 28px;
}
.storage-options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-bottom: 24px;
}
.storage-option {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}
.storage-option:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.storage-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.storage-option-icon { font-size: 28px; margin-bottom: 12px; }
.storage-option h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.storage-option p { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.storage-option .storage-badge {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 8px;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.badge-local { background: rgba(74,222,128,0.15); color: var(--green); }
.badge-cloud { background: rgba(124,106,247,0.15); color: var(--accent-2); }

/* ══════════════════════════════════════════════════════════
   MAIN APP LAYOUT
══════════════════════════════════════════════════════════ */
#app {
  display: none;
  height: 100vh;
  flex-direction: column;
}
#app.visible { display: flex; }

/* Top Bar */
#topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 10;
  flex-shrink: 0;
}
.topbar-logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 15px; letter-spacing: -0.02em;
  color: var(--text-primary);
  padding-right: 12px;
  border-right: 1px solid var(--border);
}
.topbar-logo-icon {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  box-shadow: 0 0 10px var(--accent-glow);
}

.topbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.icon-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent-2); }

.topbar-storage-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-muted);
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
}
.storage-dot {
  width: 6px; height: 6px; border-radius: 50%;
}
.storage-dot.local { background: var(--green); box-shadow: 0 0 4px var(--green); }
.storage-dot.cloud { background: var(--accent-2); box-shadow: 0 0 4px var(--accent-2); }

.topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-secondary);
  padding: 0 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.topbar-user:hover { background: var(--bg-hover); color: var(--text-primary); }
.user-avatar {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
}

/* Main content area */
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.2s ease;
}
#sidebar.collapsed { width: 0; border: none; }

.sidebar-section {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.sidebar-header {
  display: flex; align-items: center;
  padding: 6px 12px 6px 16px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  gap: 6px;
}
.sidebar-header:hover { background: var(--bg-hover); }
.sidebar-header-title {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em; text-transform: uppercase;
  flex: 1;
}
.sidebar-header-icon {
  font-size: 12px; color: var(--text-disabled);
  margin-left: auto;
}

.sidebar-search {
  padding: 8px 12px;
}
.sidebar-search input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px 7px 30px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235a5a72' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 9px center;
}
.sidebar-search input:focus { border-color: var(--accent); }
.sidebar-search input::placeholder { color: var(--text-disabled); }

.new-note-btn {
  display: flex; align-items: center; gap: 8px;
  width: calc(100% - 24px);
  margin: 8px 12px;
  padding: 8px 12px;
  background: var(--accent-soft);
  border: 1px dashed rgba(124,106,247,0.35);
  border-radius: var(--radius-sm);
  color: var(--accent-2);
  font-size: 13px; font-weight: 500;
  transition: all var(--transition);
}
.new-note-btn:hover {
  background: rgba(124,106,247,0.2);
  border-color: rgba(124,106,247,0.5);
}

/* Note tree items */
.note-item {
  display: flex; align-items: center;
  padding: 6px 12px 6px 20px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 1px 6px;
  transition: all var(--transition);
  gap: 8px;
  position: relative;
}
.note-item:hover { background: var(--bg-hover); }
.note-item.active {
  background: var(--accent-soft);
  border: 1px solid rgba(124,106,247,0.2);
}
.note-item.active .note-item-title { color: var(--accent-2); }

.note-item-icon { font-size: 13px; color: var(--text-muted); flex-shrink: 0; }
.note-item-title {
  font-size: 13px; color: var(--text-secondary);
  flex: 1; truncate: true;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.note-item-date {
  font-size: 10px; color: var(--text-disabled);
  flex-shrink: 0;
}
.note-item-delete {
  display: none;
  width: 20px; height: 20px;
  align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 14px;
  transition: all var(--transition);
}
.note-item:hover .note-item-delete { display: flex; }
.note-item-delete:hover { background: rgba(248,113,113,0.15); color: var(--red); }

.notes-list {
  flex: 1; overflow-y: auto; padding: 4px 0;
}

.sidebar-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.7;
}

/* Tags section */
.tags-container {
  padding: 8px 12px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px; color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.tag-chip:hover, .tag-chip.active {
  border-color: var(--accent);
  color: var(--accent-2);
  background: var(--accent-soft);
}

/* ── Editor Area ───────────────────────────────────────── */
#editor-area {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

#editor-toolbar {
  display: flex; align-items: center;
  padding: 0 16px;
  height: 40px;
  border-bottom: 1px solid var(--border);
  gap: 4px;
  flex-shrink: 0;
  background: var(--bg-surface);
}

.toolbar-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
}
.toolbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.toolbar-btn.active { background: var(--accent-soft); color: var(--accent-2); }

.toolbar-sep {
  width: 1px; height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.editor-mode-tabs {
  display: flex; gap: 2px; margin-left: auto;
}
.editor-mode-tab {
  padding: 4px 12px;
  border-radius: 5px;
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
}
.editor-mode-tab.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

#editor-container {
  flex: 1; display: flex; overflow: hidden; position: relative;
}

#note-title-input {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 28px 60px 16px;
  font-family: var(--font-editor);
  font-size: 32px; font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#note-title-input::placeholder { color: var(--text-disabled); }

#note-editor-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#note-body-editor {
  flex: 1;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 24px 60px;
  font-family: var(--font-editor);
  font-size: 17px;
  color: var(--text-primary);
  line-height: 1.85;
  resize: none;
  overflow-y: auto;
}
#note-body-editor::placeholder { color: var(--text-disabled); }

/* Markdown preview */
#preview-pane {
  flex: 1;
  padding: 24px 60px;
  overflow-y: auto;
  font-family: var(--font-editor);
  font-size: 17px;
  line-height: 1.85;
  color: var(--text-primary);
  display: none;
}
#preview-pane.visible { display: block; }

#preview-pane h1 { font-size: 28px; font-weight: 600; margin: 24px 0 12px; letter-spacing: -0.02em; }
#preview-pane h2 { font-size: 22px; font-weight: 600; margin: 20px 0 10px; }
#preview-pane h3 { font-size: 18px; font-weight: 600; margin: 16px 0 8px; }
#preview-pane p { margin-bottom: 14px; }
#preview-pane ul, #preview-pane ol { padding-left: 24px; margin-bottom: 14px; }
#preview-pane li { margin-bottom: 4px; }
#preview-pane code {
  font-family: var(--font-mono); font-size: 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px;
  color: var(--accent-2);
}
#preview-pane pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px; margin-bottom: 16px;
  overflow-x: auto;
}
#preview-pane pre code {
  background: none; border: none; padding: 0; color: var(--text-primary);
}
#preview-pane blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px; margin: 16px 0;
  color: var(--text-secondary); font-style: italic;
}
#preview-pane strong { font-weight: 700; }
#preview-pane em { font-style: italic; color: var(--text-secondary); }
#preview-pane hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
#preview-pane a { color: var(--accent-2); text-decoration: underline; text-decoration-color: var(--accent-soft); }
#preview-pane table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
#preview-pane th, #preview-pane td {
  border: 1px solid var(--border); padding: 8px 12px;
  text-align: left; font-size: 15px;
}
#preview-pane th { background: var(--bg-elevated); font-weight: 600; }

/* No note selected */
#no-note-screen {
  flex: 1; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  color: var(--text-muted);
}
#no-note-screen .no-note-icon { font-size: 48px; opacity: 0.3; }
#no-note-screen h3 { font-size: 16px; font-weight: 500; color: var(--text-secondary); }
#no-note-screen p { font-size: 13px; color: var(--text-muted); text-align: center; max-width: 280px; }

/* ── Right Panel (Properties) ──────────────────────────── */
#right-panel {
  width: 0;
  background: var(--bg-surface);
  border-left: 0 solid var(--border);
  overflow: hidden;
  transition: width 0.2s ease, border 0.2s ease;
  flex-shrink: 0;
}
#right-panel.open {
  width: var(--panel-w);
  border-left-width: 1px;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.panel-section h4 {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 12px;
}

.prop-row {
  display: flex; align-items: center;
  padding: 8px 0;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.prop-row:last-child { border-bottom: none; }
.prop-key {
  font-size: 12px; color: var(--text-muted);
  width: 80px; flex-shrink: 0;
}
.prop-val {
  font-size: 12px; color: var(--text-secondary);
  flex: 1;
}
.prop-val.green { color: var(--green); }
.prop-val.accent { color: var(--accent-2); }

.tag-input-row {
  display: flex; gap: 8px; margin-bottom: 10px;
}
.tag-input-row input {
  flex: 1;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.tag-input-row input:focus { border-color: var(--accent); }
.tag-input-row button {
  background: var(--accent-soft);
  border: 1px solid rgba(124,106,247,0.3);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--accent-2);
  font-size: 13px;
}

.note-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.note-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  background: var(--accent-soft);
  border: 1px solid rgba(124,106,247,0.2);
  border-radius: 20px;
  font-size: 11px; color: var(--accent-2);
}
.note-tag-remove {
  cursor: pointer; color: var(--text-muted);
  transition: color var(--transition);
}
.note-tag-remove:hover { color: var(--red); }

/* ── Save Status ───────────────────────────────────────── */
#save-status {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
  opacity: 0; transform: translateY(8px);
  transition: all 0.3s ease;
  pointer-events: none;
}
#save-status.show { opacity: 1; transform: translateY(0); }
#save-status.saved { color: var(--green); }
#save-status.saving { color: var(--amber); }
#save-status.error { color: var(--red); }

.save-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.save-dot.pulse { animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Loading Overlay ───────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0;
  background: var(--bg-base);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  z-index: 2000;
  transition: opacity 0.4s ease;
}
#loading-overlay.fade { opacity: 0; pointer-events: none; }

.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { font-size: 13px; color: var(--text-muted); }

/* ── Encryption indicator ──────────────────────────────── */
.enc-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.05em; text-transform: uppercase;
  background: rgba(74,222,128,0.1);
  border: 1px solid rgba(74,222,128,0.2);
  color: var(--green);
}

/* ── Confirm dialog ────────────────────────────────────── */
#confirm-dialog {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1500;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
#confirm-dialog.show { opacity: 1; pointer-events: all; }

.confirm-card {
  width: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
.confirm-card h3 { font-size: 16px; margin-bottom: 8px; }
.confirm-card p { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-cancel {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  color: var(--text-secondary);
  transition: all var(--transition);
}
.btn-cancel:hover { background: var(--bg-hover); }
.btn-danger {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  background: rgba(248,113,113,0.15);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--red);
  transition: all var(--transition);
}
.btn-danger:hover { background: rgba(248,113,113,0.25); }

/* ── Toast ─────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 13px; color: var(--text-primary);
  box-shadow: var(--shadow);
  opacity: 0; transition: all 0.3s ease;
  pointer-events: none; white-space: nowrap;
  z-index: 3000;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { position: absolute; z-index: 20; height: calc(100vh - var(--topbar-h)); top: var(--topbar-h); }
  #sidebar.collapsed { width: 0; }
  #note-title-input, #note-body-editor, #preview-pane { padding-left: 20px; padding-right: 20px; }
  .auth-card { width: calc(100vw - 32px); padding: 28px; }
  .storage-options { grid-template-columns: 1fr; }
}

/* ── Animations ────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.note-item { animation: fadeIn 0.2s ease both; }
