/* ═══════════════════════════════════════════════════════════
   Notes App — Stylesheet
   A light, minimalist, pastel design with glassmorphism accents,
   dark mode support, and responsive mobile layout.
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens (CSS Custom Properties) — Light Theme ── */
:root {
  /* Pastel palette */
  --color-bg:           hsl(240, 30%, 97%);
  --color-surface:      hsl(0, 0%, 100%);
  --color-surface-alt:  hsl(240, 25%, 95%);
  --color-sidebar-bg:   hsl(240, 20%, 98%);

  --color-lavender:     hsl(250, 55%, 88%);
  --color-lavender-dk:  hsl(250, 45%, 72%);
  --color-mint:         hsl(160, 40%, 85%);
  --color-mint-dk:      hsl(160, 35%, 60%);
  --color-peach:        hsl(20, 80%, 90%);
  --color-peach-dk:     hsl(20, 70%, 72%);
  --color-rose:         hsl(350, 65%, 88%);
  --color-rose-dk:      hsl(350, 55%, 62%);

  /* Text */
  --color-text:         hsl(220, 20%, 25%);
  --color-text-muted:   hsl(220, 12%, 55%);
  --color-text-faint:   hsl(220, 10%, 72%);

  /* Accent (primary action) */
  --color-primary:      hsl(250, 55%, 72%);
  --color-primary-hover:hsl(250, 55%, 64%);
  --color-primary-text: hsl(0, 0%, 100%);

  /* Danger */
  --color-danger:       hsl(350, 55%, 62%);
  --color-danger-hover: hsl(350, 55%, 52%);

  /* Borders & shadows */
  --color-border:       hsl(240, 15%, 90%);
  --shadow-sm:          0 1px 3px hsla(240, 20%, 40%, 0.06);
  --shadow-md:          0 4px 12px hsla(240, 20%, 40%, 0.08);
  --shadow-lg:          0 8px 28px hsla(240, 20%, 40%, 0.10);

  /* Glassmorphism */
  --glass-bg:           hsla(0, 0%, 100%, 0.65);
  --glass-blur:         12px;

  /* Code blocks */
  --color-code-bg:      hsl(230, 20%, 18%);
  --color-code-text:    hsl(220, 15%, 85%);

  /* Radii */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:   'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* Sizing */
  --sidebar-width: 280px;
}

/* ── Dark Theme ──────────────────────────────────────────── */
[data-theme="dark"] {
  --color-bg:           hsl(230, 20%, 10%);
  --color-surface:      hsl(230, 18%, 14%);
  --color-surface-alt:  hsl(230, 16%, 18%);
  --color-sidebar-bg:   hsl(230, 18%, 12%);

  --color-lavender:     hsl(250, 30%, 30%);
  --color-lavender-dk:  hsl(250, 40%, 65%);
  --color-mint:         hsl(160, 25%, 25%);
  --color-mint-dk:      hsl(160, 35%, 55%);
  --color-peach:        hsl(20, 40%, 25%);
  --color-peach-dk:     hsl(20, 50%, 60%);
  --color-rose:         hsl(350, 30%, 25%);
  --color-rose-dk:      hsl(350, 45%, 55%);

  --color-text:         hsl(220, 15%, 85%);
  --color-text-muted:   hsl(220, 10%, 55%);
  --color-text-faint:   hsl(220, 8%, 40%);

  --color-primary:      hsl(250, 50%, 65%);
  --color-primary-hover:hsl(250, 50%, 58%);
  --color-primary-text: hsl(0, 0%, 100%);

  --color-danger:       hsl(350, 45%, 55%);
  --color-danger-hover: hsl(350, 50%, 48%);

  --color-border:       hsl(230, 15%, 22%);
  --shadow-sm:          0 1px 3px hsla(0, 0%, 0%, 0.2);
  --shadow-md:          0 4px 12px hsla(0, 0%, 0%, 0.25);
  --shadow-lg:          0 8px 28px hsla(0, 0%, 0%, 0.3);

  --glass-bg:           hsla(230, 18%, 14%, 0.75);

  --color-code-bg:      hsl(230, 22%, 12%);
  --color-code-text:    hsl(220, 15%, 80%);
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  color: var(--color-text);
  background: var(--color-bg);
  height: 100vh;
  overflow: hidden;
  /* Smooth theme transition */
  transition: background 0.3s ease, color 0.3s ease;
}

