/* ============================================================
   Notes - Never Notes minimal notes app
   Plain vanilla CSS. No frameworks, no build step.
   ============================================================ */

:root {
  /* Paper + ink — clean white UI, gray ink in the editor */
  --paper:        #ffffff;
  --dot:          #e0e0e0;
  --ink:          #35383a;
  --ink-soft:     #66665e;
  --ink-faint:    #9e9d94;

  /* UI chrome (headers, menus, cards) — high-contrast sans */
  --ui-ink:       #1a1a1a;
  --ui-ink-soft:  #666666;
  --ui-ink-faint: #999999;
  --ui-sans:      "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Accent — warm yellow (NOTECRAFT-inspired) */
  --accent:       #F6C519;
  --accent-hover: #e2b714;
  --accent-btn-fg: #1a1a1a;
  --accent-btn-bg: var(--accent);
  --accent-btn-bg-hover: var(--accent-hover);
  --public-gate-dot: rgba(0, 0, 0, 0.07);
  --selection:    rgba(245, 197, 24, 0.28);
  --selection-fg: #1a1a1a;
  --diff-highlight: rgba(32, 168, 130, 0.34);
  --search-hit:   rgba(245, 197, 24, 0.38);
  --find-hit:     rgba(37, 99, 235, 0.12);
  --link:         #2563EB;   /* link bar accent */
  --shared-accent: #10B981;
  --shared-surface: rgba(16, 185, 129, 0.09);
  --shared-surface-strong: rgba(16, 185, 129, 0.16);
  --shared-ring:    rgba(16, 185, 129, 0.25);
  --public-accent: #2563EB;
  --public-surface: rgba(37, 99, 235, 0.09);
  --public-surface-strong: rgba(37, 99, 235, 0.16);
  --public-ring:    rgba(37, 99, 235, 0.25);

  /* List + code accents */
  --check-box:    #aeada4;
  --check-done:   var(--accent);
  --done-text:    #9e9d94;
  --comment:      #919187;   /* // and # header lines */
  /* Code syntax — Atom One Light–style tokens (matches reference theme). */
  --code-key:     #a626a4;   /* keywords: import, const, as, if, … */
  --code-fn:      #4078f2;   /* method / function calls: foo( */
  --code-str:     #50a14f;   /* strings */
  --code-num:     #c18401;   /* literals, types, params, globals */
  --code-com:     #a0a1a7;   /* comments */
  --code-sel:     #a34f00;   /* CSS .class / #id selectors */
  --code-prop:    #087e8b;   /* CSS properties, HTML attributes */
  --code-tag:     #c41d7f;   /* HTML / XML tag names */
  --code-hex:     #1a7f4b;   /* CSS hex colors */
  --code-at:      #8b27c7;   /* CSS @rules (@media, @keyframes) */

  /* Math variables — ordered for max contrast (slot 0 vs 1 are far apart on the wheel). */
  --math-var-0: #1a56c4;   /* cobalt */
  --math-var-1: #c44b16;   /* vermillion */
  --math-var-2: #0b7a6e;   /* jade */
  --math-var-3: #7b2cbf;   /* amethyst */
  --math-var-4: #b91c5c;   /* raspberry */
  --math-var-5: #2f6b1f;   /* moss */
  --math-var-6: #0e6e8c;   /* peacock */
  --math-var-7: #6b4c9a;   /* dusk violet */

  /* IBM Plex Mono (Google Fonts) with system mono fallbacks. */
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", "SFMono-Regular", "Menlo",
          "DejaVu Sans Mono", "Roboto Mono", "Consolas", monospace;

  /* Body weight is a touch bolder for readability; accent is bold. */
  --edit-weight: 500;
  --accent-weight: 700;

  /* Shared editor metrics — MUST be identical for textarea + backdrop
     so the caret lines up exactly with the rendered decorations. */
  --edit-font-size: 16px;
  /* UI chrome (headers, menus, icons) — one step above prior defaults. */
  --ui-font-2xs: 10px;
  --ui-font-xs:  11px;
  --ui-font-sm:  12px;
  --ui-font-md:  13px;
  --ui-font-lg:  14px;
  --ui-font-xl:  15px;
  --ui-font-2xl: 16px;
  --ui-font-3xl: 17px;
  --ui-font-stat: 23px;
  --ui-font-glyph: 19px;
  --ui-icon-sm: 17px;
  --ui-icon-md: 23px;
  --ui-icon-find: 15px;
  --edit-line-height: 1.6;
  --edit-line-box: calc(var(--edit-font-size) * var(--edit-line-height));
  --edit-pad-top: calc(48px - var(--edit-line-box));
  --edit-pad-bottom: calc(3 * var(--edit-line-box));
  --edit-pad-x: 28px;
  --edit-max-width: 760px;

  /* List mode: the checkbox and item gap scale with the editor font so the box,
     text, line-height, and spacing always stay in proportion. Calibrated at the
     14px reference size: 14px font -> 15px box, 12px gap. */
  --list-check-size: calc(var(--edit-font-size) * 15 / 14);
  --list-item-gap: calc(var(--edit-font-size) * 12 / 14);
  --list-item-indent: calc(var(--list-check-size) + var(--list-item-gap));
  /* Fixed checkbox-style mark for non-editor UI (e.g. theme menu radios), which
     must not scale with the editor font. */
  --ui-check-size: 15px;

  --panel-width: 300px;
  --top-bar-height: 52px;
  --subheader-height: 40px;
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --radius-xl:    20px;
  --radius-pill:  999px;
  --timer-bar-height: 22px;
  --timer-bar-offset: 0px;

  --motion-panel: 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  --motion-note: 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  --motion-fade: 0.26s ease;

  /* Semantic surfaces (theme-aware) */
  --border-subtle:  rgba(0, 0, 0, 0.065);
  --border:         rgba(0, 0, 0, 0.100);
  --border-strong:  rgba(0, 0, 0, 0.100);
  --border-hover:   rgba(0, 0, 0, 0.15);
  --surface-muted:  rgba(0, 0, 0, 0.035);
  --surface-hover:  rgba(0, 0, 0, 0.045);
  --surface-active: rgba(0, 0, 0, 0.055);
  --accent-surface: rgba(200, 153, 15, 0.13);
  --accent-surface-strong: rgba(200, 153, 15, 0.19);
  --accent-ring:    rgba(226, 183, 20, 0.21);
  --overlay:        rgba(0, 0, 0, 0.19);
  --overlay-light:  rgba(0, 0, 0, 0.13);
  --shadow-sm:      0 4px 16px rgba(0, 0, 0, 0.18);
  --shadow-md:      0 8px 28px rgba(0, 0, 0, 0.12);
  --shadow-lg:      0 16px 48px rgba(0, 0, 0, 0.14);
  --shadow-panel:   8px 0 32px rgba(0, 0, 0, 0.12);
  --shadow-up:      0 -8px 32px rgba(0, 0, 0, 0.1);
  --tooltip-bg:     rgba(60, 63, 65, 0.92);
  --tooltip-fg:     #fff;
  --popup-bg:       rgba(255, 255, 255, 0.96);
  --danger:         #b42318;
  --danger-hover:   #9f1f15;
  --danger-surface: rgba(180, 35, 24, 0.09);
  --danger-btn-fg:  #ffffff;
  --danger-btn-bg:  var(--danger);
  --danger-btn-bg-hover: var(--danger-hover);
  --on-primary:     #1a1a1a;
  --code-ink:       #282d38;
  --timer-done-scrim: rgba(0, 0, 0, 0.62);
  --timer-done-blur: 12px;
  --timer-done-fg:  #f8f7f4;
  --timer-done-fg-soft: rgba(248, 247, 244, 0.88);
  --timer-list-ink: #1a1a1a;
  --timer-done-btn-bg: #f8f7f4;
  --timer-done-btn-fg: #2a2c2e;
  --timer-done-btn-hover: #ffffff;
}

html[data-theme="dark"] {
  --paper:        #141416;
  --dot:          #252528;
  --ink:          #b8beca;
  --ink-soft:     #a9b1c0;
  --ink-faint:    #7a8290;
  --ui-ink:       #f0f0f0;
  --ui-ink-soft:  #a8a8a8;
  --ui-ink-faint: #777777;
  --accent:       #e2b714;
  --accent-hover: #f0c420;
  --accent-btn-fg: #1a1a1a;
  --accent-btn-bg: var(--accent);
  --accent-btn-bg-hover: var(--accent-hover);
  --public-gate-dot: rgba(255, 255, 255, 0.06);
  --selection:    rgba(226, 183, 20, 0.22);
  --selection-fg: #ffffff;
  --diff-highlight: rgba(72, 200, 165, 0.26);
  --search-hit:   rgba(245, 197, 24, 0.32);
  --find-hit:     rgba(37, 99, 235, 0.12);
  --link:         #2563EB;
  --shared-accent: #10B981;
  --shared-surface: rgba(16, 185, 129, 0.12);
  --shared-surface-strong: rgba(16, 185, 129, 0.22);
  --shared-ring:    rgba(16, 185, 129, 0.28);
  --public-accent: #2563EB;
  --public-surface: rgba(37, 99, 235, 0.12);
  --public-surface-strong: rgba(37, 99, 235, 0.22);
  --public-ring:    rgba(37, 99, 235, 0.28);
  --check-box:    #666d7a;
  --done-text:    #7a8290;
  --comment:      #888d97;
  --code-ink:     #abb2bf;
  --code-key:     #c678dd;
  --code-fn:      #61afef;
  --code-str:     #98c379;
  --code-num:     #d19a66;
  --code-com:     #5c6370;
  --code-sel:     #e5c07b;
  --code-prop:    #56b6c2;
  --code-tag:     #e06c75;
  --code-hex:     #98c379;
  --code-at:      #c678dd;
  --math-var-0:   #61afef;
  --math-var-1:   #e06c75;
  --math-var-2:   #56b6c2;
  --math-var-3:   #c678dd;
  --math-var-4:   #be5046;
  --math-var-5:   #98c379;
  --math-var-6:   #2bb0b8;
  --math-var-7:   #d19a66;
  --border-subtle:  rgba(255, 255, 255, 0.065);
  --border:         rgba(255, 255, 255, 0.085);
  --border-strong:  rgba(255, 255, 255, 0.105);
  --border-hover:   rgba(255, 255, 255, 0.15);
  --surface-muted:  rgba(255, 255, 255, 0.045);
  --surface-hover:  rgba(255, 255, 255, 0.065);
  --surface-active: rgba(255, 255, 255, 0.085);
  --accent-surface: rgba(226, 183, 20, 0.15);
  --accent-surface-strong: rgba(226, 183, 20, 0.23);
  --accent-ring:    rgba(226, 183, 20, 0.26);
  --overlay:        rgba(0, 0, 0, 0.45);
  --overlay-light:  rgba(0, 0, 0, 0.35);
  --shadow-sm:      0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-md:      0 8px 28px rgba(0, 0, 0, 0.5);
  --shadow-lg:      0 16px 48px rgba(0, 0, 0, 0.55);
  --shadow-panel:   8px 0 32px rgba(0, 0, 0, 0.5);
  --shadow-up:      0 -8px 32px rgba(0, 0, 0, 0.45);
  --tooltip-bg:     rgba(12, 14, 18, 0.97);
  --tooltip-fg:     #eceef1;
  --popup-bg:       rgba(20, 22, 26, 0.98);
  --timer-done-scrim: rgba(0, 0, 0, 0.78);
  --timer-done-blur: 14px;
  --timer-done-fg:  #f0f1f4;
  --timer-done-fg-soft: rgba(240, 241, 244, 0.9);
  --timer-list-ink: #e8e8e6;
  --timer-done-btn-bg: #eef0f3;
  --timer-done-btn-fg: #1a1c1f;
  --timer-done-btn-hover: #ffffff;
  --danger:         #e06c75;
  --danger-hover:   #be5046;
  --danger-surface: rgba(224, 108, 117, 0.13);
  --danger-btn-fg:  #ffffff;
  --danger-btn-bg:  var(--danger);
  --danger-btn-bg-hover: var(--danger-hover);
  --on-primary:     #1a1a1a;
}

* { box-sizing: border-box; }

/* Text selection: brand-yellow highlighter instead of the browser's default blue. */
::selection {
  background: var(--search-hit);
  color: var(--selection-fg);
}
::-moz-selection {
  background: var(--search-hit);
  color: var(--selection-fg);
}

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

/* Disable double-tap zoom on mobile (viewport blocks pinch zoom). */
html {
  touch-action: manipulation;
}

body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Brand mark (shared across app + auth) ---------- */
.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  min-width: 0;
  user-select: none;
}

a.app-brand-link {
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-sm, 6px);
}

a.app-brand-link:hover .app-brand-name,
a.app-brand-link:focus-visible .app-brand-name {
  color: var(--ui-ink-soft);
}

a.app-brand-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-logo {
  display: block;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  object-fit: cover;
}

.app-logo-lg {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.app-brand-name {
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ui-ink);
  line-height: 1;
  white-space: nowrap;
}

.app-brand-centered {
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.app-brand-centered .app-brand-name {
  font-size: var(--ui-font-xl);
  letter-spacing: 0.14em;
}

#app {
  display: flex;
  flex-direction: row;
  height: 100vh;
  height: 100dvh;
  position: relative;
}

.app-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Hide main chrome until first paint (avoids placeholder flash). */
#app.app-loading .app-body,
#dash-app.app-loading .dash-body {
  visibility: hidden;
}

.app-splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #fff;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.28s ease-out;
}

#app.app-ready .app-splash,
#dash-app.app-ready .app-splash {
  opacity: 0;
  pointer-events: none;
}

