/* TinyNote — ported & polished design system (no Tailwind; hand-authored). */

/* ===================== Design tokens ===================== */
:root {
  --radius: 0.9rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --radius-2xl: calc(var(--radius) + 8px);

  --background: oklch(0.985 0.006 90);
  --foreground: oklch(0.22 0.02 270);
  --surface: oklch(1 0 0 / 0.6);
  --surface-2: oklch(1 0 0 / 0.85);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.22 0.02 270);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.22 0.02 270);
  --primary: oklch(0.55 0.19 275);
  --primary-foreground: oklch(0.99 0.003 250);
  --secondary: oklch(0.96 0.01 270);
  --secondary-foreground: oklch(0.25 0.02 270);
  --muted: oklch(0.95 0.008 270);
  --muted-foreground: oklch(0.5 0.02 270);
  --accent: oklch(0.72 0.16 55);
  --accent-foreground: oklch(0.15 0.02 270);
  --destructive: oklch(0.6 0.22 25);
  --destructive-foreground: oklch(0.99 0.003 250);
  --border: oklch(0.9 0.01 270 / 0.7);
  --input: oklch(0.92 0.008 270);
  --ring: oklch(0.55 0.19 275);
  --grad-bg:
    radial-gradient(1200px 600px at 10% -10%, oklch(0.85 0.12 300 / 0.35), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, oklch(0.88 0.1 55 / 0.35), transparent 60%),
    radial-gradient(700px 400px at 50% 110%, oklch(0.85 0.1 200 / 0.3), transparent 60%);

  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
}

.dark {
  --background: oklch(0.17 0.02 270);
  --foreground: oklch(0.96 0.005 250);
  --surface: oklch(0.24 0.02 275 / 0.55);
  --surface-2: oklch(0.24 0.02 275 / 0.8);
  --card: oklch(0.22 0.02 275);
  --card-foreground: oklch(0.96 0.005 250);
  --popover: oklch(0.22 0.02 275);
  --popover-foreground: oklch(0.96 0.005 250);
  --primary: oklch(0.72 0.17 285);
  --primary-foreground: oklch(0.15 0.02 270);
  --secondary: oklch(0.28 0.02 275);
  --secondary-foreground: oklch(0.96 0.005 250);
  --muted: oklch(0.28 0.02 275);
  --muted-foreground: oklch(0.72 0.02 270);
  --accent: oklch(0.78 0.16 55);
  --accent-foreground: oklch(0.15 0.02 270);
  --destructive: oklch(0.65 0.23 25);
  --destructive-foreground: oklch(0.99 0.003 250);
  --border: oklch(1 0 0 / 0.1);
  --input: oklch(1 0 0 / 0.12);
  --ring: oklch(0.72 0.17 285);
  --grad-bg:
    radial-gradient(1200px 600px at 10% -10%, oklch(0.45 0.2 285 / 0.35), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, oklch(0.5 0.18 320 / 0.28), transparent 60%),
    radial-gradient(700px 400px at 50% 110%, oklch(0.45 0.18 200 / 0.25), transparent 60%);
}

.amoled {
  --background: oklch(0 0 0);
  --foreground: oklch(0.98 0 0);
  --surface: oklch(0.15 0 0 / 0.6);
  --surface-2: oklch(0.12 0 0 / 0.85);
  --card: oklch(0.08 0 0);
  --card-foreground: oklch(0.98 0 0);
  --popover: oklch(0.08 0 0);
  --popover-foreground: oklch(0.98 0 0);
  --primary: oklch(0.8 0.18 285);
  --primary-foreground: oklch(0 0 0);
  --secondary: oklch(0.15 0 0);
  --secondary-foreground: oklch(0.98 0 0);
  --muted: oklch(0.15 0 0);
  --muted-foreground: oklch(0.7 0 0);
  --accent: oklch(0.85 0.17 60);
  --accent-foreground: oklch(0 0 0);
  --destructive: oklch(0.7 0.24 25);
  --destructive-foreground: oklch(0 0 0);
  --border: oklch(1 0 0 / 0.08);
  --input: oklch(1 0 0 / 0.1);
  --ring: oklch(0.8 0.18 285);
  --grad-bg:
    radial-gradient(1000px 500px at 20% 0%, oklch(0.35 0.2 285 / 0.25), transparent 60%),
    radial-gradient(800px 400px at 100% 100%, oklch(0.35 0.18 320 / 0.2), transparent 60%);
}

