/* Design tokens — light (default) */
:root,
[data-theme="light"] {
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-text: #1f2937;
  --color-text-gray: #6b7280;
  --color-muted: #9ca3af;
  --color-border: #e5e7eb;
  --color-bg: #f3f4f6;
  --color-sidebar: #f9fafb;
  --color-surface: #ffffff;
  --color-surface-elevated: #ffffff;
  --color-heading: #111827;
  --color-logo: #000000;
  --color-primary-light: #eff6ff;
  --color-icon-bg: #dbeafe;
  --color-hover: rgba(0, 0, 0, 0.03);
  --color-watermark: #e0e7ff;
  --color-delete-hover-bg: #fef2f2;
  --color-delete-hover-border: #fecaca;
  --color-delete-active-bg: #fee2e2;
  --color-secondary-hover-border: #d1d5db;
  --skeleton-base: #e5e7eb;
  --skeleton-shine: #f3f4f6;

  --font: "Inter", system-ui, -apple-system, sans-serif;
  --sidebar-width: 320px;
  --editor-content-max-width: 1063px;
  --editor-content-padding-x: 48px;
  --radius-btn: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;
  --color-text: #e5e7eb;
  --color-text-gray: #9ca3af;
  --color-muted: #6b7280;
  --color-border: #374151;
  --color-bg: #111827;
  --color-sidebar: #0f172a;
  --color-surface: #111827;
  --color-surface-elevated: #1f2937;
  --color-heading: #f9fafb;
  --color-logo: #f9fafb;
  --color-primary-light: #1e3a5f;
  --color-icon-bg: #1e3a5f;
  --color-hover: rgba(255, 255, 255, 0.06);
  --color-watermark: #1e293b;
  --color-delete-hover-bg: #450a0a;
  --color-delete-hover-border: #7f1d1d;
  --color-delete-active-bg: #581c1c;
  --color-secondary-hover-border: #4b5563;
  --skeleton-base: #1f2937;
  --skeleton-shine: #374151;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
}

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

html,
body {
  height: 100%;
  margin: 0;
}

html.theme-loading,
html.theme-loading * {
  transition: none !important;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-surface);
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

button,
input,
textarea {
  font-family: inherit;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  padding: 20px 16px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 20px;
  padding: 0 4px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-logo {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: block;
  object-fit: contain;
}

.sidebar-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-heading);
  letter-spacing: -0.02em;
}

.btn-sidebar-cancel {
  flex-shrink: 0;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-btn);
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
}

.btn-sidebar-cancel:hover {
  background: var(--color-primary-light);
}

.btn-settings {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--color-text-gray);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-settings:hover {
  background: var(--color-hover);
  color: var(--color-heading);
}

.btn-settings.is-disabled {
  pointer-events: none;
  opacity: 0.45;
}