/* ---------- Notes sidebar ---------- */
.notes-panel {
  flex: 0 0 auto;
  width: var(--panel-width);
  background: var(--paper);
  border-right: 1px solid var(--border);
  z-index: 20;
}

.notes-panel-slide {
  display: flex;
  flex-direction: column;
  width: var(--panel-width);
  min-width: var(--panel-width);
  height: 100%;
  min-height: 0;
}

@media (min-width: 769px) {
  .notes-panel {
    overflow: hidden;
    transition: width var(--motion-panel);
  }

  .notes-panel-slide {
    transform: translateX(0);
    transition: transform var(--motion-panel);
  }

  #app.panel-closed .notes-panel,
  #dash-app.panel-closed .notes-panel {
    width: 0;
    border-right-width: 0;
    pointer-events: none;
  }

  #app.panel-closed .notes-panel-slide,
  #dash-app.panel-closed .notes-panel-slide {
    transform: translateX(-100%);
  }
}

.notes-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  height: var(--top-bar-height);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  font-family: var(--ui-sans);
}

.notes-panel-head .app-brand {
  flex: 1 1 auto;
  min-width: 0;
}

.notes-panel-head .notes-panel-title {
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ui-ink);
}

.notes-panel-head-spacer {
  flex: 1 1 auto;
}

.notes-panel-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ui-ink-soft);
  cursor: pointer;
  flex: 0 0 auto;
}
.notes-panel-icon-btn:hover,
.notes-panel-icon-btn:focus-visible {
  color: var(--ui-ink);
  background: var(--surface-hover);
  outline: none;
}

.notes-panel-search-wrap {
  flex: 0 0 auto;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border-subtle);
}
.notes-panel-search-wrap[hidden] {
  display: none;
}

.notes-panel-icon-btn[aria-expanded="true"],
.notes-panel-icon-btn.notes-search-active {
  color: var(--accent);
  background: var(--accent-surface);
}

.notes-panel-search {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='1.75' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
  color: var(--ui-ink);
  outline: none;
}
.notes-panel-search::placeholder {
  color: var(--ink-faint);
}
.notes-panel-search:hover {
  border-color: var(--border-hover);
}
.notes-panel-search:focus {
  border-color: var(--accent);
  background-color: var(--paper);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

.notes-panel-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex: 0 0 auto;
  box-sizing: border-box;
  height: var(--subheader-height);
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
}

.notes-panel-tabs[hidden] {
  display: none;
}

.notes-panel-tab {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0 16px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-sm);
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ui-ink-faint);
  cursor: pointer;
  transition:
    color 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.notes-panel-tab:hover {
  color: var(--ui-ink-soft);
  background: var(--surface-hover);
}

.notes-panel-tab[aria-selected="true"] {
  color: var(--ui-ink);
  border-bottom-color: var(--accent);
}

.notes-panel-tab[data-notes-tab="shared"][aria-selected="true"] {
  border-bottom-color: var(--shared-accent);
}

.notes-panel-tab[data-notes-tab="public"][aria-selected="true"] {
  border-bottom-color: var(--public-accent);
}

.notes-panel-tab:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: -2px;
}

.notes-search-results {
  margin: 0;
  padding: 8px 16px 4px;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-sm);
  font-weight: 400;
  color: var(--ui-ink-faint);
}

.notes-search-results[hidden] {
  display: none;
}

.notes-list {
  list-style: none;
  margin: 0;
  padding: 0 0 16px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.notes-row {
  border-bottom: 1px solid var(--border-subtle);
}

.notes-row:last-child {
  border-bottom: none;
}

.notes-row.active + .notes-row,
.notes-row + .notes-row.active {
  border-top-color: transparent;
}

/* Pinned rows: a 4px yellow accent on the left edge. Absolutely positioned so it
   never shifts the note text out of alignment with the unpinned rows below. */
.notes-row-pinned {
  position: relative;
}

.notes-row-pinned::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  background: var(--accent);
  pointer-events: none;
  z-index: 1;
}

/* ---------- Folders ---------- */
/* Scope bar: a compact, tappable indicator of the current folder that sits
   above the notes list. Tapping it opens the folder browser. */
.notes-scope-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font: inherit;
  font-family: var(--ui-sans);
  color: var(--ui-ink);
  text-align: left;
  cursor: pointer;
  transition: background var(--motion-fade);
}

.notes-scope-bar[hidden] {
  display: none;
}

.notes-scope-bar:hover {
  background: var(--surface-hover);
}

.notes-scope-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  color: var(--ui-ink-faint);
}

/* All Notes active: yellow stroke on the note icon, no fill. */
.notes-scope-bar:not(.is-scoped) .notes-scope-icon {
  color: var(--accent);
}

.notes-scope-bar:not(.is-scoped) .notes-scope-icon .notes-allnotes-glyph {
  fill: none;
  stroke: var(--accent);
}

/* Specific folder active: yellow on the folder icon wrapper. */
.notes-scope-bar.is-scoped .notes-scope-icon {
  color: var(--accent);
}

.notes-scope-icon svg {
  width: 18px;
  height: 18px;
}

.notes-scope-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--ui-font-md);
  font-weight: 600;
}

.notes-scope-count {
  flex: 0 0 auto;
  font-size: var(--ui-font-xs, 11px);
  font-variant-numeric: tabular-nums;
  color: var(--ui-ink-faint);
}

.notes-scope-caret {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  color: var(--ui-ink-faint);
}

.notes-scope-caret svg {
  width: 15px;
  height: 15px;
  transform: rotate(90deg);
}

/* Clear-scope X: shown on a specific folder; jumps straight back to All Notes. */
.notes-scope-clear {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: -4px -4px -4px 0;
  border-radius: 7px;
  color: var(--ui-ink-faint);
  cursor: pointer;
  transition: background var(--motion-fade), color var(--motion-fade);
}

.notes-scope-clear:hover {
  background: var(--surface-hover);
  color: var(--ui-ink);
}

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

.notes-scope-clear svg {
  width: 16px;
  height: 16px;
}

/* Folder browser: a drill-down list that replaces the notes list, so folders
   and notes are never crowded together and the hierarchy can grow freely. */
.notes-folder-browser {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 6px 8px 12px;
  font-family: var(--ui-sans);
}

.notes-folder-browser[hidden] {
  display: none;
}

.notes-fb-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0 6px;
  background: var(--paper);
}

.notes-fb-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--ui-ink-soft);
  cursor: pointer;
  transition: background var(--motion-fade), color var(--motion-fade);
}

.notes-fb-back:hover,
.notes-fb-back:focus-visible {
  color: var(--ui-ink);
  background: var(--surface-hover);
  outline: none;
}

.notes-fb-back-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.notes-fb-title {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--ui-font-md);
  font-weight: 700;
  color: var(--ui-ink);
}

.notes-fb-head-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ui-ink-soft);
  cursor: pointer;
  transition: background var(--motion-fade), color var(--motion-fade);
}

.notes-fb-head-add:hover,
.notes-fb-head-add:focus-visible {
  color: var(--ui-ink);
  background: var(--surface-hover);
  outline: none;
}

.notes-fb-crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1px;
  padding: 0 2px 6px;
  font-size: var(--ui-font-xs, 11px);
  color: var(--ui-ink-faint);
}

.notes-fb-crumb {
  max-width: 120px;
  padding: 2px 5px;
  border: none;
  background: transparent;
  border-radius: 5px;
  font: inherit;
  color: var(--ui-ink-faint);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-fb-crumb:hover {
  background: var(--surface-hover);
  color: var(--ui-ink);
}

.notes-fb-crumb.is-current {
  color: var(--ui-ink);
  font-weight: 600;
}

.notes-fb-crumb-sep {
  display: inline-flex;
  align-items: center;
  opacity: 0.45;
}

.notes-fb-crumb-sep svg {
  width: 12px;
  height: 12px;
}

.notes-fb-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.notes-fb-row,
.notes-fb-allnotes {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 9px;
  transition: background var(--motion-fade);
}

.notes-fb-row:hover,
.notes-fb-allnotes:hover {
  background: var(--surface-hover);
}

.notes-fb-allnotes.active {
  background: var(--accent-surface);
}

.notes-fb-open,
.notes-fb-allnotes {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 44px;
  padding: 6px 8px;
  border: none;
  background: transparent;
  font: inherit;
  text-align: left;
  color: var(--ui-ink);
  cursor: pointer;
}

.notes-fb-allnotes {
  flex: 0 0 auto;
  width: 100%;
  margin-bottom: 4px;
}

.notes-fb-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  color: var(--ui-ink-faint);
}

.notes-fb-icon svg {
  width: 20px;
  height: 20px;
}

/* All Notes active in the folder browser: yellow stroke, no fill. */
.notes-fb-allnotes.active .notes-fb-icon {
  color: var(--accent);
}

.notes-fb-allnotes.active .notes-fb-icon .notes-allnotes-glyph {
  fill: none;
  stroke: var(--accent);
}

/* Active folder: fill the folder glyph solid yellow. */
.notes-scope-bar.is-scoped .notes-scope-icon .notes-folder-glyph,
.notes-fb-allnotes.active .notes-fb-icon .notes-folder-glyph,
.notes-fb-row.active .notes-fb-icon .notes-folder-glyph {
  fill: var(--accent);
  stroke: var(--accent);
  color: var(--accent);
}

.notes-fb-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--ui-font-md);
}

.notes-fb-count {
  flex: 0 0 auto;
  font-size: var(--ui-font-xs, 11px);
  font-variant-numeric: tabular-nums;
  color: var(--ui-ink-faint);
  padding: 0 2px;
}

.notes-fb-menu {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  /* Right-align the dots so they sit ~10px from the row edge, matching the
     All Notes count above them, instead of floating mid-padding. */
  justify-content: flex-end;
  width: auto;
  height: 40px;
  padding: 0 10px 0 4px;
  border: none;
  background: transparent;
  color: var(--ui-ink-faint);
  cursor: pointer;
  transition: color var(--motion-fade);
}

.notes-fb-menu svg {
  width: 16px;
  height: 16px;
  /* Vertical dots, matching the three-dot menus elsewhere in the app. */
  transform: rotate(90deg);
}

.notes-fb-menu:hover {
  color: var(--ui-ink);
}

.notes-fb-drill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-right: 2px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ui-ink-faint);
  border-radius: 7px;
  cursor: pointer;
  transition: background var(--motion-fade), color var(--motion-fade);
}

.notes-fb-drill svg {
  width: 18px;
  height: 18px;
}

.notes-fb-drill:hover {
  background: var(--surface-hover);
  color: var(--ui-ink);
}

/* No subfolders: drop the chevron column entirely (and its flex gap) so the
   three-dot menu becomes the right-most element, flush near the edge. */
.notes-fb-drill.is-leaf {
  display: none;
}

.notes-fb-empty {
  margin: 16px 8px;
  font-size: var(--ui-font-sm);
  color: var(--ui-ink-faint);
  text-align: center;
}

.notes-fb-add {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 11px 10px;
  border: 1px dashed var(--border);
  background: transparent;
  border-radius: 9px;
  font: inherit;
  font-size: var(--ui-font-sm);
  color: var(--ui-ink-faint);
  cursor: pointer;
  transition: background var(--motion-fade), color var(--motion-fade), border-color var(--motion-fade);
}

.notes-fb-add:hover {
  background: var(--surface-hover);
  color: var(--ui-ink);
  border-color: var(--ui-ink-faint);
}

.notes-fb-add-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 17px;
  line-height: 1;
}

.notes-folder-menu {
  position: fixed;
  z-index: 60;
}

/* Folder membership picker */
.folder-picker-list {
  max-height: 320px;
  overflow-y: auto;
  margin: 4px 0 12px;
  text-align: left;
}

.folder-picker-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  padding-left: calc(6px + var(--folder-depth, 0) * 16px);
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
  color: var(--ui-ink);
}

.folder-picker-opt:hover {
  background: var(--surface-hover);
}

.folder-picker-opt input {
  flex: 0 0 auto;
  appearance: none;
  -webkit-appearance: none;
  width: var(--ui-check-size);
  height: var(--ui-check-size);
  margin: 0;
  border: 1.5px solid var(--check-box);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: border-color var(--motion-fade);
}

.folder-picker-opt input:checked {
  border-color: var(--accent);
}

.folder-picker-opt input:checked::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
}

.folder-picker-opt input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.folder-picker-opt-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-panel-account-footer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex: 0 0 auto;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  background: var(--paper);
  font-family: var(--ui-sans);
}

.notes-panel-account-footer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.notes-panel-account-footer-body {
  flex: 1 1 auto;
  min-width: 0;
}

.notes-panel-account-footer:has(#notes-panel-account-guest:not([hidden])) .notes-panel-login-btn {
  width: 100%;
}

.notes-panel-account-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.notes-panel-account-bar[hidden] {
  display: none;
}

.notes-panel-account-name {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  font-size: var(--ui-font-md);
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ui-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-panel-account-footer .settings-action-item {
  border-radius: 6px;
}

.notes-panel-account-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  align-self: center;
  margin-left: auto;
}

.notes-panel-account-actions > .notes-panel-icon-btn {
  flex: 0 0 auto;
}

.notes-panel-account-actions .notes-panel-icon-btn[hidden] {
  display: none;
}

#notes-panel-account-heading[hidden] {
  display: none;
}

a.notes-panel-icon-btn {
  text-decoration: none;
  box-sizing: border-box;
}

.notes-empty {
  padding: 20px 16px;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
  color: var(--ui-ink-faint);
  text-align: center;
  font-style: normal;
}

.notes-item {
  display: flex;
  align-items: flex-start;
  gap: 0;
  min-width: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  transition: background var(--motion-fade);
}

