/* =========================================================
   拾页 · Leafnote
   A quiet, local-first notes app
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #e7e2d7;
  --sidebar: #f0ece3;
  --list: #f7f4ed;
  --paper: #fbf9f4;
  --paper-2: #fffdf8;
  --paper-3: #f3efe5;
  --ink: #25241e;
  --ink-2: #5f5c50;
  --ink-3: #938f80;
  --line: rgba(45, 43, 35, 0.10);
  --line-strong: rgba(45, 43, 35, 0.18);
  --accent: #326e52;
  --accent-2: #3e7d5f;
  --accent-ink: #24533d;
  --accent-soft: #e0ebe1;
  --accent-softer: #edf3ec;
  --accent-wash: rgba(50, 110, 82, 0.075);
  --danger: #ad493e;
  --danger-ink: #913429;
  --danger-soft: #f5e6e2;
  --gold: #b27d32;
  --gold-soft: #f3e8cf;
  --mark-bg: #f2dda2;
  --mark-ink: #3e3320;
  --switch-bg: #25241e;
  --switch-ink: #fbf9f4;
  --toast-bg: #25241e;
  --toast-ink: #f8f5ed;
  --toast-action: #b9dcc6;
  --code-bg: #24251f;
  --code-ink: #ece8dc;
  --shadow-sm: 0 1px 2px rgba(46, 42, 31, 0.04), 0 4px 12px rgba(46, 42, 31, 0.035);
  --shadow-md: 0 20px 55px -22px rgba(46, 42, 31, 0.30);
  --shadow-menu: 0 16px 44px -14px rgba(40, 37, 27, 0.32), 0 2px 8px rgba(40, 37, 27, 0.06);
  --radius-sm: 8px;
  --radius: 13px;
  --radius-lg: 18px;
  --font-ui: "Aptos", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", "STSong", "Noto Serif SC", "SimSun", Georgia, serif;
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.22, 0.72, 0.22, 1);
  --sidebar-w: 250px;
  --list-w: 352px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10110e;
  --sidebar: #161713;
  --list: #1a1b17;
  --paper: #1f201b;
  --paper-2: #24251f;
  --paper-3: #1b1c17;
  --ink: #eae6da;
  --ink-2: #b6b2a4;
  --ink-3: #7d7a6d;
  --line: rgba(235, 231, 219, 0.09);
  --line-strong: rgba(235, 231, 219, 0.17);
  --accent: #8fc3a4;
  --accent-2: #a7d3b8;
  --accent-ink: #bde1ca;
  --accent-soft: #29392e;
  --accent-softer: #222e26;
  --accent-wash: rgba(143, 195, 164, 0.075);
  --danger: #e08b80;
  --danger-ink: #eea298;
  --danger-soft: #352522;
  --gold: #d7ae70;
  --gold-soft: #3a3122;
  --mark-bg: #6e5426;
  --mark-ink: #fff1c8;
  --switch-bg: #eae6da;
  --switch-ink: #1c1d18;
  --toast-bg: #eae6da;
  --toast-ink: #1b1c17;
  --toast-action: #2d6347;
  --code-bg: #13140f;
  --code-ink: #dedacd;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.18), 0 4px 14px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 24px 60px -24px rgba(0, 0, 0, 0.65);
  --shadow-menu: 0 18px 48px -12px rgba(0, 0, 0, 0.68), 0 2px 10px rgba(0, 0, 0, 0.2);
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--accent);
}

h1,
h2,
h3,
p {
  margin: 0;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--paper-3);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Shell ---------- */
.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: var(--bg);
}

.app-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 500;
  pointer-events: none;
  opacity: 0.022;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

html[data-theme="dark"] .app-shell::after {
  opacity: 0.045;
  mix-blend-mode: screen;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  min-height: 0;
  flex-direction: column;
  min-width: 0;
  padding: 22px 16px 16px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 13px;
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 0.22), transparent 42%),
    linear-gradient(145deg, #3c7a5c 0%, #295a44 58%, #1e4735 100%);
  color: #f5f1e7;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 8px 18px -8px rgba(31, 73, 54, 0.7);
}

.brand-mark svg {
  width: 33px;
  height: 33px;
  overflow: visible;
}

.brand-leaf-bg {
  fill: rgba(255, 255, 255, 0.11);
  stroke: none;
}

.brand-leaf-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.12em;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 7.5px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.26em;
  color: var(--ink-3);
}

.sidebar-close {
  display: none !important;
}

.new-note-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 46px;
  margin-top: 24px;
  padding: 0 10px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper-2);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 18px -10px rgba(34, 33, 26, 0.6);
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), background 180ms var(--ease);
}

html[data-theme="dark"] .new-note-btn {
  background: var(--ink);
  color: var(--sidebar);
}

.new-note-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px -10px rgba(34, 33, 26, 0.65);
}

.new-note-btn:active {
  transform: translateY(0);
}

.new-note-plus {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

html[data-theme="dark"] .new-note-plus {
  background: rgba(20, 20, 16, 0.1);
}

.new-note-plus .icon {
  width: 15px;
  height: 15px;
}

.new-note-btn kbd {
  margin-left: auto;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.48);
}

html[data-theme="dark"] .new-note-btn kbd {
  border-color: rgba(20, 20, 16, 0.14);
  background: rgba(20, 20, 16, 0.06);
  color: rgba(20, 20, 16, 0.5);
}