.btn-settings:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Theme toggle switch (legacy; theme now in Settings) ── */
.theme-toggle {
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:focus {
  outline: none;
}

.theme-toggle:focus-visible .theme-toggle-track {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

.theme-toggle-track {
  position: relative;
  display: block;
  width: 52px;
  height: 28px;
  border-radius: 999px;
  background: #e5e7eb;
  border: 1px solid var(--color-border);
  transition: background 0.28s ease, border-color 0.28s ease, box-shadow 0.28s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .theme-toggle-track {
  background: #334155;
  border-color: #475569;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

.theme-toggle:hover .theme-toggle-track {
  border-color: var(--color-secondary-hover-border);
}

.theme-toggle-decor {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  opacity: 0.55;
  transition: opacity 0.2s ease, color 0.2s ease;
  pointer-events: none;
}

.theme-toggle-decor-sun {
  left: 7px;
}

.theme-toggle-decor-moon {
  right: 7px;
}

[data-theme="dark"] .theme-toggle-decor-sun {
  opacity: 0.35;
}

[data-theme="dark"] .theme-toggle-decor-moon {
  opacity: 0.9;
  color: #93c5fd;
}

.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.08),
    0 2px 6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f59e0b;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.28s ease, color 0.28s ease;
}

[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(24px);
  background: #1e293b;
  color: #93c5fd;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 2px 8px rgba(0, 0, 0, 0.35);
}

.theme-thumb-icon {
  position: absolute;
  display: block;
}

.theme-thumb-sun {
  opacity: 0;
  transform: scale(0.6) rotate(-30deg);
  transition: opacity 0.2s ease, transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-thumb-moon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
  transition: opacity 0.2s ease, transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .theme-thumb-sun {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

[data-theme="dark"] .theme-thumb-moon {
  opacity: 0;
  transform: scale(0.6) rotate(30deg);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-btn);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

.btn-primary {
  width: 100%;
  padding: 10px 16px;
  background: var(--color-primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

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

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  padding: 10px 20px;
  background: var(--color-surface-elevated);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-sidebar);
  border-color: var(--color-secondary-hover-border);
}

.btn-add-note {
  margin-bottom: 8px;
}

.sidebar-list-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.sidebar.is-selection-mode .sidebar-list-toolbar,
.sidebar.is-selection-mode .note-list-filter {
  display: none;
}

.note-list-filter {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  padding: 3px;
  border-radius: var(--radius-btn);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.note-list-filter-btn {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-gray);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.note-list-filter-btn:hover:not(:disabled) {
  color: var(--color-text);
  background: var(--color-hover);
}

.note-list-filter-btn.is-active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.note-list-filter-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  background: var(--color-surface);
  cursor: text;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sidebar-search:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.sidebar-search-icon {
  display: flex;
  flex-shrink: 0;
  color: var(--color-muted);
}

.sidebar-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  padding: 0;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font);
  font-size: 13px;
}

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

.sidebar-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.note-list-empty {
  padding: 20px 12px;
  font-size: 13px;
  color: var(--color-muted);
  text-align: center;
  list-style: none;
}

/* ── Note list ── */
.note-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  margin-right: -8px;
  padding-right: 8px;
}

.note-list::-webkit-scrollbar {
  width: 6px;
}

.note-list::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.note-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 12px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
  transition: background 0.12s, border-color 0.12s;
}

.note-item-content {
  flex: 1;
  min-width: 0;
}

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

.note-item.is-active {
  background: var(--color-surface-elevated);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.note-item.is-pinned:not(.is-active) {
  background: var(--color-primary-light);
}

.note-item.is-favorite:not(.is-active):not(.is-pinned) {
  background: rgba(250, 204, 21, 0.08);
}

.note-item.is-entering {
  opacity: 0;
  transform: translateY(-14px);
  pointer-events: none;
}

.note-item.is-entering.is-entering-active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  transition:
    opacity 0.32s cubic-bezier(0, 0, 0.2, 1),
    transform 0.32s cubic-bezier(0, 0, 0.2, 1);
}

.note-item.is-checked {
  background: var(--color-primary-light);
  border-color: rgba(59, 130, 246, 0.25);
}

.note-item-check {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  cursor: pointer;
}

.note-item-check-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.note-item-check-box {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.note-item-check-input:checked + .note-item-check-box {
  border-color: var(--color-primary);
  background: var(--color-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8.5L6.5 11.5L12.5 5.5' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
}

.note-item-check-input:focus-visible + .note-item-check-box {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.note-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.note-item-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-heading);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.note-item-time {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--color-muted);
  line-height: 1.3;
}

.note-item-snippet {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-gray);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Loading skeletons ── */
.note-item-skeleton {
  pointer-events: none;
  cursor: default;
}

.note-item-skeleton:hover {
  background: transparent;
}

.skeleton-line {
  display: block;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--skeleton-base) 0%,
    var(--skeleton-shine) 50%,
    var(--skeleton-base) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.25s ease-in-out infinite;
}

.skeleton-title {
  flex: 1;
  min-width: 0;
  height: 16px;
  max-width: 72%;
}

.skeleton-time {
  flex-shrink: 0;
  width: 44px;
  height: 12px;
}

.skeleton-snippet {
  height: 12px;
  margin-bottom: 8px;
}

.skeleton-snippet-short {
  width: 58%;
  margin-bottom: 0;
}

.editor-skeleton {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px var(--editor-content-padding-x) 24px;
  width: 100%;
  max-width: var(--editor-content-max-width);
  margin: 0 auto;
  overflow: hidden;
  box-sizing: border-box;
}

.editor-skeleton[hidden] {
  display: none !important;
}

.editor-skeleton-header {
  margin-bottom: 12px;
}

.skeleton-editor-title {
  width: 42%;
  height: 24px;
  margin-bottom: 12px;
  border-radius: 8px;
}

.skeleton-editor-meta {
  width: 28%;
  height: 14px;
}

.editor-skeleton-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.skeleton-body-line {
  height: 14px;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-line {
    animation: none;
    background: var(--skeleton-base);
  }

  .note-item.is-entering,
  .note-item.is-entering.is-entering-active {
    opacity: 1;
    transform: none;
    transition: none;
    pointer-events: auto;
  }
}

/* ── Main pane ── */
.main {
  flex: 1;
  position: relative;
  background: var(--color-surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background 0.2s ease;
}

/* ── Empty state ── */
.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 40px 24px;
}

.empty-state[hidden],
.editor[hidden],
.editor-skeleton[hidden] {
  display: none !important;
}

.empty-state-inner {
  max-width: 420px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.empty-icon-wrap {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: var(--color-icon-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon {
  color: var(--color-primary);
}

.empty-heading {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 700;
  color: var(--color-heading);
  letter-spacing: -0.02em;
}

.empty-body {
  margin: 0 0 28px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text-gray);
}

.empty-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0 20px;
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.empty-divider::before,
.empty-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.empty-shortcut {
  margin: 0;
  font-size: 13px;
  color: var(--color-muted);
}

.empty-shortcut kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 6px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--color-text-gray);
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.empty-watermark {
  position: absolute;
  right: 48px;
  bottom: 32px;
  width: 140px;
  height: 140px;
  color: var(--color-watermark);
  opacity: 0.9;
  pointer-events: none;
  z-index: 0;
}

/* ── Main pane header (delete, logout) ── */
.pane-header {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  width: 100%;
  max-width: var(--editor-content-max-width);
  margin: 0 auto;
  padding: 20px var(--editor-content-padding-x) 0;
  box-sizing: border-box;
}

.pane-header-toolbar {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.pane-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.pane-header-note-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.btn-note-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.btn-note-action:hover {
  background: var(--color-hover);
}

.btn-note-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-note-favorite:hover,
.btn-note-favorite.is-favorite {
  color: #ca8a04;
}

.btn-note-pin:hover,
.btn-note-pin.is-pinned {
  color: var(--color-primary);
}

/* ── Editor ── */
.editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 8px var(--editor-content-padding-x) 24px;
  width: 100%;
  max-width: var(--editor-content-max-width);
  margin: 0 auto;
  overflow: hidden;
  box-sizing: border-box;
}

.editor-header {
  margin-bottom: 12px;
}

.editor-header-text {
  flex: 1;
  min-width: 0;
}

.editor-title {
  border: none;
  outline: none;
  width: 100%;
  margin: 0 0 8px;
  padding: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--color-heading);
  letter-spacing: -0.02em;
  background: transparent;
}

.editor-title::placeholder {
  color: var(--color-muted);
}

.editor-meta {
  margin: 0;
  font-size: 12px;
  color: var(--color-muted);
}

.btn-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px 12px;
  background: transparent;
  color: var(--color-text-gray);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
}

