/* default.css — off-white, serif, minimal */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=PT+Serif:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  --bg: #f9f7f4;
  --surface: #ffffff;
  --border: #e2ddd8;
  --text: #2c2825;
  --text-muted: #8a8278;
  --accent: #57534e;
  --accent-hover: #44403c;
  --sidebar-bg: #f2efe9;
  --sidebar-width: 220px;
  --nav-height: 48px;
  --font-body: 'PT Serif', Georgia, serif;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, monospace;
  --radius: 4px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  z-index: 100;
}
.topnav-left { display: flex; align-items: center; gap: 10px; flex: 1; }
.topnav-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.brand {
  font-weight: 600; color: var(--text); font-size: 14px;
  letter-spacing: 0.01em;
}
.brand:hover { text-decoration: none; color: var(--text); }

.icon-btn {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--text-muted); padding: 5px 7px;
  line-height: 1; border-radius: var(--radius);
  text-decoration: none; display: inline-flex; align-items: center;
}
.icon-btn:hover { color: var(--text); background: rgba(0,0,0,0.04); text-decoration: none; }

/* Git group — three ghost buttons in a pill border */
.nav-git-group {
  display: flex; align-items: center;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.nav-git-btn {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--text-muted);
  padding: 4px 10px; line-height: 1.4;
  font-family: var(--font-ui);
  white-space: nowrap;
}
.nav-git-btn:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.nav-git-sep { width: 1px; height: 16px; background: var(--border); }

/* Vertical divider between nav sections */
.nav-divider { width: 1px; height: 18px; background: var(--border); margin: 0 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px; height: 34px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: var(--font-ui);
  text-decoration: none; white-space: nowrap;
  letter-spacing: 0.01em;
  transition: background 0.12s, box-shadow 0.12s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.14); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12px; }
.btn-outline {
  background: transparent; color: var(--text);
  border-color: var(--border); box-shadow: none;
}
.btn-outline:hover { background: rgba(0,0,0,0.03); color: var(--text); box-shadow: none; }
.btn-ghost {
  background: transparent; color: var(--text-muted);
  border-color: transparent; box-shadow: none;
}
.btn-ghost:hover { background: rgba(0,0,0,0.04); color: var(--text); }

.sync-status { font-size: 11px; color: var(--text-muted); padding: 0 4px; }
.behind-badge {
  font-size: 11px; background: #c2693a; color: #fff;
  padding: 2px 8px; border-radius: 10px;
}
.hidden { display: none !important; }

/* Flash */
.flash-messages { position: fixed; top: var(--nav-height); left: 0; right: 0; z-index: 200; }
.flash { background: #d4edda; color: #155724; padding: 10px 16px; border-bottom: 1px solid #c3e6cb; }

/* Layout */
.layout {
  display: flex;
  padding-top: var(--nav-height);
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.2s ease;
  display: flex;
  flex-direction: column;
}
.sidebar.collapsed { width: 0; }

.sidebar-modes {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 8px 0;
}
.sidebar-toggle-group {
  display: flex;
  background: rgba(0,0,0,0.05);
  border-radius: 7px;
  padding: 2px;
  gap: 1px;
}
.sidebar-mode-btn {
  flex: 1;
  background: none; border: none; cursor: pointer;
  font-size: 12px; font-weight: 500; font-family: var(--font-ui);
  color: var(--text-muted);
  padding: 4px 8px; border-radius: 5px;
  transition: all 0.12s;
  line-height: 1.4;
}
.sidebar-mode-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.10), 0 0 0 0.5px rgba(0,0,0,0.04);
}

.sidebar-group { margin-bottom: 16px; }
.sidebar-group-header {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 0 14px 4px;
}
.sidebar-year a {
  display: block; padding: 4px 14px;
  font-size: 13px; color: var(--text);
}
.sidebar-year.active a { color: var(--accent); background: rgba(87,83,78,0.06); }