.primary-nav {
  flex: 1;
  min-height: 0;
  margin-top: 27px;
  margin-right: -7px;
  padding-right: 7px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.nav-heading {
  padding: 0 10px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.nav-item {
  display: grid;
  grid-template-columns: 19px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 40px;
  margin-top: 3px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--ink-2);
  text-align: left;
  font-size: 12.5px;
  letter-spacing: 0.01em;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}

.nav-item .icon {
  width: 17px;
  height: 17px;
  color: var(--ink-3);
  transition: color 160ms var(--ease);
}

.nav-item:hover {
  background: rgba(50, 110, 82, 0.06);
  color: var(--ink);
}

html[data-theme="dark"] .nav-item:hover {
  background: rgba(235, 231, 219, 0.055);
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

.nav-item.is-active .icon {
  color: var(--accent);
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(45, 43, 35, 0.055);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  text-align: center;
  line-height: 1.45;
}

html[data-theme="dark"] .nav-count {
  background: rgba(235, 231, 219, 0.065);
}

.nav-item.is-active .nav-count {
  background: rgba(50, 110, 82, 0.12);
  color: var(--accent-ink);
}

html[data-theme="dark"] .nav-item.is-active .nav-count {
  background: rgba(143, 195, 164, 0.12);
}

.tag-section {
  margin-top: 26px;
}

.nav-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 10px;
}

.tag-total {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-3);
}

.tag-nav {
  margin-top: 6px;
}

.tag-nav-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 33px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ink-2);
  text-align: left;
  font-size: 12px;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}

.tag-nav-item:hover {
  background: rgba(50, 110, 82, 0.06);
  color: var(--ink);
}

html[data-theme="dark"] .tag-nav-item:hover {
  background: rgba(235, 231, 219, 0.055);
}

.tag-nav-item.is-active {
  background: var(--accent-softer);
  color: var(--accent-ink);
  font-weight: 600;
}

.tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tag-color, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tag-color, var(--accent)) 13%, transparent);
}

.tag-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-count {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-3);
}

.tag-nav-empty {
  padding: 7px 10px;
  color: var(--ink-3);
  font-size: 11px;
  font-style: italic;
}

.sidebar-bottom {
  flex: 0 0 auto;
  margin-top: 16px;
}

.storage-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background:
    radial-gradient(120% 140% at 100% 0%, var(--accent-wash) 0%, transparent 62%),
    var(--paper-3);
}

.storage-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.storage-mark .icon {
  width: 15px;
  height: 15px;
}

.storage-card.is-offline {
  border-color: color-mix(in srgb, var(--gold) 24%, var(--line));
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--gold) 8%, transparent) 0%, transparent 62%),
    var(--paper-3);
}

.storage-card.is-offline .storage-mark {
  background: var(--gold-soft);
  color: var(--gold);
}

.storage-card div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.storage-card strong {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-2);
}

.storage-card span {
  overflow: hidden;
  color: var(--ink-3);
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.tool-link {
  display: flex;
  min-width: 0;
  height: 45px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 8px;
  color: var(--ink-3);
  font-size: 9.5px;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}

.tool-link .icon {
  width: 15px;
  height: 15px;
}

.tool-link:hover {
  background: var(--accent-softer);
  color: var(--accent-ink);
}

.sidebar-version {
  margin-top: 10px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-align: center;
  opacity: 0.72;
}

.sidebar-scrim {
  display: none;
}

/* ---------- List pane ---------- */
.list-pane {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--list);
  border-right: 1px solid var(--line);
}

.list-header {
  flex: 0 0 auto;
  padding: 25px 22px 13px;
}

.list-heading-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-btn {
  display: none !important;
}

.heading-copy {
  min-width: 0;
}

.eyebrow {
  overflow: hidden;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.22em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.list-heading-row h1 {
  margin-top: 3px;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count-badge {
  margin-left: auto;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.5;
  transition: color 180ms var(--ease), border-color 180ms var(--ease);
}

.tag-clear {
  display: inline-flex;
  height: 23px;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  padding: 0 6px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: 999px;
  background: var(--accent-softer);
  color: var(--accent-ink);
  font-size: 9.5px;
  white-space: nowrap;
  transition: background 150ms var(--ease), border-color 150ms var(--ease);
}

.tag-clear:hover {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  background: var(--accent-soft);
}

.tag-clear .icon {
  width: 10px;
  height: 10px;
}

.tag-clear:not([hidden]) + .count-badge {
  margin-left: 0;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 43px;
  margin-top: 18px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper-2);
  box-shadow: inset 0 1px 2px rgba(45, 43, 35, 0.025);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease), background 160ms var(--ease);
}

.search-field:focus-within {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line));
  box-shadow: 0 0 0 3px var(--accent-wash), inset 0 1px 2px rgba(45, 43, 35, 0.02);
}

.search-icon {
  width: 17px;
  height: 17px;
  color: var(--ink-3);
}

.search-field input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
}

.search-field input::placeholder {
  color: var(--ink-3);
  opacity: 0.72;
}

.search-field input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 6px;
  color: var(--ink-3);
  transition: background 140ms var(--ease), color 140ms var(--ease);
}

.search-clear:hover {
  background: var(--paper-3);
  color: var(--ink);
}

.search-clear .icon {
  width: 13px;
  height: 13px;
}

.search-kbd {
  height: 19px;
  padding: 0 5px;
  font-size: 8.5px;
  opacity: 0.72;
}

.list-subheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-top: 11px;
}

.scope-tabs {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 2px;
  border-radius: 8px;
  background: rgba(45, 43, 35, 0.045);
}

html[data-theme="dark"] .scope-tabs {
  background: rgba(235, 231, 219, 0.045);
}

.scope-tabs button {
  height: 25px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--ink-3);
  font-size: 10.5px;
  transition: background 150ms var(--ease), color 150ms var(--ease), box-shadow 150ms var(--ease);
}

