/* =========================================
   MarkNote - Markdown Notes App
   Premium Dark Theme CSS (Glassmorphism Edition)
   ========================================= */

:root {
  /* Colors - Premium Dark Theme */
  --bg-primary: #09090b; /* Deep Zinc */
  --bg-secondary: rgba(24, 24, 27, 0.7); /* Zinc 900 with opacity */
  --bg-tertiary: rgba(39, 39, 42, 0.5); /* Zinc 800 with opacity */
  --bg-hover: rgba(63, 63, 70, 0.5); /* Zinc 700 with opacity */
  --bg-active: rgba(39, 39, 42, 0.8);

  --backdrop-blur: 12px;
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.03);

  --border-primary: rgba(255, 255, 255, 0.1);
  --border-secondary: rgba(255, 255, 255, 0.06);
  --border-active: #3b82f6; /* Blue 500 */

  --text-primary: #f4f4f5; /* Zinc 100 */
  --text-secondary: #a1a1aa; /* Zinc 400 */
  --text-muted: #71717a; /* Zinc 500 */
  --text-link: #60a5fa; /* Blue 400 */

  --accent-primary: #10b981; /* Emerald 500 */
  --accent-hover: #059669; /* Emerald 600 */
  --accent-blue: #3b82f6; /* Blue 500 */
  --accent-purple: #8b5cf6; /* Violet 500 */
  --accent-orange: #f59e0b; /* Amber 500 */
  --accent-red: #ef4444; /* Red 500 */
  --accent-pink: #ec4899; /* Pink 500 */

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  --gradient-sunset: linear-gradient(135deg, #f472b6 0%, #facc15 100%);
  --gradient-dark: linear-gradient(
    to bottom,
    rgba(24, 24, 27, 0) 0%,
    rgba(24, 24, 27, 0.8) 100%
  );

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3),
    0 2px 4px -1px rgba(0, 0, 0, 0.16);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4),
    0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.3);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.2);

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

  /* Spacing */
  --sidebar-width: 280px;
  --menubar-height: 44px;
  --toolbar-height: 60px;
  --panel-header-height: 48px;

  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
}

/* Light Theme - Adjusted for consistency */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: rgba(244, 244, 245, 0.8); /* Zinc 100 */
  --bg-tertiary: rgba(228, 228, 231, 0.6); /* Zinc 200 */
  --bg-hover: rgba(212, 212, 216, 0.6); /* Zinc 300 */
  --bg-active: rgba(228, 228, 231, 1); /* Zinc 200 */

  --glass-border: rgba(0, 0, 0, 0.06);
  --glass-highlight: rgba(255, 255, 255, 0.5);

  --border-primary: rgba(0, 0, 0, 0.1);
  --border-secondary: rgba(0, 0, 0, 0.05);
  --border-active: #3b82f6;

  --text-primary: #18181b; /* Zinc 950 */
  --text-secondary: #52525b; /* Zinc 600 */
  --text-muted: #a1a1aa; /* Zinc 400 */
  --text-link: #2563eb; /* Blue 600 */

  --accent-primary: #059669;
  --accent-hover: #047857;
  --accent-blue: #2563eb;
  --accent-purple: #7c3aed;
  --accent-orange: #d97706;
  --accent-red: #dc2626;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 15px rgba(37, 99, 235, 0.2);
}

/* =========================================
   Reset & Base
   ========================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  background-image: radial-gradient(
      circle at 15% 50%,
      rgba(59, 130, 246, 0.08),
      transparent 25%
    ),
    radial-gradient(
      circle at 85% 30%,
      rgba(139, 92, 246, 0.08),
      transparent 25%
    );
  background-attachment: fixed;
}

::selection {
  background: rgba(59, 130, 246, 0.3);
  color: inherit;
}

/* Custom Scrollbar - Minimalist */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* =========================================
   App Container
   ========================================= */

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* =========================================
   Sidebar (Glassmorphism)
   ========================================= */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  backdrop-filter: blur(var(--backdrop-blur));
  -webkit-backdrop-filter: blur(var(--backdrop-blur));
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal), width var(--transition-normal),
    margin-left var(--transition-normal);
  z-index: 50;
  position: relative;
}