.notes-item:hover {
  background: var(--surface-hover);
}

.notes-item.active {
  background: var(--accent-surface);
}

.notes-item-select {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 14px 16px;
  border: none;
  border-radius: 0;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}

.notes-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.notes-item-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.notes-item-kind,
.notes-item-date {
  font-family: var(--ui-sans);
  font-size: var(--ui-font-sm);
  font-weight: 400;
  line-height: 1.2;
  color: var(--ui-ink-faint);
}

.notes-item-kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-item-kind.is-folder-assignable {
  cursor: pointer;
}

.notes-item-kind.is-filed .notes-item-kind-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.notes-item-kind.is-filed .notes-item-kind-icon .notes-folder-glyph {
  width: 14px;
  height: 14px;
  fill: var(--accent);
  stroke: var(--accent);
}

.notes-item-kind-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-item-date {
  margin-left: auto;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.notes-item-title {
  display: block;
  width: 100%;
  min-width: 0;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-lg);
  font-weight: 700;
  line-height: 1.25;
  color: var(--ui-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-item-title + .notes-item-preview {
  margin-top: -3px;
}

.notes-item-preview {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  min-width: 0;
}

.notes-item-preview-line {
  font-family: var(--ui-sans);
  font-size: var(--ui-font-sm);
  font-weight: 400;
  line-height: 1.35;
  color: var(--ui-ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-search-hit {
  background: var(--search-hit);
  border-radius: 2px;
  color: inherit;
}

.notes-section-head {
  display: none;
}

.notes-section-header {
  list-style: none;
  padding: 14px 16px 4px;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-xs, 11px);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ui-ink-faint);
}

.notes-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.notes-item-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 auto;
  min-width: 0;
}

.notes-item-icons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.notes-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ui-ink-faint);
}

.notes-item-icon svg {
  width: 13px;
  height: 13px;
}

#notes-list[data-notes-panel-tab="shared"] .notes-item-dot {
  background: var(--shared-accent);
}

.notes-item-icon-viewonly {
  color: var(--ui-ink-faint);
}

/* Status icons stay neutral on the Notes tab; accent colors only on Shared/Public. */
#notes-list[data-notes-panel-tab="personal"] .notes-item-icon-shared,
#notes-list[data-notes-panel-tab="personal"] .notes-item-icon-pin,
#notes-list[data-notes-panel-tab="personal"] .notes-item-icon-public {
  color: var(--ui-ink-faint);
}

#notes-list[data-notes-panel-tab="shared"] .notes-item-icon-shared {
  color: var(--shared-accent);
}

#notes-list[data-notes-panel-tab="shared"] .notes-item.active {
  background: var(--shared-surface);
}

#notes-list[data-notes-panel-tab="shared"] .notes-item.active:hover {
  background: var(--shared-surface-strong);
}

#notes-list[data-notes-panel-tab="public"] .notes-item-dot {
  background: var(--public-accent);
}

#notes-list[data-notes-panel-tab="public"] .notes-item-icon-public {
  color: var(--public-accent);
}

#notes-list[data-notes-panel-tab="public"] .notes-item.active {
  background: var(--public-surface);
}

#notes-list[data-notes-panel-tab="public"] .notes-item.active:hover {
  background: var(--public-surface-strong);
}

.notes-panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 15;
  background: var(--overlay);
}

.notes-panel-backdrop[hidden] { display: none; }

@media (max-width: 768px) {
  :root {
    --edit-pad-x: 16px;
    --timer-bar-height: 40px;
  }

  .timer-bar {
    padding: 0 12px;
    gap: 10px;
  }
  .timer-bar-title {
    font-size: var(--ui-font-sm);
    max-width: 34%;
  }
  .timer-bar-track {
    height: 4px;
  }
  .timer-bar-label {
    font-size: var(--ui-font-md);
    min-width: 3.6em;
  }
  .timer-done {
    padding: 28px 20px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  }
  .timer-done-ok {
    min-height: 44px;
    min-width: 128px;
    padding: 12px 32px;
    font-size: var(--ui-font-3xl);
  }

  .notes-panel-slide {
    width: 100%;
    min-width: 0;
  }

  .notes-panel {
    position: fixed;
    left: -90vw;
    top: 0;
    bottom: 0;
    width: 90vw;
    max-width: 90vw;
    box-shadow: var(--shadow-panel);
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    transition:
      left var(--motion-panel),
      visibility 0s linear var(--motion-panel);
  }

  #app.panel-open .notes-panel {
    left: 0;
    visibility: visible;
    pointer-events: auto;
    transition:
      left var(--motion-panel),
      visibility 0s;
  }

  /* Transform breaks overflow scrolling on iOS — keep scroll in the list only. */
  .notes-list {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  /* Don't let vertical swipes scroll the note behind the open panel. */
  #app.panel-open .app-body,
  #app.panel-open .editor-wrap,
  #app.panel-open #editor {
    overflow: hidden;
    touch-action: none;
  }

  #app.panel-closed .notes-panel {
    transition:
      left var(--motion-panel),
      visibility 0s linear var(--motion-panel);
  }

  #app.panel-closed .notes-panel-backdrop {
    transition:
      opacity var(--motion-fade),
      visibility 0s linear var(--motion-fade);
  }

  .notes-panel-backdrop {
    display: block;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      opacity var(--motion-fade),
      visibility 0s linear var(--motion-fade);
  }

  #app.panel-open .notes-panel-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition:
      opacity var(--motion-fade),
      visibility 0s;
  }

  .notes-panel-backdrop[hidden] {
    display: block;
  }
}

/* Note reveal when switching or loading a note. */
.editor-wrap.note-enter {
  animation: note-enter var(--motion-note) both;
}

.editor-wrap.note-enter-fast {
  animation: note-enter-fast 0.16s both;
}

@keyframes note-enter {
  from {
    opacity: 0.35;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes note-enter-fast {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .notes-panel,
  .notes-panel-slide,
  .notes-panel-backdrop,
  .editor-wrap,
  .notes-item {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Top hint bar ---------- */
#hintbar {
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  width: 100%;
  height: var(--top-bar-height);
  padding: 0 16px;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
  color: var(--ui-ink-faint);
  user-select: none;
  flex: 0 0 auto;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  z-index: 5;
}

#hintbar .app-brand {
  display: none;
}

#app.panel-closed #hintbar .app-brand {
  display: inline-flex;
}

#app.panel-open #hintbar .app-brand {
  display: none;
}

.hint-cell { white-space: nowrap; }
.hint-spacer { flex: 1 1 auto; }

.hint-readonly-badge {
  flex-shrink: 0;
  font-size: var(--ui-font-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ui-ink-faint);
  background: color-mix(in srgb, var(--border) 55%, transparent);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  line-height: 1.2;
}

.hint-readonly-badge[hidden] {
  display: none;
}

.collab-bar {
  position: absolute;
  left: max(var(--edit-pad-x), calc((100% - var(--edit-max-width)) / 2));
  right: max(var(--edit-pad-x), calc((100% - var(--edit-max-width)) / 2));
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  pointer-events: none;
  will-change: transform;
}
.collab-bar[hidden] { display: none; }

.collab-bar-fill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  background: var(--paper);
  border-radius: 4px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.collab-label {
  font-size: var(--ui-font-md);
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

#hint-time {
  display: none;
}

.nav-loading {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--ink-faint);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: nav-spin 0.65s linear infinite;
  flex: 0 0 auto;
  opacity: 0.85;
}
.nav-loading[hidden] { display: none; }

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

.hint-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ui-ink-soft);
  cursor: pointer;
  flex: 0 0 auto;
}
.hint-icon-btn:hover,
.hint-icon-btn:focus-visible {
  color: var(--ui-ink);
  background: var(--surface-hover);
  outline: none;
}

#btn-new-note {
  width: 35px;
  height: 35px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-btn-bg);
  color: var(--accent-btn-fg);
}

#btn-new-note:hover,
#btn-new-note:focus-visible {
  background: var(--accent-btn-bg-hover);
  border-color: var(--accent);
  color: var(--accent-btn-fg);
}

/* ---------- Countdown timer bar ---------- */
.timer-bars {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  z-index: 6;
  background: var(--paper);
}
.timer-bars[hidden] { display: none; }

.timer-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  box-sizing: border-box;
  height: var(--timer-bar-height);
  padding: 0 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.timer-bars .timer-bar:last-child {
  border-bottom: none;
}

.timer-bar-title {
  flex: 0 1 auto;
  max-width: 28%;
  font-family: var(--mono);
  font-size: var(--ui-font-xs);
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timer-bar-title[hidden] { display: none; }

.timer-bar-track {
  flex: 1 1 auto;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}

.timer-bar-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform-origin: right center;
  transform: scaleX(1);
  will-change: transform;
}

.timer-bar-label {
  flex: 0 0 auto;
  min-width: 3.2em;
  font-family: var(--mono);
  font-size: var(--ui-font-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  text-align: right;
  user-select: none;
}
.timer-bar.is-paused .timer-bar-fill {
  opacity: 0.45;
}
.timer-bar.is-paused .timer-bar-label {
  color: var(--ink-soft);
}
.timer-bar.is-stopwatch .timer-bar-fill {
  opacity: 0.85;
}
.hint-icon-btn[aria-expanded="true"] {
  color: var(--accent);
  background: var(--accent-surface);
}

#btn-toggle-panel[aria-expanded="true"] {
  color: var(--ui-ink-soft);
  background: transparent;
}

#btn-toggle-panel[aria-expanded="true"]:hover,
#btn-toggle-panel[aria-expanded="true"]:focus-visible {
  color: var(--ui-ink);
  background: var(--surface-hover);
}

.hint-icon-btn-public[hidden] {
  display: none;
}

.hint-icon-btn-danger:hover,
.hint-icon-btn-danger:focus-visible {
  color: var(--danger);
  background: var(--danger-surface);
}

.hint-icon {
  display: block;
  width: var(--ui-icon-sm);
  height: var(--ui-icon-sm);
  flex: 0 0 auto;
}

.rates-tooltip {
  position: fixed;
  z-index: 130;
  pointer-events: none;
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: var(--ui-font-sm);
  font-weight: 500;
  line-height: 1.3;
  color: var(--tooltip-fg);
  background: var(--tooltip-bg);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  max-width: calc(100vw - 20px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.rates-tooltip[hidden] { display: none !important; }
.rates-tooltip.rates-tooltip-feedback {
  color: var(--paper);
  background: var(--accent);
  font-weight: 600;
  animation: rates-tooltip-pop 0.35s ease-out;
}
@keyframes rates-tooltip-pop {
  0% { opacity: 0.7; transform: scale(0.94); }
  55% { opacity: 1; transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}

#editor.rates-hover { cursor: pointer; }

/* Mobile prev/next note buttons. */
.mobile-nav {
  display: none;
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 6;
  flex-direction: column;
  gap: 4px;
  padding: 5px;
  border-radius: var(--radius-pill);
  background: var(--paper);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
}
.mobile-nav[hidden] { display: none !important; }

@media (max-width: 768px) {
  .mobile-nav:not([hidden]) {
    display: flex;
  }
}

.mobile-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-btn:hover,
.mobile-nav-btn:focus-visible {
  color: var(--accent);
  outline: none;
}
.mobile-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

.mobile-nav-icon {
  display: block;
  width: var(--ui-icon-md);
  height: var(--ui-icon-md);
}

/* ---------- Editor (CodeMirror 6 single surface) ---------- */
.editor-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;          /* allow internal scroll */
  overflow: hidden;
  isolation: isolate;
  transition: opacity var(--motion-note), transform var(--motion-note);
}

/* Dot grid stays pinned to the editor viewport; text/cards scroll above it. */
.editor-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: 0 0;
}

#editor.cm-editor-host,
#editor.cm-editor-mount {
  position: absolute;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  overflow: hidden;
  overscroll-behavior: none;

  font-family: var(--mono);
  font-size: var(--edit-font-size);
  font-weight: var(--edit-weight);
  line-height: var(--edit-line-box);
  letter-spacing: -0.5px;
  tab-size: 4;
  -moz-tab-size: 4;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;

  /* Vertical padding lives on .cm-content so text scrolls *through* it
     instead of being clipped by a fixed top/bottom margin. */
  padding-top: 0;
  padding-right: max(var(--edit-pad-x), calc((100% - var(--edit-max-width)) / 2));
  padding-bottom: 0;
  padding-left: max(var(--edit-pad-x), calc((100% - var(--edit-max-width)) / 2));

  border: 0;
  background: transparent;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  outline: none;
  box-sizing: border-box;
}

#editor .cm-editor {
  height: 100%;
  background: transparent;
  outline: none;
  display: flex;
  flex-direction: column;
}

#editor .cm-editor.cm-focused {
  outline: none;
}

#editor .cm-scroller {
  flex: 1 1 auto;
  height: 100%;
  min-height: 100%;
  overflow: auto;
  overscroll-behavior: none;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  scrollbar-gutter: stable;
}

#editor .cm-content {
  max-width: var(--edit-max-width);
  margin: 0 auto;
  /* CodeMirror's drawSelection injects a highest-precedence theme that forces
     `caret-color: transparent !important` and renders its own `.cm-cursor`
     element instead. That drawn caret measures its height from a line's inline
     content, so it collapses to 0px (invisible) on blank lines and only appears
     after a character is typed. We hide the drawn caret (see `.cm-cursor` below)
     and re-enable the browser's native caret, which renders reliably on empty
     lines. `!important` + the `#editor` id are required to beat drawSelection. */
  caret-color: var(--ink) !important;
  min-height: 100%;
  padding-top: var(--edit-pad-top);
  padding-bottom: var(--edit-pad-bottom);
  box-sizing: border-box;
}