.scope-tabs button:hover {
  color: var(--ink);
}

.scope-tabs button.is-active {
  background: var(--paper-2);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(45, 43, 35, 0.09);
}

html[data-theme="dark"] .scope-tabs button.is-active {
  background: var(--paper-2);
}

.subheader-right {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.sort-wrap {
  position: relative;
  flex: 0 0 auto;
}

.sort-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 29px;
  padding: 0 6px;
  border-radius: 7px;
  color: var(--ink-3);
  font-size: 10.5px;
  white-space: nowrap;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}

.sort-btn:hover,
.sort-btn[aria-expanded="true"] {
  background: var(--paper-3);
  color: var(--ink);
}

.sort-btn .icon {
  width: 13px;
  height: 13px;
}

.sort-btn .chevron {
  width: 11px;
  height: 11px;
  opacity: 0.72;
}

.text-btn {
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--accent-ink);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 150ms var(--ease);
}

.text-btn:hover {
  background: var(--accent-soft);
}

.danger-text {
  color: var(--danger);
}

.danger-text:hover {
  background: var(--danger-soft);
}

.search-summary {
  margin-top: 11px;
  padding: 8px 10px;
  border-left: 2px solid var(--accent);
  border-radius: 0 7px 7px 0;
  background: var(--accent-softer);
  color: var(--ink-3);
  font-size: 10.5px;
  line-height: 1.55;
  animation: soft-in 220ms var(--ease);
}

.search-summary strong {
  color: var(--accent-ink);
  font-weight: 650;
}