/* ── App Layout ──────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.sidebar-header {
  padding: 16px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-primary);
}

/* ── Search ──────────────────────────────────────────────── */
.search-wrapper {
  position: relative;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
}

.search-icon {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  pointer-events: none;
  opacity: 0.5;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-family: var(--font-family);
  font-size: 0.82rem;
  color: var(--color-text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input::placeholder {
  color: var(--color-text-faint);
}

.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px hsla(250, 55%, 72%, 0.15);
}

/* ── Note List ───────────────────────────────────────────── */
.note-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.note-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  margin-bottom: 4px;
  animation: fadeSlideIn 0.3s ease-out both;
}

.note-item:hover {
  background: var(--color-surface-alt);
  transform: translateX(2px);
}

.note-item.active {
  background: var(--color-lavender);
  box-shadow: var(--shadow-sm);
}

.note-item-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item-date {
  font-size: 0.73rem;
  color: var(--color-text-muted);
  margin-top: 3px;
}

/* ── Sidebar Empty State ─────────────────────────────────── */
.sidebar-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* ── Sidebar Filters (Folders & Tags) ────────────────────── */
.sidebar-filters {
  border-bottom: 1px solid var(--color-border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dropdown {
  position: relative;
  width: 100%;
}

.dropdown-btn {
  width: 100%;
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.dropdown-btn:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-primary);
}

.dropdown-content {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  padding: 8px;
  z-index: 100;
  max-height: 250px;
  overflow-y: auto;
  
  display: flex;
  flex-direction: column;
  gap: 4px;
}

[data-theme="dark"] .dropdown-content {
  background: rgba(30, 41, 59, 0.75);
  border-color: rgba(255, 255, 255, 0.1);
}

.dropdown-content.hidden {
  display: none;
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--color-text);
  transition: all 0.2s ease;
  width: 100%;
  text-align: left;
}

.tag-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  opacity: 0.8;
}

.filter-chip:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.filter-chip.active {
  background: var(--color-primary);
  color: var(--color-primary-text);
  border-color: var(--color-primary);
}

.filter-chip.trash.active {
  background: hsl(0, 72%, 51%); /* Soft red for Trash */
  color: white;
  border-color: hsl(0, 72%, 51%);
}

.sidebar-divider {
  height: 1px;
  background: var(--color-border);
  margin: 12px 4px;
  opacity: 0.6;
}

/* ── Main Content ────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
  transition: background 0.3s ease;
}

/* ── Mobile Back Button ──────────────────────────────────── */
.btn-mobile-back {
  display: none; /* shown via media query */
}

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-text-faint);
  gap: 12px;
}

.empty-state-icon {
  font-size: 3rem;
  animation: float 3s ease-in-out infinite;
}

/* ── Editor View ─────────────────────────────────────────── */
.editor-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.25s ease-out;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--color-border);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.note-title-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-family);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
  outline: none;
  letter-spacing: -0.01em;
}

.note-title-input::placeholder {
  color: var(--color-text-faint);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Ensure Edit and Save buttons are the same size/location */
.btn-action {
  min-width: 85px;
  justify-content: center;
}

/* ── Editor Metadata (Folders & Tags) ────────────────────── */
.editor-metadata {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.82rem;
}

.folder-wrapper,
.tags-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metadata-icon {
  font-size: 1rem;
  opacity: 0.7;
}

.note-folder-input,
.note-tag-input {
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--font-family);
  font-size: 0.82rem;
  color: var(--color-text);
  outline: none;
  padding: 2px 4px;
  border-radius: 4px;
  transition: border-color 0.2s, background 0.2s;
}