#editor .cm-line {
  padding: 0;
  /* Empty lines have no inline content, so `line-height` alone collapses the
     block to zero height. Reserve a full line box so the line keeps its height
     (and the native caret has somewhere to sit) on blank lines. */
  min-height: var(--edit-line-box);
  /* Override drawSelection's per-line `caret-color: transparent !important`. */
  caret-color: var(--ink) !important;
}

#editor .cm-gutters {
  background: transparent;
  border: none;
  color: var(--ink-faint);
}

#app[data-line-nums] #editor .cm-lineNumbers {
  min-width: calc(var(--line-num-prefix-ch, 4) * 1ch + 6px);
}

#app[data-line-nums] #editor .cm-lineNumbers .cm-gutterElement {
  font-family: var(--mono);
  font-size: var(--ui-font-sm);
  font-weight: 500;
  line-height: var(--edit-line-box);
  color: var(--ink-faint);
  text-align: left;
  padding: 0 6px 0 0;
  min-width: 0;
}

#editor .cm-gutterElement {
  padding: 0 6px 0 0;
}

#editor .cm-activeLine {
  background: transparent;
}

#editor .cm-selectionBackground,
#editor.cm-focused .cm-selectionBackground {
  background: var(--selection) !important;
}

#editor .cm-cursor {
  border-left-color: var(--ink);
  /* Hide drawSelection's drawn caret; we use the native caret (re-enabled on
     .cm-content / .cm-line above) so the cursor is visible on blank lines too. */
  display: none !important;
}

#editor .cm-placeholder {
  color: var(--ink-faint);
}

/* Default (plain/sum/avg/count/math): wrap like prose. */
#editor .cm-line {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Bullet lines ("- " / "* "): hanging indent so wrapped text aligns with the
   first character after the marker. --bullet-indent is set per line in app.js. */
#editor .cm-line.cm-bullet-line {
  padding-left: var(--bullet-indent, 2ch);
  text-indent: calc(-1 * var(--bullet-indent, 2ch));
}

.cm-footer-block {
  display: block;
  margin-top: var(--edit-line-box);
}

.cm-footer-line {
  display: block;
}

/* Pending-mode hint: greyed explanation shown under line 1 until the user
   commits the mode with Enter (or edits the keyword away). */
.cm-mode-hint {
  display: block;
  margin-top: var(--edit-line-box);
  color: var(--ink-faint);
  font-style: italic;
  white-space: pre-wrap;
  pointer-events: none;
  user-select: none;
}

.cm-mode-hint .cm-footer-line {
  min-height: var(--edit-line-box);
}

/* Legacy backdrop layers removed — keep token classes for CM decorations. */

/* Solid paper behind each wrapped visual line — width follows the glyphs, not the editor. */
.tok-ink-fill {
  background: var(--paper);
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  /* Horizontal pad only — vertical pad inflates backdrop rows vs the textarea grid. */
  padding: 0 3px;
  margin: 0 -3px;
}

/* Let the selection tint show cleanly without a paper band behind it. */
#app.has-selection .tok-ink-fill,
#app.has-diff-highlight .tok-ink-fill {
  background: transparent;
}

/* Ink fill without horizontal pad — padding skews the monospace caret grid. */
#app[data-mode="bible"] .tok-ink-fill {
  padding: 0;
  margin: 0;
}

/* ---------- Recipe mode ---------- */
.recipe-yield-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-sizing: border-box;
  height: var(--subheader-height);
  padding: 0 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 6;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.recipe-yield-bar[hidden] { display: none; }

.recipe-yield-label {
  font-family: var(--mono);
  font-size: var(--ui-font-sm);
  font-weight: 600;
  color: var(--ink-soft);
}

.recipe-yield-value {
  font-family: var(--mono);
  font-size: var(--ui-font-md);
  font-weight: 700;
  color: var(--accent);
  min-width: 1.5ch;
  text-align: center;
}

.recipe-yield-suffix {
  font-family: var(--mono);
  font-size: var(--ui-font-sm);
  color: var(--ink-soft);
}

.recipe-yield-mult {
  font-family: var(--mono);
  font-size: var(--ui-font-sm);
  font-weight: 600;
  color: var(--accent);
  margin-left: 4px;
}

.recipe-yield-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.recipe-yield-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#app.public-view .recipe-yield-bar {
  flex: 0 0 auto;
  cursor: default;
}

#app.public-view[data-mode="recipe"] .recipe-yield-bar[data-local-override="1"] .recipe-yield-value {
  color: var(--accent);
}

.recipe-qty {
  color: var(--accent);
  font-weight: var(--accent-weight);
}

.recipe-yield-label-text {
  color: var(--ink);
  font-weight: inherit;
  font-style: normal;
}

.recipe-yield-num {
  color: var(--ink);
  font-weight: inherit;
}

.recipe-yield-mult-num {
  color: var(--accent);
  font-weight: var(--accent-weight);
}

.recipe-mult {
  color: var(--ink-faint);
  font-weight: 500;
}

#app[data-mode="recipe"] #editor .cm-scroller {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* List: the checkbox lives in a CodeMirror gutter, so item text needs no
   leading tab or extra indent — every row's text starts at the content edge. */
#app[data-mode="list"] #editor .cm-scroller {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

#app[data-mode="list"] .li-done-text {
  text-decoration: line-through;
  color: var(--ink-soft);
}

/* Most non-item lines (comments, blanks) stay in the item *text* column. A
   negative margin renders flush-left, but CodeMirror's drawSelection derives one
   global `leftSide` for wrapped rows from the content box + first line
   padding/text-indent and ignores per-line margins — so a margin-shifted line
   that *wraps* gets a ragged selection (first row at the glyph, later rows at the
   gutter edge). Keeping wrapping lines in the same text column makes their
   selection a clean rectangle.

   The keyword line and the summary footer are the exceptions: they never wrap, so
   a negative *margin* (ignored by the leftSide math) safely pulls them out to the
   checkbox column to match every other mode's title/footer — without disturbing
   selection. The footer is a non-selectable block widget, so it's free to shift. */
#app[data-mode="list"] #editor .cm-line.cm-list-flush-line,
#app[data-mode="list"] #editor .cm-footer-block {
  margin-left: calc(1.5px - 3ch);
}

/* Code mode: same idea, but the gutter is the (variable-width) line-number
   column. Pull the keyword line back by that width so "code" aligns with every
   other mode's title. Only applies when line numbers are actually shown; the
   keyword never wraps, so the negative margin doesn't affect selection. */
#app[data-line-nums][data-mode="code"] #editor .cm-line.cm-code-flush-line {
  margin-left: calc(-1 * (var(--line-num-prefix-ch, 4) * 1ch + 6px));
}

/* Code: wrap long lines; line numbers align to the first visual row only. */
#app[data-mode="code"] #editor .cm-scroller {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* ---------- Backdrop token styling ---------- */
/* Keyword line (e.g. "sum"), the auto-total line, and math results all share
   the golden-yellow accent + bold. */
.tok-keyword-line { color: var(--accent); font-weight: var(--accent-weight); }
.tok-mode-title   { color: var(--ink); font-weight: inherit; }
.tok-bible-ref    { color: var(--accent); font-weight: var(--accent-weight); }

/* Bible: native soft-wrap via CodeMirror lineWrapping. */
#app[data-mode="bible"] #editor .cm-scroller {
  tab-size: var(--bible-verse-indent, 3ch);
  -moz-tab-size: var(--bible-verse-indent, 3ch);
  -webkit-tab-size: var(--bible-verse-indent, 3ch);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

#app[data-mode="bible"][data-bible-split] #editor .cm-scroller {
  overflow-x: hidden;
}

/* Numbered verse rows: number + body laid out as inline-block columns so the
   body wraps within its own box and every line hangs at the same column. This
   avoids tab stops / text-indent, which Safari measures inconsistently. */
#app[data-mode="bible"] #editor .cm-line.cm-bible-verse-line {
  padding-left: 0;
  text-indent: 0;
}

#app[data-mode="bible"] .cm-bible-verse-body {
  display: inline-block;
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  width: calc(100% - var(--bible-verse-indent, 3ch));
}

#app[data-mode="bible"] .bible-verse-num {
  color: var(--ink-faint);
  font-style: normal;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#app[data-mode="bible"] .bible-verse-text {
  font-style: italic;
}

/* Side-by-side bible: the translation header is a block widget (its labels are
   not in the document); verse rows are real, editable text laid out as two
   independently-wrapping inline-block columns so the caret works normally. */

/* Header widget: inline replacement that mirrors the verse columns (so labels
   line up with each column's text) but renders compact, adding no extra height. */
#app[data-mode="bible"] .cm-bible-split-widget {
  display: inline-block;
  width: 100%;
  vertical-align: top;
}

#app[data-mode="bible"] .cm-bible-split-header-line {
  line-height: 1.25;
  padding-top: calc(var(--edit-line-box) * 0.6);
}

#app[data-mode="bible"] .cm-bible-split-label {
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-style: normal;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transform: scale(0.72);
  transform-origin: left top;
}

/* Verse rows — editable inline-block columns over the real document text. */
#app[data-mode="bible"] .cm-bible-col-num {
  display: inline-block;
  width: var(--bible-verse-indent, 3ch);
  vertical-align: top;
}

#app[data-mode="bible"] .cm-bible-split-line .cm-bible-col-left,
#app[data-mode="bible"] .cm-bible-split-line .cm-bible-col-right {
  display: inline-block;
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  width: calc((100% - var(--bible-verse-indent, 3ch) - var(--bible-split-gap, 2ch)) / 2);
}

#app[data-mode="bible"] .cm-bible-split-line .cm-bible-col-right {
  margin-left: var(--bible-split-gap, 2ch);
}

#app[data-mode="bible"] .cm-bible-split-line-flush .cm-bible-col-left,
#app[data-mode="bible"] .cm-bible-split-line-flush .cm-bible-col-right {
  width: calc((100% - var(--bible-split-gap, 2ch)) / 2);
}

#app[data-mode="bible"] .cm-bible-sep {
  display: inline-block;
  width: 0;
  overflow: hidden;
}

.tok-result-line  { color: var(--accent); font-weight: var(--accent-weight); }
.tok-math-result  { color: var(--accent); font-weight: var(--accent-weight); }

.tok-timer-line .tok-timer-label,
.tok-timer-line .tok-timer-suffix {
  color: var(--timer-list-ink);
  font-weight: 400;
  font-style: normal;
}
.tok-timer-line .tok-timer-value {
  color: var(--accent);
  font-weight: var(--accent-weight);
}

.tok-math-result[data-currency-conversion].rates-refreshing {
  animation: rates-refreshing-pulse 0.85s ease-in-out infinite;
}
.tok-math-result[data-currency-conversion].rates-refreshed {
  animation: rates-refresh-flash 0.6s ease-out;
}
@keyframes rates-refreshing-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
@keyframes rates-refresh-flash {
  0% { opacity: 1; filter: brightness(1); }
  25% { opacity: 0.3; filter: brightness(1.35); }
  100% { opacity: 1; filter: brightness(1); }
}
/* Math variables: one hue per name so defs and refs look linked. */
.tok-math-var { font-weight: var(--accent-weight); }
.tok-math-var-0 { color: var(--math-var-0); }
.tok-math-var-1 { color: var(--math-var-1); }
.tok-math-var-2 { color: var(--math-var-2); }
.tok-math-var-3 { color: var(--math-var-3); }
.tok-math-var-4 { color: var(--math-var-4); }
.tok-math-var-5 { color: var(--math-var-5); }
.tok-math-var-6 { color: var(--math-var-6); }
.tok-math-var-7 { color: var(--math-var-7); }
.tok-comment      { color: var(--comment); font-style: italic; }

#editor .tok-comment,
#app[data-mode="recipe"] #editor .tok-comment,
#app[data-mode="bible"] #editor .tok-comment,
#app[data-mode="list"] #editor .tok-comment,
#app.public-view #editor .tok-comment {
  color: var(--comment);
  font-style: italic;
}

/* List // comment lines — line decoration backs up mark spans in CodeMirror. */
#app[data-mode="list"] #editor .cm-line.cm-line-comment {
  color: var(--comment);
  font-style: italic;
}
.tok-search-hit    { background: var(--search-hit); border-radius: 2px; }
.tok-find-hit      { background: var(--find-hit); border-radius: 2px; }
.tok-find-active {
  background: var(--accent);
  color: var(--paper);
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--accent);
}

/* Math mode variable autocomplete */
.math-ac {
  position: absolute;
  z-index: 12;
  min-width: 160px;
  max-width: min(320px, 90vw);
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font-family: var(--mono);
  font-size: var(--ui-font-md);
  pointer-events: auto;
}
.math-ac[hidden] { display: none; }

.math-ac-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  color: var(--ink);
  cursor: pointer;
}
.math-ac-item:hover {
  background: var(--surface-hover);
}
.math-ac-item-hint {
  flex: 0 0 auto;
  font-size: var(--ui-font-xs);
  font-weight: 600;
  color: var(--ink-faint);
  width: 14px;
  text-align: center;
}
.math-ac-item-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Bible mode translation picker (after bible: on line 1) */
.bible-tr-ac {
  position: absolute;
  z-index: 12;
  min-width: 220px;
  max-width: min(360px, 92vw);
  margin: 0;
  padding: 4px 0;
  background: var(--paper);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font-family: var(--mono);
  font-size: var(--ui-font-md);
  pointer-events: auto;
}
.bible-tr-ac[hidden] { display: none; }