.btn-delete[hidden] {
  display: none !important;
}

.btn-delete:hover {
  color: #dc2626;
  background: var(--color-delete-hover-bg);
  border-color: var(--color-delete-hover-border);
}

.btn-delete:active {
  background: var(--color-delete-active-bg);
}

.btn-delete.btn-delete-bulk {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  background: #dc2626;
  border-color: #dc2626;
  font-weight: 600;
}

.btn-delete.btn-delete-bulk:hover:not(:disabled) {
  color: #fff;
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn-delete.btn-delete-bulk:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  color: #fff;
  background: #dc2626;
  border-color: #dc2626;
}

.btn-delete.btn-delete-bulk svg {
  flex-shrink: 0;
}

.editor-body {
  flex: 1;
  width: 100%;
  min-height: 120px;
  border: none;
  outline: none;
  padding: 0;
  overflow-y: auto;
  font-size: 16px;
  line-height: 1.65;
  color: var(--color-text);
  background: transparent;
  word-wrap: break-word;
}

.editor-body:empty::before {
  content: attr(data-placeholder);
  color: var(--color-muted);
  pointer-events: none;
}

.editor-body h1,
.editor-body h2,
.editor-body h3 {
  margin: 0.65em 0 0.35em;
  font-weight: 600;
  color: var(--color-heading);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.editor-body h1 {
  font-size: 1.625rem;
}

.editor-body h2 {
  font-size: 1.375rem;
}

.editor-body h3 {
  font-size: 1.125rem;
}

.editor-body h1:first-child,
.editor-body h2:first-child,
.editor-body h3:first-child {
  margin-top: 0;
}

.editor-body b,
.editor-body strong {
  font-weight: 700;
}

.editor-body i,
.editor-body em {
  font-style: italic;
}

.editor-body u {
  text-decoration: underline;
}

.editor-body s,
.editor-body strike {
  text-decoration: line-through;
}

.editor-body ul,
.editor-body ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.editor-body blockquote {
  margin: 0.5em 0;
  padding-left: 1em;
  border-left: 3px solid var(--color-border);
  color: var(--color-text-gray);
}

.editor-body a {
  color: var(--color-primary);
  text-decoration: underline;
}

.editor-format-underline {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.editor-format-strike {
  text-decoration: line-through;
}

/* Fixed rich-text toolbar (above note body) */
.editor-format-toolbar {
  flex-shrink: 0;
  width: 100%;
  margin: 0 0 12px;
  padding: 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.editor-format-toolbar-inner {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
  gap: 0;
  padding: 6px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.editor-format-toolbar-inner::-webkit-scrollbar {
  height: 4px;
}

.editor-format-toolbar-inner::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

.editor-format-spacer {
  flex: 1 1 auto;
  min-width: 12px;
  height: 1px;
}

.editor-format-group {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 2px;
}

.editor-format-group-selects {
  gap: 6px;
}

#editorFontFamily {
  width: 108px;
  max-width: 108px;
}

.editor-format-select {
  height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.editor-format-select:hover {
  border-color: var(--color-secondary-hover-border);
  background-color: var(--color-hover);
}

.editor-format-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.editor-format-select-size {
  min-width: 64px;
  padding-right: 26px;
}

.editor-format-select option {
  font-family: var(--font);
  font-size: 13px;
}

.editor-format-divider {
  flex-shrink: 0;
  width: 1px;
  height: 24px;
  margin: 0 6px;
  background: var(--color-border);
}

.editor-format-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #2d3748;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

[data-theme="dark"] .editor-format-btn {
  color: #e5e7eb;
}

.editor-format-btn:hover {
  background: var(--color-hover);
}

.editor-format-btn:active {
  background: var(--color-border);
}

.editor-format-icon {
  display: block;
  flex-shrink: 0;
}

.editor-format-serif {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 17px;
  line-height: 1;
  color: inherit;
}

.editor-format-bold {
  font-weight: 700;
}

.editor-format-italic {
  font-style: italic;
  font-weight: 400;
}

.editor-format-heading {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: inherit;
}

.editor-format-heading sub {
  font-size: 0.62em;
  font-weight: 600;
  line-height: 1;
  margin-left: 1px;
}

.editor-image-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.editor-body .note-image,
.note-read-body .note-image {
  position: relative;
  display: inline-block;
  margin: 1rem 0;
  max-width: 100%;
  vertical-align: top;
  line-height: 0;
}

.editor-body .note-image.is-selected {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-btn);
}

.editor-body .note-image img,
.note-read-body .note-image img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-btn);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.note-read-body .note-image-delete,
.note-read-body .note-image-resize-handle {
  display: none !important;
}

.note-read-body .note-image.is-selected {
  outline: none;
}

.editor-body .note-image-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.editor-body .note-image-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 3;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 4px;
  background: var(--color-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: nwse-resize;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.editor-body .note-image-resize-handle::after {
  content: "";
  position: absolute;
  right: -12px;
  bottom: -12px;
  width: 44px;
  height: 44px;
}

.editor-body .note-image:hover .note-image-delete,
.editor-body .note-image.is-selected .note-image-delete,
.editor-body .note-image:hover .note-image-resize-handle,
.editor-body .note-image.is-selected .note-image-resize-handle {
  opacity: 1;
}

@media (pointer: coarse), (max-width: 768px) {
  .editor-body .note-image .note-image-resize-handle {
    opacity: 0.92;
    width: 28px;
    height: 28px;
  }

  .editor-body .note-image.is-selected {
    touch-action: none;
  }

  .editor-body .note-image.is-selected img {
    touch-action: none;
  }
}

.editor-body .note-image-delete:hover {
  background: rgba(220, 38, 38, 0.92);
}

.editor-body .note-image-resize-handle:hover {
  background: var(--color-primary-hover);
}

body.is-image-resizing {
  cursor: nwse-resize;
  user-select: none;
}

body.is-image-resizing * {
  cursor: nwse-resize !important;
}

/* ── Delete modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-dialog {
  width: 100%;
  max-width: 400px;
  padding: 24px;
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .modal-dialog {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-heading);
  letter-spacing: -0.02em;
}

.modal-body {
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--color-text-gray);
}

.modal-body strong {
  color: var(--color-heading);
  font-weight: 600;
}

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

.modal-actions .btn-secondary {
  padding: 8px 16px;
}

.btn-danger {
  padding: 8px 16px;
  background: #dc2626;
  color: #ffffff;
  border: none;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-danger:active {
  transform: translateY(1px);
}

/* ── Sidebar footer ── */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.sidebar-welcome {
  margin: -12px 0 16px;
  padding: 0 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-muted);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-welcome-name {
  font-weight: 700;
  color: var(--color-heading);
  letter-spacing: -0.01em;
}

.sidebar-welcome[hidden] {
  display: none !important;
}

.btn-select-notes {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-gray);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-select-notes svg {
  flex-shrink: 0;
  color: var(--color-muted);
  transition: color 0.15s ease;
}

.btn-select-notes:hover {
  color: var(--color-text);
  background: var(--color-hover);
}

.btn-select-notes:hover svg {
  color: var(--color-text-gray);
}

.btn-sign-out {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--color-text-gray);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-sign-out svg {
  flex-shrink: 0;
}

.btn-sign-out:hover {
  color: var(--color-heading);
  background: var(--color-hover);
  border-color: var(--color-secondary-hover-border);
}

/* ── App loading ── */
.app-loading {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--color-text-gray);
  font-size: 14px;
}

[data-theme="dark"] .app-loading {
  background: rgba(15, 23, 42, 0.75);
}

.app-loading[hidden] {
  display: none !important;
}

.app-loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: app-spin 0.7s linear infinite;
}

@keyframes app-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Auth page ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: var(--color-bg);
}

