/* ============================================
   RESET & BASE
============================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --ink-blue: #1e40af;
  --ink-blue-hover: #1e3a8a;
  --ink-blue-soft: rgba(30, 64, 175, 0.1);
  --ink-blue-glow: rgba(30, 64, 175, 0.25);
  --red: #dc2626;
  --red-hover: #b91c1c;
  --red-soft: rgba(220, 38, 38, 0.1);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 10px;
  --radius-lg: 14px;
  --topbar-h: 60px;
  --sidebar-w: 280px;
}

body[data-theme="light"] {
  --bg: #faf7f0;
  --bg-2: #f3efe5;
  --bg-3: #ebe6d9;
  --surface: #ffffff;
  --surface-2: #faf7f0;
  --border: rgba(30, 27, 20, 0.08);
  --border-strong: rgba(30, 27, 20, 0.15);
  --text: #1a1712;
  --text-soft: #4a4439;
  --text-muted: #8a8070;
  --text-dim: #b8b0a0;
  --shadow-sm: 0 1px 2px rgba(30, 27, 20, 0.04);
  --shadow: 0 4px 12px -2px rgba(30, 27, 20, 0.08);
  --shadow-lg: 0 20px 50px -15px rgba(30, 27, 20, 0.2);
  --code-bg: #f3efe5;
  --code-text: #8b3a62;
  --quote-border: #d4c9b0;
  --quote-bg: rgba(212, 201, 176, 0.2);
  --hr-color: rgba(30, 27, 20, 0.15);
  --link-color: #1e40af;
}

body[data-theme="dark"] {
  --bg: #17140f;
  --bg-2: #1e1a14;
  --bg-3: #25201a;
  --surface: #1c1812;
  --surface-2: #201c16;
  --border: rgba(255, 245, 220, 0.06);
  --border-strong: rgba(255, 245, 220, 0.12);
  --text: #f2ede1;
  --text-soft: #c4bcac;
  --text-muted: #8a8072;
  --text-dim: #5c5445;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px -15px rgba(0, 0, 0, 0.6);
  --code-bg: #25201a;
  --code-text: #f0a8c8;
  --quote-border: #4a4232;
  --quote-bg: rgba(74, 66, 50, 0.25);
  --hr-color: rgba(255, 245, 220, 0.15);
  --link-color: #93b4f5;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

img { max-width: 100%; display: block; }
a { color: var(--link-color); text-decoration: none; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
textarea {
  font-family: inherit;
  color: inherit;
}
input:focus,
textarea:focus { outline: none; }

::selection { background: var(--ink-blue); color: white; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================
   APP SHELL
============================================ */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ============================================
   TOPBAR
============================================ */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
  z-index: 40;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-right { justify-content: flex-end; }

.topbar-center {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.view-toggle {
  width: 32px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.2s var(--ease);
}
.view-toggle:hover { color: var(--text); }
.view-toggle.active {
  background: var(--surface);
  color: var(--ink-blue);
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.2s var(--ease);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  margin-left: 0.3rem;
}

.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--ink-blue), #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px -3px var(--ink-blue-glow);
}

.logo-text {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  position: relative;
  transition: all 0.2s var(--ease);
}
.theme-toggle:hover {
  background: var(--surface-2);
  color: var(--text);
}
.theme-toggle svg {
  position: absolute;
  transition: opacity 0.3s var(--ease), transform 0.4s var(--ease);
}
body[data-theme="light"] .theme-icon-light { opacity: 0; transform: rotate(90deg); }
body[data-theme="light"] .theme-icon-dark { opacity: 1; transform: rotate(0); }
body[data-theme="dark"] .theme-icon-dark { opacity: 0; transform: rotate(-90deg); }
body[data-theme="dark"] .theme-icon-light { opacity: 1; transform: rotate(0); }

@media (max-width: 800px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    padding: 0 0.6rem;
    gap: 0.4rem;
  }
  .logo-text { display: none; }
  .btn-primary span { display: none; }
  .btn-primary { padding: 0.5rem 0.7rem; }
}

/* ============================================
   BUTTONS
============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
}
.btn-sm { padding: 0.45rem 0.75rem; font-size: 0.78rem; }

.btn-primary {
  background: var(--ink-blue);
  color: white;
  box-shadow: 0 4px 12px -3px var(--ink-blue-glow);
}
.btn-primary:hover {
  background: var(--ink-blue-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -3px var(--ink-blue-glow);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

.btn-danger {
  background: var(--red);
  color: white;
  box-shadow: 0 4px 12px -3px rgba(220, 38, 38, 0.3);
}
.btn-danger:hover {
  background: var(--red-hover);
  transform: translateY(-1px);
}

/* ============================================
   BODY LAYOUT
============================================ */
.body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ============================================
   SIDEBAR