.bible-tr-ac-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  color: var(--ink);
  cursor: pointer;
}
.bible-tr-ac-item:hover,
.bible-tr-ac-item.selected {
  background: var(--surface-hover);
}
.bible-tr-ac-item-hint {
  flex: 0 0 auto;
  font-size: var(--ui-font-xs);
  font-weight: 600;
  color: var(--ink-faint);
  width: 14px;
  text-align: center;
}
.bible-tr-ac-item-id {
  flex: 0 0 auto;
  font-weight: var(--accent-weight);
  color: var(--accent);
  min-width: 2.5em;
}
.bible-tr-ac-item-desc {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-muted);
}

/* List/code: one block row per note line (wrap grows inside the row). */
#app[data-mode="code"] .code-line {
  display: block;
}

#app[data-mode="code"] .code-line-empty {
  min-height: var(--edit-line-box);
}

.li-done-text { color: var(--done-text); text-decoration: line-through; }

/* Line numbers — code mode (always) and math mode (duplicate variables). */
.line-num-gutter {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow-x: hidden;
  overflow-y: hidden;
  pointer-events: none;
}
.line-num-gutter[hidden] { display: none; }

/* Gutter offset via negative margin on header rows so they align with code body. */
#app[data-line-nums][data-mode="code"] .cm-line-pre-content {
  position: relative;
  z-index: 5;
  margin-left: calc(-1 * var(--line-num-prefix-ch, 4) * 1ch);
}

/* Line numbers — rows positioned from measured backdrop line rects (app.js). */
.line-num-gutter-inner {
  position: absolute;
  inset: 0;
  left: max(var(--edit-pad-x), calc((100% - var(--edit-max-width)) / 2));
  will-change: transform;
  width: calc(var(--line-num-prefix-ch, 4) * 1ch);
  box-sizing: border-box;
  font-family: var(--mono);
  font-size: var(--edit-font-size);
  font-weight: 500;
  line-height: var(--edit-line-box);
  text-align: left;
  color: var(--ink-faint);
  user-select: none;
  overflow: visible;
  pointer-events: none;
}

.line-num-row {
  position: absolute;
  left: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
  font-size: var(--ui-font-sm);
  line-height: 1;
  pointer-events: none;
}
.line-num-row-dup {
  color: var(--danger);
  font-weight: 700;
}

/* Clickable checkbox overlay — above the textarea in list mode. */
.list-gutter {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.list-gutter-inner {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-sizing: border-box;
  overflow: visible;
  will-change: transform;
}

.li-gutter-row {
  position: absolute;
  /* Absolute children ignore parent padding — match editor inset explicitly. */
  left: max(var(--edit-pad-x), calc((100% - var(--edit-max-width)) / 2));
  width: var(--list-check-size);
  display: flex;
  /* Row height is one line box; center the checkbox on that line. */
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
  pointer-events: none;
}

.li-check-btn {
  position: relative;
  pointer-events: auto;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--list-check-size);
  height: var(--list-check-size);
  padding: 0;
  border: 1.5px solid var(--check-box);
  border-radius: calc(var(--list-check-size) * 0.2);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.85;
}

/* Larger invisible tap target on mobile (visual checkbox unchanged). */
@media (max-width: 768px) {
  .li-check-btn::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: var(--edit-line-box);
    max-height: 44px;
    transform: translate(-50%, -50%);
  }
}

.li-check-btn:hover {
  opacity: 1;
  border-color: var(--ink-faint);
}

.li-check-btn.checked {
  background: var(--accent);
  border-color: var(--accent);
  opacity: 1;
}

/* Proportional checkmark — drawn, not a thin glyph; scales with the box. */
.li-check-btn.checked::after {
  content: '';
  display: block;
  width: calc(var(--list-check-size) * 0.27);
  height: calc(var(--list-check-size) * 0.47);
  border: solid var(--paper);
  border-width: 0 calc(var(--list-check-size) * 0.13) calc(var(--list-check-size) * 0.13) 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

#editor .cm-list-gutter {
  /* Reserve exactly the width of "// " (three mono chars, less the 3×0.5px
     letter-spacing) so item text lines up with comment text after the slashes. */
  width: calc(3ch - 1.5px);
}

/* Flexbox positions the checkbox without relying on the inline baseline (avoids
   a ~1px jump when the checkmark SVG is added). Top-align so wrapped items keep
   the box on the first line instead of floating mid-block. */
#editor .cm-list-gutter .cm-gutterElement {
  display: flex;
  align-items: flex-start;
}

#editor .cm-list-gutter .li-check-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--list-check-size);
  height: var(--list-check-size);
  /* Nudge down to match the first text line; flex-start keeps this fixed when the item wraps. */
  margin: calc((var(--edit-line-box) - var(--list-check-size)) / 2) 0 0;
  padding: 0;
  border: 1.5px solid var(--check-box);
  border-radius: calc(var(--list-check-size) * 0.2);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.85;
}

#editor .cm-list-gutter .li-check-btn-checked {
  background: var(--accent);
  border-color: var(--accent);
  opacity: 1;
}

#editor .cm-list-gutter .li-check-icon {
  width: calc(var(--list-check-size) * 0.66);
  height: calc(var(--list-check-size) * 0.66);
  color: var(--paper);
}

/* Public list notes (view only): show checkboxes read-only. */
#app.public-view:not(.public-can-edit) #editor .cm-list-gutter .li-check-btn {
  cursor: default;
  pointer-events: none;
}

#app[data-mode="code"] #editor .cm-content { color: var(--code-ink); }

#app[data-mode="code"] #editor .cm-content .code-key  { color: var(--code-key);  font-weight: 600; }
#app[data-mode="code"] #editor .cm-content .code-fn   { color: var(--code-fn); }
#app[data-mode="code"] #editor .cm-content .code-str  { color: var(--code-str); }
#app[data-mode="code"] #editor .cm-content .code-num  { color: var(--code-num); }
#app[data-mode="code"] #editor .cm-content .code-com  { color: var(--code-com);  font-style: italic; }
#app[data-mode="code"] #editor .cm-content .code-sel  { color: var(--code-sel);  font-weight: 600; }
#app[data-mode="code"] #editor .cm-content .code-prop { color: var(--code-prop); }
#app[data-mode="code"] #editor .cm-content .code-tag  { color: var(--code-tag);  font-weight: 700; }
#app[data-mode="code"] #editor .cm-content .code-hex  { color: var(--code-hex);  font-weight: 600; }
#app[data-mode="code"] #editor .cm-content .code-at   { color: var(--code-at);   font-weight: 600; }

.code-key  { color: var(--code-key);  font-weight: 600; }
.code-fn   { color: var(--code-fn); }
.code-str  { color: var(--code-str); }
.code-num  { color: var(--code-num); }
.code-com  { color: var(--code-com);  font-style: italic; }
.code-sel  { color: var(--code-sel);  font-weight: 600; }
.code-prop { color: var(--code-prop); }
.code-tag  { color: var(--code-tag);  font-weight: 700; }
.code-hex  { color: var(--code-hex);  font-weight: 600; }
.code-at   { color: var(--code-at);   font-weight: 600; }

/* ---------- Transient save status ---------- */
.status {
  font-family: var(--ui-sans);
  font-size: var(--ui-font-sm);
  color: var(--ui-ink-faint);
  user-select: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status.show { opacity: 1; }

.history-hint {
  position: fixed;
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%);
  z-index: 110;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: var(--ui-font-md);
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--popup-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  user-select: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.history-hint.show { opacity: 1; }

.math-dup-hint {
  position: fixed;
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%);
  z-index: 110;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: var(--ui-font-md);
  font-weight: 500;
  line-height: 1.45;
  color: var(--danger);
  background: var(--popup-bg);
  border: 1px solid var(--danger);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  user-select: none;
  max-width: min(560px, calc(100vw - 32px));
  text-align: center;
  pointer-events: none;
}
.math-dup-hint[hidden] { display: none !important; }

body:has(#math-dup-hint:not([hidden])) .history-hint.show {
  bottom: 88px;
}

.tok-math-var-dup {
  color: var(--danger);
  font-weight: var(--accent-weight);
  background: var(--danger-surface);
  border-radius: 2px;
}

#editor.link-hover,
#editor.math-var-hover { cursor: pointer; }

#editor .tok-link,
#app.public-view #editor .tok-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.link-tooltip {
  position: fixed;
  z-index: 120;
  pointer-events: none;
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: var(--ui-font-sm);
  font-weight: 500;
  line-height: 1.3;
  color: var(--tooltip-fg);
  background: var(--tooltip-bg);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  max-width: calc(100vw - 20px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-tooltip[hidden] { display: none; }

/* ---------- Note options menu (⋮) ---------- */
.note-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: var(--overlay-light);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.note-menu-backdrop[hidden],
.note-menu[hidden] {
  display: none;
}

.note-menu {
  position: fixed;
  z-index: 111;
  min-width: 140px;
  margin: 0;
  padding: 4px 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow-md);
  font-family: var(--mono);
  font-size: var(--ui-font-md);
}

.settings-menu {
  position: fixed;
  z-index: 111;
  min-width: 220px;
  max-height: min(70vh, 360px);
  margin: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--popup-bg);
  box-shadow: var(--shadow-lg);
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
  overflow-y: auto;
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
}
.settings-menu[hidden] {
  display: none;
}

#notes-panel-menu,
#notes-panel-settings-menu,
#note-menu {
  max-height: none;
  overflow-y: visible;
}

#notes-panel-account-guest[hidden] {
  display: none;
}

.notes-panel-guest-hint {
  margin: 0 0 8px;
  padding: 0;
  font-size: var(--ui-font-sm);
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  color: var(--ink-faint);
  letter-spacing: normal;
  text-transform: none;
}

.notes-panel-login-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin: 0;
  min-height: 34px;
  box-sizing: border-box;
  font-size: var(--ui-font-sm) !important;
  padding: 10px 12px !important;
  border-radius: var(--radius-pill) !important;
  font-weight: 600 !important;
  text-align: center !important;
  text-decoration: none;
  color: var(--accent-btn-fg) !important;
  background: var(--accent-btn-bg) !important;
  border-color: var(--accent) !important;
}

.notes-panel-login-btn:hover,
.notes-panel-login-btn:focus-visible {
  background: var(--accent-btn-bg-hover) !important;
  border-color: var(--accent) !important;
  color: var(--accent-btn-fg) !important;
}

.notes-panel-login-btn[hidden] {
  display: none !important;
}

.settings-menu-section + .settings-menu-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.settings-action-item[hidden] {
  display: none !important;
}

.settings-action-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: var(--ui-font-md);
  font-weight: 500;
  text-align: left;
  color: var(--ui-ink);
  cursor: pointer;
}
.settings-action-item:hover,
.settings-action-item:focus-visible {
  background: var(--surface-hover);
  outline: none;
}

.settings-action-item:disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

a.settings-action-item {
  text-decoration: none;
  box-sizing: border-box;
}

.settings-menu-user {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  color: var(--ink-soft);
}

.settings-menu-heading {
  margin: 0;
  padding: 6px 12px 8px;
  font-size: var(--ui-font-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ui-ink-faint);
}

.settings-font-size {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px 6px;
}

.settings-font-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 32px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: var(--ui-font-lg);
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.settings-font-btn:hover,
.settings-font-btn:focus-visible {
  background: var(--surface-hover);
  outline: none;
}
.settings-font-btn:disabled {
  opacity: 0.4;
  cursor: default;
  background: transparent;
}

.settings-font-label {
  flex: 1 1 auto;
  text-align: center;
  font-size: var(--ui-font-md);
  font-weight: 500;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.theme-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: var(--ui-font-md);
  font-weight: 500;
  text-align: left;
  color: var(--ui-ink);
  cursor: pointer;
}
.theme-menu-item:hover,
.theme-menu-item:focus-visible {
  background: var(--surface-hover);
  outline: none;
}
.theme-menu-item[aria-checked="true"] {
  background: var(--accent-surface);
  font-weight: 600;
  color: var(--ui-ink);
}
.theme-menu-item[aria-checked="true"]:hover,
.theme-menu-item[aria-checked="true"]:focus-visible {
  background: var(--accent-surface-strong);
}

.theme-menu-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--ui-check-size);
  height: var(--ui-check-size);
  flex: 0 0 var(--ui-check-size);
  border: 1.5px solid var(--check-box);
  border-radius: 50%;
  background: transparent;
  box-sizing: border-box;
  opacity: 0.85;
}
.theme-menu-item[aria-checked="true"] .theme-menu-mark {
  background: transparent;
  border-color: var(--accent);
  opacity: 1;
}
.theme-menu-item[aria-checked="true"] .theme-menu-mark::after {
  content: '';
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.theme-menu-label {
  flex: 1 1 auto;
  line-height: 1.2;
}

.note-menu-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 14px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--ui-font-md);
  font-weight: 500;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}
.note-menu-item:hover,
.note-menu-item:focus-visible {
  background: var(--surface-hover);
  outline: none;
}
.note-menu-item-danger,
.settings-action-item.note-menu-item-danger {
  color: var(--danger);
}
.note-menu-item-danger:hover,
.note-menu-item-danger:focus-visible,
.settings-action-item.note-menu-item-danger:hover,
.settings-action-item.note-menu-item-danger:focus-visible {
  background: var(--danger-surface);
}

/* ---------- Find / replace bar ---------- */
.find-bar {
  position: fixed;
  top: calc(var(--top-bar-height) + var(--timer-bar-offset, 0px) + 8px);
  right: 16px;
  z-index: 105;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: min(360px, calc(100vw - 32px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-lg);
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
}
.find-bar[hidden] { display: none; }

.find-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.find-bar-row[hidden] {
  display: none;
}

.find-bar-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--ui-ink);
  font: inherit;
  outline: none;
}
.find-bar-input::placeholder { color: var(--ink-faint); }
.find-bar-input::selection {
  background: var(--accent);
  color: var(--selection-fg);
}
.find-bar-input::-moz-selection {
  background: var(--accent);
  color: var(--selection-fg);
}
.find-bar-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-surface);
}

