/* ═══════════════════════════════════════════════════════════
   NotesKarts Online Notepad — styles.css
   Author: NotesKarts Team | noteskarts.com
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables & Themes ─────────────────────────────── */
:root {
  /* Accent palette — teal default */
  --accent: #247E84;
  --accent-hover: #1d6b70;
  --accent-light: #e8f5f6;
  --accent-muted: rgba(36,126,132,0.12);

  /* Layout */
  --header-h: 52px;
  --status-h: 32px;
  --sidebar-w: 240px;

  /* Surfaces — LIGHT */
  --bg-base: #f6f7f9;
  --bg-surface: #ffffff;
  --bg-sidebar: #f0f1f4;
  --bg-hover: rgba(0,0,0,0.05);
  --bg-active: rgba(36,126,132,0.1);
  --bg-header: #ffffff;
  --bg-status: #f0f1f4;
  --bg-editor: #ffffff;
  --bg-modal: #ffffff;
  --bg-overlay: rgba(0,0,0,0.4);
  --bg-dropdown: #ffffff;
  --bg-input: #f6f7f9;

  /* Text */
  --text-primary: #1a1d23;
  --text-secondary: #5a6070;
  --text-muted: #8892a4;
  --text-accent: var(--accent);
  --text-inverse: #ffffff;
  --text-editor: #1a1d23;

  /* Border */
  --border: rgba(0,0,0,0.09);
  --border-strong: rgba(0,0,0,0.15);
  --border-accent: var(--accent);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.15);
  --shadow-dropdown: 0 8px 24px rgba(0,0,0,0.12);

  /* Typography */
  --font-ui: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-editor: 'Lora', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-size-ui: 13.5px;
  --font-size-editor: 16.5px;
  --line-height-editor: 1.85;

  /* Radius */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;

  /* Transitions */
  --ease: cubic-bezier(0.4,0,0.2,1);
  --transition: 180ms var(--ease);
}

/* Dark Mode */
[data-theme="dark"] {
  --bg-base: #0f1117;
  --bg-surface: #1a1d27;
  --bg-sidebar: #14161f;
  --bg-hover: rgba(255,255,255,0.06);
  --bg-active: rgba(36,126,132,0.15);
  --bg-header: #14161f;
  --bg-status: #14161f;
  --bg-editor: #1a1d27;
  --bg-modal: #1e2130;
  --bg-overlay: rgba(0,0,0,0.65);
  --bg-dropdown: #1e2130;
  --bg-input: #0f1117;

  --text-primary: #e8eaf0;
  --text-secondary: #9aa0b4;
  --text-muted: #636878;
  --text-editor: #dce0ec;

  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --accent-light: rgba(36,126,132,0.15);
  --accent-muted: rgba(36,126,132,0.2);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --shadow-dropdown: 0 8px 24px rgba(0,0,0,0.45);
}