.note-folder-input:hover,
.note-folder-input:focus,
.note-tag-input:hover,
.note-tag-input:focus {
  border-color: var(--color-border);
  background: var(--color-surface-alt);
}

.note-tag-input {
  width: 80px;
}

.note-tags-container {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--color-lavender);
  color: var(--color-lavender-dk);
  font-size: 0.75rem;
  font-weight: 500;
}

[data-theme="dark"] .tag-chip {
  color: var(--color-text);
}

.tag-remove {
  cursor: pointer;
  font-weight: bold;
  opacity: 0.5;
}

.tag-remove:hover {
  opacity: 1;
}

/* ── Save Indicator ──────────────────────────────────────── */
.save-indicator {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  animation: fadeIn 0.2s ease-out;
}

.save-indicator.saved {
  color: var(--color-mint-dk);
}

/* ── Markdown Toolbar ────────────────────────────────────── */
.md-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 24px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.md-toolbar::-webkit-scrollbar {
  display: none;
}

.md-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font-family);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.md-btn:hover {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.md-btn:active {
  transform: scale(0.95);
}

.md-toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--color-border);
  margin: 0 6px;
  flex-shrink: 0;
}

/* ── Find & Replace Bar ──────────────────────────────────── */
.find-replace-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.find-replace-bar.hidden {
  display: none;
}

.find-replace-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.find-replace-icon {
  font-size: 0.9rem;
  opacity: 0.7;
}

.find-replace-input {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  width: 150px;
  outline: none;
}

.find-replace-input:focus {
  border-color: var(--color-primary);
}

.find-matches-count {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  min-width: 35px;
  text-align: center;
}

.find-btn {
  padding: 4px 8px;
  font-size: 0.75rem;
}

.find-replace-spacer {
  flex: 1;
}

.find-close-btn {
  padding: 4px 8px;
  font-weight: bold;
}

/* ── Editor Body ─────────────────────────────────────────── */
.editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.note-content-input {
  flex: 1;
  border: none;
  background: var(--color-surface);
  padding: 24px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--color-text);
  resize: none;
  outline: none;
  transition: background 0.3s ease;
}

.note-content-input::placeholder {
  color: var(--color-text-faint);
}

/* ── Preview Pane ────────────────────────────────────────── */
.preview-pane {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  background: var(--color-surface);
  animation: fadeIn 0.2s ease-out;
  transition: background 0.3s ease;
}

/* Read-only styling for inputs in preview mode */
.note-title-input[readonly],
.note-folder-input[readonly] {
  cursor: default;
  pointer-events: none;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--color-text);
}

/* Markdown rendered content styles */
.preview-pane h1,
.preview-pane h2,
.preview-pane h3,
.preview-pane h4 {
  color: var(--color-text);
  margin: 1.4em 0 0.6em;
  line-height: 1.3;
}

.preview-pane h1 { font-size: 1.6rem; font-weight: 700; }
.preview-pane h2 { font-size: 1.3rem; font-weight: 600; border-bottom: 1px solid var(--color-border); padding-bottom: 6px; }
.preview-pane h3 { font-size: 1.1rem; font-weight: 600; }

.preview-pane p {
  margin: 0.8em 0;
  line-height: 1.75;
}

.preview-pane ul, .preview-pane ol {
  margin: 0.6em 0;
  padding-left: 1.5em;
}

.preview-pane li {
  margin: 0.3em 0;
  line-height: 1.65;
}

.preview-pane code {
  background: var(--color-surface-alt);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--color-lavender-dk);
}

.preview-pane pre {
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 1em 0;
}

.preview-pane pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.preview-pane blockquote {
  border-left: 3px solid var(--color-lavender);
  padding: 8px 16px;
  margin: 1em 0;
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.preview-pane a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-color: var(--color-lavender);
  text-underline-offset: 2px;
}