.find-bar-status {
  flex: 0 0 auto;
  min-width: 4.5em;
  font-size: var(--ui-font-sm);
  color: var(--ink-faint);
  text-align: right;
  white-space: nowrap;
}

.find-bar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  flex: 0 0 auto;
  font-size: var(--ui-font-glyph);
  line-height: 1;
}
.find-bar-icon-btn:hover,
.find-bar-icon-btn:focus-visible {
  color: var(--accent);
  background: var(--surface-hover);
  outline: none;
}

.find-bar-icon {
  display: block;
  width: var(--ui-icon-find);
  height: var(--ui-icon-find);
}

.find-bar-text-btn {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ui-ink-soft);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.find-bar-text-btn:hover,
.find-bar-text-btn:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-surface);
  outline: none;
}

.find-bar-replace-row .find-bar-input {
  flex: 1 1 auto;
}

/* ---------- List complete confetti ---------- */
.list-confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 185;
}

@media (prefers-reduced-motion: reduce) {
  .list-confetti-canvas {
    display: none;
  }
}

/* ---------- Timer finished overlay ---------- */
.timer-done-backdrop {
  position: fixed;
  inset: 0;
  z-index: 190;
  background: var(--timer-done-scrim);
  -webkit-backdrop-filter: blur(var(--timer-done-blur));
  backdrop-filter: blur(var(--timer-done-blur));
  animation: timer-done-fade-in 0.35s ease-out;
}
.timer-done-backdrop[hidden],
.timer-done[hidden] {
  display: none;
}

.timer-done {
  position: fixed;
  inset: 0;
  z-index: 191;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 24px;
  text-align: center;
  font-family: var(--mono);
  pointer-events: none;
  animation: timer-done-fade-in 0.35s ease-out;
}
.timer-done > * {
  pointer-events: auto;
}

.timer-done-title {
  margin: 0;
  font-size: clamp(2.4rem, 12vw, 4.5rem);
  font-weight: var(--accent-weight);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--accent);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.45);
  animation: timer-done-pulse 1.1s ease-in-out infinite alternate;
}

.timer-done-message {
  margin: 0;
  max-width: 20em;
  font-size: clamp(1rem, 4.5vw, 1.35rem);
  font-weight: 500;
  line-height: 1.4;
  color: var(--timer-done-fg-soft);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}

.timer-done-ok {
  margin-top: 12px;
  padding: 11px 28px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: var(--timer-done-btn-bg);
  font-family: inherit;
  font-size: var(--ui-font-xl);
  font-weight: 600;
  color: var(--timer-done-btn-fg);
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.timer-done-ok:hover,
.timer-done-ok:focus,
.timer-done-ok:focus-visible {
  background: var(--timer-done-btn-hover);
  color: var(--timer-done-btn-fg);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@keyframes timer-done-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes timer-done-pulse {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(1.04); opacity: 0.88; }
}

/* ---------- Delete note confirmation ---------- */
.delete-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.delete-dialog-backdrop[hidden],
.delete-dialog[hidden] {
  display: none;
}

.delete-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 121;
  width: min(380px, calc(100vw - 32px));
  padding: 24px 24px 20px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  font-family: var(--ui-sans);
}

.delete-dialog-title {
  margin: 0 0 10px;
  font-size: var(--ui-font-3xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ui-ink);
}

.delete-dialog-message {
  margin: 0 0 18px;
  font-size: var(--ui-font-lg);
  line-height: 1.5;
  color: var(--ink-soft);
}

.delete-dialog-message strong {
  font-weight: 600;
  color: var(--ink);
}

.stop-sharing-user-list {
  margin: 10px 0 0;
  padding-left: 1.25em;
  color: var(--ink);
}

.stop-sharing-user-list li {
  margin: 4px 0;
}

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

.delete-dialog-btn {
  font-family: inherit;
  font-size: var(--ui-font-md);
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ui-ink-soft);
  cursor: pointer;
}
.delete-dialog-btn:hover,
.delete-dialog-btn:focus-visible {
  background: var(--surface-hover);
  outline: none;
}
.delete-dialog-btn-danger {
  color: var(--danger-btn-fg);
  background: var(--danger-btn-bg);
  border-color: var(--danger);
}
.delete-dialog-btn-danger:hover,
.delete-dialog-btn-danger:focus-visible {
  color: var(--danger-btn-fg);
  background: var(--danger-btn-bg-hover);
  border-color: var(--danger-hover);
}

.delete-dialog-btn-primary {
  color: var(--accent-btn-fg);
  background: var(--accent-btn-bg);
  border-color: var(--accent);
}
.delete-dialog-btn-primary:hover,
.delete-dialog-btn-primary:focus-visible {
  color: var(--accent-btn-fg);
  background: var(--accent-btn-bg-hover);
  border-color: var(--accent-hover);
}

.prompt-dialog-input {
  margin-bottom: 18px;
}

/* ---------- Date field + calendar popover ---------- */

.notes-date-field {
  width: 100%;
}

/* When the underlying input is hidden, hide the whole field (trigger + clear),
   otherwise the absolutely-positioned icons float on their own. */
.notes-date-field:has(.notes-date-native-input[hidden]) {
  display: none;
}

.notes-date-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.notes-date-native-input {
  flex: 1 1 auto;
  min-width: 0;
  padding-right: 72px !important;
  cursor: pointer;
}

.notes-date-native-input::-webkit-calendar-picker-indicator {
  display: none;
}

.notes-date-trigger,
.notes-date-clear {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ui-ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.notes-date-trigger {
  right: 34px;
}

.notes-date-clear {
  right: 4px;
  font-size: 1.25rem;
  line-height: 1;
}

.notes-date-trigger svg {
  width: 16px;
  height: 16px;
}

.notes-date-trigger:hover,
.notes-date-trigger:focus-visible,
.notes-date-clear:hover,
.notes-date-clear:focus-visible {
  background: var(--surface-hover);
  color: var(--ui-ink);
  outline: none;
}

.notes-date-field.is-disabled .notes-date-trigger,
.notes-date-field.is-disabled .notes-date-clear,
.notes-date-trigger:disabled,
.notes-date-clear:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

#notes-date-popover.notes-date-popover {
  position: fixed;
  z-index: 122;
  width: min(280px, calc(100vw - 16px));
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-md);
  font-family: var(--ui-sans);
}

.notes-date-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.notes-date-popover-title {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-size: var(--ui-font-md);
  font-weight: 700;
  color: var(--ui-ink);
}

.notes-date-nav-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ui-ink-soft);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.notes-date-nav-btn:hover,
.notes-date-nav-btn:focus-visible {
  background: var(--surface-hover);
  color: var(--ui-ink);
  outline: none;
}

.notes-date-weekdays,
.notes-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.notes-date-weekdays {
  margin-bottom: 6px;
}

.notes-date-weekday {
  text-align: center;
  font-size: var(--ui-font-xs);
  font-weight: 600;
  color: var(--ui-ink-faint);
}

.notes-date-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ui-ink);
  font-family: inherit;
  font-size: var(--ui-font-sm);
  cursor: pointer;
}

.notes-date-day-empty {
  pointer-events: none;
}

.notes-date-day:hover:not(.is-disabled):not(.notes-date-day-empty),
.notes-date-day:focus-visible:not(.is-disabled) {
  background: var(--surface-hover);
  outline: none;
}

.notes-date-day.is-today {
  box-shadow: inset 0 0 0 1px var(--border-hover);
}

.notes-date-day.is-selected {
  background: var(--accent-btn-bg);
  color: var(--accent-btn-fg);
  font-weight: 700;
}

.notes-date-day.is-selected:hover,
.notes-date-day.is-selected:focus-visible {
  background: var(--accent-btn-bg-hover);
  color: var(--accent-btn-fg);
}

.notes-date-day.is-disabled {
  opacity: 0.35;
  cursor: default;
}

/* ---------- Share dialog ---------- */
.share-dialog {
  --share-section-gap: 16px;
  --share-label-gap: 8px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 121;
  width: min(420px, calc(100vw - 32px));
  padding: 22px 22px 18px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  font-family: var(--ui-sans);
}
.share-dialog[hidden] { display: none; }

.share-dialog:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: var(--share-section-gap);
}

.share-tabs {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 4px;
  background: var(--surface-hover);
  border-radius: var(--radius-lg, 12px);
}

.share-tabs.share-tabs-single {
  display: none;
}

.share-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 1 1 0;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius-md, 9px);
  background: transparent;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background var(--motion-fade), color var(--motion-fade);
}

.share-tab:hover {
  color: var(--ui-ink);
}

.share-tab.is-active {
  background: var(--paper);
  color: var(--ui-ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.share-tab-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.share-dialog-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-dialog-title {
  margin: 0;
  font-size: var(--ui-font-3xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ui-ink);
}

.share-dialog-hint {
  margin: 0;
  font-size: var(--ui-font-md);
  line-height: 1.45;
  color: var(--ink-soft);
}

.share-dialog-label {
  display: block;
  margin: 0;
  font-size: var(--ui-font-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.share-dialog-section,
.share-access-section,
.share-dialog-list-wrap,
.share-dialog-owner-block,
.public-dialog-url-wrap,
.public-dialog-expiry-section,
.public-dialog-password-section {
  display: flex;
  flex-direction: column;
  gap: var(--share-label-gap);
  margin: 0;
}

.share-dialog-manage-wrap,
.share-dialog-details-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--share-section-gap);
  margin: 0;
}

.share-dialog-details-wrap[hidden],
.share-dialog-manage-wrap[hidden] {
  display: none;
}

.share-dialog-owner-block {
  margin: 0;
}

.share-dialog-owner-name {
  margin: 0;
  padding: 10px 12px;
  font-size: var(--ui-font-xl);
  font-weight: 600;
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-muted);
}

.share-dialog-list-wrap[hidden] {
  display: none;
}

.share-dialog-list-readonly .share-dialog-list-item {
  padding-right: 12px;
}

.share-dialog-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-muted);
  overflow: hidden;
}

.share-dialog-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.share-dialog-list-item:last-child {
  border-bottom: none;
}

.share-dialog-list-name {
  font-size: var(--ui-font-lg);
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-dialog-list-remove {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: var(--ui-font-glyph);
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
}
.share-dialog-list-remove:hover,
.share-dialog-list-remove:focus-visible {
  color: var(--danger);
  background: var(--danger-surface);
  outline: none;
}

.share-dialog-add-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin: 0;
}
.share-dialog-add-row .share-dialog-input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  margin: 0;
}

.share-dialog-input {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  font-family: inherit;
  font-size: var(--ui-font-lg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}
.share-dialog-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-surface);
}

.share-dialog-error {
  margin: 0;
  font-size: var(--ui-font-md);
  color: var(--danger);
}
.share-dialog-error[hidden] { display: none; }

.share-dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.share-dialog-actions-spacer {
  flex: 1 1 auto;
}

.share-dialog-btn-danger {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
}
.share-dialog-btn-danger:hover,
.share-dialog-btn-danger:focus-visible {
  color: var(--danger);
  background: var(--danger-surface, rgba(200, 60, 60, 0.1));
  outline: none;
}

.share-dialog-btn {
  font-family: inherit;
  font-size: var(--ui-font-md);
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ui-ink-soft);
  cursor: pointer;
}
.share-dialog-btn:not(.share-dialog-btn-primary):hover,
.share-dialog-btn:not(.share-dialog-btn-primary):focus-visible {
  background: var(--surface-hover);
  outline: none;
}
.share-dialog-btn-primary {
  color: var(--accent-btn-fg);
  background: var(--accent-btn-bg);
  border-color: var(--accent);
}
.share-dialog-btn-primary:hover,
.share-dialog-btn-primary:focus-visible {
  color: var(--accent-btn-fg);
  background: var(--accent-btn-bg-hover);
  border-color: var(--accent);
  outline: none;
}
.share-dialog-btn-add {
  flex: 0 0 auto;
  align-self: stretch;
  padding-left: 14px;
  padding-right: 14px;
}

/* ---------- Mode picker (slash command) ---------- */
.mode-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: var(--overlay-light);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.mode-picker-backdrop[hidden],
.mode-picker[hidden] {
  display: none;
}

.mode-picker {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  width: min(340px, calc(100vw - 32px));
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 12px 0 8px;
  font-family: var(--ui-sans);
}

.mode-picker-title {
  margin: 0 0 6px;
  padding: 0 20px 10px;
  font-size: var(--ui-font-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ui-ink-faint);
  border-bottom: 1px solid var(--border-subtle);
}

.mode-picker-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

.mode-picker-item {
  display: block;
  width: 100%;
  padding: 12px 20px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--ui-font-lg);
  color: var(--ui-ink);
}

.mode-picker-item:hover,
.mode-picker-item.selected {
  background: var(--surface-hover);
}

.mode-picker-item .mode-name {
  display: block;
  color: var(--accent);
  font-weight: var(--accent-weight);
}

.mode-picker-item .mode-desc {
  display: block;
  margin-top: 2px;
  font-size: var(--ui-font-md);
  font-weight: 400;
  color: var(--ink-soft);
}

.mode-picker-list-extra {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

.mode-picker-item-help .mode-name {
  color: var(--ui-ink);
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
}

.mode-picker-item-help .mode-desc {
  color: var(--ui-ink-faint);
  font-style: italic;
}

.mode-picker-item-help:hover,
.mode-picker-item-help.selected {
  background: var(--accent-surface);
}

/* Public link viewer (/p/…) */
.public-view-page {
  overflow: hidden;
}

#app.public-view {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
}