.notes-list {
  flex: 1;
  min-height: 0;
  padding: 7px 14px 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.note-card {
  position: relative;
  margin-bottom: 8px;
  padding: 15px 15px 13px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: color-mix(in srgb, var(--paper-2) 54%, transparent);
  cursor: pointer;
  transition: background 170ms var(--ease), border-color 170ms var(--ease), transform 170ms var(--ease), box-shadow 170ms var(--ease);
}

.note-card::before {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: -1px;
  width: 2.5px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  opacity: 0;
  transform: scaleY(0.35);
  transition: opacity 180ms var(--ease), transform 220ms var(--ease);
}

.note-card:hover {
  border-color: var(--line);
  background: color-mix(in srgb, var(--paper-2) 78%, transparent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.note-card.is-active {
  border-color: var(--line);
  background: var(--paper-2);
  box-shadow: var(--shadow-sm);
}

.note-card.is-active::before {
  opacity: 1;
  transform: scaleY(1);
}

.note-card:focus-visible {
  outline-offset: -1px;
}

.note-card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.note-card-title {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.005em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-card.is-active .note-card-title {
  color: var(--ink);
}

.card-star {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  margin: -2px -3px 0 0;
  border-radius: 6px;
  color: var(--ink-3);
  opacity: 0;
  transition: opacity 150ms var(--ease), color 150ms var(--ease), background 150ms var(--ease);
}

.card-star .icon {
  width: 14px;
  height: 14px;
}

.note-card:hover .card-star,
.note-card.is-active .card-star,
.card-star.is-favorite {
  opacity: 1;
}

.card-star:hover {
  background: var(--gold-soft);
  color: var(--gold);
}

.card-star.is-favorite {
  color: var(--gold);
}

.card-star.is-favorite .icon {
  fill: currentColor;
  fill-opacity: 0.92;
}

.note-card-excerpt {
  display: -webkit-box;
  margin-top: 5px;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 11.5px;
  line-height: 1.62;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.note-card-excerpt.is-empty {
  color: var(--ink-3);
  font-style: italic;
}

.match-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.match-badges span {
  padding: 2px 6px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 4px;
  background: var(--accent-softer);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 8.5px;
  line-height: 1.45;
}

.note-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.card-tags {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}

.tag-chip {
  --tag-color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-height: 19px;
  padding: 1px 6px;
  border: 1px solid color-mix(in srgb, var(--tag-color) 20%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--tag-color) 10%, transparent);
  color: color-mix(in srgb, var(--tag-color) 82%, var(--ink));
  font-size: 9.5px;
  line-height: 1.4;
  white-space: nowrap;
}

html[data-theme="dark"] .tag-chip {
  color: color-mix(in srgb, var(--tag-color) 58%, var(--ink));
  border-color: color-mix(in srgb, var(--tag-color) 22%, transparent);
  background: color-mix(in srgb, var(--tag-color) 9%, transparent);
}

.tag-chip .tag-dot {
  width: 4px;
  height: 4px;
  box-shadow: none;
}

.tag-chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-hash {
  margin-right: -2px;
  opacity: 0.52;
}

.card-more-tag {
  color: var(--ink-3);
  font-size: 9px;
}

.card-time {
  flex: 0 0 auto;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.015em;
  white-space: nowrap;
}

.card-trash-actions {
  display: flex;
  gap: 5px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
}

.card-trash-actions button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 25px;
  padding: 0 7px;
  border-radius: 6px;
  color: var(--ink-3);
  font-size: 9.5px;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}

.card-trash-actions button .icon {
  width: 12px;
  height: 12px;
}

.card-trash-actions button:hover {
  background: var(--accent-softer);
  color: var(--accent-ink);
}

.card-trash-actions button.danger-text:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* tag color tones */
.tone-0 { --tag-color: #5e8b72; }
.tone-1 { --tag-color: #a2764e; }
.tone-2 { --tag-color: #6f7f9d; }
.tone-3 { --tag-color: #a06466; }
.tone-4 { --tag-color: #87795a; }
.tone-5 { --tag-color: #58868d; }
.tone-6 { --tag-color: #9270a0; }
.tone-7 { --tag-color: #7c8b4f; }

html[data-theme="dark"] .tone-0 { --tag-color: #8fbf9f; }
html[data-theme="dark"] .tone-1 { --tag-color: #d1a676; }
html[data-theme="dark"] .tone-2 { --tag-color: #9eafca; }
html[data-theme="dark"] .tone-3 { --tag-color: #cf9294; }
html[data-theme="dark"] .tone-4 { --tag-color: #b7a77f; }
html[data-theme="dark"] .tone-5 { --tag-color: #86b4bb; }
html[data-theme="dark"] .tone-6 { --tag-color: #b99ac5; }
html[data-theme="dark"] .tone-7 { --tag-color: #a7b57a; }

/* ---------- List empty ---------- */
.list-empty {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 26px 70px;
  text-align: center;
  animation: soft-in 260ms var(--ease);
}

.empty-orbit {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper-2);
  box-shadow: var(--shadow-sm);
}

.empty-orbit svg {
  width: 55px;
  height: 55px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.72;
}

.list-empty h2 {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.list-empty p {
  max-width: 220px;
  margin-top: 6px;
  color: var(--ink-3);
  font-size: 11.5px;
  line-height: 1.65;
}

.small-primary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  margin-top: 17px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper-2);
  font-size: 11px;
  font-weight: 600;
  transition: transform 160ms var(--ease), opacity 160ms var(--ease);
}

html[data-theme="dark"] .small-primary {
  color: var(--sidebar);
}

.small-primary:hover {
  transform: translateY(-1px);
}

.small-primary .icon {
  width: 14px;
  height: 14px;
}

/* ---------- Editor pane ---------- */
.editor-pane {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(950px 420px at 88% -12%, var(--accent-wash) 0%, transparent 62%),
    radial-gradient(600px 360px at -8% 104%, rgba(178, 125, 50, 0.045) 0%, transparent 65%),
    var(--paper);
}

.editor-shell {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
}

.editor-bar {
  position: relative;
  z-index: 12;
  display: flex;
  height: 58px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  backdrop-filter: blur(14px);
}

.editor-bar-left,
.editor-bar-right {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.bar-divider {
  width: 1px;
  height: 17px;
  margin: 0 3px;
  background: var(--line);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--ink-3);
  transition: background 150ms var(--ease), color 150ms var(--ease);
}

.icon-btn:hover {
  background: var(--paper-3);
  color: var(--ink);
}

.icon-btn .icon {
  width: 17px;
  height: 17px;
}

.icon-btn.compact {
  width: 27px;
  height: 27px;
  border-radius: 6px;
}

.icon-btn.compact .icon {
  width: 14px;
  height: 14px;
}

.back-btn {
  display: none;
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.015em;
  white-space: nowrap;
}

.save-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
  transition: background 160ms var(--ease), box-shadow 160ms var(--ease);
}

.save-status.is-saving .save-dot {
  background: var(--gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 13%, transparent);
  animation: save-pulse 1.1s ease-in-out infinite;
}

.save-status.is-error {
  color: var(--danger);
}

.save-status.is-error .save-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 12%, transparent);
}

.find-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 31px;
  padding: 0 8px;
  border-radius: 7px;
  color: var(--ink-3);
  font-size: 10.5px;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}

.find-btn:hover,
.find-btn[aria-expanded="true"] {
  background: var(--paper-3);
  color: var(--ink);
}

.find-btn .icon {
  width: 15px;
  height: 15px;
}

.fav-btn.is-favorite {
  color: var(--gold);
}

.fav-btn.is-favorite .icon {
  fill: currentColor;
  fill-opacity: 0.92;
}

.fav-btn.is-favorite:hover {
  background: var(--gold-soft);
}

.fav-btn:disabled {
  opacity: 0.38;
}

/* find bar */
.find-bar {
  position: relative;
  z-index: 11;
  display: flex;
  height: 43px;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--accent-softer);
  animation: find-in 180ms var(--ease);
}

.find-icon {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

.find-bar input {
  min-width: 0;
  flex: 1;
  height: 28px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11.5px;
}

.find-bar input::placeholder {
  color: var(--ink-3);
}

.find-count {
  min-width: 42px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 9px;
  text-align: right;
  white-space: nowrap;
}

.find-divider {
  width: 1px;
  height: 14px;
  background: var(--line);
}

/* trash banner */
.trash-banner {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 22px 0;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 16%, transparent);
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger-ink);
  font-size: 10.5px;
  animation: soft-in 180ms var(--ease);
}

.trash-copy,
.trash-banner-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.trash-copy .icon {
  width: 14px;
  height: 14px;
}

.trash-banner-actions .text-btn {
  color: var(--accent-ink);
}

.trash-banner-actions .danger-text {
  color: var(--danger);
}

/* editor scroll & inner */
.editor-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.editor-scroll:focus {
  outline: none;
}

.editor-inner {
  width: 100%;
  max-width: 812px;
  min-height: 100%;
  margin: 0 auto;
  padding: 42px 42px 34px;
  animation: page-in 280ms var(--ease);
}

.note-kicker {
  display: flex;
  min-height: 24px;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.note-tags .tag-chip {
  min-height: 22px;
  padding: 2px 7px;
  font-size: 10px;
}

.tag-chip .tag-remove {
  display: grid;
  place-items: center;
  width: 13px;
  height: 13px;
  margin-right: -2px;
  border-radius: 3px;
  color: inherit;
  opacity: 0.58;
  transition: background 140ms var(--ease), opacity 140ms var(--ease);
}

.tag-chip .tag-remove .icon {
  width: 9px;
  height: 9px;
}

.tag-chip .tag-remove:hover {
  background: color-mix(in srgb, var(--tag-color) 18%, transparent);
  opacity: 1;
}

.tag-add {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  padding: 0 6px;
  border-radius: 5px;
  color: var(--ink-3);
  font-size: 9.5px;
  opacity: 0.78;
  transition: background 150ms var(--ease), color 150ms var(--ease), opacity 150ms var(--ease);
}

.tag-add .icon {
  width: 11px;
  height: 11px;
}

.tag-add:hover {
  background: var(--accent-softer);
  color: var(--accent-ink);
  opacity: 1;
}

.tag-editor {
  display: flex;
  align-items: center;
}

.tag-editor input {
  width: 138px;
  height: 23px;
  padding: 0 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line));
  border-radius: 5px;
  outline: none;
  background: var(--paper-2);
  color: var(--ink);
  font-size: 10px;
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.tag-editor input::placeholder {
  color: var(--ink-3);
}

.note-title {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: clamp(32px, 3.35vw, 42px);
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.018em;
  caret-color: var(--accent);
}

.note-title::placeholder {
  color: var(--ink-3);
  opacity: 0.58;
}

.note-title:read-only {
  color: var(--ink-2);
  cursor: default;
}

.note-title.is-find-hit {
  background: transparent;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--gold) 72%, transparent);
  text-decoration-thickness: 2px;
  text-underline-offset: 8px;
}

.note-subline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.035em;
}

.dot-sep {
  opacity: 0.55;
}

.toolbar-row {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 25px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
}

.format-toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
  box-shadow: var(--shadow-sm);
}

.format-toolbar button {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 5px;
  color: var(--ink-3);
  transition: background 140ms var(--ease), color 140ms var(--ease);
}

.format-toolbar button:hover {
  background: var(--accent-softer);
  color: var(--accent-ink);
}

.format-toolbar button:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.format-toolbar button:active {
  transform: translateY(1px);
}

.format-toolbar .icon {
  width: 14px;
  height: 14px;
}

.fmt-text {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
}

.fmt-bold {
  font-weight: 800;
}

.fmt-italic {
  font-style: italic;
}

.fmt-strike {
  text-decoration: line-through;
}

.tool-divider {
  width: 1px;
  height: 15px;
  margin: 0 3px;
  background: var(--line);
}

.preview-hint {
  display: inline-flex;
  align-items: center;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mode-switch {
  display: flex;
  flex: 0 0 auto;
  gap: 1px;
  margin-left: auto;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
}

.mode-switch button {
  display: inline-flex;
  height: 27px;
  align-items: center;
  gap: 4px;
  padding: 0 7px;
  border-radius: 5px;
  color: var(--ink-3);
  font-size: 10px;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}

.mode-switch button .icon {
  width: 12px;
  height: 12px;
}

.mode-switch button.is-active {
  background: var(--switch-bg);
  color: var(--switch-ink);
}

.mode-switch button:not(.is-active):hover {
  color: var(--ink);
}

.editor-shell.is-preview .format-toolbar {
  display: none;
}

.editor-shell.is-trash .format-toolbar {
  opacity: 0.42;
  pointer-events: none;
}

.editor-body {
  margin-top: 20px;
}

.note-content {
  display: block;
  width: 100%;
  min-height: 390px;
  padding: 0;
  border: 0;
  outline: 0;
  overflow: hidden;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15.5px;
  font-weight: 400;
  line-height: 1.92;
  letter-spacing: 0.008em;
  caret-color: var(--accent);
  resize: none;
  tab-size: 2;
}

.note-content::placeholder {
  color: var(--ink-3);
  opacity: 0.66;
}

.note-content:read-only {
  color: var(--ink-2);
}

.editor-shell.is-trash .note-title,
.editor-shell.is-trash .tag-add,
.editor-shell.is-trash .tag-remove {
  opacity: 0.72;
}

.editor-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 46px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.035em;
}

.footer-line {
  height: 1px;
  flex: 1;
  background: var(--line);
}

.autosave-note {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.autosave-note .icon {
  width: 10px;
  height: 10px;
  color: var(--accent);
}

/* ---------- Markdown preview ---------- */
.markdown-body {
  min-height: 390px;
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.92;
  letter-spacing: 0.008em;
  overflow-wrap: break-word;
}

.markdown-body > :first-child {
  margin-top: 0 !important;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.45em 0 0.55em;
  color: var(--ink);
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.008em;
}

.markdown-body h1 {
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--line);
  font-size: 26px;
}

.markdown-body h2 {
  font-size: 21px;
}

.markdown-body h3 {
  font-size: 18px;
}

.markdown-body h4 {
  font-size: 16px;
}

.markdown-body p {
  margin: 0 0 1.08em;
}

.markdown-body strong {
  font-weight: 650;
  color: var(--ink);
}

.markdown-body em {
  font-style: italic;
}

.markdown-body del {
  color: var(--ink-3);
}

.markdown-body a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 38%, transparent);
  text-underline-offset: 3px;
  transition: color 150ms var(--ease), text-decoration-color 150ms var(--ease);
}

.markdown-body a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 1.08em;
  padding-left: 1.45em;
}

.markdown-body li {
  margin: 0.28em 0;
  padding-left: 0.12em;
}

.markdown-body li::marker {
  color: var(--ink-3);
}

.markdown-body blockquote {
  margin: 1.15em 0;
  padding: 0.15em 0 0.15em 16px;
  border-left: 2px solid var(--accent);
  color: var(--ink-2);
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.markdown-body code {
  padding: 0.12em 0.36em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--accent-softer);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 0.84em;
}

.markdown-body pre {
  margin: 1.2em 0;
  padding: 15px 17px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: var(--code-bg);
  color: var(--code-ink);
  box-shadow: var(--shadow-sm);
}

.markdown-body pre code {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 12.5px;
  line-height: 1.72;
}

.markdown-body hr {
  height: 1px;
  margin: 2em 0;
  border: 0;
  background: var(--line);
}

.markdown-body .task-list {
  padding-left: 0;
  list-style: none;
}

.markdown-body .task-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding-left: 0;
}

.task-check {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 0.43em;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--paper-2);
  color: transparent;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.task-check.is-checked {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper-2);
}

.task-check.is-checked::after {
  content: "✓";
}

.markdown-body mark {
  padding: 0.06em 0.1em;
  border-radius: 2px;
  background: var(--mark-bg);
  color: var(--mark-ink);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--mark-bg) 40%, transparent);
}