============================================ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left 0.3s var(--ease), width 0.3s var(--ease);
}

body.focus-mode .sidebar {
  margin-left: calc(-1 * var(--sidebar-w));
}

.sidebar-search {
  padding: 0.75rem 0.75rem 0.5rem;
  flex-shrink: 0;
}

.search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s var(--ease);
}
.search:focus-within {
  border-color: var(--ink-blue);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--ink-blue-soft);
}
.search svg { color: var(--text-muted); flex-shrink: 0; }
.search input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 0.82rem;
  min-width: 0;
}
.search input::placeholder { color: var(--text-muted); }

.sidebar-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem 0.4rem;
  flex-shrink: 0;
}

.sidebar-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-count {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background: var(--surface-2);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}

.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.note-item {
  padding: 0.7rem 0.75rem;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s var(--ease);
  position: relative;
  border: 1px solid transparent;
}

.note-item:hover {
  background: var(--surface-2);
}

.note-item.active {
  background: var(--ink-blue-soft);
  border-color: rgba(30, 64, 175, 0.2);
}

.note-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.note-item.active .note-item-title { color: var(--ink-blue); }

.note-item-preview {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.3rem;
  min-height: 2em;
}

.note-item-meta {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.sidebar-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
  gap: 0.7rem;
  flex: 1;
}
.sidebar-empty.visible { display: flex; }
.sidebar-empty p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ============================================
   WORKSPACE
============================================ */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.workspace-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.6rem;
  height: 100%;
  padding: 2rem;
  color: var(--text-muted);
}
.workspace-empty.visible { display: flex; }

.workspace-empty-icon {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.workspace-empty h2 {
  font-family: var(--font-sans);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.workspace-empty p {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 320px;
}

.workspace-content {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.workspace-content.visible { display: flex; }

/* ============================================
   TOOLBAR
============================================ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-2);
  flex-wrap: wrap;
}

.toolbar-title-wrap {
  flex: 1;
  min-width: 0;
  max-width: 400px;
}

.note-title-input {
  width: 100%;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
}
.note-title-input:focus {
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--ink-blue);
}
.note-title-input::placeholder { color: var(--text-dim); }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: wrap;
}

.format-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s var(--ease);
  flex-shrink: 0;
}
.format-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.format-btn.format-btn-danger:hover {
  background: var(--red-soft);
  color: var(--red);
}

.format-text {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.toolbar-divider {
  width: 1px;
  height: 16px;
  background: var(--border-strong);
  margin: 0 0.2rem;
  flex-shrink: 0;
}

/* ============================================
   SPLIT VIEW
============================================ */
.split {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.editor-pane,
.preview-pane {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor-pane {
  flex: 1 1 50%;
  background: var(--bg);
}

.preview-pane {
  flex: 1 1 50%;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
}

.resizer {
  width: 4px;
  background: transparent;
  cursor: col-resize;
  position: relative;
  flex-shrink: 0;
  z-index: 5;
  transition: background 0.15s var(--ease);
}
.resizer:hover { background: var(--ink-blue-soft); }
.resizer.dragging { background: var(--ink-blue); }

body.view-edit .preview-pane,
body.view-edit .resizer { display: none; }
body.view-edit .editor-pane { flex: 1 1 100%; border-left: none; }

body.view-preview .editor-pane,
body.view-preview .resizer { display: none; }
body.view-preview .preview-pane { flex: 1 1 100%; border-left: none; }

/* ============================================
   EDITOR
============================================ */
.editor {
  flex: 1;
  width: 100%;
  padding: 1.5rem 2rem;
  background: transparent;
  border: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text);
  overflow-y: auto;
  tab-size: 2;
  letter-spacing: -0.005em;
}
.editor::placeholder { color: var(--text-dim); }

/* ============================================
   MARKDOWN PREVIEW
============================================ */
.preview {
  flex: 1;
  padding: 1.5rem 2rem 3rem;
  overflow-y: auto;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.75;
  max-width: 100%;
}

.preview > *:first-child { margin-top: 0; }

/* Headings */
.preview h1,
.preview h2,
.preview h3,
.preview h4,
.preview h5,
.preview h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-top: 1.8em;
  margin-bottom: 0.6em;
}

.preview h1 {
  font-size: 1.9rem;
  font-weight: 800;
  border-bottom: 1px solid var(--hr-color);
  padding-bottom: 0.4em;
  margin-top: 0;
}
.preview h2 {
  font-size: 1.5rem;
  font-weight: 700;
}
.preview h3 {
  font-size: 1.25rem;
  font-weight: 700;
}
.preview h4 { font-size: 1.1rem; font-weight: 600; }
.preview h5 { font-size: 1rem; font-weight: 600; }
.preview h6 {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Paragraphs */
.preview p {
  margin-bottom: 1em;
}

/* Links */
.preview a {
  color: var(--link-color);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: opacity 0.15s var(--ease);
}
.preview a:hover { opacity: 0.8; }

/* Bold / italic / strike */
.preview strong { font-weight: 700; color: var(--text); }
.preview em { font-style: italic; }
.preview del {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Code */
.preview code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.15em 0.45em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.preview pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 1.2em 0;
  line-height: 1.6;
}

.preview pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 0.82rem;
}

/* Blockquote */
.preview blockquote {
  border-left: 3px solid var(--quote-border);
  background: var(--quote-bg);
  padding: 0.8em 1.2em;
  margin: 1.2em 0;
  border-radius: 0 8px 8px 0;
  font-family: var(--font-sans);
  font-style: italic;
  font-weight: 400;
  font-size: 1em;
  color: var(--text-soft);
}
.preview blockquote p:last-child { margin-bottom: 0; }

/* Lists */
.preview ul,
.preview ol {
  margin: 0.8em 0 1.2em;
  padding-left: 1.6em;
}
.preview li {
  margin-bottom: 0.35em;
  line-height: 1.7;
}
.preview li > p { margin-bottom: 0.4em; }

/* Task list */
.preview ul.task-list {
  list-style: none;
  padding-left: 0.2em;
}
.preview ul.task-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.6em;
  margin-bottom: 0.5em;
}
.preview .task-checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  flex-shrink: 0;
  margin-top: 0.2em;
  transition: all 0.15s var(--ease);
}
.preview .task-checkbox.checked {
  background: var(--ink-blue);
  border-color: var(--ink-blue);
  color: white;
}
.preview .task-checkbox svg {
  width: 11px;
  height: 11px;
  display: none;
}
.preview .task-checkbox.checked svg { display: block; }

.preview .task-item-text.done {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: var(--text-dim);
}

/* Horizontal rule */
.preview hr {
  border: none;
  border-top: 1px solid var(--hr-color);
  margin: 2em 0;
}

/* Images */
.preview img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 1em 0;
  border: 1px solid var(--border);
}

