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

:root {
  --bg: #f2f0e8;
  --surface: #ffffff;
  --surface-alt: #f8f7f3;
  --text: #2a2a2a;
  --text-secondary: #5a6348;
  --text-tertiary: #8a9a6a;
  --border: rgba(0, 0, 0, 0.09);
  --border-subtle: rgba(0, 0, 0, 0.06);
  --accent: #4a7a00;
  --accent-hover: #3d5a1a;
  --accent-light: rgba(74, 122, 0, 0.10);
  --danger: #b44040;
  --danger-hover: #933434;
  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 22px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 2px 4px rgba(0, 0, 0, 0.06);
  --font: 'Georgia', 'Times New Roman', serif;
  --font-sans: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --title-font-size: 2.25rem;
  --content-font-size: 2rem;
  --sidebar-width: 280px;
  --content-inset: 12px;
  --brand: #4a6a2a;
  --brand-secondary: #5a6e3a;
  --brand-hover: #3d5a1a;
}

/* ==================== DARK MODE ==================== */
body.dark-mode {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-alt: #1c2128;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --text-tertiary: #6e7681;
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --accent: #7aaa30;
  --accent-hover: #8fc040;
  --accent-light: rgba(122, 170, 48, 0.12);
  --danger: #f85149;
  --danger-hover: #ff6e67;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.4);
  --brand: #8fc040;
  --brand-secondary: #7aaa30;
  --brand-hover: #a0d050;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Scanlines overlay — dark mode only */
body.dark-mode::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

.hidden { display: none !important; }

/* ==================== AUTH SCREEN ==================== */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  gap: 16px;
}

.auth-container h1 {
  font-size: 2.5rem;
  font-weight: 400;
  letter-spacing: -0.5px;
}

.auth-container p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 16px;
}

/* ==================== BUTTONS ==================== */
.btn {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn:hover { border-color: var(--text-secondary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary { background: var(--bg); color: var(--text-secondary); }
.btn-secondary:hover { background: var(--surface); border-color: var(--accent); color: var(--text); }

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-ghost {
  border: none;
  background: none;
  color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text); }

.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
}

.btn-sm {
  font-size: 0.78rem;
  padding: 4px 10px;
}

/* ==================== LAYOUT: SIDEBAR + CONTENT CARD ==================== */
#main-screen {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar (Layer 0 — part of the background) --- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px 16px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
}

/* Collapsed sidebar */
.sidebar.collapsed,
body.sidebar-collapsed-init .sidebar {
  width: 44px !important;
  padding: 28px 8px;
  overflow: hidden;
}
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .sidebar-sort-bar,
.sidebar.collapsed .sidebar-entries,
.sidebar.collapsed .sidebar-empty,
.sidebar.collapsed #new-entry-sidebar-btn,
.sidebar.collapsed #new-folder-sidebar-btn,
body.sidebar-collapsed-init .sidebar .sidebar-brand,
body.sidebar-collapsed-init .sidebar .sidebar-search,
body.sidebar-collapsed-init .sidebar .sidebar-sort-bar,
body.sidebar-collapsed-init .sidebar .sidebar-entries,
body.sidebar-collapsed-init .sidebar .sidebar-empty,
body.sidebar-collapsed-init .sidebar #new-entry-sidebar-btn,
body.sidebar-collapsed-init .sidebar #new-folder-sidebar-btn {
  display: none;
}
.sidebar.collapsed .sidebar-header,
body.sidebar-collapsed-init .sidebar .sidebar-header {
  justify-content: center;
  margin-bottom: 4px;
}
.sidebar.collapsed .sidebar-header-actions,
body.sidebar-collapsed-init .sidebar .sidebar-header-actions {
  gap: 0;
}

/* Collapsed-only elements (hidden when expanded) */
.collapsed-only.sidebar-icon-btn {
  display: none;
}
.sidebar.collapsed .collapsed-only.sidebar-icon-btn,
body.sidebar-collapsed-init .sidebar .collapsed-only.sidebar-icon-btn {
  display: flex;
  margin-top: 4px;
}

/* Content wrapper offset for collapsed-init */
body.sidebar-collapsed-init .content-wrapper {
  margin-left: 44px;
}

/* Resize handle */
.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s ease;
  z-index: 25;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
  background: transparent;
}
.sidebar.collapsed .sidebar-resize-handle {
  display: none;
}