.markdown-body mark.is-current {
  background: var(--accent);
  color: var(--paper-2);
  box-shadow: 0 0 0 1px var(--accent);
}

.preview-empty {
  display: flex;
  min-height: 280px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--ink-3);
  font-size: 12px;
  text-align: center;
}

.preview-empty .icon {
  width: 22px;
  height: 22px;
  opacity: 0.65;
}

.page-mark {
  background: var(--mark-bg);
  color: var(--mark-ink);
  border-radius: 2px;
  padding: 0.02em 0.08em;
}

/* search marks in cards */
.note-card mark {
  padding: 0 0.08em;
  border-radius: 2px;
  background: var(--mark-bg);
  color: var(--mark-ink);
}

/* ---------- Editor empty state ---------- */
.editor-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  text-align: center;
  overflow: hidden;
}

.editor-empty::before {
  content: "";
  position: absolute;
  top: 7%;
  left: 50%;
  width: min(560px, 78%);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 50%;
  opacity: 0.4;
  transform: translateX(-50%);
  pointer-events: none;
}

.editor-empty::after {
  content: "";
  position: absolute;
  top: calc(7% + 40px);
  left: 50%;
  width: min(440px, 62%);
  aspect-ratio: 1;
  border: 1px dashed var(--line);
  border-radius: 50%;
  opacity: 0.35;
  transform: translateX(-50%);
  pointer-events: none;
}