.sepia {
  --background: oklch(0.94 0.03 80);
  --foreground: oklch(0.28 0.04 55);
  --surface: oklch(0.97 0.02 80 / 0.6);
  --surface-2: oklch(0.97 0.02 80 / 0.9);
  --card: oklch(0.96 0.025 80);
  --card-foreground: oklch(0.28 0.04 55);
  --popover: oklch(0.96 0.025 80);
  --popover-foreground: oklch(0.28 0.04 55);
  --primary: oklch(0.45 0.11 45);
  --primary-foreground: oklch(0.98 0.02 80);
  --secondary: oklch(0.9 0.03 75);
  --secondary-foreground: oklch(0.28 0.04 55);
  --muted: oklch(0.9 0.03 75);
  --muted-foreground: oklch(0.5 0.04 55);
  --accent: oklch(0.6 0.15 40);
  --accent-foreground: oklch(0.98 0.02 80);
  --destructive: oklch(0.55 0.2 25);
  --destructive-foreground: oklch(0.98 0.02 80);
  --border: oklch(0.75 0.04 65 / 0.5);
  --input: oklch(0.88 0.03 75);
  --ring: oklch(0.45 0.11 45);
  --grad-bg:
    radial-gradient(1200px 600px at 10% -10%, oklch(0.85 0.1 55 / 0.5), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, oklch(0.82 0.09 35 / 0.4), transparent 60%);
}

/* ===================== Base ===================== */
* { box-sizing: border-box; border-color: var(--border); }
html, body, #root { height: 100%; margin: 0; }
body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  background-image: var(--grad-bg);
  background-attachment: fixed;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: color-mix(in oklch, var(--primary) 35%, transparent); }
.hidden { display: none !important; }
.ml-auto { margin-left: auto; }
.muted { color: var(--muted-foreground); }

.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }
.icon-xs { width: 12px; height: 12px; }
.icon-lg { width: 28px; height: 28px; }

.glass {
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border);
}
.glass-strong {
  background: var(--surface-2);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--border);
}

.scroll-thin::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-thin::-webkit-scrollbar-thumb { background: color-mix(in oklch, var(--foreground) 15%, transparent); border-radius: 8px; }
.scroll-thin::-webkit-scrollbar-track { background: transparent; }

.scroll-x-thin::-webkit-scrollbar { height: 0; }

@keyframes float-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.anim-float { animation: float-in 0.25s ease-out; }

/* ---- "Shine" polish: a soft specular sweep used on brand marks / hero icons / CTAs ---- */
@keyframes shine-sweep {
  0% { transform: translateX(-160%) rotate(10deg); opacity: 0; }
  12% { opacity: 1; }
  55% { opacity: 1; }
  100% { transform: translateX(220%) rotate(10deg); opacity: 0; }
}
.shine { position: relative; overflow: hidden; isolation: isolate; }
.shine::after {
  content: "";
  position: absolute;
  top: -70%;
  left: -30%;
  width: 34%;
  height: 240%;
  background: linear-gradient(115deg, transparent, oklch(1 0 0 / 0.65), transparent);
  animation: shine-sweep 4.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}
@media (prefers-reduced-motion: reduce) {
  .shine::after { animation: none; display: none; }
}

/* ===================== Layout ===================== */
.app-root { display: flex; height: 100vh; width: 100%; overflow: hidden; }