/* Disable transitions while dragging */
.sidebar.resizing {
  transition: none;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sidebar-brand {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand);
  padding: 0 4px;
}

.sidebar-header-actions {
  display: flex;
  gap: 4px;
  position: relative;
}

.sidebar-icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-secondary);
  opacity: 0.6;
  transition: all 0.15s ease;
}
.sidebar-icon-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
}
.sidebar-icon-btn svg {
  width: 16px;
  height: 16px;
}

.sidebar-search {
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.5);
  color: var(--text);
  width: 100%;
  margin-bottom: 12px;
}
.sidebar-search:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.8);
}
.sidebar-search::placeholder {
  color: var(--text-tertiary);
}

.sidebar-sort-bar {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
}

.sidebar-sort-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
}

.sidebar-sort-btn:hover {
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.04);
}

.sidebar-sort-btn.active {
  color: var(--accent);
}

.sidebar-entries {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s ease;
  gap: 8px;
}
.sidebar-entry:hover {
  background: rgba(0, 0, 0, 0.04);
  transform: translateX(3px);
}
.sidebar-entry.active {
  background: rgba(74, 122, 0, 0.1);
}
.sidebar-entry.selected {
  background: rgba(74, 122, 0, 0.07);
}
.sidebar-entry.selected.active {
  background: rgba(74, 122, 0, 0.1);
}

.sidebar-entry-title {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.sidebar-entry.active .sidebar-entry-title {
  color: var(--accent);
  font-weight: 500;
}
.sidebar-entry.selected .sidebar-entry-title {
  color: var(--accent);
}

.sidebar-entry-date {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-empty {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 20px 4px;
  text-align: center;
}

.sidebar-link {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-secondary);
  text-decoration: none;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.sidebar-link:hover {
  color: var(--brand-hover);
  transform: translateX(8px);
}

.sidebar-link svg {
  width: 16px;
  height: 16px;
  min-width: 16px;
  flex-shrink: 0;
  opacity: 0.5;
  transition: all 0.3s ease;
}

.sidebar-link:hover svg {
  opacity: 0.7;
}

.sidebar-bottom {
  padding-top: 16px;
}

.sidebar-logout {
  color: var(--brand-secondary);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  gap: 12px;
  opacity: 0.6;
}
.sidebar-logout svg {
  width: 14px;
  height: 14px;
  min-width: 14px;
  opacity: 0.5;
}
.sidebar-logout:hover {
  opacity: 1;
  transform: translateX(8px);
}
.sidebar-logout:hover svg {
  opacity: 0.8;
}

/* --- Content wrapper (Layer 1 — the floating card) --- */
.content-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: var(--content-inset);
  padding-left: 0;
  min-height: 100vh;
  display: flex;
}
.content-wrapper.resizing {
  transition: none;
}

.content-card {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: calc(100vh - var(--content-inset) * 2);
  transition: box-shadow 0.15s ease;
}

/* Highlight content card border when sidebar resize handle is hovered or dragged */
.sidebar:has(.sidebar-resize-handle:hover) ~ .content-wrapper .content-card,
.content-wrapper.resizing .content-card {
  box-shadow: 0 0 0 4px rgba(74, 122, 0, 0.35), var(--shadow-card);
}

/* --- Welcome / empty state in content area --- */
.welcome-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

/* --- Settings panel extras --- */
.settings-select {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.settings-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(74, 122, 0, 0.15);
}

.settings-hint {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

/* --- Main content area --- */
main {
  flex: 1;
  width: 100%;
  padding: 32px 48px 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

#entry-form-view {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#entry-form-view .editor-container {
  flex: 1;
  cursor: text;
  padding-bottom: 60px;
}

/* ==================== DETAIL VIEW (legacy — tags/rendered-md still used) ==================== */

/* ==================== RENDERED MARKDOWN ==================== */
.rendered-md h1, .rendered-md h2, .rendered-md h3, .rendered-md h4 {
  font-weight: 600;
  line-height: 1.4;
  margin: 1.25em 0 0.5em;
}
.rendered-md h1:first-child, .rendered-md h2:first-child, .rendered-md h3:first-child {
  margin-top: 0;
}
.rendered-md h1 { font-size: 1.5rem; }
.rendered-md h2 { font-size: 1.25rem; }
.rendered-md h3 { font-size: 1.1rem; }
.rendered-md h4 { font-size: 1rem; }

.rendered-md p { margin-bottom: 0.8em; }
.rendered-md p:last-child { margin-bottom: 0; }

.rendered-md ul, .rendered-md ol {
  margin: 0.5em 0 1em 1.5em;
}
.rendered-md li {
  margin-bottom: 0.35em;
}
.rendered-md li > ul, .rendered-md li > ol {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
}

.rendered-md blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 1em 0;
  color: var(--text-secondary);
  font-style: italic;
  background: rgba(0, 0, 0, 0.015);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.rendered-md blockquote p:last-child { margin-bottom: 0; }

.rendered-md code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.875em;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.rendered-md pre {
  background: #2d2d2d;
  color: #ccc;
  padding: 16px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1em 0;
  line-height: 1.5;
}
.rendered-md pre code {
  background: none;
  padding: 0;
  border: none;
  color: inherit;
  font-size: 0.85em;
}

.rendered-md hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.75em 0;
}

.rendered-md a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rendered-md a:hover { color: var(--accent-hover); }

.rendered-md img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 0.75em 0;
}