/* Accent overrides */
[data-accent="midnight"] { --accent:#1E3A5F; --accent-hover:#163055; --accent-light:#e8eef6; --accent-muted:rgba(30,58,95,0.12); }
[data-accent="forest"]   { --accent:#2D6A4F; --accent-hover:#255c43; --accent-light:#e8f5f0; --accent-muted:rgba(45,106,79,0.12); }
[data-accent="crimson"]  { --accent:#C0392B; --accent-hover:#a93226; --accent-light:#fdf0ee; --accent-muted:rgba(192,57,43,0.12); }
[data-accent="amber"]    { --accent:#D97706; --accent-hover:#c06b05; --accent-light:#fdf4e3; --accent-muted:rgba(217,119,6,0.12); }
[data-theme="dark"][data-accent="midnight"] { --accent-light:rgba(30,58,95,0.2); }
[data-theme="dark"][data-accent="forest"]   { --accent-light:rgba(45,106,79,0.2); }
[data-theme="dark"][data-accent="crimson"]  { --accent-light:rgba(192,57,43,0.2); }
[data-theme="dark"][data-accent="amber"]    { --accent-light:rgba(217,119,6,0.2); }

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  height: 100%;
  font-family: var(--font-ui);
  font-size: var(--font-size-ui);
  background: var(--bg-base);
  color: var(--text-primary);
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; font-size: inherit; border: none; background: none; }
input, textarea { font-family: inherit; font-size: inherit; border: none; outline: none; }
a { color: inherit; text-decoration: none; }
svg { display: block; width: 16px; height: 16px; flex-shrink: 0; }

/* ── App Shell ───────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: var(--header-h) 1fr var(--status-h);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 8px 0 4px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 100;
  position: relative;
}

.header-left { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.header-center { flex: 1; display: flex; justify-content: center; overflow: hidden; }
.header-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* Logo */
.logo {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: var(--r-md);
  transition: background var(--transition);
  flex-shrink: 0;
}
.logo:hover { background: var(--bg-hover); }
.logo-icon { width: 28px; height: 28px; }
.logo-text {
  font-size: 15px; font-weight: 600; letter-spacing: -0.3px;
  color: var(--text-primary);
}
.logo-accent { color: var(--accent); }
.logo-tag {
  font-size: 10px; font-weight: 500; letter-spacing: 0.5px;
  color: var(--text-muted); text-transform: uppercase;
  background: var(--accent-muted); color: var(--accent);
  padding: 2px 6px; border-radius: 100px; line-height: 1.4;
}

/* Note Title */
.note-title-display {
  font-size: 13.5px; font-weight: 500;
  color: var(--text-secondary);
  max-width: 280px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  padding: 4px 10px; border-radius: var(--r-sm);
  cursor: pointer; transition: background var(--transition), color var(--transition);
}
.note-title-display:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Toolbar buttons */
.toolbar-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--r-sm);
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.toolbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.toolbar-btn.accent {
  background: var(--accent); color: #fff; padding: 6px 12px;
}
.toolbar-btn.accent:hover { background: var(--accent-hover); }
.toolbar-btn svg { width: 15px; height: 15px; }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-sm);
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn.small { width: 26px; height: 26px; }
.icon-btn.small svg { width: 14px; height: 14px; }

.divider-v {
  width: 1px; height: 20px; background: var(--border);
  margin: 0 4px; flex-shrink: 0;
}

/* ── Dropdown Menus ──────────────────────────────────────── */
.theme-dropdown-wrapper,
.export-dropdown-wrapper { position: relative; }

.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--bg-dropdown);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-dropdown);
  min-width: 180px; z-index: 999;
  padding: 6px;
  animation: menuIn 140ms var(--ease);
}
.dropdown-menu.hidden { display: none; }
@keyframes menuIn {
  from { opacity:0; transform:translateY(-6px) scale(0.97); }
  to   { opacity:1; transform:translateY(0) scale(1); }
}
.dropdown-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--text-muted);
  padding: 4px 8px 6px;
}
.dropdown-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--text-primary); font-size: 13px; font-weight: 400;
  transition: background var(--transition);
  white-space: nowrap;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item svg { width: 14px; height: 14px; color: var(--text-muted); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Theme swatches */
.theme-swatch {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--text-primary); font-size: 13px;
  transition: background var(--transition);
  white-space: nowrap;
}
.theme-swatch:hover { background: var(--bg-hover); }
.theme-swatch.active { background: var(--accent-muted); color: var(--accent); font-weight: 500; }
.swatch-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--sw); flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}

/* ── Main Layout ─────────────────────────────────────────── */
#main-layout {
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width var(--transition), min-width var(--transition), max-width var(--transition), opacity var(--transition);
}
#sidebar.sidebar-closed {
  width: 0; min-width: 0; max-width: 0; opacity: 0; pointer-events: none;
}

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.7px;
  text-transform: uppercase; color: var(--text-muted);
}

/* Notes list */
#notes-list {
  flex: 1; overflow-y: auto; padding: 6px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
#notes-list::-webkit-scrollbar { width: 4px; }
#notes-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.note-item {
  position: relative;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--transition);
  margin-bottom: 2px;
}
.note-item:hover { background: var(--bg-hover); }
.note-item.active { background: var(--bg-active); }
.note-item.active .ni-title { color: var(--accent); font-weight: 600; }

