/* ── CSS Variables ───────────────────────────────────────────────── */
:root {
  --bg-app:        #0d0d12;
  --bg-left:       #111118;
  --bg-right:      #16161f;
  --bg-hover:      #1c1c28;
  --bg-active:     #22223a;
  --bg-input:      #1a1a26;
  --bg-toolbar:    #111118;
  --bg-modal:      #1e1e2e;

  --text-primary:  #e2e2f0;
  --text-secondary:#8888a8;
  --text-muted:    #55556a;
  --text-placeholder: #44445a;

  --accent:        #6366f1;
  --accent-hover:  #4f52d9;
  --accent-dim:    rgba(99, 102, 241, 0.15);

  --danger:        #f87171;
  --danger-hover:  #ef4444;
  --danger-dim:    rgba(248, 113, 113, 0.12);

  --border:        #222232;
  --border-focus:  #6366f1;

  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;

  --font-ui:       system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:     ui-monospace, 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

  --transition:    150ms ease;
  --shadow-modal:  0 24px 64px rgba(0,0,0,0.6);
}

/* Light mode overrides */
.light-mode {
  --bg-app:        #f5f5f8;
  --bg-left:       #ebebf2;
  --bg-right:      #f8f8fc;
  --bg-hover:      #e2e2ec;
  --bg-active:     #d8d8f0;
  --bg-input:      #ffffff;
  --bg-toolbar:    #ebebf2;
  --bg-modal:      #ffffff;

  --text-primary:  #1a1a2e;
  --text-secondary:#55557a;
  --text-muted:    #9898b8;
  --text-placeholder: #aaaacc;

  --border:        #d8d8e8;
  --shadow-modal:  0 24px 64px rgba(0,0,0,0.2);
}

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

html { height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--bg-app);
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, textarea { font-family: inherit; color: inherit; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── App Shell ───────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Left Panel ──────────────────────────────────────────────────── */
.panel-left {
  width: 300px;
  min-width: 220px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  background: var(--bg-left);
  border-right: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}

.panel-left-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.brand svg { color: var(--accent); }

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

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}

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

/* Search */
.search-wrap {
  position: relative;
  padding: 10px 12px 8px;
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px 7px 30px;
  font-size: 13px;
  color: var(--text-primary);
  transition: border-color var(--transition);
}

.search-input::placeholder { color: var(--text-placeholder); }
.search-input:focus { outline: none; border-color: var(--accent); }

/* Tag filters */
.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 12px 8px;
  flex-shrink: 0;
}

.tag-filter {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
}

.tag-filter:hover { border-color: var(--accent); color: var(--accent); }
.tag-filter.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* Note list */
.note-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.note-list::-webkit-scrollbar { width: 4px; }
.note-list::-webkit-scrollbar-track { background: transparent; }
.note-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.note-item {
  padding: 10px 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 1px 6px;
  transition: background var(--transition);
  position: relative;
}

.note-item::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 0;
  background: var(--accent);
  border-radius: 2px;
  transition: height var(--transition);
}

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

.note-item.active {
  background: var(--bg-active);
}

.note-item.active::after { height: 60%; }

.note-item-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
  cursor: text;
}

.note-item-rename {
  width: 100%;
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  margin-bottom: 3px;
  outline: none;
}

.note-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.note-date {
  font-size: 11px;
  color: var(--text-muted);
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.tag-chip {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

.empty-state, .loading-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.search-count {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 14px 2px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

mark.search-hl {
  background: rgba(250, 204, 21, 0.3);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
  font-style: normal;
}

.light-mode mark.search-hl {
  background: rgba(234, 179, 8, 0.35);
}

.cm-search-match {
  background: rgba(250, 204, 21, 0.3);
  border-radius: 2px;
}

.light-mode .cm-search-match {
  background: rgba(234, 179, 8, 0.35);
}

.note-snippet {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 2px 0 1px;
  line-height: 1.45;
}

/* Left footer */
.panel-left-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-new-note {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
}

.btn-new-note:hover { background: var(--accent-hover); }
.btn-new-note:active { transform: scale(0.98); }

/* ── Right Panel ─────────────────────────────────────────────────── */
.panel-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--editor-bg-custom, var(--bg-right));
  overflow: hidden;
  min-width: 0;
}

/* Empty state */
.empty-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Editor area */
.editor-area {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-toolbar);
  gap: 12px;
  flex-shrink: 0;
}