.rendered-md strong { font-weight: 600; }
.rendered-md em { font-style: italic; }

.rendered-md table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.95em;
}
.rendered-md th, .rendered-md td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.rendered-md th {
  background: var(--bg);
  font-weight: 600;
  font-family: var(--font-sans);
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.rendered-md tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.015);
}

.rendered-md input[type="checkbox"] {
  margin-right: 6px;
}
.rendered-md ul.contains-task-list {
  list-style: none;
  margin-left: 0;
  padding-left: 0;
}
.rendered-md .task-list-item {
  padding-left: 4px;
}

.detail-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.tag {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 12px;
  color: var(--text-secondary);
}


.content-card {
  position: relative;
}

/* ==================== ENTRY TITLE INPUT ==================== */
.entry-title-input {
  font-family: var(--font);
  font-size: var(--title-font-size);
  font-weight: 400;
  color: var(--brand);
  width: 100%;
  border: none;
  background: none;
  outline: none;
  padding: 0;
  margin-bottom: 8px;
}
.entry-title-input::placeholder {
  color: var(--text-tertiary);
}

/* ==================== TIPTAP / PROSEMIRROR EDITOR ==================== */
.editor-container {
  position: relative;
  background: transparent;
  min-height: 300px;
}

.editor-container .ProseMirror {
  font-family: var(--font);
  font-size: var(--content-font-size);
  line-height: 1.4;
  padding: 0;
  min-height: 300px;
  outline: none;
  color: var(--text);
  caret-color: var(--accent);
}

/* Ghost character animations */
@keyframes ghostReveal {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes ghostFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.char-ghost-in {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  animation: ghostReveal 150ms ease-out forwards;
}

.char-ghost-out {
  position: absolute;
  pointer-events: none;
  font-family: var(--font);
  font-size: var(--content-font-size);
  line-height: normal;
  margin: 0;
  padding: 0;
  color: var(--text);
  animation: ghostFadeOut 150ms ease-out forwards;
}

/* ==================== NOTE LINKS (wiki-style [[]] links) ==================== */
.editor-container .ProseMirror a.note-link,
a.note-link {
  color: var(--accent);
  text-decoration: none;
  background: var(--accent-light);
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease;
}
.editor-container .ProseMirror a.note-link:hover,
a.note-link:hover {
  background: rgba(74, 122, 0, 0.18);
}

/* ==================== NOTE LINK SUGGESTION POPUP ==================== */
.note-link-popup {
  position: fixed;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
  padding: 4px;
  min-width: 200px;
  max-width: 320px;
  max-height: 240px;
  overflow-y: auto;
}
.note-link-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-link-item:hover,
.note-link-item.selected {
  background: var(--accent-light);
  color: var(--accent);
}
.note-link-empty {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-tertiary);
  padding: 12px;
  text-align: center;
}

/* Placeholder */
.editor-container .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: var(--text-secondary);
  opacity: 0.5;
  pointer-events: none;
  height: 0;
}