.auth-shell {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.auth-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-header-logo {
  display: block;
  flex-shrink: 0;
}

.auth-header-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.auth-tabs {
  position: relative;
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--color-border);
}

.auth-tab-indicator {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--color-primary);
  transform: translateX(0);
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.auth-tab {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 0 0 12px;
  margin: 0;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-muted);
  cursor: pointer;
  transition: color 0.28s ease;
}

.auth-tab:hover {
  color: var(--color-text-gray);
}

.auth-tab.is-active {
  font-weight: 600;
  color: var(--color-text);
}

.auth-panel {
  display: flex;
  flex-direction: column;
}

.auth-panel-viewport {
  overflow: hidden;
}

.auth-panel-content {
  will-change: opacity, transform;
}

.auth-panel-content.is-exiting {
  opacity: 0;
  transform: translate3d(var(--auth-shift, 0), 10px, 0);
  transition: opacity 0.26s cubic-bezier(0.4, 0, 1, 1),
    transform 0.26s cubic-bezier(0.4, 0, 1, 1);
  pointer-events: none;
}

.auth-panel-content.is-entering {
  opacity: 0;
  transform: translate3d(var(--auth-shift, 0), -10px, 0);
}

.auth-panel-content.is-entering.is-entering-active {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  transition: opacity 0.34s cubic-bezier(0, 0, 0.2, 1),
    transform 0.34s cubic-bezier(0, 0, 0.2, 1);
}