/* Desktop Collapsed State */
.sidebar.collapsed {
  margin-left: calc(var(--sidebar-width) * -1);
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 24px;
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.3));
}

.logo-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.new-note-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.new-note-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.new-note-btn:active {
  transform: translateY(0);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-inner);
}

.search-box:focus-within {
  border-color: var(--accent-blue);
  background: var(--bg-hover);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.search-box:focus-within svg {
  color: var(--text-primary);
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
}

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

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

.note-item {
  padding: 16px 18px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.note-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-secondary);
}

.note-item.active {
  background: var(--bg-active);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
}

.note-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--gradient-primary);
}

.note-item-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 10px;
}

.note-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
}

.note-item-date {
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.8;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-secondary);
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(5px);
}

.note-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
}

/* =========================================
   Main Content
   ========================================= */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: visible;
  background: var(--bg-primary);
  position: relative;
}

/* =========================================
   Menubar (Word-style)
   ========================================= */

.menubar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--menubar-height);
  padding: 0 16px;
  background: var(--bg-secondary);
  backdrop-filter: blur(var(--backdrop-blur));
  -webkit-backdrop-filter: blur(var(--backdrop-blur));
  border-bottom: 1px solid var(--border-primary);
  position: relative;
  z-index: 1200;
  overflow: visible;
}

.menu-group {
  position: relative;
  flex: 0 0 auto;
}

.menu-trigger {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.menu-trigger:hover,
.menu-group.open .menu-trigger {
  background: var(--bg-tertiary);
  border-color: var(--border-secondary);
  color: var(--text-primary);
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  max-height: 70vh;
  overflow: auto;
  display: none;
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
  background: rgba(24, 24, 27, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  z-index: 1500 !important;
  animation: scaleIn 0.15s ease;
}

[data-theme="light"] .menu-dropdown {
  background: rgba(244, 244, 245, 0.95);
}

.menu-group.open .menu-dropdown {
  display: block;
}

.menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.menu-item:hover {
  background: var(--bg-hover);
}

.menu-subtitle {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.menu-separator {
  height: 1px;
  background: var(--border-secondary);
  margin: 6px 0;
}

/* Focus Mode */
body.focus-mode .sidebar {
  display: none;
}

body.focus-mode .toolbar-left #toggleSidebar {
  display: none;
}

/* =========================================
   Toolbar (Glass Header)
   ========================================= */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--toolbar-height);
  padding: 0 24px;
  background: var(--bg-secondary);
  backdrop-filter: blur(var(--backdrop-blur));
  -webkit-backdrop-filter: blur(var(--backdrop-blur));
  border-bottom: 1px solid var(--border-primary);
  gap: 20px;
  z-index: 1100 !important;
  overflow: visible !important;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: visible !important;
  max-width: 100%;
  padding-bottom: 4px; /* Space for scrollbar if needed */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Hide scrollbar for cleaner look if possible, or keep it */
}

.toolbar-right::-webkit-scrollbar {
  display: none; /* Hide scrollbar for Chrome/Safari */
}

.toolbar-center {
  flex: 1;
  max-width: 600px;
}

.toolbar-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.toolbar-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.toolbar-btn.active {
  background: var(--bg-active);
  color: var(--accent-blue);
  box-shadow: var(--shadow-sm);
}

.toolbar-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  border-color: rgba(239, 68, 68, 0.2);
}

.note-title-input {
  width: 100%;
  background: transparent;
  border: none;
  padding: 8px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  outline: none;
  text-align: center;
  transition: all var(--transition-fast);
  border-bottom: 2px solid transparent;
}

.note-title-input:focus {
  border-bottom-color: var(--accent-blue);
}

.note-title-input::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

/* Format Buttons Group */
.format-buttons {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-secondary);
}

.format-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.format-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.format-btn.text-btn {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  min-width: 32px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-secondary);
  margin: 0 8px;
}

/* =========================================
   Editor Container
   ========================================= */

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

/* WYSIWYG Panel */
.wysiwyg-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* Preview Panel */
.preview-panel {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

.preview-content {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 32px 100px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-primary);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--panel-header-height);
  padding: 0 32px;
  background: transparent;
  border-bottom: 1px solid var(--border-secondary);
  font-size: 12px;
  color: var(--text-muted);
}