/* Headings */
.editor-container .ProseMirror h1,
.editor-container .ProseMirror h2,
.editor-container .ProseMirror h3 {
  font-weight: 600;
  line-height: 1.4;
  margin: 1.25em 0 0.5em;
}
.editor-container .ProseMirror h1:first-child,
.editor-container .ProseMirror h2:first-child,
.editor-container .ProseMirror h3:first-child {
  margin-top: 0;
}
.editor-container .ProseMirror h1 { font-size: 1.5rem; }
.editor-container .ProseMirror h2 { font-size: 1.25rem; }
.editor-container .ProseMirror h3 { font-size: 1.1rem; }

/* Paragraphs */
.editor-container .ProseMirror p { margin-bottom: 0.4em; }
.editor-container .ProseMirror p:last-child { margin-bottom: 0; }

/* Lists */
.editor-container .ProseMirror ul,
.editor-container .ProseMirror ol {
  margin: 0.5em 0 1em 1.5em;
}
.editor-container .ProseMirror li { margin-bottom: 0.35em; }

/* Task list / Checklists */
.editor-container .ProseMirror ul[data-type="taskList"] {
  list-style: none;
  padding-left: 0;
  margin-left: 0;
}
.editor-container .ProseMirror ul[data-type="taskList"] li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.editor-container .ProseMirror ul[data-type="taskList"] li > label {
  display: inline-flex;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  margin-top: 4px;
  text-transform: none;
  letter-spacing: normal;
  font-size: inherit;
  font-weight: normal;
  color: inherit;
}
.editor-container .ProseMirror ul[data-type="taskList"] li > label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.editor-container .ProseMirror ul[data-type="taskList"] li > div {
  flex: 1;
}
.editor-container .ProseMirror ul[data-type="taskList"] li[data-checked="true"] > div {
  text-decoration: line-through;
  opacity: 0.6;
}

/* Blockquotes */
.editor-container .ProseMirror blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 1em 0;
  color: var(--text-secondary);
  font-style: italic;
  background: rgba(0, 0, 0, 0.015);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* Code */
.editor-container .ProseMirror code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.875em;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.editor-container .ProseMirror pre {
  background: #2d2d2d;
  color: #ccc;
  padding: 16px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1em 0;
}
.editor-container .ProseMirror pre code {
  background: none;
  padding: 0;
  border: none;
  color: inherit;
}

/* Horizontal rule */
.editor-container .ProseMirror hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.75em 0;
}

/* Links */
.editor-container .ProseMirror a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Images */
.editor-container .ProseMirror img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 0.75em 0;
}

/* Tables */
.editor-container .ProseMirror table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.95em;
}
.editor-container .ProseMirror th,
.editor-container .ProseMirror td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  min-width: 80px;
}
.editor-container .ProseMirror th {
  background: var(--bg);
  font-weight: 600;
  font-family: var(--font-sans);
  font-size: 0.85em;
}

/* Highlight marks */
.editor-container .ProseMirror mark {
  border-radius: 2px;
  padding: 1px 2px;
}

/* Text align */
.editor-container .ProseMirror [style*="text-align: center"] { text-align: center; }
.editor-container .ProseMirror [style*="text-align: right"] { text-align: right; }
.editor-container .ProseMirror [style*="text-align: justify"] { text-align: justify; }

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 42, 42, 0.25);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 16px;
  border-bottom: none;
}

.modal-header h2 {
  font-family: var(--font);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--brand);
}

.modal-header .btn-ghost {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.1rem;
  color: var(--text-tertiary);
}
.modal-header .btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

.modal-body {
  padding: 8px 24px 24px;
}

.modal-body .form-group {
  margin-bottom: 20px;
}
.modal-body .form-group:last-child {
  margin-bottom: 0;
}
.modal-body .form-group label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.modal-divider {
  border-top: 1px solid var(--border);
}