.empty-art {
  position: relative;
  width: 268px;
  max-width: 76%;
  margin-bottom: 12px;
  z-index: 1;
}

.empty-art svg {
  position: relative;
  display: block;
  width: 100%;
  overflow: visible;
  filter: drop-shadow(0 18px 22px rgba(52, 45, 30, 0.09));
}

html[data-theme="dark"] .empty-art svg {
  filter: drop-shadow(0 18px 25px rgba(0, 0, 0, 0.35));
}

.empty-art-halo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 240px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(ellipse, var(--accent-wash) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  filter: blur(5px);
}

.art-paper {
  fill: var(--paper-2);
  stroke: var(--line-strong);
  stroke-width: 1.1;
}

.art-paper-back {
  fill: var(--paper-3);
  opacity: 0.8;
}

.art-fold {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.1;
}

.art-line {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.2;
  stroke-linecap: round;
  opacity: 0.48;
}

.art-leaf {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 1.15;
}

.art-stem {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.art-dot {
  fill: var(--gold);
  opacity: 0.6;
}

.art-spark {
  fill: none;
  stroke: var(--gold);
  stroke-width: 1;
  opacity: 0.65;
}

.editor-empty .eyebrow {
  position: relative;
  z-index: 1;
  margin-top: 9px;
}

.editor-empty h2 {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.025em;
}

.empty-lede {
  position: relative;
  z-index: 1;
  max-width: 430px;
  margin-top: 13px;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.8;
}

.empty-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.primary-btn,
.ghost-btn {
  display: inline-flex;
  height: 38px;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 600;
  transition: transform 180ms var(--ease), background 180ms var(--ease), border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}

.primary-btn {
  background: var(--ink);
  color: var(--paper-2);
  box-shadow: 0 8px 18px -11px rgba(40, 37, 27, 0.55);
}

html[data-theme="dark"] .primary-btn {
  color: var(--sidebar);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px -11px rgba(40, 37, 27, 0.6);
}

.ghost-btn {
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink-2);
}

.ghost-btn:hover {
  border-color: var(--line-strong);
  background: var(--paper-3);
  color: var(--ink);
  transform: translateY(-1px);
}

.primary-btn .icon,
.ghost-btn .icon {
  width: 14px;
  height: 14px;
}

.shortcut-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(420px, 100%);
  margin-top: 40px;
}

.shortcut-grid div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 11px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: color-mix(in srgb, var(--paper-2) 55%, transparent);
  color: var(--ink-3);
  font-size: 9.5px;
}

.shortcut-grid kbd {
  height: 20px;
  padding: 0 6px;
  background: var(--paper);
}

/* ---------- Popovers ---------- */
.popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 90;
  min-width: 164px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-2);
  box-shadow: var(--shadow-menu);
  animation: pop-in 140ms var(--ease);
}

.popover button {
  display: flex;
  width: 100%;
  min-height: 31px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--ink-2);
  text-align: left;
  font-size: 11px;
  transition: background 130ms var(--ease), color 130ms var(--ease);
}

.popover button:hover {
  background: var(--accent-softer);
  color: var(--ink);
}

.popover button .icon {
  width: 14px;
  height: 14px;
  color: var(--ink-3);
}

.sort-menu button {
  justify-content: space-between;
}

.sort-menu .check-icon {
  width: 12px;
  height: 12px;
  color: var(--accent);
  opacity: 0;
}