/* Sidebar */
.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  width: 300px;
  border-right: 1px solid var(--border);
}
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 20px 16px 12px; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: var(--primary-foreground);
  box-shadow: 0 2px 10px color-mix(in oklch, var(--primary) 45%, transparent), inset 0 1px 0 oklch(1 0 0 / 0.35);
}
.brand-mark .icon { width: 17px; height: 17px; }
.brand-text { line-height: 1.15; }
.brand-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--muted-foreground); letter-spacing: 0.01em; }

.btn-icon {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-md);
  color: var(--muted-foreground); transition: color .15s, background .15s, transform .15s;
}
.btn-icon:hover { background: var(--secondary); color: var(--foreground); }
.btn-icon:active { transform: scale(0.92); }

.sidebar-search-wrap { padding: 0 12px 8px; }
.search-box { display: flex; align-items: center; gap: 8px; border-radius: var(--radius-lg); padding: 6px 10px; transition: box-shadow .15s, border-color .15s; }
.search-box:focus-within { box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 22%, transparent); border-color: color-mix(in oklch, var(--ring) 55%, transparent); }
.search-input { flex: 1; background: transparent; border: none; outline: none; font-size: 13px; }
.search-input::placeholder { color: var(--muted-foreground); }
.recent-searches { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.recent-chip {
  border-radius: 999px; border: 1px solid color-mix(in oklch, var(--border) 60%, transparent);
  background: color-mix(in oklch, var(--secondary) 60%, transparent);
  padding: 2px 8px; font-size: 11px; color: var(--muted-foreground); transition: color .15s, background .15s;
}
.recent-chip:hover { color: var(--foreground); background: var(--secondary); }

.sidebar-tabs { display: flex; align-items: center; gap: 4px; padding: 0 12px 8px; font-size: 12px; color: var(--muted-foreground); }
.tab-btn { border-radius: var(--radius-md); padding: 4px 8px; transition: background .15s, color .15s; }
.tab-btn:hover { background: color-mix(in oklch, var(--secondary) 60%, transparent); }
.tab-active { background: var(--secondary); color: var(--foreground); }
.sort-wrap { display: flex; align-items: center; gap: 4px; }
.sort-select { background: transparent; border: none; outline: none; font-size: 12px; }

.notes-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.note-card {
  position: relative; margin-bottom: 6px; cursor: pointer; border-radius: var(--radius-xl);
  border: 1px solid transparent; padding: 10px 12px; font-size: 13px; transition: all .15s;
}
.note-card:hover { border-color: var(--border); background: color-mix(in oklch, var(--secondary) 50%, transparent); transform: translateY(-1px); }
.note-card.active { border-color: color-mix(in oklch, var(--primary) 40%, transparent); background: color-mix(in oklch, var(--primary) 8%, transparent); box-shadow: 0 2px 8px color-mix(in oklch, var(--primary) 18%, transparent); }
.note-top { display: flex; align-items: center; gap: 6px; }
.note-title { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-title mark.search-hit { background: color-mix(in oklch, var(--accent) 55%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.note-preview { margin-top: 2px; font-size: 11px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-meta { margin-top: 4px; display: flex; align-items: center; justify-content: space-between; font-size: 10px; color: var(--muted-foreground); }
.note-actions { display: flex; opacity: 0; transition: opacity .15s; }
.note-card:hover .note-actions { opacity: 1; }
.icon-btn-xs { display: grid; place-items: center; width: 22px; height: 22px; border-radius: var(--radius-md); color: var(--muted-foreground); transition: background .15s, color .15s; }
.icon-btn-xs:hover { background: var(--secondary); color: var(--foreground); }
.icon-btn-xs .icon { width: 12px; height: 12px; }
.pin-mark { color: var(--primary); }
.fav-mark { color: var(--accent); fill: currentColor; }

.empty-list { margin-top: 40px; display: flex; flex-direction: column; align-items: center; padding: 0 24px; text-align: center; color: var(--muted-foreground); }
.empty-list-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 999px; background: var(--secondary); }
.empty-list p { margin-top: 12px; font-size: 13px; }

.empty-trash-btn {
  margin-top: 8px; width: 100%; border-radius: var(--radius-lg); border: 1px solid color-mix(in oklch, var(--destructive) 30%, transparent);
  padding: 8px 0; font-size: 12px; color: var(--destructive); transition: background .15s;
}
.empty-trash-btn:hover { background: color-mix(in oklch, var(--destructive) 10%, transparent); }

.create-first-btn {
  margin-top: 12px; border-radius: 999px; background: var(--primary); padding: 6px 12px; font-size: 12px; font-weight: 500; color: var(--primary-foreground); transition: opacity .15s, transform .15s;
}
.create-first-btn:hover { opacity: .9; transform: translateY(-1px); }

.theme-row { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--border); padding: 8px 12px; overflow-x: auto; }
.theme-chip { display: flex; align-items: center; gap: 4px; flex-shrink: 0; border-radius: var(--radius-md); padding: 4px 8px; font-size: 11px; text-transform: capitalize; color: var(--muted-foreground); transition: background .15s, color .15s; }
.theme-chip:hover { background: var(--secondary); }
.theme-chip.active { background: var(--primary); color: var(--primary-foreground); box-shadow: 0 2px 8px color-mix(in oklch, var(--primary) 40%, transparent); }
.theme-label { display: none; }
@media (min-width: 1100px) { .theme-label { display: inline; } }

.resize-handle { position: absolute; right: 0; top: 0; z-index: 10; height: 100%; width: 4px; cursor: col-resize; }
.resize-handle:hover { background: color-mix(in oklch, var(--primary) 40%, transparent); }

/* Main */
.main-panel { position: relative; display: flex; height: 100%; min-width: 0; flex: 1; flex-direction: column; }
.editor-view { display: flex; flex-direction: column; height: 100%; position: relative; }

/* Floating actions anchored to the bottom-right of the editor, always
   reachable regardless of scroll position within the note. */
.editor-fab-group { position: absolute; right: 20px; bottom: 20px; z-index: 12; display: flex; flex-direction: column; gap: 10px; }
.editor-fab {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 999px;
  background: var(--surface-2); backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border); color: var(--muted-foreground);
  box-shadow: 0 8px 24px rgba(0,0,0,.15), inset 0 1px 0 oklch(1 0 0 / 0.25);
  transition: color .15s, transform .15s, box-shadow .15s;
}
.editor-fab .icon { width: 18px; height: 18px; }
.editor-fab:hover { color: var(--foreground); transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0,0,0,.2); }
.editor-fab:active { transform: translateY(0) scale(0.94); }
.editor-fab.danger:hover { color: var(--destructive); }
.editor-fab.fab-success { color: var(--primary); box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 30%, transparent), 0 8px 24px rgba(0,0,0,.15); }
.editor-fab:disabled { opacity: .35; pointer-events: none; }
@media (max-width: 720px) {
  .editor-fab-group { right: 14px; bottom: 68px; }
  .editor-fab { width: 38px; height: 38px; }
}