.preview-pane hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 1.5em 0;
}

.preview-pane img {
  max-width: 100%;
  border-radius: var(--radius-md);
}

.preview-pane table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
}

.preview-pane th, .preview-pane td {
  border: 1px solid var(--color-border);
  padding: 8px 12px;
  text-align: left;
}

.preview-pane th {
  background: var(--color-surface-alt);
  font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-text);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}

.btn-ghost:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.btn-ghost.active {
  background: var(--color-mint);
  color: var(--color-text);
}

.btn-danger {
  background: transparent;
  color: var(--color-danger);
}

.btn-danger:hover {
  background: hsl(350, 80%, 95%);
  color: var(--color-danger-hover);
}

[data-theme="dark"] .btn-danger:hover {
  background: hsl(350, 30%, 18%);
}

.btn-icon {
  font-size: 1.1em;
  font-weight: 600;
}

.btn-icon-only {
  padding: 6px 8px;
  font-size: 1rem;
  min-width: 34px;
  justify-content: center;
}

/* ── Toast Notifications ─────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  animation: toastIn 0.3s ease-out;
}

.toast.auto-dismiss {
  animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s forwards;
}

.toast.success { border-left: 3px solid var(--color-mint-dk); }
.toast.error   { border-left: 3px solid var(--color-danger); }
.toast.info    { border-left: 3px solid var(--color-lavender-dk); }

.toast .undo-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  white-space: nowrap;
}

.toast .undo-btn:hover {
  color: var(--color-primary-hover);
}

/* ── Utility ─────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* ── Responsive — Mobile (≤ 720px) ───────────────────────── */
@media (max-width: 720px) {
  /* Sidebar becomes full-screen overlay that slides in/out */
  .sidebar {
    position: fixed;
    inset: 0;
    width: 100%;
    min-width: unset;
    z-index: 100;
    transform: translateX(0);
    transition: transform 0.3s ease, visibility 0.3s;
    border-right: none;
  }

  .sidebar.mobile-hidden {
    transform: translateX(-100%);
    visibility: hidden;
  }

  /* Show mobile back button */
  .btn-mobile-back {
    display: flex;
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    font-size: 0.9rem;
    font-weight: 500;
  }

  /* Main content fills viewport */
  .main-content {
    width: 100%;
  }

  /* Toolbar wraps */
  .editor-toolbar {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 8px;
  }

  .note-title-input {
    min-width: 100%;
    order: -1;
  }

  .toolbar-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* Markdown toolbar scrolls horizontally */
  .md-toolbar {
    padding: 6px 16px;
  }

  .md-btn {
    min-width: 40px;
    height: 36px;
  }

  /* Editor body stacks vertically */
  .editor-body {
    flex-direction: column;
  }

  .preview-pane {
    border-left: none;
    border-top: 1px solid var(--color-border);
    max-height: 45vh;
  }

  /* Larger touch targets */
  .note-item {
    padding: 14px 16px;
  }

  .btn {
    padding: 10px 16px;
    font-size: 0.88rem;
  }

  .btn-icon-only {
    min-width: 40px;
    padding: 8px;
  }

  /* Toast at bottom center on mobile */
  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }
}

/* Desktop: hide mobile-only elements */
@media (min-width: 721px) {
  .hidden-desktop {
    display: none !important;
  }
}

/* ── Login Overlay ───────────────────────────────────────── */
.login-overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: fadeIn 0.4s ease-out;
}

.login-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  animation: fadeSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  color: var(--color-text);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-group input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px hsla(250, 55%, 72%, 0.15);
  background: var(--color-surface);
}

.login-submit {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 10px;
  justify-content: center;
}

.login-error {
  margin-top: 16px;
  color: var(--color-danger);
  font-size: 0.85rem;
  font-weight: 500;
  display: block;
}