.word-count {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* Editor Area */
.wysiwyg-editor {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 32px 100px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-primary);
}

#editor {
  outline: none;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.8;
  color: var(--text-primary);
  position: relative;
}

#preview {
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.8;
  color: var(--text-primary);
}

#editor.is-empty::before {
  content: "Düşüncelerinizi yazın...";
  color: var(--text-muted);
  opacity: 0.5;
  pointer-events: none;
  position: absolute;
  font-style: italic;
  font-size: 17px;
}

/* =========================================
   Content Styles (Markdown)
   ========================================= */

:is(#editor, #preview) h1,
:is(#editor, #preview) h2,
:is(#editor, #preview) h3,
:is(#editor, #preview) h4,
:is(#editor, #preview) h5,
:is(#editor, #preview) h6 {
  margin-top: 2em;
  margin-bottom: 0.8em;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

:is(#editor, #preview) h1 {
  font-size: 2.5em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border-secondary);
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
  margin-top: 1em;
}

:is(#editor, #preview) h2 {
  font-size: 1.8em;
  border-bottom: 1px solid var(--border-secondary);
  padding-bottom: 0.3em;
}

:is(#editor, #preview) h3 {
  font-size: 1.4em;
}
:is(#editor, #preview) h4 {
  font-size: 1.2em;
}

:is(#editor, #preview) h5 {
  font-size: 1.05em;
  color: var(--text-secondary);
}

:is(#editor, #preview) h6 {
  font-size: 0.95em;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

:is(#editor, #preview) p {
  margin-bottom: 1.5em;
}

:is(#editor, #preview) a {
  color: var(--text-link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

:is(#editor, #preview) a:hover {
  border-bottom-color: var(--text-link);
}

:is(#editor, #preview) strong {
  font-weight: 700;
  color: var(--text-primary);
}

:is(#editor, #preview) code {
  padding: 0.2em 0.4em;
  margin: 0 0.2em;
  font-size: 0.9em;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  color: var(--accent-orange);
}

:is(#editor, #preview) mark {
  background: rgba(245, 158, 11, 0.28);
  color: inherit;
  padding: 0.05em 0.25em;
  border-radius: 4px;
}

[data-theme="light"] :is(#editor, #preview) mark {
  background: rgba(245, 158, 11, 0.22);
}

:is(#editor, #preview) u {
  text-decoration: underline;
  text-decoration-color: rgba(59, 130, 246, 0.9);
  text-underline-offset: 3px;
}

:is(#editor, #preview) pre {
  padding: 20px;
  overflow: auto;
  background: #111113; /* Darker than bg */
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  margin: 1.5em 0;
  box-shadow: var(--shadow-inner);
}

:is(#editor, #preview) pre code {
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 14px;
}

:is(#editor, #preview) blockquote {
  margin: 1.5em 0;
  padding: 1em 1.5em;
  border-left: 4px solid var(--accent-purple);
  background: var(--bg-secondary); /* Glassy background */
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Hashtags / Tags */
:is(#editor, #preview) .hashtag {
  display: inline-block;
  background: linear-gradient(
    135deg,
    rgba(217, 165, 32, 0.2),
    rgba(217, 165, 32, 0.1)
  );
  color: #d9a520;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.9em;
  font-weight: 500;
  margin: 2px 4px 2px 0;
  border: 1px solid rgba(217, 165, 32, 0.3);
  cursor: pointer;
  transition: all 0.2s;
}

:is(#editor, #preview) .hashtag:hover {
  background: linear-gradient(
    135deg,
    rgba(217, 165, 32, 0.3),
    rgba(217, 165, 32, 0.2)
  );
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(217, 165, 32, 0.2);
}

:is(#editor, #preview, .template-preview) blockquote.md-callout {
  font-style: normal;
  position: relative;
}

:is(#editor, #preview, .template-preview) .md-callout-title {
  font-weight: 900;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
  color: var(--text-primary);
}

:is(#editor, #preview, .template-preview) blockquote.md-callout-note {
  border-left-color: var(--accent-blue);
}

:is(#editor, #preview, .template-preview) blockquote.md-callout-tip {
  border-left-color: var(--accent-primary);
}

:is(#editor, #preview, .template-preview) blockquote.md-callout-important {
  border-left-color: var(--accent-purple);
}

:is(#editor, #preview, .template-preview) blockquote.md-callout-warning {
  border-left-color: var(--accent-orange);
}

:is(#editor, #preview, .template-preview) blockquote.md-callout-caution {
  border-left-color: var(--accent-red);
}

:is(#editor, #preview, .template-preview) dl.md-deflist {
  margin: 1.5em 0;
  padding: 14px 16px;
  border: 1px solid var(--border-secondary);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

:is(#editor, #preview, .template-preview) dl.md-deflist dt {
  font-weight: 900;
  color: var(--text-primary);
  margin-top: 8px;
}

:is(#editor, #preview, .template-preview) dl.md-deflist dd {
  margin-left: 18px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

:is(#editor, #preview, .template-preview) .mermaid {
  margin: 1.5em 0;
  padding: 14px 16px;
  border: 1px solid var(--border-secondary);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  overflow: auto;
}

:is(#editor, #preview, .template-preview) .mermaid svg {
  max-width: 100%;
  height: auto;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
}

:is(#editor, #preview, .template-preview) details {
  margin: 1.5em 0;
  padding: 12px 14px;
  border: 1px solid var(--border-secondary);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

:is(#editor, #preview, .template-preview) summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--text-primary);
}

:is(#editor, #preview, .template-preview) summary::-webkit-details-marker {
  color: var(--text-secondary);
}

:is(#editor, #preview, .template-preview) progress {
  width: min(400px, 80%);
  height: 16px;
  vertical-align: middle;
}

/* Progress bar container - align bar and percentage text */
:is(#editor, #preview, .template-preview) p:has(progress) {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 1em 0;
}

:is(#editor, #preview) ul,
:is(#editor, #preview) ol {
  margin: 1.5em 0;
  padding-left: 2em;
}

:is(#editor, #preview) li {
  margin-bottom: 0.5em;
  padding-left: 0.5em;
}

:is(#editor, #preview) hr {
  border: none;
  height: 1px;
  background: var(--border-primary);
  margin: 3em 0;
}

/* Tables */
:is(#editor, #preview) table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 2em 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-primary);
}

:is(#editor, #preview) th,
:is(#editor, #preview) td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-secondary);
  border-right: 1px solid var(--border-secondary);
  text-align: left;
}

:is(#editor, #preview) th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
}

:is(#editor, #preview) tr:last-child td {
  border-bottom: none;
}

:is(#editor, #preview) tr:hover td {
  background: var(--bg-hover);
}

/* Task Checkboxes */
:is(#editor, #preview) .task-list-item {
  list-style: none;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  transition: background 0.1s;
}

:is(#editor, #preview) .task-list-item:hover {
  background: var(--bg-secondary);
}

:is(#editor, #preview) input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 4px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

:is(#editor, #preview) input[type="checkbox"]:checked + .task-text {
  color: var(--text-muted);
  text-decoration: line-through;
  opacity: 0.7;
}

/* Task text span - editable area */
:is(#editor, #preview) .task-text {
  flex: 1;
  min-width: 100px;
  min-height: 1.5em;
  display: inline-block;
  outline: none;
  cursor: text;
}

:is(#editor, #preview) .task-text:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  opacity: 0.5;
  pointer-events: none;
}

:is(#editor, #preview) .task-text:focus {
  outline: none;
  background: rgba(59, 130, 246, 0.05);
  border-radius: var(--radius-sm);
}

/* =========================================
   Table Tools & Floaties
   ========================================= */

.table-tools {
  background: rgba(24, 24, 27, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-active);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border-radius: var(--radius-md);
  padding: 6px;
  display: flex;
  gap: 6px;
  z-index: 1000;
  position: fixed;
  animation: fadeIn 0.2s ease;
}

.table-tool-btn {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-secondary);
  background: var(--bg-tertiary);
  color: var(--text-display);
  cursor: pointer;
  transition: all 0.2s;
}

.table-tool-btn:hover {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}

.table-tool-btn.danger:hover {
  background: var(--accent-red);
  border-color: var(--accent-red);
}

/* =========================================
   Find & Replace (Floating)
   ========================================= */

.find-replace-panel {
  position: absolute;
  top: calc(var(--menubar-height) + 10px);
  right: 24px;
  background: rgba(24, 24, 27, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-primary);
  padding: 12px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 900;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: none;
}

.find-input-group {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  border: 1px solid var(--border-secondary);
}

.find-input-group:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.find-input-group input {
  background: transparent;
  border: none;
  color: white;
  padding: 4px;
  width: 160px;
  outline: none;
  font-size: 13px;
}

.find-buttons button {
  padding: 4px 8px;
  margin-right: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-secondary);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
}

.find-buttons button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* =========================================
   Toast Notifications
   ========================================= */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(24, 24, 27, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 14px;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.toast.show {
  transform: translateX(0);
}

.toast.success {
  border-left: 4px solid var(--accent-primary);
}
.toast.error {
  border-left: 4px solid var(--accent-red);
}
.toast.info {
  border-left: 4px solid var(--accent-blue);
}

/* =========================================
   Modal (Glass)
   ========================================= */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 3000;
  display: none; /* Flex when active */
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  width: 90%;
  max-width: 550px;
  max-height: 80vh;
  overflow-y: auto;
  animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.25em;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
}

.modal-content.modal-lg {
  max-width: 860px;
}

.modal-content.modal-xl {
  max-width: 1100px;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-secondary);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-action-btn {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-secondary);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  transition: all var(--transition-fast);
}

.modal-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Template Center */
.template-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.template-toolbar input,
.template-toolbar select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text-primary);
  outline: none;
  font-size: 13px;
}

.template-toolbar input:focus,
.template-toolbar select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.template-toolbar input {
  flex: 1;
  min-width: 200px;
}

.template-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
}

.template-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.template-card {
  border: 1px solid var(--border-secondary);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.template-card-title {
  font-weight: 800;
  letter-spacing: -0.01em;
}

.template-card-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.template-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.template-card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.template-mini-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-secondary);
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  transition: all var(--transition-fast);
}

.template-mini-btn:hover {
  background: var(--bg-hover);
}

.template-mini-btn.primary {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--accent-blue);
}

.template-mini-btn.primary:hover {
  background: rgba(59, 130, 246, 0.26);
}

/* Template Editor */
.template-editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.template-editor-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.field input,
.field textarea {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text-primary);
  outline: none;
  font-size: 13px;
  font-family: var(--font-sans);
}

.field textarea {
  font-family: var(--font-mono);
  line-height: 1.6;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.template-editor-preview {
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

.template-preview-title {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-secondary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.template-preview {
  padding: 12px;
  overflow: auto;
  max-height: 520px;
}

.template-preview h1,
.template-preview h2,
.template-preview h3,
.template-preview h4,
.template-preview h5,
.template-preview h6 {
  margin: 0.9em 0 0.5em;
  line-height: 1.3;
}

.template-preview p {
  margin: 0.6em 0;
}

.template-preview code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-secondary);
}

.template-preview pre {
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-secondary);
  overflow: auto;
}

.template-preview pre code {
  padding: 0;
  border: none;
  background: transparent;
}

.template-preview blockquote {
  border-left: 4px solid var(--accent-purple);
  padding: 0.6em 1em;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.template-editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.template-editor-actions .spacer {
  flex: 1;
}

.btn {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-secondary);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 800;
  transition: all var(--transition-fast);
}

.btn:hover {
  background: var(--bg-hover);
}

.btn.primary {
  background: rgba(59, 130, 246, 0.95);
  border-color: rgba(59, 130, 246, 1);
  color: white;
}

.btn.primary:hover {
  filter: brightness(1.04);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.25);
  color: var(--accent-red);
}

.btn.danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.shortcut-group h4 {
  margin-bottom: 12px;
  color: var(--accent-blue);
}
.shortcut-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
}

kbd {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-secondary);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

/* =========================================
   Responsive & Sidebar Mobile Fixes
   ========================================= */

@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
    --toolbar-height: auto;
    --menubar-height: 40px;
  }

  /* =========================================
     Sidebar (Mobile Off-Canvas)
     ========================================= */
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px !important;
    min-width: 280px !important;
    max-width: 85vw !important;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    border-right: 1px solid var(--glass-border);
    margin-left: 0 !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    margin-left: 0 !important;
    transform: translateX(-100%);
  }

  /* Sidebar Overlay */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 95;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
  }

  /* =========================================
     Menubar (Mobile)
     ========================================= */
  .menubar {
    padding: 0 8px;
    height: var(--menubar-height);
    gap: 2px;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .menubar::-webkit-scrollbar {
    display: none;
  }

  .menu-trigger {
    padding: 6px 8px;
    font-size: 12px;
    white-space: nowrap;
  }

  .menu-dropdown {
    min-width: 200px;
    max-width: 90vw;
    left: 0;
    right: auto;
  }

  .menu-item {
    padding: 12px 14px;
    font-size: 14px;
  }

  /* =========================================
     Toolbar (Mobile)
     ========================================= */
  .toolbar {
    display: flex !important;
    flex-wrap: wrap !important;
    padding: 8px 12px !important;
    gap: 8px !important;
    min-height: 56px;
    height: auto !important;
  }

  .toolbar-left {
    order: 1;
    flex: 0 0 auto;
  }

  .toolbar-center {
    order: 3;
    flex: 1 1 100% !important;
    max-width: 100% !important;
    margin-top: 4px;
  }

  .toolbar-right {
    order: 2;
    flex: 1 1 auto;
    display: flex !important;
    flex-wrap: nowrap;
    justify-content: flex-end;
    overflow-x: visible;
    overflow-y: visible;
    gap: 4px !important;
    -webkit-overflow-scrolling: touch;
    max-width: calc(100% - 50px);
  }

  .note-title-input {
    font-size: 15px;
    text-align: left;
    padding: 6px 0;
  }

  /* Touch-friendly button sizes */
  .toolbar-btn {
    min-width: 40px;
    min-height: 40px;
    width: 40px;
    height: 40px;
  }

  .toolbar-btn.dropdown-trigger {
    min-width: 44px;
    padding: 0 8px;
  }

  .toolbar-btn.dropdown-trigger .btn-label {
    display: none;
  }

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

  .toolbar-divider {
    display: none;
  }

  /* Hide some toolbar items on mobile */
  .toolbar-right #findReplaceBtn,
  .toolbar-right #exportBtn {
    display: none;
  }

  /* =========================================
     Toolbar Dropdowns (Mobile)
     ========================================= */
  .toolbar .toolbar-group {
    position: static;
  }

  .toolbar .toolbar-dropdown-menu {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    min-width: 100%;
    max-width: 100%;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 12px 16px 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    animation: slideUp 0.25s ease;
    z-index: 9999 !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
  }

  /* Dropdown overlay for mobile */
  .dropdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
  }

  .dropdown-overlay.visible {
    opacity: 1;
    visibility: visible;
  }

  .toolbar-dropdown-menu .dropdown-item {
    padding: 14px 16px;
    font-size: 15px;
    border-radius: var(--radius-md);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
    user-select: none;
  }

  .toolbar-dropdown-menu .dropdown-item:active {
    background: var(--bg-hover);
    transform: scale(0.98);
  }

  .dropdown-divider {
    margin: 8px 0;
  }

  @keyframes slideUp {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  /* =========================================
     Find & Replace Panel (Mobile)
     ========================================= */
  .find-replace-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 16px;
  }

  .find-replace-inner {
    flex-direction: column;
    gap: 12px;
  }

  .find-input-group {
    width: 100%;
  }

  .find-input-group input {
    width: 100%;
  }

  .find-buttons {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .find-btn {
    flex: 1;
    min-width: 60px;
    padding: 12px;
  }

  /* =========================================
     Modals (Mobile)
     ========================================= */
  .modal-content {
    width: 95vw;
    max-width: 95vw;
    max-height: 90vh;
    margin: 5vh auto;
    border-radius: var(--radius-lg);
  }

  .modal-content.modal-lg,
  .modal-content.modal-xl {
    width: 95vw;
    max-width: 95vw;
  }

  .modal-header {
    padding: 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .modal-header h3 {
    font-size: 1.1em;
    flex: 1 1 100%;
  }

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

  .modal-body {
    padding: 16px;
    overflow-y: auto;
  }

  /* Template Center Mobile */
  .template-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .template-toolbar input {
    min-width: 100%;
  }

  .template-list {
    grid-template-columns: 1fr;
  }

  .template-editor-grid {
    grid-template-columns: 1fr;
  }

  .template-preview {
    max-height: 200px;
  }

  .template-editor-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  .template-editor-actions .btn {
    flex: 1;
    min-width: 80px;
  }

  /* Shortcuts Modal Mobile */
  .shortcuts-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .shortcut-item {
    font-size: 13px;
  }

  .shortcut-item kbd {
    padding: 4px 6px;
    font-size: 11px;
  }

  /* =========================================
     Editor & Preview (Mobile)
     ========================================= */
  .wysiwyg-editor {
    padding: 20px 16px 100px;
  }

  .preview-content {
    padding: 20px 16px 100px;
  }

  #editor,
  #preview {
    font-size: 16px;
    line-height: 1.7;
  }

  .panel-header {
    padding: 0 16px;
    height: 40px;
  }

  .word-count {
    font-size: 11px;
    padding: 3px 8px;
  }

  /* Context Menu Mobile */
  .context-menu {
    min-width: 180px;
  }

  .context-item {
    padding: 12px 16px;
  }

  /* Toast Notifications Mobile */
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    width: 100%;
  }
}