.auth-panel[data-mode="signup"] .auth-login-only {
  opacity: 0;
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(-4px);
}

.auth-panel[data-mode="signin"] .auth-signup-only {
  opacity: 0;
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(-4px);
}

.auth-panel .auth-login-only {
  max-height: 48px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease,
    transform 0.3s ease;
}

.auth-panel .auth-signup-only {
  max-height: 132px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease,
    transform 0.3s ease;
}

.auth-panel[data-mode="signup"] .auth-label-row .auth-login-only {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
}

.auth-panel .auth-label-row .auth-login-only {
  width: auto;
  transition: opacity 0.28s ease, width 0.28s ease;
}

@media (prefers-reduced-motion: reduce) {
  .auth-tab-indicator,
  .auth-panel-content,
  .auth-panel .auth-login-only,
  .auth-panel .auth-signup-only {
    transition: none !important;
  }

  .auth-panel-content.is-exiting,
  .auth-panel-content.is-entering {
    opacity: 1;
    transform: none;
  }
}

.auth-heading {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.auth-lead {
  margin: 0 0 24px;
  font-size: 14px;
  color: var(--color-text-gray);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.auth-field.has-error .auth-input {
  border-color: #ef4444;
}

.auth-field.has-error .auth-input:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.auth-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}

.auth-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auth-label-row .auth-label {
  margin: 0;
}

.auth-text-link {
  padding: 0;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-primary);
  cursor: pointer;
  white-space: nowrap;
}