.public-hintbar {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  height: var(--top-bar-height);
  padding: 0 12px 0 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  z-index: 5;
}

.public-hintbar-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.public-hintbar-brand-wrap {
  grid-column: 2;
  justify-self: center;
  min-width: 0;
  max-width: 100%;
}

.public-hintbar-actions {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.public-hintbar-brand {
  justify-content: center;
}

#public-settings-menu {
  max-height: none;
  overflow-y: visible;
}

#app.public-view .public-editor-wrap {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
}

/* Public link viewer — print the full note, not just the visible viewport. */
@media print {
  body.public-view-page,
  body.public-view-page #app.public-view {
    overflow: visible !important;
    height: auto !important;
    min-height: 0 !important;
    display: block !important;
  }

  body.public-view-page .public-hintbar,
  body.public-view-page #app-splash,
  body.public-view-page .public-gate,
  body.public-view-page .public-error,
  body.public-view-page #public-settings-menu,
  body.public-view-page #public-settings-backdrop,
  body.public-view-page .math-ac,
  body.public-view-page .bible-tr-ac,
  body.public-view-page .rates-tooltip,
  body.public-view-page .cm-cursor,
  body.public-view-page .cm-selectionBackground {
    display: none !important;
  }

  body.public-view-page .public-editor-wrap,
  body.public-view-page .editor-wrap {
    position: relative !important;
    flex: none !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    break-inside: auto;
    page-break-inside: auto;
  }

  body.public-view-page #editor.cm-editor-host,
  body.public-view-page #editor.cm-editor-mount {
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  body.public-view-page #editor .cm-editor {
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Keep gutter + content side by side (block stacking misaligns list checkboxes). */
  body.public-view-page #editor .cm-scroller {
    overflow: visible !important;
    height: auto !important;
    min-height: 0 !important;
    display: flex !important;
    align-items: flex-start !important;
    position: relative !important;
  }

  body.public-view-page #editor .cm-content {
    min-height: 0 !important;
    height: auto !important;
    flex: 1 1 auto !important;
  }

  body.public-view-page #editor .cm-gutters {
    height: auto !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.public-view-page #editor .cm-gutter {
    overflow: visible !important;
    min-height: 0 !important;
  }

  /* Checked boxes use accent fill + SVG; browsers often skip backgrounds when printing. */
  body.public-view-page #editor .cm-list-gutter .li-check-btn-checked {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body.public-view-page #editor .cm-list-gutter .li-check-btn-checked::after {
    content: '';
    display: block;
    width: calc(var(--list-check-size) * 0.27);
    height: calc(var(--list-check-size) * 0.47);
    /* Ink checkmark stays visible even when “Background graphics” is off. */
    border: solid var(--ink);
    border-width: 0 calc(var(--list-check-size) * 0.13) calc(var(--list-check-size) * 0.13) 0;
    transform: rotate(45deg) translate(-1px, -1px);
  }

  body.public-view-page #editor .cm-list-gutter .li-check-btn-checked .li-check-icon {
    display: none;
  }

  /* Kanban public notes: unclip columns and card lists. */
  body.public-view-page .kanban-board {
    flex: none !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
  }

  body.public-view-page .kanban-toolbar,
  body.public-view-page .kanban-column-head button,
  body.public-view-page .kanban-add-column-btn,
  body.public-view-page .kanban-add-card-btn {
    display: none !important;
  }

  body.public-view-page .kanban-columns {
    flex: none !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
    flex-wrap: wrap !important;
    align-items: flex-start !important;
  }

  body.public-view-page .kanban-column {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.public-view-page .kanban-cards-wrap,
  body.public-view-page .kanban-cards {
    flex: none !important;
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
  }

  body.public-view-page .kanban-cards-wrap::after,
  body.public-view-page .kanban-cards::before {
    display: none !important;
  }
}

.public-gate,
.public-error {
  position: fixed;
  top: var(--top-bar-height);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px 40px;
  box-sizing: border-box;
  overflow: hidden;
  background-color: var(--paper);
}

.public-gate::before,
.public-error::before {
  content: '';
  position: absolute;
  inset: -44px;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--public-gate-dot) 1px, transparent 1px);
  background-size: 22px 22px;
  animation: public-gate-dot-drift 56s linear infinite;
}

.public-gate[hidden],
.public-error[hidden] {
  display: none;
}

.public-gate-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  font-family: var(--ui-sans);
}

.public-gate-enter {
  animation: public-gate-enter 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.public-gate-title {
  margin: 0 0 8px;
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ui-ink);
}

.public-gate-lead {
  margin: 0 0 24px;
  font-size: var(--ui-font-lg);
  line-height: 1.5;
  color: var(--ui-ink-soft);
}

@keyframes public-gate-dot-drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(22px, 22px, 0);
  }
}

@keyframes public-gate-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .public-gate::before,
  .public-error::before {
    animation: none;
  }

  .public-gate-enter {
    animation: none;
  }

  .public-gate-btn,
  .public-gate-input {
    transition: none;
  }
}

.public-gate-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.public-gate-field-label {
  font-size: var(--ui-font-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ui-ink-faint);
}

.public-gate-input {
  width: 100%;
  box-sizing: border-box;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ui-ink);
  font-family: var(--ui-sans);
  font-size: var(--ui-font-lg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.public-gate-input::placeholder {
  color: var(--ui-ink-faint);
  opacity: 0.85;
}

.public-gate-input:hover {
  border-color: var(--border-hover);
}

.public-gate-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.public-dialog-select,
.public-dialog-datetime {
  width: 100%;
}

.public-gate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 4px;
  padding: 13px 20px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  background: var(--accent-btn-bg);
  color: var(--accent-btn-fg);
  font-family: var(--ui-sans);
  font-size: var(--ui-font-lg);
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.1s ease;
}

.public-gate-btn:hover {
  background: var(--accent-btn-bg-hover);
  border-color: var(--accent);
  color: var(--accent-btn-fg);
}

.public-gate-btn:active {
  transform: scale(0.985);
}

.public-gate-error {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(180, 35, 24, 0.22);
  border-radius: var(--radius-md);
  background: var(--danger-surface);
  color: var(--danger);
  font-size: var(--ui-font-md);
  font-weight: 500;
}

.public-gate-error[hidden] {
  display: none;
}

.share-access-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.share-access-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ink-muted);
  font-size: var(--ui-font-md);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.share-access-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-surface);
  color: var(--ink);
}

.share-access-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.share-access-option span {
  pointer-events: none;
}

.public-dialog-expiry-section .share-dialog-input {
  margin: 0;
}

.public-dialog-expiry-status {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 11px 13px;
  border: 1px solid var(--public-ring);
  border-radius: var(--radius-md);
  background: var(--public-surface);
}

.public-dialog-expiry-status-text {
  flex: 1 1 auto;
  min-width: 0;
}

.public-dialog-expiry-status-headline {
  display: block;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-lg);
  font-weight: 600;
  line-height: 1.3;
  color: var(--public-accent);
}

.public-dialog-expiry-status.is-never .public-dialog-expiry-status-headline {
  color: var(--ui-ink);
}

.public-dialog-expiry-status.is-expired .public-dialog-expiry-status-headline,
.public-dialog-expiry-status.is-invalid .public-dialog-expiry-status-headline {
  color: var(--danger);
}

.public-dialog-expiry-status-detail {
  display: block;
  margin-top: 2px;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-sm);
  line-height: 1.45;
  color: var(--ui-ink-soft);
}

.public-dialog-expiry-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ui-ink-faint);
  cursor: pointer;
}

.public-dialog-expiry-clear:hover,
.public-dialog-expiry-clear:focus-visible {
  color: var(--danger);
  background: var(--danger-surface);
  outline: none;
}

.public-dialog-expiry-clear svg {
  width: 16px;
  height: 16px;
}

.public-dialog-expiry-clear[hidden] {
  display: none;
}

.public-dialog-expiry-pickers {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.public-dialog-expiry-pickers[hidden] {
  display: none;
}

.public-dialog-datetime[hidden] {
  display: none;
}

.public-link-lock-icon {
  width: 15px;
  height: 15px;
  display: block;
}

.notes-public-status {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.notes-public-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--public-accent);
}

.notes-public-status-expiry {
  min-width: 0;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-sm);
  font-weight: 400;
  line-height: 1.45;
  color: var(--ui-ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-public-status-expiry.is-expired {
  color: var(--danger);
}

.public-dialog-url-wrap[hidden] {
  display: none;
}

.public-dialog-url-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin: 0;
}
.public-dialog-url-row .share-dialog-input {
  margin: 0;
}

.public-dialog-url {
  flex: 1;
  min-width: 0;
  font-size: var(--ui-font-md);
}

.public-dialog-url-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  align-items: stretch;
}

.public-dialog-url-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  min-width: 38px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--ui-ink-soft);
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.public-dialog-url-icon-btn:hover,
.public-dialog-url-icon-btn:focus-visible {
  color: var(--ui-ink);
  background: var(--surface-hover);
  outline: none;
}

.public-dialog-url-icon-btn.is-copied {
  color: var(--accent-btn-fg);
  background: var(--accent-btn-bg);
  border-color: var(--accent);
}

.public-dialog-url-icon-btn.is-copied:hover,
.public-dialog-url-icon-btn.is-copied:focus-visible {
  color: var(--accent-btn-fg);
  background: var(--accent-btn-bg-hover);
  border-color: var(--accent);
}

.public-dialog-url-icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.public-dialog-url-icon-check {
  display: none;
}

.public-dialog-url-icon-btn.is-copied .public-dialog-url-icon-copy {
  display: none;
}

.public-dialog-url-icon-btn.is-copied .public-dialog-url-icon-check {
  display: block;
}

.public-dialog-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.public-dialog-password-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.public-dialog-password-save {
  flex: 0 0 auto;
  align-self: stretch;
  padding: 0 16px;
  border-radius: 8px;
  line-height: 1.2;
  white-space: nowrap;
  font-size: var(--ui-font-md);
}

.public-dialog-password-save[hidden] {
  display: none;
}

.public-dialog-password-save:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.public-dialog-password-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.public-dialog-password-wrap .public-dialog-password-input {
  margin: 0;
  padding-right: 40px;
}

.public-dialog-password-input.is-visible {
  -webkit-text-security: none;
  text-security: none;
}

.public-dialog-password-wrap.is-locked .public-dialog-password-input {
  padding-right: 72px;
  background: var(--surface-muted);
  color: var(--ui-ink-soft);
  border-color: var(--border);
  cursor: default;
}

.public-dialog-password-wrap.is-locked .public-dialog-password-input:focus {
  border-color: var(--border);
  box-shadow: none;
}

.public-dialog-password-actions {
  position: absolute;
  top: 50%;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 2px;
  transform: translateY(-50%);
}

.public-dialog-password-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ui-ink-faint);
  cursor: pointer;
}

.public-dialog-password-action:hover,
.public-dialog-password-action:focus-visible {
  color: var(--ui-ink-soft);
  background: var(--surface-hover);
  outline: none;
}

.public-dialog-password-clear:hover,
.public-dialog-password-clear:focus-visible {
  color: var(--danger);
  background: var(--danger-surface);
}

.public-dialog-password-action svg {
  width: 16px;
  height: 16px;
}

.public-dialog-password-action[hidden] {
  display: none;
}

.public-dialog-password-toggle .icon-eye-off {
  display: none;
}

.public-dialog-password-toggle.is-visible .icon-eye {
  display: none;
}

.public-dialog-password-toggle.is-visible .icon-eye-off {
  display: block;
}

.share-dialog-btn-primary.public-dialog-create {
  background: var(--public-accent);
  border-color: var(--public-accent);
}

/* Public link dialog — type scale tweaks on top of shared spacing. */
.public-dialog .share-dialog-title {
  font-size: var(--ui-font-2xl);
}

.public-dialog .share-dialog-label {
  font-size: var(--ui-font-xs);
  letter-spacing: 0.06em;
}

.public-dialog .share-dialog-input {
  margin: 0;
  padding: 9px 12px;
  font-size: var(--ui-font-md);
}

/* Keep room for the inline eye / clear icons (shorthand above would clobber it). */
.public-dialog .public-dialog-password-wrap .public-dialog-password-input {
  padding-right: 40px;
}
.public-dialog .public-dialog-password-wrap.is-locked .public-dialog-password-input {
  padding-right: 72px;
}

.public-dialog .share-dialog-error {
  margin: 0;
  font-size: var(--ui-font-sm);
}

.public-dialog .share-dialog-actions {
  margin: 0;
}

.public-dialog .share-dialog-btn {
  font-size: var(--ui-font-md);
}

/* ---------- Kanban mode ---------- */

:root {
  --kanban-gray: #9ca3af;
  --kanban-red: #ef4444;
  --kanban-orange: #f97316;
  --kanban-yellow: #eab308;
  --kanban-green: #22c55e;
  --kanban-blue: #3b82f6;
  --kanban-purple: #a855f7;
}

.kanban-board {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
}

#app[data-mode="kanban"] .editor-wrap {
  display: none;
}

#app[data-mode="kanban"] .kanban-board:not([hidden]) {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

#app.public-view[data-mode="kanban"] .public-editor-wrap {
  display: none;
}

.kanban-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 0;
}

.kanban-board-title-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.kanban-board-title {
  display: inline;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 0 3px;
  border: none;
  border-radius: 3px;
  background: var(--paper);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  font-family: var(--ui-sans);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ui-ink);
}

input.kanban-board-title {
  display: inline-block;
  field-sizing: content;
  min-width: 11ch;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
}

.kanban-board-title::placeholder {
  color: var(--ink-faint);
  font-weight: 600;
}