.ni-title {
  font-size: 13px; font-weight: 500; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.4; margin-bottom: 2px;
}
.ni-meta {
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ni-actions {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: none; align-items: center; gap: 2px;
}
.note-item:hover .ni-actions { display: flex; }
.ni-action-btn {
  width: 22px; height: 22px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: background var(--transition), color var(--transition);
}
.ni-action-btn:hover { background: var(--bg-surface); color: var(--text-primary); }
.ni-action-btn svg { width: 12px; height: 12px; }
.ni-action-btn.danger:hover { color: #e74c3c; }

.sidebar-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.import-btn {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
  cursor: pointer; padding: 4px 6px; border-radius: var(--r-sm);
  transition: background var(--transition), color var(--transition);
}
.import-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.import-btn svg { width: 13px; height: 13px; }
.notes-count { font-size: 11px; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════
   RICH TEXT TOOLBAR — Professional Single-Row Design
══════════════════════════════════════════════════════ */
.rich-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;          /* ← KEY: single row always */
  gap: 1px;
  padding: 0 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border), 0 2px 6px rgba(0,0,0,0.04);
  position: sticky; top: 0; z-index: 80;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.rich-toolbar::-webkit-scrollbar { display: none; }

/* ── Separator ── */
.rt-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
  opacity: 0.8;
}

/* ── Group container ── */
.rt-group {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

/* ── Base icon button ── */
.rt-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 100ms ease, color 100ms ease;
  position: relative;
}
.rt-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.rt-btn.active {
  background: var(--accent-muted);
  color: var(--accent);
}
.rt-btn svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
  display: block;
}

/* ── Format buttons B I U S — styled like real type controls ── */
.rt-fmt-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: background 100ms ease, color 100ms ease;
  line-height: 1;
}
.rt-fmt-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.rt-fmt-btn.active { background: var(--accent-muted); color: var(--accent); }
.rt-fmt-btn b {
  font-size: 13.5px;
  font-weight: 900;
  font-family: 'DM Sans', sans-serif;
  letter-spacing: -0.3px;
}
.rt-fmt-btn i {
  font-size: 14px;
  font-style: italic;
  font-family: Georgia, serif;
  font-weight: 400;
}
.rt-fmt-btn u {
  font-size: 13px;
  text-decoration: underline;
  font-family: 'DM Sans', sans-serif;
  text-underline-offset: 2px;
}
.rt-fmt-btn s {
  font-size: 13px;
  text-decoration: line-through;
  font-family: 'DM Sans', sans-serif;
}

/* ── Font size stepper ── */
.rt-size-group { gap: 1px; }

.rt-sz-btn {
  width: 18px;
  height: 26px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
  flex-shrink: 0;
  border: none;
  background: none;
}
.rt-sz-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.rt-sz-btn svg { width: 10px; height: 10px; }

.rt-size-input {
  width: 32px;
  height: 24px;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  -moz-appearance: textfield;
  flex-shrink: 0;
}
.rt-size-input::-webkit-inner-spin-button,
.rt-size-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.rt-size-input:focus { outline: none; border-color: var(--accent); }

/* ── Dropdown selects ── */
.rt-select {
  height: 26px;
  padding: 0 20px 0 7px;
  background: var(--bg-surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23aaa'/%3E%3C/svg%3E")
    no-repeat right 6px center;
  background-size: 7px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-ui);
  cursor: pointer;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 100ms ease, background 100ms ease;
  white-space: nowrap;
}
.rt-select:hover { border-color: var(--border-strong); }
.rt-select:focus { outline: none; border-color: var(--accent); }

/* ── Color preview buttons ── */
.rt-color-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.rt-color-preview {
  flex-direction: column;
  gap: 0;
  height: 26px;
  padding: 3px 4px 2px;
  width: 26px;
}
.rt-color-preview svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}
.rt-color-bar {
  display: block;
  width: 14px;
  height: 2.5px;
  border-radius: 2px;
  margin-top: 2px;
  flex-shrink: 0;
  align-self: center;
}
.hidden-color-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* ── Line spacing submenu ── */
.rt-dropdown-wrap { position: relative; }
.rt-submenu {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dropdown);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  padding: 4px;
  min-width: 170px;
  z-index: 999;
  animation: menuIn 130ms cubic-bezier(0.4,0,0.2,1);
}
.rt-submenu.hidden { display: none; }
.rt-submenu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  font-size: 12.5px;
  border-radius: 5px;
  color: var(--text-primary);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 100ms ease;
  white-space: nowrap;
  font-family: var(--font-ui);
}
.rt-submenu-item:hover { background: var(--bg-hover); }
.rt-submenu-item.active {
  color: var(--accent);
  font-weight: 600;
}