.editor-toolbar-left { flex: 1; min-width: 0; }
.editor-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.note-title-input {
  width: 100%;
  background: transparent;
  border: none;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 2px 0;
}

.note-title-input::placeholder { color: var(--text-placeholder); }
.note-title-input:focus { outline: none; }

.last-saved {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  transition: all var(--transition);
}

.toolbar-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.toolbar-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.toolbar-btn-danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

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

.note-content {
  width: 100%;
  height: 100%;
  padding: 20px 24px;
  background: transparent;
  border: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: var(--editor-font-size, 14px);
  line-height: 1.8;
  color: var(--text-primary);
  overflow-y: auto;
}

.note-content::placeholder { color: var(--text-placeholder); }
.note-content:focus { outline: none; }
.note-content::-webkit-scrollbar { width: 6px; }
.note-content::-webkit-scrollbar-track { background: transparent; }
.note-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── CodeMirror editor ──────────────────────────────────────────────────── */
.editor-body .CodeMirror {
  height: 100%;
  width: 100%;
  font-family: var(--font-mono);
  font-size: var(--editor-font-size, 14px);
  line-height: 1.7;
  background: transparent;
  color: var(--text-primary);
}
.editor-body .CodeMirror-scroll { padding: 18px 22px; }
.editor-body .CodeMirror-lines { padding: 0; }
.editor-body .CodeMirror-cursor { border-left-color: var(--accent); }
.editor-body .CodeMirror-selected { background: var(--accent-dim) !important; }
.editor-body .CodeMirror-gutters { background: transparent; border: none; }
.editor-body .CodeMirror-scrollbar-filler { background: transparent; }

/* scrollbar */
.editor-body .CodeMirror-vscrollbar::-webkit-scrollbar { width: 6px; }
.editor-body .CodeMirror-vscrollbar::-webkit-scrollbar-track { background: transparent; }
.editor-body .CodeMirror-vscrollbar::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 4px;
}

/* light-mode CM tweaks (default theme has white bg — make transparent) */
.editor-body .CodeMirror.cm-s-default { background: transparent; }
.editor-body .CodeMirror.cm-s-one-dark { background: transparent; }