.auth-text-link:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

.auth-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-input::placeholder {
  color: var(--color-muted);
}

.auth-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.auth-password-wrap {
  position: relative;
}

.auth-input-password {
  padding-right: 44px;
}

.auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--color-muted);
  cursor: pointer;
}

.auth-password-toggle:hover {
  color: var(--color-text-gray);
}

.auth-password-toggle .auth-eye {
  display: block;
}

.auth-password-toggle .auth-eye-hide {
  display: none;
}

.auth-password-toggle.is-password-visible .auth-eye-show {
  display: none;
}

.auth-password-toggle.is-password-visible .auth-eye-hide {
  display: block;
}

.auth-field-error {
  margin: 0;
  font-size: 13px;
  color: #ef4444;
}

.auth-field-error[hidden],
.auth-banner[hidden] {
  display: none !important;
}

.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.auth-checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.auth-checkbox-box {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.auth-checkbox input:checked + .auth-checkbox-box {
  border-color: var(--color-primary);
  background: var(--color-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8.5L6.5 11.5L12.5 5.5' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px;
}

.auth-checkbox input:focus-visible + .auth-checkbox-box {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.auth-checkbox-label {
  font-size: 14px;
  color: var(--color-text-gray);
}

.auth-banner {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-btn);
  font-size: 13px;
  line-height: 1.45;
}

.auth-banner-error {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

[data-theme="dark"] .auth-banner-error {
  color: #fecaca;
  background: #450a0a;
  border-color: #7f1d1d;
}

.auth-banner-success {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

[data-theme="dark"] .auth-banner-success {
  color: #bbf7d0;
  background: #14532d;
  border-color: #166534;
}

.auth-btn-primary {
  width: 100%;
  margin-top: 2px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-btn);
  background: var(--color-primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.auth-btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.auth-btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.auth-oauth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0 20px;
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.auth-oauth-divider::before,
.auth-oauth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.auth-oauth-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.auth-oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.auth-oauth-btn:hover:not(:disabled) {
  border-color: var(--color-secondary-hover-border);
  background: var(--color-hover);
}

.auth-oauth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-legal {
  margin-top: 32px;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: var(--color-text-gray);
}

.auth-legal-link {
  color: var(--color-text-gray);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-legal-link:hover {
  color: var(--color-text);
}

.auth-flow-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.auth-flow-panel[hidden] {
  display: none !important;
}

.auth-back-link {
  display: inline-block;
  margin-top: 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-primary);
  text-decoration: none;
  text-align: center;
}

.auth-back-link:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

.auth-field-hint {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--color-text-gray);
}

.auth-field-hint.is-invalid {
  color: #ef4444;
}

.auth-field-hint.is-valid {
  color: #16a34a;
}

.auth-lead-centered {
  text-align: center;
}

.auth-success-panel {
  align-items: center;
  text-align: center;
}

.auth-success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.auth-btn-link {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  text-decoration: none;
  box-sizing: border-box;
}

a.auth-text-link {
  display: inline;
  text-decoration: none;
}

a.auth-text-link:hover {
  text-decoration: underline;
}

/* ── Mobile shell (hidden on desktop) ── */
.sidebar-mobile-top,
.mobile-detail-header,
.editor-read,
.mobile-fab,
.mobile-detail-menu,
.btn-select-notes-label-mobile {
  display: none;
}

.note-list-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 10px;
  padding: 0 4px;
}

.note-list-section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-heading);
}

.btn-select-notes--link {
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-primary);
  background: transparent;
}