/* Settings modal — wider, two-column layout with floating content card */
.settings-modal {
  max-width: 640px;
  overflow: hidden;
  background: var(--bg);
}
.settings-layout {
  display: flex;
  height: 420px;
  padding: 12px 12px 12px 0;
}
.settings-nav {
  width: 170px;
  flex-shrink: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  background: none;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease;
}
.settings-nav-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
  transform: translateX(3px);
}
.settings-nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}
.settings-nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}
.settings-nav-item.active svg {
  opacity: 1;
}
.settings-content {
  flex: 1;
  padding: 20px 24px 24px;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.settings-content .form-group {
  margin-bottom: 20px;
}
.settings-content .form-group:last-child {
  margin-bottom: 0;
}
.settings-content .form-group label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.settings-section {
  display: none;
}
.settings-section.active {
  display: block;
}

/* Font family cards */
.font-card-row {
  display: flex;
  gap: 10px;
}
.font-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.font-card:hover {
  border-color: var(--text-tertiary);
}
.font-card.active {
  border-color: var(--accent);
  background: var(--accent-light);
}
.font-card-preview {
  font-size: 1.5rem;
  color: var(--text);
  line-height: 1;
}
.font-card.active .font-card-preview {
  color: var(--accent);
}
.font-card-name {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}
.font-card.active .font-card-name {
  color: var(--accent);
  font-weight: 500;
}

/* Font size sliders */
.font-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.font-slider-label {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.font-slider-label-lg {
  font-size: 1.1rem;
}
.font-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
.font-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.font-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.font-slider-value {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  min-width: 32px;
  text-align: right;
}

/* Accent color swatches */
.color-swatch-row {
  display: flex;
  gap: 10px;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
  padding: 0;
}
.color-swatch:hover {
  transform: scale(1.15);
}
.color-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--swatch);
}

/* Search modal */
.search-modal {
  max-width: 480px;
  width: 480px;
  height: 420px;
  padding: 0;
  overflow: hidden;
}
.search-modal-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.search-modal-input-wrap svg {
  flex-shrink: 0;
  color: var(--text-tertiary);
}
#search-modal-input {
  flex: 1;
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
}
#search-modal-input::placeholder {
  color: var(--text-tertiary);
}
.search-modal-results {
  max-height: 340px;
  overflow-y: auto;
  padding: 6px 0;
}
.search-modal-item {
  padding: 10px 18px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s ease;
}
.search-modal-item:hover {
  background: var(--accent-light);
}
.search-modal-item.active {
  background: var(--accent-light);
  color: var(--brand);
  font-weight: 500;
}
.search-modal-empty {
  padding: 20px 18px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-tertiary);
  text-align: center;
}

/* ==================== IMPORT PROGRESS ==================== */
.import-progress {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
}

.import-progress-text {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: var(--text);
}

.import-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.import-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.2s ease;
  width: 0%;
}

/* ==================== FOCUS WRITING MODE ==================== */
.focus-toggle-btn,
.focus-exit-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all 0.15s ease;
  z-index: 5;
}
.focus-toggle-btn svg g,
.focus-exit-btn svg g {
  transition: transform 0.25s ease;
}
.focus-toggle-btn:hover,
.focus-exit-btn:hover {
  color: var(--accent);
  background: rgba(0, 0, 0, 0.05);
}
/* Expand: top-right arrow moves out, bottom-left moves out */
.focus-toggle-btn:hover svg .arrow-tr {
  transform: translate(2px, -2px);
}
.focus-toggle-btn:hover svg .arrow-bl {
  transform: translate(-2px, 2px);
}
/* Contract: both arrows move inward toward center */
.focus-exit-btn:hover svg .arrow-bl {
  transform: translate(1px, -1px);
}
.focus-exit-btn:hover svg .arrow-tr {
  transform: translate(-1px, 1px);
}

/* Sidebar + content transitions for focus mode */
.sidebar {
  transition: width 0.35s ease, padding 0.35s ease, opacity 0.35s ease, transform 0.35s ease;
}
.content-wrapper {
  transition: margin-left 0.35s ease, padding 0.35s ease;
}
.content-card {
  transition: border-radius 0.35s ease, box-shadow 0.35s ease;
}

/* Focus mode: hide sidebar, expand content edge-to-edge */
body.focus-mode .sidebar {
  opacity: 0;
  transform: translateX(-100%);
  pointer-events: none;
}
body.focus-mode .content-wrapper {
  margin-left: 0 !important;
  padding: 0;
}
body.focus-mode .content-card {
  border-radius: 0;
  box-shadow: none;
}
body.focus-mode .editor-status-bar {
  display: none;
}

/* ==================== NEW ENTRY POPOVER ==================== */
.new-entry-popover {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  min-width: 150px;
  padding: 4px;
}
.new-entry-popover-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
.new-entry-popover-item:hover {
  background: var(--accent-light);
  color: var(--accent);
}
.new-entry-popover-item svg {
  flex-shrink: 0;
  opacity: 0.6;
}
.new-entry-popover-item:hover svg {
  opacity: 1;
}