/* ── One Dark Pro custom theme ──────────────────────────────────────────── */
.cm-s-one-dark.CodeMirror { color: #abb2bf; }
.cm-s-one-dark .CodeMirror-cursor { border-left-color: #61afef; }
.cm-s-one-dark .CodeMirror-selected { background: rgba(97,175,239,0.18) !important; }
.cm-s-one-dark .CodeMirror-line::selection,
.cm-s-one-dark .CodeMirror-line > span::selection,
.cm-s-one-dark .CodeMirror-line > span > span::selection { background: rgba(97,175,239,0.25); }
.cm-s-one-dark .CodeMirror-activeline-background { background: rgba(255,255,255,0.03); }
.cm-s-one-dark .CodeMirror-matchingbracket { color: #56b6c2 !important; text-decoration: underline; }

/* generic code tokens */
.cm-s-one-dark .cm-keyword    { color: #c678dd; }
.cm-s-one-dark .cm-atom       { color: #d19a66; }
.cm-s-one-dark .cm-number     { color: #d19a66; }
.cm-s-one-dark .cm-def        { color: #61afef; }
.cm-s-one-dark .cm-variable   { color: #e06c75; }
.cm-s-one-dark .cm-variable-2 { color: #e06c75; }
.cm-s-one-dark .cm-variable-3,
.cm-s-one-dark .cm-type       { color: #e5c07b; }
.cm-s-one-dark .cm-property   { color: #61afef; }
.cm-s-one-dark .cm-operator   { color: #56b6c2; }
.cm-s-one-dark .cm-string     { color: #98c379; }
.cm-s-one-dark .cm-string-2   { color: #98c379; }
.cm-s-one-dark .cm-meta       { color: #d19a66; }
.cm-s-one-dark .cm-qualifier  { color: #e5c07b; }
.cm-s-one-dark .cm-builtin    { color: #e5c07b; }
.cm-s-one-dark .cm-bracket    { color: #abb2bf; }
.cm-s-one-dark .cm-tag        { color: #e06c75; }
.cm-s-one-dark .cm-attribute  { color: #d19a66; }
.cm-s-one-dark .cm-error      { color: #f44747; }
.cm-s-one-dark .cm-comment    { color: #5c6370; font-style: italic; }

/* markdown tokens */
.cm-s-one-dark .cm-header     { color: #61afef; font-weight: 600; }
.cm-s-one-dark .cm-header-1   { font-size: 1.15em; }
.cm-s-one-dark .cm-header-2   { font-size: 1.08em; }
.cm-s-one-dark .cm-quote      { color: #98c379; font-style: italic; }
.cm-s-one-dark .cm-link       { color: #61afef; text-decoration: underline; }
.cm-s-one-dark .cm-url        { color: #56b6c2; }
.cm-s-one-dark .cm-strong     { color: #e5c07b; font-weight: 700; }
.cm-s-one-dark .cm-em         { color: #c678dd; font-style: italic; }
.cm-s-one-dark .cm-formatting { color: #5c6370; }

/* ── Light (default) theme tokens — GitHub Light style ──────────────────── */
.cm-s-default .cm-keyword     { color: #cf222e; }
.cm-s-default .cm-atom        { color: #0550ae; }
.cm-s-default .cm-number      { color: #0550ae; }
.cm-s-default .cm-def         { color: #8250df; }
.cm-s-default .cm-variable    { color: #953800; }
.cm-s-default .cm-variable-2  { color: #953800; }
.cm-s-default .cm-variable-3,
.cm-s-default .cm-type        { color: #953800; }
.cm-s-default .cm-property    { color: #0969da; }
.cm-s-default .cm-operator    { color: #cf222e; }
.cm-s-default .cm-string      { color: #0a3069; }
.cm-s-default .cm-string-2    { color: #0a3069; }
.cm-s-default .cm-meta        { color: #cf222e; }
.cm-s-default .cm-qualifier   { color: #953800; }
.cm-s-default .cm-builtin     { color: #6639ba; }
.cm-s-default .cm-bracket     { color: #24292f; }
.cm-s-default .cm-tag         { color: #116329; }
.cm-s-default .cm-attribute   { color: #0550ae; }
.cm-s-default .cm-comment     { color: #6e7781; font-style: italic; }
.cm-s-default .cm-header      { color: #0550ae; font-weight: 600; }
.cm-s-default .cm-quote       { color: #116329; font-style: italic; }
.cm-s-default .cm-link        { color: #0969da; }
.cm-s-default .cm-url         { color: #0a3069; }
.cm-s-default .cm-strong      { color: #953800; font-weight: 700; }
.cm-s-default .cm-em          { color: #8250df; font-style: italic; }
.cm-s-default .cm-formatting  { color: #afb8c1; }

/* Markdown preview */
.note-preview {
  width: 100%;
  height: 100%;
  padding: 20px 24px;
  overflow-y: auto;
  font-family: var(--font-ui);
  font-size: var(--editor-font-size, 14px);
  line-height: 1.8;
  color: var(--text-primary);
}

.note-preview::-webkit-scrollbar { width: 6px; }
.note-preview::-webkit-scrollbar-track { background: transparent; }
.note-preview::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Markdown styles */
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin: 1.2em 0 0.5em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}
.markdown-body h1 { font-size: 1.7em; }
.markdown-body h2 { font-size: 1.35em; }
.markdown-body h3 { font-size: 1.15em; }
.markdown-body p { margin: 0.75em 0; }
.markdown-body a { color: var(--accent); }
.markdown-body a:hover { text-decoration: underline; }
/* inline code only — NOT inside pre blocks */
.markdown-body :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
  color: #a78bfa;
}
/* reset code inside pygments highlight blocks */
.markdown-body .highlight,
.markdown-body .highlight pre {
  margin: 1em 0;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  border: 1px solid var(--border);
}
.markdown-body .highlight pre {
  margin: 0;
  border: none;
}
.markdown-body .highlight code {
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  border-radius: 0 !important;
  font-size: 13px;
  line-height: 1.7;
}
.markdown-body pre {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 1em 0;
}
/* language badge */
.markdown-body pre code[class*="language-"]::before {
  content: attr(class);
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  margin: 1em 0;
  color: var(--text-secondary);
}
.markdown-body ul, .markdown-body ol {
  padding-left: 1.5em;
  margin: 0.75em 0;
}
.markdown-body li { margin: 0.3em 0; }
.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 13.5px;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.markdown-body th { background: var(--bg-hover); font-weight: 600; }
.markdown-body img { max-width: 100%; border-radius: var(--radius-sm); }

/* Editor footer */
.editor-footer {
  padding: 8px 20px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.tags-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tags-input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 12.5px;
  color: var(--text-secondary);
  padding: 2px 0;
}
.tags-input::placeholder { color: var(--text-placeholder); }
.tags-input:focus { outline: none; }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 150ms ease;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 340px;
  box-shadow: var(--shadow-modal);
  animation: slideUp 150ms ease;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-body {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 22px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-full { width: 100%; }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--text-secondary); color: var(--text-primary); }

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ── Login ───────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-left);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  text-align: center;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  background: var(--accent-dim);
  color: var(--accent);
  margin-bottom: 16px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.login-error {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.login-form { text-align: left; }

.field-group { margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.field-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color var(--transition);
}
.field-input::placeholder { color: var(--text-placeholder); }
.field-input:focus { outline: none; border-color: var(--accent); }

/* ── Responsive / Mobile ─────────────────────────────────────────── */
@media (max-width: 680px) {
  .app-shell {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .panel-left {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .note-list {
    max-height: 280px;
  }

  .panel-right {
    flex: none;
    height: auto;
    min-height: 60vh;
  }

  .editor-area {
    height: auto;
  }

  .note-content, .note-preview,
  .editor-body .CodeMirror {
    min-height: 50vh;
    height: auto;
  }

  body { overflow: auto; }
}

@media (max-width: 480px) {
  .editor-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .editor-toolbar-right {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ── Font size control ───────────────────────────────────────────── */
.font-size-ctrl {
  display: flex;
  align-items: center;
  gap: 1px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 30px;
  overflow: hidden;
}
.font-ctrl-btn {
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  height: 100%;
  transition: background var(--transition), color var(--transition);
}
.font-ctrl-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.font-size-label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 26px;
  text-align: center;
  user-select: none;
  pointer-events: none;
}

/* ── Background color picker ─────────────────────────────────────── */
.bg-picker-wrap { position: relative; }

.bg-picker-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-modal);
  z-index: 50;
  width: 220px;
  animation: slideUp 150ms ease;
}
.bg-panel-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.bg-swatch-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.bg-swatch {
  aspect-ratio: 1;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition), border-color var(--transition);
}
.bg-swatch:hover { transform: scale(1.12); border-color: var(--text-muted); }
.bg-swatch.active { border-color: var(--accent) !important; }
.bg-swatch-reset {
  background: conic-gradient(#888 0deg 180deg, #333 180deg 360deg);
}
.bg-custom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.bg-custom-label { font-size: 12px; color: var(--text-secondary); flex: 1; }
.bg-color-input {
  width: 40px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  background: var(--bg-input);
}

/* ── Formatting toolbar ──────────────────────────────────────────── */
.fmt-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-toolbar);
  flex-shrink: 0;
}
.fmt-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 26px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-ui);
  transition: background var(--transition), color var(--transition);
}
.fmt-btn:hover  { background: var(--bg-hover); color: var(--text-primary); }
.fmt-btn.active { background: var(--accent-dim); color: var(--accent); }
.fmt-sep { width: 1px; height: 18px; background: var(--border); margin: 0 6px; }
.fmt-font-btn { padding: 0 8px; font-size: 11px; font-weight: 600; min-width: 34px; }

/* ── Split view ──────────────────────────────────────────────────── */
.editor-body.split-mode {
  display: flex;
  flex-direction: row;
}
.editor-body.split-mode .CodeMirror {
  width: 50% !important;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.editor-body.split-mode #note-preview {
  flex: 1;
  display: block !important;
  border-left: none;
  overflow-y: auto;
  min-width: 0;
}