.sort-menu button[aria-checked="true"] {
  color: var(--accent-ink);
  font-weight: 600;
}

.sort-menu button[aria-checked="true"] .check-icon {
  opacity: 1;
}

.more-menu {
  min-width: 188px;
}

.menu-divider {
  height: 1px;
  margin: 4px 3px;
  background: var(--line);
}

.popover .danger-item {
  color: var(--danger);
}

.popover .danger-item .icon {
  color: var(--danger);
}

.popover .danger-item:hover {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

/* ---------- Boot overlay ---------- */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(700px 420px at 50% 42%, var(--accent-wash) 0%, transparent 68%),
    var(--bg);
  opacity: 1;
  visibility: visible;
  transition: opacity 420ms var(--ease), visibility 420ms var(--ease);
}

.boot-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: boot-float 2.4s ease-in-out infinite;
}

.boot-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 17px;
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 0.22), transparent 42%),
    linear-gradient(145deg, #3c7a5c 0%, #295a44 58%, #1e4735 100%);
  color: #f5f1e7;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 16px 34px -18px rgba(31, 73, 54, 0.8);
}

.boot-mark svg {
  width: 45px;
  height: 45px;
  overflow: visible;
}

.boot-title {
  margin-top: 20px;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.boot-sub {
  margin-top: 7px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.16em;
}

.boot-sub::after {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  margin-left: 3px;
  border-radius: 50%;
  background: var(--accent);
  animation: boot-dot 1.3s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes boot-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes boot-dot {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

.noscript-note {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  text-align: center;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  z-index: 400;
  display: flex;
  max-width: min(460px, calc(100vw - 30px));
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  box-shadow: 0 18px 50px -15px rgba(20, 19, 14, 0.48);
  font-size: 11.5px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 200ms var(--ease), transform 240ms var(--ease);
}

.toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.toast > .icon {
  width: 14px;
  height: 14px;
  color: var(--toast-action);
}

.toast-message {
  min-width: 0;
}

.toast-action {
  flex: 0 0 auto;
  padding: 3px 6px;
  border-radius: 5px;
  color: var(--toast-action);
  font-size: 10.5px;
  font-weight: 650;
  white-space: nowrap;
  transition: background 140ms var(--ease);
}

.toast-action:hover {
  background: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .toast-action:hover {
  background: rgba(20, 20, 16, 0.07);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 17, 13, 0.42);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 180ms var(--ease);
}

.modal-backdrop.is-open {
  opacity: 1;
}

.modal-card {
  width: min(396px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-2);
  box-shadow: 0 30px 90px -20px rgba(17, 16, 12, 0.55);
  transform: translateY(8px) scale(0.975);
  transition: transform 200ms var(--ease);
}

.modal-backdrop.is-open .modal-card {
  transform: none;
}

.modal-kicker {
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.modal-card h3 {
  margin-top: 8px;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 600;
  line-height: 1.35;
}

.modal-card p {
  margin-top: 8px;
  color: var(--ink-2);
  font-size: 11.5px;
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 24px;
}

.modal-btn {
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  transition: background 150ms var(--ease), color 150ms var(--ease), border-color 150ms var(--ease);
}

.modal-btn:hover {
  border-color: var(--line-strong);
  background: var(--paper-3);
  color: var(--ink);
}

.modal-btn.is-danger {
  border-color: transparent;
  background: var(--danger);
  color: #fff8f5;
}

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

/* ---------- Scrollbars ---------- */
.primary-nav,
.notes-list,
.editor-scroll,
.markdown-body pre {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.primary-nav::-webkit-scrollbar,
.notes-list::-webkit-scrollbar,
.editor-scroll::-webkit-scrollbar,
.markdown-body pre::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.primary-nav::-webkit-scrollbar-track,
.notes-list::-webkit-scrollbar-track,
.editor-scroll::-webkit-scrollbar-track,
.markdown-body pre::-webkit-scrollbar-track {
  background: transparent;
}

.primary-nav::-webkit-scrollbar-thumb,
.notes-list::-webkit-scrollbar-thumb,
.editor-scroll::-webkit-scrollbar-thumb,
.markdown-body pre::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 8px;
  background: var(--line-strong);
  background-clip: padding-box;
}

/* ---------- Animations ---------- */
@keyframes card-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes soft-in {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes find-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-3px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes save-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  :root {
    --sidebar-w: 228px;
    --list-w: 330px;
  }

  .sidebar {
    padding-right: 13px;
    padding-left: 13px;
  }

  .list-header {
    padding-right: 19px;
    padding-left: 19px;
  }

  .editor-inner {
    padding-right: 32px;
    padding-left: 32px;
  }

  .note-title {
    font-size: clamp(30px, 3.1vw, 38px);
  }
}

@media (max-width: 1120px) {
  :root {
    --sidebar-w: 210px;
    --list-w: 316px;
  }

  .brand-name {
    font-size: 21px;
  }

  .brand-sub {
    letter-spacing: 0.2em;
  }

  .new-note-btn kbd {
    display: none;
  }

  .editor-inner {
    padding-right: 28px;
    padding-left: 28px;
  }

  .format-toolbar button {
    width: 25px;
    height: 26px;
  }

  .toolbar-row {
    gap: 7px;
  }
}

@media (max-width: 1024px) {
  :root {
    --list-w: 340px;
  }

  .app-shell {
    grid-template-columns: var(--list-w) minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 200;
    width: 272px;
    padding: 22px 16px 16px;
    border-right: 1px solid var(--line);
    box-shadow: 24px 0 60px -30px rgba(25, 23, 17, 0.35);
    transform: translateX(-104%);
    transition: transform 300ms var(--ease);
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-close {
    display: grid !important;
  }

  .menu-btn {
    display: grid !important;
    margin-left: -5px;
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 190;
    display: block;
    background: rgba(18, 17, 13, 0.32);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 260ms var(--ease);
  }

  .app-shell.sidebar-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .list-header {
    padding-top: 22px;
  }

  .note-title {
    font-size: clamp(32px, 4vw, 40px);
  }
}

@media (max-width: 760px) {
  :root {
    --list-w: 100%;
  }

  body {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    height: 100dvh;
  }

  .list-pane {
    height: 100dvh;
    border-right: 0;
  }

  .list-header {
    padding: 18px 17px 11px;
  }

  .list-heading-row h1 {
    font-size: 27px;
  }

  .eyebrow {
    font-size: 8px;
  }

  .search-field {
    margin-top: 15px;
  }

  .list-subheader {
    margin-top: 9px;
  }

  .search-kbd {
    display: none;
  }

  .notes-list {
    padding-right: 12px;
    padding-left: 12px;
  }

  .editor-pane {
    position: fixed;
    inset: 0;
    z-index: 300;
    height: 100dvh;
    visibility: hidden;
    transform: translateX(103%);
    transition: transform 320ms var(--ease), visibility 320ms;
  }

  .app-shell.mobile-editor-open .editor-pane {
    visibility: visible;
    transform: translateX(0);
  }

  .editor-bar {
    height: 55px;
    padding: 0 13px;
  }

  .back-btn {
    display: grid;
  }

  .editor-bar .bar-divider {
    display: none;
  }

  .find-btn {
    width: 32px;
    justify-content: center;
    padding: 0;
  }

  .find-btn span {
    display: none;
  }

  .editor-inner {
    padding: 29px 21px 24px;
  }

  .note-title {
    margin-top: 13px;
    font-size: 34px;
  }

  .toolbar-row {
    margin-top: 20px;
    padding: 9px 0;
    gap: 8px;
  }

  .format-toolbar {
    max-width: calc(100vw - 150px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .format-toolbar::-webkit-scrollbar {
    display: none;
  }

  .format-toolbar button {
    width: 25px;
    height: 25px;
    flex: 0 0 auto;
  }

  .tool-divider {
    flex: 0 0 auto;
  }

  .editor-body {
    margin-top: 17px;
  }

  .note-content,
  .markdown-body {
    min-height: 340px;
    font-size: 15px;
    line-height: 1.88;
  }

  .editor-footer {
    margin-top: 36px;
  }

  .find-bar {
    height: 44px;
    padding: 0 12px;
    gap: 6px;
  }

  .find-count {
    min-width: 37px;
  }

  .trash-banner {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    margin: 10px 13px 0;
  }

  .trash-banner-actions {
    align-self: flex-end;
  }

  .editor-empty {
    padding: 28px 20px;
  }

  .editor-empty::before,
  .editor-empty::after {
    display: none;
  }

  .empty-art {
    width: 215px;
    margin-bottom: 6px;
  }

  .editor-empty h2 {
    margin-top: 9px;
    font-size: clamp(30px, 8vw, 38px);
  }

  .empty-lede {
    max-width: 330px;
    font-size: 11.5px;
  }

  .empty-actions {
    margin-top: 19px;
  }

  .shortcut-grid {
    margin-top: 28px;
  }

  .toast {
    bottom: 18px;
  }

  .sidebar {
    width: min(288px, 86vw);
  }
}

@media (max-width: 420px) {
  .list-header {
    padding-right: 14px;
    padding-left: 14px;
  }

  .count-badge {
    display: none;
  }

  .scope-tabs button {
    padding: 0 7px;
  }

  .sort-btn {
    padding-right: 3px;
    padding-left: 3px;
  }

  .sort-btn .icon:first-child {
    display: none;
  }

  .editor-inner {
    padding-right: 17px;
    padding-left: 17px;
  }

  .note-title {
    font-size: 30px;
  }

  .format-toolbar {
    max-width: calc(100vw - 158px);
  }

  .mode-switch button {
    padding: 0 6px;
  }

  .mode-switch button .icon {
    width: 13px;
    height: 13px;
  }

  .find-divider {
    display: none;
  }

  .shortcut-grid {
    gap: 5px;
  }

  .shortcut-grid div {
    padding: 9px 4px;
    font-size: 8.5px;
  }

  .shortcut-grid kbd {
    padding: 0 4px;
    font-size: 8px;
  }

  .empty-art {
    width: 180px;
  }
}

@media (max-height: 720px) and (min-width: 761px) {
  .sidebar {
    padding-top: 16px;
  }

  .new-note-btn {
    margin-top: 16px;
  }

  .primary-nav {
    margin-top: 18px;
  }

  .storage-card {
    display: none;
  }

  .shortcut-grid {
    margin-top: 24px;
  }

  .empty-art {
    width: 210px;
  }
}

@media (max-height: 640px) {
  .empty-art {
    display: none;
  }

  .shortcut-grid {
    display: none;
  }

  .editor-empty h2 {
    margin-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .sidebar,
  .list-pane,
  .editor-bar,
  .find-bar,
  .toolbar-row,
  .editor-footer,
  .trash-banner,
  .toast {
    display: none !important;
  }

  .app-shell {
    display: block;
    height: auto;
    overflow: visible;
  }

  .editor-pane {
    position: static;
    display: block;
    height: auto;
    overflow: visible;
    background: #fff;
  }

  .editor-scroll {
    overflow: visible;
  }

  .editor-inner {
    max-width: none;
    padding: 0;
  }
}