/* ── Super/Sub text labels ── */
.rt-supersub-label {
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-ui);
  line-height: 1;
  pointer-events: none;
}



#editor-area {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; position: relative;
  background: var(--bg-editor);
}

/* Find & Replace Panel */
.fr-panel {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
  box-shadow: var(--shadow-sm);
  animation: slideDown 150ms var(--ease);
}
.fr-panel.hidden { display: none; }
@keyframes slideDown {
  from { opacity:0; transform:translateY(-8px); }
  to   { opacity:1; transform:translateY(0); }
}
.fr-row { display: flex; align-items: center; gap: 8px; }
.fr-input-group {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0 10px; height: 32px;
  transition: border-color var(--transition);
}
.fr-input-group:focus-within { border-color: var(--accent); }
.fr-icon { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }
.fr-input-group input {
  flex: 1; background: none; color: var(--text-primary);
  font-size: 13px;
}
.fr-match-info { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.fr-actions-row { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.fr-btn {
  padding: 5px 10px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500;
  background: var(--bg-hover); color: var(--text-primary);
  transition: background var(--transition);
  white-space: nowrap;
}
.fr-btn:hover { background: var(--border); }
.fr-btn.accent { background: var(--accent); color: #fff; }
.fr-btn.accent:hover { background: var(--accent-hover); }
.fr-options { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fr-check {
  display: flex; align-items: center; gap: 5px; cursor: pointer;
  font-size: 12px; color: var(--text-secondary); user-select: none;
}
.fr-check input { width: 13px; height: 13px; accent-color: var(--accent); cursor: pointer; }
.fr-check span { font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.fr-close-btn {
  position: absolute; right: 12px; top: 10px;
  width: 22px; height: 22px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.fr-close-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Highlight matches */
::selection { background: rgba(36,126,132,0.25); }
.highlight-match { background: rgba(255, 213, 0, 0.4); border-radius: 2px; }
.highlight-active { background: rgba(255, 150, 0, 0.55); border-radius: 2px; }

/* Editor Wrapper */
.editor-wrapper {
  flex: 1; display: flex; overflow: hidden; position: relative;
}

/* Placeholder */
.editor-placeholder {
  position: absolute;
  top: 32px; left: calc(10% + 50px); right: 10%;
  color: var(--text-muted);
  font-style: italic; font-family: var(--font-editor);
  font-size: var(--font-size-editor); line-height: var(--line-height-editor);
  pointer-events: none; opacity: 0.65; z-index: 1;
}
.editor-placeholder.hidden { display: none; }

/* Line Numbers */
.line-numbers {
  width: 50px; min-width: 50px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow: hidden; padding: 32px 0;
  font-family: var(--font-mono);
  font-size: 12.5px; line-height: var(--line-height-editor);
  color: var(--text-muted);
  text-align: right; padding-right: 10px;
  user-select: none;
}
.line-numbers.hidden { display: none; }

/* Main ContentEditable Editor */
#editor {
  flex: 1; width: 100%; height: 100%;
  background: var(--bg-editor);
  color: var(--text-editor);
  font-family: var(--font-editor);
  font-size: var(--font-size-editor);
  line-height: var(--line-height-editor);
  padding: 32px 10% 80px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  transition: background var(--transition), color var(--transition), padding var(--transition);
  caret-color: var(--accent);
  position: relative; z-index: 2;
  word-wrap: break-word; overflow-wrap: break-word;
  white-space: pre-wrap;
  box-sizing: border-box;
}
#editor::-webkit-scrollbar { width: 6px; }
#editor::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
#editor:focus { outline: none; }
/* Rich content inside editor */
#editor h1 { font-size: 2em; font-weight: 700; margin: .4em 0 .2em; line-height: 1.25; }
#editor h2 { font-size: 1.5em; font-weight: 700; margin: .4em 0 .2em; line-height: 1.3; }
#editor h3 { font-size: 1.25em; font-weight: 600; margin: .35em 0 .15em; }
#editor h4 { font-size: 1.1em; font-weight: 600; margin: .3em 0 .1em; }
#editor p { margin: 0 0 .4em; }
#editor pre { font-family: var(--font-mono); font-size: .88em; background: var(--bg-sidebar); padding: 10px 14px; border-radius: 4px; white-space: pre-wrap; margin: .4em 0; }
#editor ul, #editor ol { padding-left: 2em; margin: .25em 0 .4em; }
#editor li { margin-bottom: .15em; }
#editor a { color: var(--accent); text-decoration: underline; }
#editor blockquote { border-left: 3px solid var(--accent); margin: .4em 0; padding: 3px 14px; color: var(--text-secondary); font-style: italic; }
#editor mark.fr-match { background: rgba(255,213,0,.45); border-radius: 2px; padding: 0 1px; }
#editor mark.fr-match-active { background: rgba(255,140,0,.6); }

/* ── Editor Toolbar (floating) ───────────────────────────── */
.editor-toolbar {
  position: absolute; bottom: 48px; right: 20px;
  display: flex; align-items: center; gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
  box-shadow: var(--shadow-md);
  z-index: 50;
}
.et-btn {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}
.et-btn:hover { background: var(--bg-hover); color: var(--accent); }
.et-btn.active { background: var(--accent-muted); color: var(--accent); }
.et-divider { width: 1px; height: 16px; background: var(--border); margin: 0 2px; }

/* Drop Overlay */
.drop-overlay {
  position: absolute; inset: 0;
  background: rgba(36,126,132,0.12);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; border: 3px dashed var(--accent); border-radius: var(--r-lg);
  margin: 8px;
}
.drop-overlay.hidden { display: none; }
.drop-message {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--accent); font-size: 18px; font-weight: 600;
}
.drop-message svg { width: 48px; height: 48px; }

/* ── Status Bar ──────────────────────────────────────────── */
#status-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-status);
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-muted);
  z-index: 100;
}

.status-left { display: flex; align-items: center; gap: 12px; }
.status-stats { display: flex; align-items: center; gap: 6px; }
.status-right { display: flex; align-items: center; gap: 10px; }

.save-status {
  display: flex; align-items: center; gap: 5px;
  font-weight: 500; font-size: 11.5px;
  transition: color var(--transition);
}
.save-status svg { width: 12px; height: 12px; }
.save-status.saved { color: #27ae60; }
.save-status.saving { color: var(--accent); }
.save-status.error { color: #e74c3c; }

.last-saved { font-size: 11px; color: var(--text-muted); }
.stat-item strong { color: var(--text-secondary); font-weight: 600; }
.stat-sep { color: var(--border-strong); }
.cursor-pos { font-family: var(--font-mono); font-size: 11px; }
.status-btn {
  padding: 1px 6px; border-radius: 3px;
  color: var(--text-muted); font-size: 13px;
  transition: background var(--transition);
}
.status-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg-overlay);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
  animation: fadeIn 150ms var(--ease);
}
.modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.modal-box {
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 24px;
  min-width: 320px; max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: modalIn 180ms var(--ease);
}
.modal-box.wide { min-width: 520px; }
@keyframes modalIn {
  from { opacity:0; transform:scale(0.95) translateY(-10px); }
  to   { opacity:1; transform:scale(1) translateY(0); }
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.modal-body { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }
.modal-input {
  width: 100%; padding: 9px 12px; border-radius: var(--r-sm);
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text-primary); font-size: 14px; margin-bottom: 16px;
  transition: border-color var(--transition);
}
.modal-input:focus { border-color: var(--accent); outline: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-btn {
  padding: 8px 18px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500;
  transition: background var(--transition), opacity var(--transition);
}
.modal-btn.primary { background: var(--accent); color: #fff; }
.modal-btn.primary:hover { background: var(--accent-hover); }
.modal-btn.secondary { background: var(--bg-hover); color: var(--text-primary); }
.modal-btn.secondary:hover { background: var(--border); }
.modal-btn.danger { background: #e74c3c; color: #fff; }
.modal-btn.danger:hover { background: #c0392b; }

/* Shortcuts grid */
.shortcuts-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 20px; margin-bottom: 20px;
}
.sg-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px;
}
.shortcut-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; border-bottom: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-secondary);
}
kbd {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  background: var(--bg-input); border: 1px solid var(--border-strong);
  border-radius: 4px; padding: 2px 6px; color: var(--text-primary);
}

/* Toast */
.toast {
  position: fixed; bottom: 50px; left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary); color: var(--bg-surface);
  padding: 9px 18px; border-radius: 100px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 2000;
  white-space: nowrap;
  animation: toastIn 200ms var(--ease);
}
.toast.hidden { display: none; }
@keyframes toastIn {
  from { opacity:0; transform:translateX(-50%) translateY(10px); }
  to   { opacity:1; transform:translateX(-50%) translateY(0); }
}

/* ── Special Modes ───────────────────────────────────────── */

/* Focus Mode */
body.focus-mode #sidebar { width:0; min-width:0; max-width:0; opacity:0; pointer-events:none; }
body.focus-mode #header .header-right > *:not(#btn-focus) { opacity:0; pointer-events:none; }
body.focus-mode #header .header-left .logo-tag { display:none; }
body.focus-mode .editor-toolbar { opacity:0; }
body.focus-mode .rich-toolbar { opacity:0; transition: opacity 0.25s ease; pointer-events: none; }
body.focus-mode #editor { padding-left: 15%; padding-right: 15%; }
body.focus-mode #status-bar .status-right,
body.focus-mode #status-bar .status-left { opacity:0; }
body.focus-mode #editor-area:hover .editor-toolbar { opacity:1; }
body.focus-mode #editor-area:hover .rich-toolbar { opacity:1; pointer-events:all; }
body.focus-mode:hover #status-bar .status-right,
body.focus-mode:hover #status-bar .status-left { opacity:1; }

/* Fullscreen */
body.fullscreen #header,
body.fullscreen #status-bar { display:none; }
body.fullscreen #main-layout { height:100vh; }
body.fullscreen #editor { padding: 48px 12%; }
body.fullscreen #sidebar { display:none; }

/* Line numbers active */
body.line-numbers-active #editor { padding-left: 16px; }

/* ── Print Styles ────────────────────────────────────────── */
@media print {
  #header, #sidebar, #status-bar, .editor-toolbar, .rich-toolbar,
  .fr-panel, #find-replace-panel, .modal-overlay, #toast { display:none !important; }
  #app { display:block; }
  #main-layout { display:block; height:auto; }
  #editor-area { height:auto; overflow:visible; }
  .editor-wrapper { height:auto; overflow:visible; }
  #editor {
    all:unset;
    display:block; width:100%; height:auto;
    font-family: 'Lora', Georgia, serif;
    font-size: 12pt; line-height: 1.8;
    color: #000; white-space: pre-wrap;
    padding: 0; overflow: visible;
  }
  body { overflow: auto; }
}

/* ── Scrollbar (global) ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 100vw; --font-size-editor: 15px; }
  #header { padding: 0 6px; }
  .toolbar-btn span { display: none; }
  .logo-tag { display: none; }
  .logo-text { font-size: 14px; }
  .note-title-display { display: none; }
  .status-stats .stat-sep:nth-child(n+6),
  .status-stats .stat-item:nth-child(n+4) { display:none; }
  #sidebar { position:absolute; top:0; left:0; bottom:0; z-index:200; }
  #editor { padding: 24px 6% 60px; }
  .shortcuts-grid { grid-template-columns: 1fr; }
  .modal-box.wide { min-width: 90vw; }
}
@media (max-width: 480px) {
  .status-stats { display: none; }
  .logo-text { display: none; }
  .logo-icon { width: 26px; height: 26px; }
  #editor { padding: 20px 4% 60px; }
}