/* Export as PDF: print only the active note via the browser's print dialog. */
@media print {
  body.printing-note > *:not(#root) { visibility: hidden; }
  body.printing-note .app-root > *:not(.main-panel) { visibility: hidden; }
  body.printing-note .main-panel > *:not(#editorView) { visibility: hidden; }
  body.printing-note #editorView > *:not(.editor-scroll) { visibility: hidden; }
  body.printing-note .editor-scroll, body.printing-note .editor-scroll * { visibility: visible; }
  body.printing-note .editor-scroll { position: absolute; inset: 0; overflow: visible; padding: 24px; }
}

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; border-bottom: 1px solid var(--border); padding: 10px 16px; }
.title-input { min-width: 0; flex: 1; margin-right: 12px; background: transparent; border: none; outline: none; font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.title-input::placeholder { color: var(--muted-foreground); }

.tool-group { display: flex; align-items: center; gap: 2px; flex-shrink: 0; border-right: 1px solid var(--border); padding-right: 6px; margin-right: 4px; }
.tool-group-last, .tool-group:last-child { border-right: none; padding-right: 0; margin-right: 0; }
.tool-btn { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: var(--radius-md); color: var(--muted-foreground); transition: color .15s, background .15s, transform .1s; }
.tool-btn:hover { background: var(--secondary); color: var(--foreground); }
.tool-btn:active { transform: scale(0.92); }
.tool-btn.active { color: var(--primary); background: color-mix(in oklch, var(--primary) 12%, transparent); }
.tool-btn.fav-active { color: var(--accent); fill: currentColor; }
.tool-btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.mobile-back-btn { display: none; }

.popover-wrap { position: relative; }
.popover { display: flex; flex-wrap: wrap; gap: 6px; border-radius: var(--radius-lg); padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.swatch { width: 24px; height: 24px; border-radius: 999px; transition: transform .1s; }
.swatch:hover { box-shadow: 0 0 0 2px var(--primary); transform: scale(1.08); }
.swatch-clear { display: grid; place-items: center; border: 1px solid var(--border); font-size: 10px; }

.menu { min-width: 220px; overflow: hidden; border-radius: var(--radius-lg); padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.menu-item { display: flex; width: 100%; align-items: center; gap: 8px; border-radius: var(--radius-md); padding: 6px 10px; text-align: left; font-size: 12px; }
.menu-item:hover { background: var(--secondary); }

/* ---- Floating menus: portaled to <body> so an ancestor's overflow-x:auto
   (e.g. the mobile toolbar) can never clip them, with a slide+fade reveal
   on open. On mobile they switch to a bottom sheet instead of a dropdown. ---- */
.floating-menu {
  position: fixed;
  z-index: 200;
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  transform-origin: top right;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .16s cubic-bezier(.4,0,.2,1), transform .16s cubic-bezier(.4,0,.2,1), visibility 0s linear .16s;
}
.floating-menu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
  transition: opacity .2s cubic-bezier(.4,0,.2,1), transform .2s cubic-bezier(.4,0,.2,1);
}
.floating-scrim {
  position: fixed; inset: 0; z-index: 190;
  background: color-mix(in oklch, var(--background) 45%, transparent);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.floating-scrim.show { opacity: 1; pointer-events: auto; }

@media (max-width: 720px) {
  .floating-menu.sheet-mode {
    left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important;
    width: 100%; max-width: 100%; max-height: 75vh; overflow-y: auto;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    transform: translateY(100%);
    transform-origin: bottom center;
    box-shadow: 0 -20px 60px rgba(0,0,0,.25);
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .floating-menu.sheet-mode.open { transform: translateY(0); }
  .floating-menu.sheet-mode::before {
    content: ""; display: block; width: 36px; height: 4px; border-radius: 999px;
    background: var(--border); margin: 10px auto 6px;
  }
  .floating-menu.sheet-mode.popover { justify-content: center; }
  .floating-menu.sheet-mode .menu-item { padding: 11px 16px; font-size: 14px; }
}

.editor-scroll { position: relative; flex: 1; overflow-y: auto; }
.editor-inner { margin: 0 auto; width: 100%; max-width: 760px; padding: 40px 24px; }
@media (min-width: 768px) { .editor-inner { padding: 40px 40px; } }

.editor-content { position: relative; min-height: 60vh; font-size: 15px; line-height: 1.75; outline: none; }
.editor-content h1 { font-family: var(--font-display); font-size: 2rem; font-weight: 600; margin: 1rem 0 0.5rem; letter-spacing: -0.02em; }
.editor-content h2 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; margin: 0.9rem 0 0.4rem; letter-spacing: -0.01em; }
.editor-content h3 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; margin: 0.8rem 0 0.3rem; }
.editor-content p { margin: 0.4rem 0; line-height: 1.7; }
.editor-content ul { list-style: disc; padding-left: 1.5rem; margin: 0.4rem 0; }
.editor-content ol { list-style: decimal; padding-left: 1.5rem; margin: 0.4rem 0; }
.editor-content li { margin: 0.2rem 0; line-height: 1.7; }
.editor-content blockquote { border-left: 3px solid var(--primary); padding: 0.3rem 0 0.3rem 1rem; margin: 0.6rem 0; color: var(--muted-foreground); font-style: italic; }
.editor-content pre { background: var(--muted); border-radius: 0.5rem; padding: 0.75rem 1rem; overflow-x: auto; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; margin: 0.6rem 0; }
.editor-content code { font-family: ui-monospace, "SF Mono", Menlo, monospace; background: var(--muted); padding: 0.1rem 0.35rem; border-radius: 0.3rem; font-size: 0.9em; }
.editor-content hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.editor-content a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.editor-content a:hover { opacity: .8; }
.editor-content img { max-width: 100%; border-radius: var(--radius-md); margin: 0.6rem 0; display: block; }
.editor-content ul.checklist { list-style: none; padding-left: 0.1rem; }
.editor-content ul.checklist li { display: flex; align-items: flex-start; gap: 8px; margin: 0.35rem 0; line-height: 1.6; }
.editor-content ul.checklist input[type="checkbox"] { margin-top: 5px; width: 15px; height: 15px; flex-shrink: 0; accent-color: var(--primary); }
.editor-content[data-empty]:empty::before { content: attr(data-empty); color: var(--muted-foreground); pointer-events: none; position: absolute; }
.editor-content[contenteditable="false"] { cursor: default; }

.status-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; border-top: 1px solid var(--border); padding: 8px 16px; font-size: 11px; color: var(--muted-foreground); }
.save-dot { display: inline-block; width: 6px; height: 6px; border-radius: 999px; background: var(--primary); margin-right: 5px; vertical-align: middle; }

.empty-state { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; padding: 0 24px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: var(--radius-2xl); background: linear-gradient(135deg, var(--primary), var(--accent)); color: var(--primary-foreground); box-shadow: 0 10px 30px color-mix(in oklch, var(--primary) 35%, transparent), inset 0 1px 0 oklch(1 0 0 / 0.35); }
.empty-title { margin-top: 24px; font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -0.02em; }
.empty-sub { margin-top: 8px; max-width: 460px; font-size: 13px; color: var(--muted-foreground); }
.btn-primary { position: relative; overflow: hidden; margin-top: 24px; border-radius: 999px; background: var(--primary); padding: 8px 20px; font-size: 13px; font-weight: 500; color: var(--primary-foreground); box-shadow: 0 6px 20px color-mix(in oklch, var(--primary) 35%, transparent); transition: opacity .15s, transform .15s; }
.btn-primary:hover { opacity: .92; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

/* Overlays */
.overlay { position: fixed; inset: 0; z-index: 50; background: color-mix(in oklch, var(--background) 60%, transparent); backdrop-filter: blur(4px); }
.overlay-top { display: flex; align-items: flex-start; justify-content: center; padding: 16px; padding-top: 15vh; }
.overlay-end { z-index: 40; display: flex; justify-content: flex-end; }

.cmd-palette { width: 100%; max-width: 480px; overflow: hidden; border-radius: var(--radius-2xl); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.cmd-head { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); padding: 12px 16px; }
.cmd-input { width: 100%; background: transparent; border: none; outline: none; font-size: 14px; }
.cmd-input::placeholder { color: var(--muted-foreground); }
.kbd { border-radius: 4px; border: 1px solid var(--border); padding: 2px 6px; font-size: 10px; color: var(--muted-foreground); }
.cmd-body { max-height: 50vh; overflow-y: auto; padding: 6px; }
.cmd-section-label { padding: 4px 8px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-foreground); }
.cmd-row { display: flex; width: 100%; align-items: center; border-radius: var(--radius-md); padding: 6px 8px; text-align: left; font-size: 13px; gap: 8px; }
.cmd-row:hover { background: var(--secondary); }
.cmd-empty { padding: 24px; text-align: center; font-size: 13px; color: var(--muted-foreground); }

.history-panel { display: flex; height: 100%; width: 100%; max-width: 420px; flex-direction: column; border-left: 1px solid var(--border); box-shadow: -20px 0 60px rgba(0,0,0,.2); }
.history-head { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); padding: 12px 16px; }
.history-title { font-weight: 500; }
.history-body { flex: 1; overflow-y: auto; padding: 8px; }
.history-empty { padding: 24px; text-align: center; font-size: 13px; color: var(--muted-foreground); }
.history-item { margin-bottom: 8px; border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 12px; }
.history-item-top { margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.history-restore { border-radius: var(--radius-md); background: var(--primary); padding: 2px 8px; font-size: 11px; font-weight: 500; color: var(--primary-foreground); }
.history-snippet { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 12px; color: var(--muted-foreground); }

/* Drag-and-drop file import overlay */
.drop-overlay {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: color-mix(in oklch, var(--background) 55%, transparent); backdrop-filter: blur(6px);
  pointer-events: none;
}
.drop-overlay-inner {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  border: 2px dashed color-mix(in oklch, var(--primary) 55%, transparent); border-radius: var(--radius-2xl);
  background: var(--surface-2); backdrop-filter: blur(20px); padding: 48px 64px;
  box-shadow: 0 24px 70px rgba(0,0,0,.25);
  animation: float-in 0.2s ease-out;
}
.drop-overlay-icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: var(--primary-foreground);
}
.drop-overlay-inner p { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.drop-overlay-inner span { font-size: 12px; color: var(--muted-foreground); }

/* Zen / focus modes */
.zen .sidebar, .zen .toolbar, .zen .status-bar { display: none !important; }
.focus-mode .editor-content > *:not(:focus-within):not(:hover) { opacity: 0.35; transition: opacity 0.2s; }

/* Responsive: on small screens, the notes list and the editor become two
   full-screen pages that slide in/out instead of sitting side by side. */
@media (max-width: 720px) {
  .app-root { position: relative; overflow: hidden; }

  .sidebar {
    position: fixed; inset: 0; z-index: 20; width: 100% !important;
    box-shadow: none; transform: translateX(0); transition: transform .3s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.mobile-hide { transform: translateX(-100%); }

  .resize-handle { display: none; }

  .main-panel {
    position: fixed; inset: 0; z-index: 15; width: 100%;
    transform: translateX(100%); transition: transform .3s cubic-bezier(.4,0,.2,1);
  }
  .main-panel.mobile-show { transform: translateX(0); z-index: 25; }

  .mobile-back-btn { display: grid; }

  /* Note actions rely on :hover which never fires on touch — always show them
     on mobile so pin/favorite/duplicate/delete stay reachable. */
  .note-actions { opacity: 1; }
  .note-card { padding: 12px 12px; }

  /* Keep the toolbar a single scrollable row (highest-priority tools first)
     instead of wrapping into several rows that push the editor down. */
  .toolbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 8px 10px; }
  .toolbar::-webkit-scrollbar { display: none; }
  .title-input { flex: 1 1 auto; min-width: 96px; font-size: 17px; margin-right: 8px; }
  .tool-group { padding-right: 4px; margin-right: 2px; }
  .tool-btn { width: 30px; height: 30px; }

  .theme-row::-webkit-scrollbar { display: none; }
  .sidebar-tabs { flex-wrap: nowrap; }

  .editor-inner { padding: 24px 18px; }
  .empty-title { font-size: 24px; }
  .empty-sub { font-size: 12px; }

  .status-bar { padding: 8px 12px; font-size: 10px; gap: 6px 10px; }

  .history-panel { max-width: 100%; }

  .drop-overlay-inner { padding: 32px 28px; margin: 0 20px; }
}

@media (max-width: 360px) {
  .brand-sub { display: none; }
}