/* =========================================
   Extra Small Screens (< 576px)
   ========================================= */
@media (max-width: 576px) {
  /* Even more compact toolbar */
  .toolbar {
    padding: 6px 8px;
    gap: 6px;
  }

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

  .toolbar-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Hide more buttons on very small screens */
  .toolbar-right #themeToggleBtn,
  .toolbar-right #undoBtn,
  .toolbar-right #redoBtn {
    display: none;
  }

  /* Menubar compact */
  .menubar {
    height: 36px;
    padding: 0 4px;
  }

  .menu-trigger {
    padding: 4px 6px;
    font-size: 11px;
  }

  /* Full screen modals on very small screens */
  .modal-content,
  .modal-content.modal-lg,
  .modal-content.modal-xl {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .modal-header {
    padding: 12px;
  }

  .modal-body {
    padding: 12px;
    flex: 1;
  }

  /* Editor compact */
  .wysiwyg-editor,
  .preview-content {
    padding: 16px 12px 80px;
  }

  #editor,
  #preview {
    font-size: 15px;
  }

  /* Sidebar full width on very small */
  :root {
    --sidebar-width: 100vw;
  }

  .sidebar {
    width: 100vw;
    max-width: 100vw;
  }

  /* Note items compact */
  .note-item {
    padding: 12px 14px;
  }

  .note-item-title {
    font-size: 14px;
  }

  .note-item-preview {
    font-size: 12px;
  }

  /* Search box compact */
  .search-box {
    margin: 12px;
    padding: 10px 12px;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes slideDown {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* =========================================
   Toolbar Dropdowns (New)
   ========================================= */

.toolbar-group {
  position: relative;
  display: inline-block;
}

.toolbar-btn.dropdown-trigger {
  width: auto;
  padding: 0 10px;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}

.toolbar-btn.dropdown-trigger .btn-label {
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: rgba(24, 24, 27, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--glass-border);
  z-index: 1500 !important;
  transform-origin: top left;
  animation: scaleIn 0.15s ease;
}

[data-theme="light"] .toolbar-dropdown-menu {
  background: rgba(255, 255, 255, 0.95);
  border-color: var(--border-secondary);
}

.toolbar-dropdown-menu.show {
  display: flex;
  height: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--bg-hover);
  transform: translateX(2px);
}

.dropdown-item .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
}

.dropdown-item:hover .icon {
  color: var(--accent-blue);
}

.dropdown-item.danger-text {
  color: var(--accent-red);
}

.dropdown-item.danger-text:hover {
  background: rgba(239, 68, 68, 0.1);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-secondary);
  margin: 4px 0;
}