.kanban-board-title:hover {
  border-color: var(--border);
  background: var(--surface-hover);
}

.kanban-board-title:focus {
  outline: none;
  border-color: var(--accent-ring);
  background: var(--paper);
  box-shadow: 0 0 0 3px var(--accent-ring-soft, rgba(59, 130, 246, 0.22));
}


.kanban-add-column-btn {
  flex: 0 0 auto;
}

.kanban-toolbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 0;
}

.kanban-toolbar-menu-wrap {
  position: relative;
}

.kanban-board-menu.settings-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 260px;
  max-width: min(320px, calc(100vw - 32px));
  max-height: min(70vh, 420px);
  overflow-y: auto;
}

.kanban-board-menu .kanban-col-reorder-list {
  margin-top: 4px;
}

.kanban-col-reorder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  cursor: grab;
  user-select: none;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    opacity 0.15s ease;
}

.kanban-col-reorder-item:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.kanban-col-reorder-item.kanban-col-reorder-dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.kanban-col-reorder-item.kanban-col-reorder-drop-target {
  border-color: var(--accent-ring);
  outline: 1px dashed var(--accent-ring);
  outline-offset: -1px;
}

.kanban-col-reorder-grip {
  flex: 0 0 auto;
  color: var(--ink-faint);
  font-size: 0.7rem;
  letter-spacing: -0.12em;
  line-height: 1;
  pointer-events: none;
}

.kanban-col-reorder-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-sm);
  font-weight: 600;
  color: var(--ui-ink);
}

.kanban-col-reorder-delete {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: 4px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: color 0.15s ease, background 0.15s ease;
}

.kanban-col-reorder-delete:hover,
.kanban-col-reorder-delete:focus-visible {
  color: var(--danger);
  background: var(--danger-surface);
  outline: none;
}

.kanban-col-reorder-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kanban-columns {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: calc(28px / 3);
  padding: 4px 16px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: stretch;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.kanban-column {
  flex: 0 0 272px;
  flex-shrink: 0;
  width: 272px;
  min-width: 272px;
  max-width: 272px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  align-self: stretch;
  background: var(--surface-muted);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: none;
  padding: 0;
}

.kanban-column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 12px;
  margin-bottom: 6px;
  border: none;
  background: var(--paper);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 1px 0 var(--border);
}

.kanban-board-readonly .kanban-column-head {
  cursor: default;
}

.kanban-column-head-spacer {
  flex: 1 1 auto;
  min-width: 4px;
}

.kanban-column-title {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: -6px;
  padding: 3px 6px;
  border-radius: 6px;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--ui-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.12s ease;
}

.kanban-board:not(.kanban-board-readonly) .kanban-column-title {
  cursor: text;
}

.kanban-board:not(.kanban-board-readonly) .kanban-column-title:hover,
.kanban-board:not(.kanban-board-readonly) .kanban-column-title:focus-visible {
  background: var(--surface-hover);
  outline: none;
}

.kanban-column-title-input {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: -6px;
  padding: 3px 6px;
  border: 1px solid var(--accent-ring);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ui-ink);
  font-family: var(--ui-sans);
  font-size: var(--ui-font-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.kanban-column-title-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring-soft, rgba(59, 130, 246, 0.22));
}

.kanban-column-menu-wrap {
  position: relative;
  flex: 0 0 auto;
}

.kanban-column-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.kanban-column-menu-btn .hint-icon {
  width: 17px;
  height: 17px;
}

.kanban-column-menu-btn:hover,
.kanban-column-menu-btn:focus-visible,
.kanban-column-menu-btn[aria-expanded="true"] {
  background: var(--surface-hover);
  color: var(--ui-ink);
  outline: none;
}

.kanban-column-menu.settings-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 45;
  min-width: 190px;
  max-width: min(240px, calc(100vw - 32px));
}

.kanban-column-menu.settings-menu[hidden] {
  display: none;
}

.kanban-column-count {
  flex: 0 0 auto;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
  font-weight: 600;
  color: var(--ink-faint);
}

.kanban-column-add {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.kanban-column-add-icon {
  width: 17px;
  height: 17px;
}

.kanban-column-add:hover,
.kanban-column-add:focus-visible {
  background: var(--surface-hover);
  color: var(--ui-ink);
  outline: none;
}

.kanban-cards-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.kanban-cards-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 20px;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s ease;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.1) 0%, transparent 100%);
}

html[data-theme="dark"] .kanban-cards-wrap::after {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.38) 0%, transparent 100%);
}

.kanban-cards-wrap.has-fade-bottom::after {
  opacity: 1;
}

.kanban-cards {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kanban-cards::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 20px;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1) 0%, transparent 100%);
}

html[data-theme="dark"] .kanban-cards::before {
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.38) 0%, transparent 100%);
}

.kanban-cards-wrap.has-fade-top .kanban-cards::before {
  opacity: 1;
}

.kanban-cards.kanban-drag-over {
  background: transparent;
  outline: none;
}

.kanban-card {
  position: relative;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    box-shadow 0.15s ease,
    transform 0.15s ease,
    border-color 0.15s ease;
  overflow: hidden;
}

.kanban-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
}

.kanban-card.kanban-dragging {
  opacity: 0.45;
}

.kanban-card.kanban-drag-source {
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.kanban-card-placeholder {
  flex: 0 0 auto;
  box-sizing: border-box;
  border: 2px dashed var(--accent-ring);
  border-radius: var(--radius-md);
  background: var(--surface-hover);
  opacity: 0.85;
  transition: height 0.22s cubic-bezier(0.2, 0, 0, 1);
}

.kanban-card.kanban-card-shift {
  transition: transform 0.22s cubic-bezier(0.2, 0, 0, 1) !important;
}

.kanban-card-stripe {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.kanban-label-gray .kanban-card-stripe { background: var(--kanban-gray); }
.kanban-label-red .kanban-card-stripe { background: var(--kanban-red); }
.kanban-label-orange .kanban-card-stripe { background: var(--kanban-orange); }
.kanban-label-yellow .kanban-card-stripe { background: var(--kanban-yellow); }
.kanban-label-green .kanban-card-stripe { background: var(--kanban-green); }
.kanban-label-blue .kanban-card-stripe { background: var(--kanban-blue); }
.kanban-label-purple .kanban-card-stripe { background: var(--kanban-purple); }

.kanban-card-body {
  padding: 10px 12px 10px 14px;
}

.kanban-card-title {
  margin: 0;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
  font-weight: 600;
  line-height: 1.35;
  color: var(--ui-ink);
}

.kanban-card-title.is-placeholder {
  font-weight: 500;
  color: var(--ui-ink-faint);
}

.kanban-card-desc {
  margin: 6px 0 0;
  font-family: var(--ui-sans);
  font-size: var(--ui-font-sm);
  line-height: 1.45;
  color: var(--ui-ink-soft);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.kanban-card-due {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--ui-sans);
  font-size: var(--ui-font-xs);
  font-weight: 600;
  background: var(--surface-hover);
  color: var(--ui-ink-soft);
}

.kanban-card-due.is-overdue {
  background: var(--danger-surface);
  color: var(--danger);
}

.kanban-board-readonly .kanban-toolbar {
  display: none;
}

.kanban-board-readonly .kanban-card {
  cursor: default;
}

/* Kanban card detail panel */
.kanban-detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.kanban-detail-backdrop.is-open {
  opacity: 1;
}

.kanban-detail-backdrop[hidden] {
  display: none;
}

.kanban-detail {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 91;
  width: min(420px, 100vw);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.08);
  font-family: var(--ui-sans);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.kanban-detail.is-open {
  transform: none;
}

.kanban-detail[hidden] {
  display: none;
}

.kanban-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-sizing: border-box;
  height: var(--top-bar-height);
  min-height: var(--top-bar-height);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.kanban-detail-title {
  margin: 0;
  font-size: var(--ui-font-lg);
  font-weight: 700;
  color: var(--ui-ink);
}

.kanban-detail-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.kanban-detail-edit-btn[hidden] {
  display: none;
}

.kanban-detail-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ui-ink-soft);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.kanban-detail-close:hover {
  background: var(--surface-hover);
}

.kanban-detail-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kanban-detail-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kanban-detail-view[hidden],
.kanban-detail-edit[hidden] {
  display: none;
}

.kanban-detail-edit {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kanban-detail-view-title {
  margin: 0;
  font-family: var(--ui-sans);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--ui-ink);
}

.kanban-detail-view-title.is-placeholder {
  font-weight: 500;
  color: var(--ui-ink-faint);
}

.kanban-detail-view-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kanban-detail-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  font-family: var(--ui-sans);
  font-size: var(--ui-font-sm);
  font-weight: 600;
  color: var(--ui-ink-soft);
}

.kanban-detail-meta-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.kanban-detail-meta-swatch.kanban-label-gray { background: var(--kanban-gray); }
.kanban-detail-meta-swatch.kanban-label-red { background: var(--kanban-red); }
.kanban-detail-meta-swatch.kanban-label-orange { background: var(--kanban-orange); }
.kanban-detail-meta-swatch.kanban-label-yellow { background: var(--kanban-yellow); }
.kanban-detail-meta-swatch.kanban-label-green { background: var(--kanban-green); }
.kanban-detail-meta-swatch.kanban-label-blue { background: var(--kanban-blue); }
.kanban-detail-meta-swatch.kanban-label-purple { background: var(--kanban-purple); }

.kanban-detail-meta-due.is-overdue {
  background: var(--danger-surface);
  color: var(--danger);
}

.kanban-detail-view-desc {
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
  line-height: 1.55;
  color: var(--ui-ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.kanban-detail-view-desc[hidden] {
  display: none;
}

.kanban-detail-view-desc a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.kanban-detail-view-desc a:hover,
.kanban-detail-view-desc a:focus-visible {
  color: var(--accent-hover, var(--accent));
  outline: none;
}

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

.kanban-detail-label {
  font-size: var(--ui-font-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ui-ink-faint);
}

.kanban-detail-input,
.kanban-detail-textarea,
.kanban-detail-select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ui-ink);
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
}

.kanban-detail-textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}

.kanban-detail-input:focus,
.kanban-detail-textarea:focus,
.kanban-detail-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.kanban-label-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kanban-label-picker.is-readonly {
  pointer-events: none;
  opacity: 0.75;
}

.kanban-label-swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.kanban-label-swatch.is-selected {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent);
  transform: scale(1.06);
}

.kanban-label-swatch.kanban-label-gray { background: var(--kanban-gray); }
.kanban-label-swatch.kanban-label-red { background: var(--kanban-red); }
.kanban-label-swatch.kanban-label-orange { background: var(--kanban-orange); }
.kanban-label-swatch.kanban-label-yellow { background: var(--kanban-yellow); }
.kanban-label-swatch.kanban-label-green { background: var(--kanban-green); }
.kanban-label-swatch.kanban-label-blue { background: var(--kanban-blue); }
.kanban-label-swatch.kanban-label-purple { background: var(--kanban-purple); }

.kanban-detail-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
}

.kanban-detail-btn {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--ui-ink);
  font-family: var(--ui-sans);
  font-size: var(--ui-font-md);
  font-weight: 600;
  cursor: pointer;
}

.kanban-detail-btn:hover {
  background: var(--surface-hover);
}

.kanban-detail-btn-primary {
  color: var(--accent-btn-fg);
  background: var(--accent-btn-bg);
  border-color: var(--accent);
}

.kanban-detail-btn-primary:hover {
  background: var(--accent-btn-bg-hover);
}

.kanban-detail-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--ui-ink);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.kanban-detail-delete svg {
  width: 18px;
  height: 18px;
}

.kanban-detail-delete:hover,
.kanban-detail-delete:focus-visible {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.30);
  background: var(--danger-surface);
  outline: none;
}

body.kanban-dragging-active {
  cursor: grabbing;
  -webkit-user-select: none;
  user-select: none;
}

.kanban-card-clone {
  position: fixed;
  z-index: 200;
  margin: 0;
  pointer-events: none;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.24);
  opacity: 0.96;
  overflow: hidden;
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .kanban-detail,
  .kanban-detail-backdrop {
    transition: none;
  }
}

@media (max-width: 768px) {
  .kanban-columns {
    scroll-snap-type: x proximity;
    scroll-padding-inline: 16px;
  }

  .kanban-column {
    flex: 0 0 300px;
    flex-shrink: 0;
    width: 300px;
    min-width: 300px;
    max-width: 300px;
    scroll-snap-align: start;
  }

  .kanban-cards {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  /* Bottom sheet: slide up from the bottom with rounded top corners. */
  .kanban-detail {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 88vh;
    max-height: 88dvh;
    border-left: none;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.22);
    transform: translateY(100%);
    padding-top: 12px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .kanban-detail.is-open {
    transform: translateY(0);
  }

  .kanban-detail::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--border);
    z-index: 1;
  }

  /* Prevent iOS/Android auto-zoom when focusing form controls. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  textarea,
  select {
    font-size: 16px;
  }

  /* Public link dialog — centered modal, matching the People tab. The form is
     taller than People, so cap its height to the viewport and scroll inside
     rather than overflowing off-screen. */
  .public-dialog.share-dialog {
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Keep the dialog's controls on the same type scale as desktop — the global
     16px anti-zoom rule above doesn't apply here (zoom is disabled via viewport). */
  .public-dialog input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  .public-dialog select:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  .public-dialog textarea {
    font-size: var(--ui-font-md);
  }

}

/* ---------- Scrollbars ---------- */
/* Hide scrollbars entirely while keeping scroll functional (wheel/trackpad/keys). */
* {
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* old Edge/IE */
}

*::-webkit-scrollbar {          /* Chrome/Safari/WebKit */
  width: 0;
  height: 0;
  display: none;
}