/* ==================== CANVAS VIEW ==================== */
#canvas-form-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 48px;
  border-bottom: 1px solid var(--border-subtle);
}
.canvas-tool-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.canvas-tool-btn:hover {
  background: var(--border-subtle);
  color: var(--text);
}
.canvas-tool-btn.active {
  background: var(--accent-light);
  color: var(--accent);
}
.canvas-color-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch);
  cursor: pointer;
  padding: 0;
}
.canvas-color-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}
.canvas-toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  margin: 0 4px;
}

.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: crosshair;
}
.canvas-container .drawing-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Sidebar entry type icon */
.sidebar-entry-icon {
  flex-shrink: 0;
  opacity: 0.4;
  margin-right: 4px;
}

/* ==================== GRAPH VIEW ==================== */
.graph-toggle-btn {
  position: absolute;
  top: 44px;
  right: 16px;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all 0.15s ease;
  z-index: 5;
}
.graph-toggle-btn:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.05);
}

.graph-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 480px;
  height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  z-index: 10;
  overflow: hidden;
  animation: graphPanelIn 0.25s ease-out;
}
@keyframes graphPanelIn {
  from { opacity: 0; transform: scale(0.95) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.graph-stats {
  position: absolute;
  top: 10px;
  right: 42px;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  color: var(--text-tertiary);
  pointer-events: none;
}
.graph-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(4px);
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-tertiary);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s ease;
  line-height: 1;
}
.graph-close-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
}
#graph-canvas {
  width: 100%;
  height: 100%;
}

/* ==================== CONTEXT MENU ==================== */
.context-menu {
  position: fixed;
  z-index: 300;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
  padding: 4px;
  min-width: 160px;
}

.context-menu-item {
  display: block;
  width: 100%;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s ease;
}
.context-menu-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.context-menu-danger {
  color: var(--danger);
}
.context-menu-danger:hover {
  background: rgba(180, 64, 64, 0.08);
}

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

/* Context menu type visibility */
.ctx-entry, .ctx-folder, .ctx-empty, .ctx-multi-entry { display: none; }
.context-menu.ctx-mode-entry .ctx-entry { display: block; }
.context-menu.ctx-mode-folder .ctx-folder { display: block; }
.context-menu.ctx-mode-empty .ctx-empty { display: block; }
.context-menu.ctx-mode-multi-entry .ctx-multi-entry { display: block; }

/* ==================== FOLDER TREE ==================== */

.sidebar-folder-header {
  display: flex;
  align-items: center;
  padding: 3px 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s ease;
  gap: 3px;
  position: relative;
}

.sidebar-folder-header:hover {
  background: rgba(0, 0, 0, 0.04);
}

.sidebar-folder-chevron {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: transform 0.15s ease;
}

.sidebar-folder.expanded > .sidebar-folder-header .sidebar-folder-chevron {
  transform: rotate(90deg);
}

.sidebar-folder-name {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Drag and drop */
.sidebar-entry.dragging,
.sidebar-folder-header.dragging {
  opacity: 0.4;
}

.sidebar-folder-header.drag-over {
  background: rgba(74, 122, 0, 0.12);
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
}

/* Multi-select drag ghost */
.drag-ghost {
  position: fixed;
  top: -1000px;
  left: -1000px;
  pointer-events: none;
  opacity: 0.5;
  width: 240px;
}

/* Indent guide lines (VS Code style) */
.sidebar-folder-children {
  position: relative;
}
.sidebar-folder-children::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--guide-left, 15px);
  width: 1px;
  background: var(--border);
  opacity: 0.5;
  pointer-events: none;
}

/* Move-to-folder modal */
.move-folder-modal {
  max-width: 360px;
}

.move-folder-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.1s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.move-folder-item:hover {
  background: rgba(74, 122, 0, 0.08);
}

.move-folder-item.move-folder-root {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 10px;
  border-radius: 0;
  color: var(--text-secondary);
}

/* ==================== TOGGLE SWITCH ==================== */
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.settings-toggle-label {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text);
}
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  padding: 0;
  flex-shrink: 0;
}
.toggle-switch[aria-checked="true"] {
  background: var(--accent);
}
.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--surface);
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.toggle-switch[aria-checked="true"] .toggle-knob {
  transform: translateX(20px);
}