/* Tables */
.preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 0.88rem;
}
.preview th,
.preview td {
  padding: 0.6em 0.9em;
  border: 1px solid var(--border-strong);
  text-align: left;
}
.preview th {
  background: var(--surface-2);
  font-weight: 600;
}

/* ============================================
   WORKSPACE FOOTER
============================================ */
.workspace-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.footer-left,
.footer-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.footer-sep { color: var(--text-dim); }

#saveStatus {
  color: var(--ink-blue);
  font-weight: 600;
}
#saveStatus.saving { color: var(--text-muted); }

/* ============================================
   MODAL
============================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 12, 8, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease);
}
.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.98);
  transition: transform 0.3s var(--ease);
  text-align: center;
}
.modal-backdrop.open .modal {
  transform: translateY(0) scale(1);
}

.confirm-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.modal-title {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.confirm-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0.4rem 0 1.5rem;
}

.modal-footer {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}

/* ============================================
   TOAST
============================================ */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--bg);
  padding: 0.7rem 1.2rem;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  transition: transform 0.4s var(--ease);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.toast-undo {
  background: rgba(255, 255, 255, 0.15);
  color: var(--bg);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}
.toast-undo:hover { background: rgba(255, 255, 255, 0.25); }

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width: 900px) {
  :root {
    --sidebar-w: 240px;
  }
}

@media (max-width: 700px) {
  .body {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    max-width: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 40vh;
  }
  .split {
    flex-direction: column;
  }
  .preview-pane {
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .resizer {
    width: 100%;
    height: 4px;
    cursor: row-resize;
  }
  body.view-split .split > .editor-pane { flex: 1 1 50%; }
  body.view-split .split > .preview-pane { flex: 1 1 50%; }

  .editor,
  .preview {
    padding: 1rem 1.2rem;
  }
  .toolbar {
    padding: 0.5rem 0.7rem;
  }
  .toolbar-title-wrap { max-width: none; }
  .toolbar-actions { gap: 0.05rem; }
  .format-btn { width: 28px; height: 28px; }
  .note-title-input { font-size: 1.05rem; }
  .workspace-footer { padding: 0.4rem 0.8rem; }
  .footer-left .footer-stat:nth-child(n+3) { display: none; }
}