.btn-select-notes--link:hover {
  background: transparent;
  color: var(--color-primary-hover);
}

.btn-select-notes-label-mobile {
  display: none;
}

@media (max-width: 768px) {
  :root {
    --editor-content-padding-x: 20px;
  }

  /* List layout before app shell JS runs */
  html.mobile-vp #app:not(.is-mobile) {
    display: block;
    height: 100dvh;
    height: 100vh;
    overflow: hidden;
    position: relative;
  }

  html.mobile-vp #app:not(.is-mobile) .sidebar {
    width: 100%;
    max-width: none;
    height: 100%;
    border-right: none;
  }

  html.mobile-vp #app:not(.is-mobile) #mainPane {
    visibility: hidden;
    pointer-events: none;
  }

  html.mobile-vp #app:not(.is-mobile) .sidebar-header--desktop,
  html.mobile-vp #app:not(.is-mobile) .pane-header,
  html.mobile-vp #app:not(.is-mobile) .sidebar-welcome,
  html.mobile-vp #app:not(.is-mobile) .btn-select-notes-label-desktop {
    display: none !important;
  }

  html.mobile-vp #app:not(.is-mobile) .sidebar-mobile-top,
  html.mobile-vp #app:not(.is-mobile) .btn-select-notes-label-mobile {
    display: flex;
  }

  html.mobile-vp #app:not(.is-mobile) .mobile-detail-header,
  html.mobile-vp #app:not(.is-mobile) .mobile-detail-menu,
  html.mobile-vp #app:not(.is-mobile) .editor-read,
  html.mobile-vp #app:not(.is-mobile) .mobile-fab {
    display: none !important;
  }

  .app.is-mobile {
    display: block;
    height: 100dvh;
    height: 100vh;
    overflow: hidden;
    position: relative;
  }

  html.mobile-vp #app.is-mobile .sidebar-mobile-top,
  html.mobile-vp #app.is-mobile .btn-select-notes-label-mobile {
    display: flex;
  }

  html.mobile-vp #app.is-mobile[data-mobile-view="detail"] .mobile-detail-header {
    display: flex;
  }

  html.mobile-vp #app.is-mobile[data-mobile-view="detail"] .mobile-detail-menu:not([hidden]) {
    display: block;
  }

  html.mobile-vp #app.is-mobile[data-mobile-view="detail"] .editor-read {
    display: flex;
    flex-direction: column;
  }

  .sidebar-header--desktop,
  .pane-header,
  .sidebar-welcome,
  .btn-select-notes-label-desktop {
    display: none !important;
  }

  html.mobile-vp:not(.app-shell-ready) .app.is-mobile .sidebar,
  html.mobile-vp:not(.app-shell-ready) .app.is-mobile .main {
    transition: none !important;
  }

  .app.is-mobile .sidebar,
  .app.is-mobile .main {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    max-height: none;
    height: 100%;
    border: none;
    transition: transform 0.22s ease, visibility 0.22s ease;
    will-change: transform;
  }

  .app.is-mobile .sidebar {
    z-index: 2;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .app.is-mobile .main {
    z-index: 3;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .app.is-mobile .empty-state,
  .app.is-mobile .editor {
    flex: 1;
    min-height: 0;
  }

  .app.is-mobile[data-mobile-view="list"] .main {
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;
  }

  .app.is-mobile[data-mobile-view="list"] .mobile-detail-header,
  .app.is-mobile[data-mobile-view="list"] .mobile-detail-menu {
    display: none !important;
  }

  .app.is-mobile[data-mobile-view="detail"] .sidebar {
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
  }

  .sidebar-mobile-top {
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 0 4px;
  }

  .sidebar-mobile-top-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }

  .btn-settings--mobile {
    flex-shrink: 0;
  }

  .btn-logout-mobile {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border: none;
    border-radius: var(--radius-btn);
    background: transparent;
    color: var(--color-text-gray);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
  }

  .btn-logout-mobile:hover {
    background: var(--color-hover);
    color: var(--color-text);
  }

  .btn-add-note {
    margin-bottom: 12px;
  }

  .mobile-detail-header {
    flex-shrink: 0;
    align-items: center;
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) var(--editor-content-padding-x) 12px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
  }

  .mobile-detail-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: var(--radius-btn);
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    flex-shrink: 0;
  }

  .mobile-detail-back:hover {
    background: var(--color-hover);
  }

  .mobile-detail-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--color-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-detail-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }

  .mobile-detail-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: var(--radius-btn);
    background: transparent;
    color: var(--color-text-gray);
    cursor: pointer;
  }

  .mobile-detail-action:hover {
    background: var(--color-hover);
    color: var(--color-text);
  }

  .app.is-mobile:has(.empty-state:not([hidden])) .mobile-detail-actions {
    visibility: hidden;
    pointer-events: none;
  }

  .mobile-detail-menu {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    z-index: 10;
    min-width: 160px;
    padding: 6px;
    border-radius: var(--radius-btn);
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  }

  .mobile-detail-menu-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--color-text);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
  }

  .mobile-detail-menu-item:hover {
    background: var(--color-hover);
  }

  .app.is-mobile .editor {
    position: relative;
    flex: 1;
    min-height: 0;
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  .editor-read {
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    padding: 16px var(--editor-content-padding-x) 24px;
  }

  .note-read-meta {
    margin: 0 0 12px;
    font-size: 12px;
    color: var(--color-muted);
  }

  .note-read-body {
    font-size: 16px;
    line-height: 1.65;
    color: var(--color-text);
    word-wrap: break-word;
  }

  .note-read-body:empty::before {
    content: "No content yet.";
    color: var(--color-muted);
  }

  .note-read-body h1,
  .note-read-body h2,
  .note-read-body h3,
  .note-read-body p,
  .note-read-body ul,
  .note-read-body ol,
  .note-read-body blockquote {
    margin: 0 0 0.75em;
  }

  .editor-compose {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 0 var(--editor-content-padding-x);
  }

  .app.is-mobile[data-editor-mode="read"] .editor-compose {
    display: none !important;
  }

  .app.is-mobile[data-editor-mode="edit"] .editor-read {
    display: none !important;
  }

  .app.is-mobile[data-editor-mode="read"] .mobile-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 5;
    width: 56px;
    height: 56px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.45);
    cursor: pointer;
  }

  .app.is-mobile[data-editor-mode="edit"] .mobile-fab,
  .app.is-mobile .empty-state:not([hidden]) ~ .editor .mobile-fab {
    display: none !important;
  }

  .app.is-mobile[data-editor-mode="edit"] .editor-header {
    padding-top: 8px;
  }

  .app.is-mobile[data-editor-mode="edit"] .editor-format-toolbar {
    margin-left: calc(-1 * var(--editor-content-padding-x));
    margin-right: calc(-1 * var(--editor-content-padding-x));
    padding-left: var(--editor-content-padding-x);
    padding-right: var(--editor-content-padding-x);
  }

  .app.is-mobile .editor-body {
    padding-bottom: 16px;
    -webkit-overflow-scrolling: touch;
  }

  .app.is-mobile[data-editor-mode="edit"] .editor-body .note-image .note-image-resize-handle,
  html.mobile-vp .editor-body .note-image .note-image-resize-handle {
    opacity: 1;
    width: 32px;
    height: 32px;
  }

  .app.is-mobile[data-editor-mode="edit"] .editor-body .note-image.is-selected img {
    cursor: ew-resize;
  }

  .app.is-mobile .empty-state {
    padding: 32px 24px 80px;
  }

  .empty-watermark {
    display: none;
  }

  .app.is-mobile .editor-skeleton {
    padding: 16px var(--editor-content-padding-x);
  }
}