/* ==================== DARK MODE OVERRIDES ==================== */
body.dark-mode .sidebar {
  background: var(--bg);
}
body.dark-mode .sidebar-search {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}
body.dark-mode .sidebar-search:focus {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(122, 170, 48, 0.15);
}
body.dark-mode .sidebar-sort-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

body.dark-mode .sidebar-icon-btn {
  color: var(--text-secondary);
}
body.dark-mode .sidebar-icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
body.dark-mode .sidebar-entry:hover {
  background: rgba(255, 255, 255, 0.04);
}
body.dark-mode .sidebar-entry.active {
  background: rgba(122, 170, 48, 0.12);
}
body.dark-mode .sidebar-entry.selected {
  background: rgba(122, 170, 48, 0.08);
}
body.dark-mode .sidebar-entry.selected.active {
  background: rgba(122, 170, 48, 0.12);
}
body.dark-mode .content-card {
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
body.dark-mode .sidebar:has(.sidebar-resize-handle:hover) ~ .content-wrapper .content-card,
body.dark-mode .content-wrapper.resizing .content-card {
  box-shadow: 0 0 0 4px rgba(122, 170, 48, 0.3), 0 2px 8px rgba(0, 0, 0, 0.4);
}
body.dark-mode .entry-title-input {
  color: var(--brand);
}
body.dark-mode .entry-title-input::placeholder {
  color: var(--text-tertiary);
}
body.dark-mode .graph-panel {
  background: var(--bg);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
body.dark-mode .graph-close-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}
body.dark-mode .graph-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
body.dark-mode .modal-overlay {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}
body.dark-mode .modal {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}
body.dark-mode .settings-modal {
  background: var(--bg);
}
body.dark-mode .settings-content {
  background: var(--surface);
}
body.dark-mode .font-card {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.08);
}
body.dark-mode .font-card:hover {
  border-color: var(--text-tertiary);
}
body.dark-mode .font-slider {
  background: rgba(255, 255, 255, 0.1);
}
body.dark-mode .font-slider::-webkit-slider-thumb {
  border-color: var(--surface);
}
body.dark-mode .color-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--swatch);
}
body.dark-mode .settings-toggle-row {
  background: var(--bg);
  border-color: rgba(255, 255, 255, 0.08);
}
body.dark-mode .settings-select {
  background: var(--bg);
  border-color: rgba(255, 255, 255, 0.08);
}
body.dark-mode .settings-select:focus {
  box-shadow: 0 0 0 2px rgba(122, 170, 48, 0.2);
}
body.dark-mode .btn {
  background: var(--bg);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}