/* Sidebar recent notes */
.sidebar-group--recent { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.sidebar-group--recent .sidebar-group-header { margin-bottom: 2px; }
.sidebar-recent-list { display: flex; flex-direction: column; padding: 0 0 8px; }
.sidebar-recent-item {
  display: block;
  font-size: 12px; font-family: var(--font-ui);
  color: var(--text-muted);
  padding: 3px 14px;
  text-decoration: none;
  transition: color 0.12s, background 0.12s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-recent-item:hover { color: var(--text); background: rgba(87,83,78,0.04); text-decoration: none; }
.sidebar-recent-item.active { color: var(--accent); font-weight: 500; }

/* Sidebar tags — one per line, matching tree-row style */
.sidebar-group--tags .sidebar-group-header { margin-bottom: 2px; }
.sidebar-tags-list {
  display: flex; flex-direction: column;
  padding: 0 0 8px;
}
.sidebar-tag-pill {
  display: block;
  font-size: 12px; font-family: var(--font-ui);
  color: var(--text-muted);
  padding: 3px 14px;
  text-decoration: none;
  transition: color 0.12s, background 0.12s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-tag-pill:hover {
  color: var(--text); background: rgba(87,83,78,0.04);
  text-decoration: none;
}
.sidebar-tag-pill.active { color: var(--accent); font-weight: 500; }

/* Tree sidebar */
.tree-section { padding-bottom: 4px; }
.tree-year-item { }

.tree-year-row {
  display: flex; align-items: center; gap: 3px;
  padding: 2px 10px 2px 6px;
}
.tree-year-row.active .tree-year-label { color: var(--accent); font-weight: 600; }

.tree-chevron-btn {
  background: none; border: none; cursor: pointer;
  width: 16px; height: 16px; padding: 0; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 8px;
  transition: transform 0.15s;
}
.tree-chevron-btn:hover { color: var(--text); }
.tree-chevron-btn.open { transform: rotate(90deg); }

.tree-year-label {
  flex: 1; font-size: 13px; color: var(--text); font-weight: 500;
  line-height: 1.6;
}
.tree-year-label:hover { color: var(--accent); text-decoration: none; }

.tree-count { font-size: 10px; color: var(--text-muted); padding: 0 2px; }

.tree-months {
  display: none; padding-bottom: 4px;
}
.tree-months.open { display: block; }

.tree-month-row {
  display: flex; align-items: center;
  padding: 2px 10px 2px 34px;
  font-size: 12px; color: var(--text-muted);
  text-decoration: none; gap: 4px;
}
.tree-month-row:hover { color: var(--text); background: rgba(87,83,78,0.04); text-decoration: none; }
.tree-month-row.active { color: var(--accent); font-weight: 500; }
.tree-month-name { flex: 1; }

.sidebar-group--tags { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }

/* Sidebar bottom — pinned to bottom via flex layout */
.sidebar-bottom {
  margin-top: auto;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  padding: 4px 0;
  flex-shrink: 0;
}
.sidebar-bottom-link {
  display: flex;
  align-items: center;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  gap: 9px;
}
.sidebar-bottom-link:hover { color: var(--text); background: rgba(87,83,78,0.04); text-decoration: none; }
.sidebar-bottom-link.active { color: var(--accent); font-weight: 500; }
.sidebar-bottom-icon {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; opacity: 0.55;
  color: currentColor;
}
.sidebar-bottom-icon svg { display: block; }
.sidebar-bottom-link:hover .sidebar-bottom-icon,
.sidebar-bottom-link.active .sidebar-bottom-icon { opacity: 1; }

.sidebar-inbox-badge {
  margin-left: auto;
  font-size: 10px; font-weight: 700;
  background: var(--accent); color: var(--bg);
  padding: 1px 6px; border-radius: 10px;
  font-family: var(--font-ui);
}

/* Outline */
.outline-link {
  display: block; padding: 3px 14px;
  font-size: 12px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.outline-h1 { font-weight: 600; color: var(--text); }
.outline-h2 { padding-left: 22px; }
.outline-h3 { padding-left: 30px; }
.outline-link:hover { color: var(--accent); text-decoration: none; }

/* Main content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 48px;
}

/* Editor page: main-content becomes the outer shell, editor scrolls internally */
.main-content:has(.editor-container) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

/* Note list */
.note-list-container { max-width: 800px; }
.note-list-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 20px; }
.note-list-header h1 { font-size: 22px; font-weight: 600; }
.note-count { font-size: 12px; color: var(--text-muted); }

.filter-input {
  width: 260px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; margin-bottom: 12px;
  background: var(--surface);
}

.note-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.note-table th {
  text-align: left; padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); cursor: pointer;
}
.note-table th:hover { color: var(--text); }
.note-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
.note-row { cursor: pointer; }
.note-row:hover { background: rgba(87,83,78,0.05); }
.note-row:hover .note-title { color: var(--accent); }
.note-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.note-title { color: var(--text); font-weight: 500; }
.note-title a { color: inherit; }
.note-title a:hover { text-decoration: none; }

.tag-pill {
  display: inline-block; font-size: 11px;
  background: #eee; color: var(--text-muted);
  padding: 1px 7px; border-radius: 10px; margin: 1px;
}
.tag-pill:hover { background: var(--accent); color: #fff; text-decoration: none; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  padding: 5px 12px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; color: var(--text);
}
.tag-chip span { color: var(--text-muted); font-size: 11px; }
.tag-chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* Editor — fills main-content, which is itself a flex item in .layout */
.editor-container {
  display: flex;
  flex-direction: column;
  flex: 1;            /* grow to fill .main-content height */
  min-height: 0;      /* allow shrinking below content size in flex column */
  max-width: 996px;   /* 900px content + 48px padding each side */
  margin: 0 auto;
  padding: 0 48px;
  width: 100%;
  box-sizing: border-box;
  align-self: stretch;
}

.editor-header {
  display: flex; flex-direction: column;
  padding: 16px 0 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
  gap: 6px;
}
.editor-header-row {
  display: flex; align-items: center;
}
.editor-header-top {
  justify-content: space-between;
  gap: 12px;
}
.editor-header-meta {
  justify-content: space-between;
  padding-bottom: 12px;
}
.note-title-input {
  font-size: 36px;
  font-weight: 400;
  border: none;
  background: transparent;
  color: var(--text);
  outline: none;
  flex: 1;
  line-height: 1.2;
  font-family: var(--font-display);
  min-width: 0;
}
.note-title-input::placeholder { color: var(--text-muted); }

/* Tag pills */
.note-tags-container {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 5px; flex: 1; min-width: 0;
}
.tag-pill-editor {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-family: var(--font-ui);
  padding: 2px 8px 2px 9px;
  border-radius: 20px;
  line-height: 1.5;
  user-select: none;
}
.tag-pill-remove {
  background: none; border: none; cursor: pointer;
  font-size: 13px; line-height: 1; padding: 0;
  opacity: 0.5; color: inherit;
}
.tag-pill-remove:hover { opacity: 1; }
.tags-adder {
  border: none; background: transparent; outline: none;
  font-size: 12px; color: var(--text-muted);
  font-family: var(--font-ui);
  width: 160px; min-width: 80px;
  padding: 2px 0;
}
.tags-adder::placeholder { color: var(--border); }

.note-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.editor-actions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.editor-action-sep { width: 1px; height: 16px; background: var(--border); margin: 0 3px; }
.editor-actions-spacer { flex: 1; min-width: 12px; }

/* Formatting toolbar buttons */
.fmt-btn {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-ui); font-size: 13px; line-height: 1;
  color: var(--text-muted); padding: 3px 7px;
  border-radius: var(--radius);
  transition: color 0.1s, background 0.1s;
}
.fmt-btn:hover { color: var(--text); background: rgba(0,0,0,0.05); }
.fmt-btn--code { font-family: var(--font-mono); font-size: 11px; }
/* Save-status: fixed-width slot to the left of Save — button never shifts */
.save-status {
  font-size: 12px;
  font-family: var(--font-ui);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.3s;
  opacity: 0;
  width: 60px;
  text-align: right;
}
.save-status:not(:empty) { opacity: 1; }
.save-status.saving { color: var(--text-muted); }
.save-status.saved  { color: #4a7c5f; }
.save-status.error  { color: #a85050; }

/* Vim */

/* Toggle button — lives in the meta row, looks like a small mono tag */
.vim-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 10px; font-family: var(--font-mono);
  font-weight: 600; letter-spacing: 0.06em;
  color: var(--text-muted); padding: 2px 6px;
  border-radius: var(--radius);
  transition: color 0.1s, background 0.1s;
  line-height: 1.6;
}
.vim-toggle:hover { color: var(--text); background: rgba(0,0,0,0.05); }
.vim-toggle.vim-active { background: var(--accent); color: var(--bg); }

/* Mode indicator — fixed bottom-right, outside the toolbar flow entirely */
.vim-indicator {
  position: fixed;
  bottom: 20px; right: 24px;
  font-size: 10px; font-family: var(--font-mono);
  font-weight: 700; letter-spacing: 0.08em;
  padding: 3px 9px; border-radius: 4px;
  background: var(--text); color: var(--bg);
  z-index: 200; pointer-events: none;
  line-height: 1.6;
}
.vim-indicator[data-mode="insert"] { background: var(--accent); }
.vim-indicator[data-mode="visual"] { background: #7c6fc0; }

/* Vim linewise visual selection (cross-block) */
.block.vim-linewise-sel {
  background: rgba(124, 111, 192, 0.15) !important;
  outline: 1px solid rgba(124, 111, 192, 0.3);
  border-radius: 2px;
}

/* Vim search highlights */
mark.vim-search-hl {
  background: #ffdd57;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
#vim-search-prompt {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* Right-side wrapper in meta row */
.editor-meta-right {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.editor-meta-sep { width: 1px; height: 14px; background: var(--border); margin: 0 4px; }
.block.vim-cursor {
  background: rgba(87,83,78,0.07) !important;
  border-radius: 3px;
  box-shadow: inset 3px 0 0 var(--accent);  /* visible left-bar cursor indicator */
}
/* Inside a block in NORMAL mode: highlight selected character as a block cursor */
.block.active .block-textarea::selection {
  background: var(--accent);
  color: var(--bg);
}

/* Typora-style single-column editor */
.typora-editor {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -ms-overflow-style: none;  /* IE/Edge legacy */
  scrollbar-width: none;     /* Firefox */
  padding: 28px 0 120px;
  width: 100%;
  font-size: 15px;
}
.typora-editor::-webkit-scrollbar { width: 0; height: 0; } /* WebKit */

.block {
  position: relative;
  cursor: text;
  border-radius: 3px;
  padding: 0 4px;
  margin: 0 -4px;
  min-height: 1.6em;
  transition: background 0.1s;
  /* BFC prevents child margins from collapsing through, so offsetHeight
     accurately captures the rendered height for textarea minHeight. */
  display: flow-root;
}
.block:hover { background: rgba(0,0,0,0.02); }
@keyframes pre-edit-countdown {
  0%   { background: rgba(59, 130, 246, 0.18); }
  100% { background: rgba(0, 0, 0, 0.02); }
}
.block.pre-edit {
  animation: pre-edit-countdown var(--click-edit-delay, 500ms) ease-out forwards;
}
.block.active { background: transparent; cursor: default; }

/* Subtle append affordance so it is clear where to click for the next block. */
.block-add-target {
  margin-top: 0.3em;
  padding: 10px 4px;
  border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent);
  color: var(--text-muted);
  opacity: 0;
  cursor: text;
  user-select: none;
  transition: opacity 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.typora-editor:hover .block-add-target {
  opacity: 0.72;
}
.block-add-target:hover,
.block-add-target:focus-visible {
  opacity: 1;
  color: var(--text);
  border-top-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.block-add-target__label {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 12px;
}
.block-add-target__hint {
  display: inline-block;
  margin-left: 8px;
  font-family: var(--font-ui);
  font-size: 11px;
  opacity: 0.9;
}

/* Block-type spacing — lives on the .block wrapper so both display and edit
   modes share identical layout.  Inner rendered elements use margin: 0. */
.block--h1,
.block--h2,
.block--h3,
.block--h4       { padding-top: 1.5em; }
.block--blockquote { padding-top: 1em; }
.block--p          { margin-bottom: 1em; }
.block--h1, .block--h2, .block--h3,
.block--h4         { margin-bottom: 0.6em; }
.block--blockquote { margin-bottom: 1em; }

/* List item blocks: strip ul/ol margins so consecutive items flow tight.
   Uses two-class selector (.block.block--li) for higher specificity than
   .note-body ul { margin: 0.6em 0 } which would otherwise win the cascade. */
.block.block--li { min-height: 0; }
.block.block--li > ul,
.block.block--li > ol { margin: 0; padding-left: 1.5em; }
.block.block--li > ul > li,
.block.block--li > ol > li { margin: 0; padding: 0; }

/* Nested list items: indent the block wrapper by nesting level */
.block--li[data-indent="1"] { padding-left: 1.5em; }
.block--li[data-indent="2"] { padding-left: 3.0em; }
.block--li[data-indent="3"] { padding-left: 4.5em; }

.block-textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: none;
  outline: none;
  resize: none;
  overflow: hidden;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* base: matches .note-body paragraph */
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  padding: 0;
  margin: 0;
  background: transparent;
  color: var(--text);
  min-height: 1.6em;
  caret-color: var(--accent);
}

/* Per-type textarea styles: font only — no padding-top needed because
   .block--h* already provides the correct top spacing on the wrapper element.
   Both display and edit mode share the same block padding-top, so text
   aligns perfectly with no visual jump on activation. */
.block-textarea--h1 {
  font-family: var(--font-display);
  font-size: 2em;
  font-weight: 400;
  line-height: 1.2;
}
.block-textarea--h2 {
  font-family: var(--font-display);
  font-size: 1.5em;
  font-weight: 400;
  line-height: 1.2;
}
.block-textarea--h3 {
  font-family: var(--font-display);
  font-size: 1.2em;
  font-weight: 400;
  line-height: 1.2;
}
.block-textarea--h4 {
  font-family: var(--font-body);
  font-size: 1em;
  font-style: italic;
  line-height: 1.7;
}
.block-textarea--code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  line-height: 1.5;
}
.block-textarea--blockquote {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.7;
  padding-top: 0.5em;   /* matches blockquote inner padding-top */
  padding-left: 1em;
}
.block-textarea--li {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
}

/* Note body (rendered markdown) */
.note-body { font-family: var(--font-body); font-size: 15px; line-height: 1.7; }
.note-body h1, .note-body h2, .note-body h3,
.note-body h4, .note-body h5, .note-body h6 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.2;
  margin: 0;  /* spacing lives on .block wrapper */
  color: var(--text);
}
.note-body h1 { font-size: 2em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.note-body h2 { font-size: 1.5em; padding-bottom: 0.25em; border-bottom: 1px solid var(--border); }
.note-body h3 { font-size: 1.2em; }
.note-body h4 { font-size: 1em; font-style: italic; }
.note-body p { margin: 0; }  /* spacing lives on .block--p wrapper */
.note-body ul, .note-body ol { margin: 0.6em 0; padding-left: 1.5em; }
.note-body li { margin: 0.3em 0; }
.note-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 0; padding: 0.5em 1em;  /* spacing lives on .block wrapper */
  color: var(--text-muted); background: rgba(87,83,78,0.04);
}
/* Task-list checkboxes */
.note-body input.task-check {
  appearance: auto; -webkit-appearance: auto;
  cursor: pointer; margin-right: 0.4em;
  position: relative; top: 1px;
}
.note-body li:has(input.task-check:checked) { color: var(--text-muted); }

/* Tables */
.note-body table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 14px; }
.note-body th, .note-body td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.note-body th { background: rgba(87,83,78,0.04); font-weight: 600; }
.note-body tr:nth-child(even) { background: rgba(87,83,78,0.02); }

.note-body code {
  font-family: var(--font-mono); font-size: 0.88em;
  background: #f0ede8; padding: 1px 5px; border-radius: 3px;
}
.note-body pre {
  background: #f0ede8; padding: 14px 16px;
  border-radius: var(--radius); overflow-x: auto; margin: 1em 0;
}
.note-body pre code { background: none; padding: 0; }
.note-body table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.note-body th, .note-body td { padding: 8px 12px; border: 1px solid var(--border); }
.note-body th { background: var(--sidebar-bg); font-weight: 600; }
.note-body hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.note-body a { color: var(--accent); }
.note-body img { max-width: 100%; border-radius: var(--radius); }


/* Highlights */
.highlights-container { max-width: 800px; }
.highlights-container h1 { font-size: 22px; font-weight: 600; margin-bottom: 20px; }
.highlights-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.highlight-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.highlight-text {
  font-family: var(--font-body); font-size: 15px;
  border-left: 3px solid #fbbf24; padding-left: 12px;
  margin: 0 0 10px; color: var(--text);
}
.highlight-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.highlight-source { color: var(--accent); flex: 1; }
.delete-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 12px; padding: 2px;
}
.delete-btn:hover { color: #dc3545; }

/* Delete note button (toolbar row, editor) */
.delete-note-btn {
  background: none; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  color: var(--text-muted);
  border-radius: var(--radius);
  transition: color 0.12s, background 0.12s;
  opacity: 0.45;
  flex-shrink: 0;
}
.delete-note-btn:hover { color: #c0392b; background: rgba(192,57,43,0.06); opacity: 1; }

/* Inbox page */
.inbox-container { max-width: 800px; }
.inbox-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.inbox-header h1 { font-size: 22px; font-weight: 600; }
.inbox-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }
.inbox-actions { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.inbox-drop-zone {
  margin: 0 0 18px;
  padding: 26px 20px;
  font-size: 14px;
}
.inbox-upload-status {
  margin: -8px 0 16px;
  font-size: 12px;
}
.inbox-upload-status.success { color: #1b6e3c; }
.inbox-upload-status.error { color: #9f2a23; }

/* Trash page */
.trash-container { max-width: 800px; }
.trash-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.trash-header h1 { font-size: 22px; font-weight: 600; }
.trash-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }
.trash-actions { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.btn-delete-perm {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--text-muted);
  font-family: var(--font-ui); padding: 2px 4px;
  border-radius: var(--radius);
  transition: color 0.1s;
}
.btn-delete-perm:hover { color: #c0392b; }

/* Settings */
.settings-container { max-width: 560px; }
.settings-container h1 { font-size: 22px; font-weight: 600; margin-bottom: 24px; }
.settings-group { margin-bottom: 28px; }
.settings-group h2 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 12px; }
.settings-group label {
  display: block; margin-bottom: 14px;
  font-size: 14px; font-weight: 500;
}
.settings-group input, .settings-group select {
  display: block; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 10px; font-size: 14px;
  background: var(--surface); color: var(--text);
  margin-top: 4px;
}
.hint { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.settings-actions { padding-top: 8px; }

/* Import */
.import-container { max-width: 680px; }
.import-container h1 { font-size: 22px; font-weight: 600; margin-bottom: 12px; }
.drop-zone {
  border: 2px dashed var(--border); border-radius: 8px;
  padding: 48px 24px; text-align: center;
  color: var(--text-muted); font-size: 15px;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer; margin: 20px 0;
}
.drop-zone.drag-over { border-color: var(--accent); background: rgba(87,83,78,0.04); }
.file-label { color: var(--accent); cursor: pointer; }
.import-queue { display: flex; flex-direction: column; gap: 14px; }
.import-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.import-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.import-card label { display: block; font-size: 13px; margin-bottom: 8px; }
.import-card input {
  display: block; width: 100%; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 5px 8px;
  font-size: 13px; margin-top: 3px;
}
.import-actions { display: flex; gap: 8px; margin-top: 12px; }
.import-result { font-size: 13px; color: #28a745; margin-top: 8px; }

/* Dialogs */
dialog {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 24px; max-width: 480px; width: 90vw;
  background: var(--surface); color: var(--text);
}
dialog h2 { font-size: 18px; margin-bottom: 16px; }
dialog label { display: block; font-size: 14px; margin-bottom: 12px; }
dialog input, dialog textarea {
  display: block; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 10px; font-size: 14px; margin-top: 4px;
  background: var(--bg); color: var(--text);
}
dialog pre {
  background: #f0ede8; padding: 12px;
  border-radius: var(--radius); overflow-x: auto;
  font-size: 12px; max-height: 300px; overflow-y: auto;
}
dialog::backdrop { background: rgba(0,0,0,0.4); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog-actions button { padding: 6px 14px; border-radius: var(--radius); border: 1px solid var(--border); cursor: pointer; font-size: 14px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: #fff;
  padding: 10px 18px; border-radius: 6px;
  font-size: 13px; z-index: 300;
  animation: fadeInOut 2s forwards;
}
@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(10px); }
  15% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* Empty state */
.empty-state { color: var(--text-muted); font-size: 14px; padding: 20px 0; }

/* ── Scratchpad ─────────────────────────────────────────────────────────── */

/* Drop overlay — covers the main content area while dragging */
.drop-overlay {
  position: fixed;
  top: var(--nav-height); left: var(--sidebar-width); right: 0; bottom: 0;
  background: rgba(249,247,244,0.92);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  pointer-events: none;
  transition: opacity 0.15s;
}
.drop-overlay.hidden { display: none; }
.drop-overlay-inner {
  text-align: center; color: var(--text-muted);
  font-size: 16px; font-family: var(--font-ui);
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 48px 64px;
  background: rgba(255,255,255,0.7);
}
.drop-icon { font-size: 48px; margin-bottom: 14px; line-height: 1; }

/* Scratchpad status hint in meta row */
.scratch-hint { font-size: 11px; color: var(--text-muted); font-style: italic; padding-left: 12px; white-space: nowrap; }

/* Empty editor placeholder */
.typora-editor.scratch-empty-hint:empty::before {
  content: attr(data-placeholder);
  display: block;
  color: var(--border);
  font-size: 15px;
  font-family: var(--font-body);
  font-style: italic;
  padding: 28px 0 0;
}
/* Once blocks are rendered, hide placeholder */
.typora-editor.scratch-empty-hint .block ~ *,
.typora-editor.scratch-empty-hint .block { /* placeholder auto-hidden once children exist */ }

/* ── Compare mode ── */
.compare-mode .sidebar { display: none; }
.compare-mode .sidebar.collapsed { display: flex; width: 40px; }

.compare-panes {
  display: none;
  flex: 1;
  min-height: 0;
}
.compare-mode .compare-panes {
  display: flex;
}
.compare-mode .main-content > .editor-container {
  display: none;
}

.compare-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: visible;
  position: relative;
}
.compare-pane + .compare-pane {
  border-left: 1px solid var(--border);
}

.compare-pane .editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: none;
  margin: 0;
  padding: 0 24px;
}

.compare-pane .typora-editor {
  flex: 1;
  overflow-y: auto;
}

.compare-pane .editor-header {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

/* ── Diff highlights (right pane) ── */
.block--diff-modified {
  background: rgba(39, 174, 96, 0.06);
  border-left: 2px solid rgba(39, 174, 96, 0.4);
  border-radius: 2px;
}
.block--diff-added {
  background: rgba(39, 174, 96, 0.06);
  border-left: 2px solid rgba(39, 174, 96, 0.4);
  border-radius: 2px;
}
.block--diff-deleted {
  background: rgba(192, 57, 43, 0.04);
  border-left: 2px solid rgba(192, 57, 43, 0.25);
  border-radius: 2px;
  text-decoration: line-through;
  opacity: 0.6;
  pointer-events: none;
}

/* ── Note selector dropdown ── */
.note-selector-trigger {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}
.note-selector-trigger:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.note-selector-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 360px;
  display: flex;
  flex-direction: column;
}

.note-selector-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.note-selector-search input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}

.note-selector-results {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.note-selector-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
}
.note-selector-item:hover {
  background: var(--hover-bg);
}
.note-selector-item .note-date {
  color: var(--text-muted);
  font-size: 11px;
}

.note-selector-browse {
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 12px;
}