body.dark-mode .btn:hover {
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text);
}
body.dark-mode .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0d1117;
}
body.dark-mode .btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
body.dark-mode .toggle-switch {
  background: rgba(255, 255, 255, 0.1);
}
body.dark-mode .toggle-knob {
  background: #e6edf3;
}
body.dark-mode .context-menu {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
body.dark-mode .context-menu-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
body.dark-mode .sidebar-folder-header:hover {
  background: rgba(255, 255, 255, 0.04);
}
body.dark-mode .sidebar-folder-header.drag-over {
  background: rgba(122, 170, 48, 0.15);
  outline-color: var(--accent);
}
body.dark-mode .sidebar-folder-children::before {
  background: rgba(255, 255, 255, 0.08);
}
body.dark-mode .move-folder-item:hover {
  background: rgba(122, 170, 48, 0.12);
}
body.dark-mode .note-link-popup {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
body.dark-mode .note-link-item:hover,
body.dark-mode .note-link-item.selected {
  background: rgba(255, 255, 255, 0.04);
}
body.dark-mode .editor-container .ProseMirror a.note-link,
body.dark-mode a.note-link {
  color: var(--accent);
  background: rgba(122, 170, 48, 0.1);
}
body.dark-mode .sidebar-logout {
  color: var(--text-secondary);
}

/* Dark mode scrollbar */
body.dark-mode ::-webkit-scrollbar {
  width: 4px;
}
body.dark-mode ::-webkit-scrollbar-track {
  background: transparent;
}
body.dark-mode ::-webkit-scrollbar-thumb {
  background: rgba(122, 170, 48, 0.15);
  border-radius: 2px;
}
body.dark-mode ::-webkit-scrollbar-thumb:hover {
  background: rgba(122, 170, 48, 0.3);
}

/* ==================== EDITOR STATUS BAR ==================== */
.editor-status-bar {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 5px 12px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
  user-select: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.status-item {
  padding: 0 6px;
}

.status-sep {
  width: 1px;
  height: 10px;
  background: var(--border);
  opacity: 0.5;
}

body.dark-mode .editor-status-bar {
  background: var(--surface);
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ==================== MOBILE-ONLY ELEMENTS (hidden on desktop) ==================== */
.mobile-menu-btn {
  display: none;
}
.mobile-close-btn {
  display: none !important;
}

/* ==================== SIDEBAR OVERLAY BACKDROP ==================== */
.sidebar-overlay {
  display: none;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px !important;
    --content-inset: 0px;
  }

  /* Eliminate slate background gap on mobile — match body to content surface */
  body, body.focus-mode {
    background: var(--surface) !important;
  }

  /* --- Mobile hamburger button --- */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 30;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
  }
  .mobile-menu-btn:active {
    opacity: 0.6;
  }

  /* --- Sidebar: full-width fade-in overlay on mobile --- */
  .sidebar {
    display: flex !important;
    width: 100% !important;
    max-width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    background: var(--bg);
    box-shadow: none;
  }
  .sidebar.mobile-open {
    opacity: 1;
    visibility: visible;
  }

  /* Mobile close button */
  .mobile-close-btn {
    display: flex !important;
  }

  /* Override collapsed styles on mobile — always show full sidebar when open */
  .sidebar.collapsed,
  body.sidebar-collapsed-init .sidebar {
    width: 100% !important;
    max-width: 100vw;
    padding: 28px 16px;
  }
  .sidebar.collapsed .sidebar-brand,
  .sidebar.collapsed .sidebar-search,
  .sidebar.collapsed .sidebar-sort-bar,
  .sidebar.collapsed .sidebar-entries,
  .sidebar.collapsed .sidebar-empty,
  .sidebar.collapsed #new-entry-sidebar-btn,
  .sidebar.collapsed #new-folder-sidebar-btn,
  body.sidebar-collapsed-init .sidebar .sidebar-brand,
  body.sidebar-collapsed-init .sidebar .sidebar-search,
  body.sidebar-collapsed-init .sidebar .sidebar-sort-bar,
  body.sidebar-collapsed-init .sidebar .sidebar-entries,
  body.sidebar-collapsed-init .sidebar .sidebar-empty,
  body.sidebar-collapsed-init .sidebar #new-entry-sidebar-btn,
  body.sidebar-collapsed-init .sidebar #new-folder-sidebar-btn {
    display: unset;
  }
  .sidebar.collapsed .collapsed-only.sidebar-icon-btn,
  body.sidebar-collapsed-init .sidebar .collapsed-only.sidebar-icon-btn {
    display: none;
  }
  .sidebar.collapsed .sidebar-header,
  body.sidebar-collapsed-init .sidebar .sidebar-header {
    justify-content: space-between;
  }

  /* Hide desktop sidebar-toggle and resize handle on mobile */
  #sidebar-toggle-btn,
  .sidebar-resize-handle {
    display: none !important;
  }

  /* --- Overlay backdrop --- */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 90;
  }
  .sidebar-overlay.visible {
    display: block;
  }
  body.dark-mode .sidebar-overlay.visible {
    background: rgba(0,0,0,0.55);
  }

  /* --- Content area: full width, full height, no offsets --- */
  .content-wrapper {
    margin-left: 0 !important;
    padding: 0;
    width: 100%;
  }
  body.sidebar-collapsed-init .content-wrapper {
    margin-left: 0 !important;
  }

  .content-card {
    border-radius: 0;
    min-height: 100vh;
    box-shadow: none;
  }

  main {
    padding: 56px 16px 20px 16px; /* top padding for hamburger button */
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  /* Entry title input: smaller on mobile */
  .entry-title-input {
    font-size: 1.5rem;
  }

  /* Hide focus mode on mobile and neutralize its effects */
  .focus-toggle-btn,
  .focus-exit-btn {
    display: none !important;
  }
  body.focus-mode .sidebar {
    pointer-events: auto;
  }
  /* Mobile-open must win over focus-mode opacity */
  body.focus-mode .sidebar.mobile-open {
    opacity: 1 !important;
    visibility: visible !important;
  }
}
