/* ==========================================================================
   cocyrus — High-Density Warm Editorial Outliner
   Designed for tight ultrawide side-docks & phone screens with zero waste.
   Light: Warm Paper & Ink  |  Dark: Warm Charcoal & Amber-Vermilion
   ========================================================================== */

:root {
  color-scheme: light;
  --bg-canvas: #faf9f6;
  --bg-rail: #f3f0ea;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f4f1ea;
  --bg-subtle: #edeae2;
  --bg-input: #ffffff;
  --bg-active-block: #f4f0e6;

  --border: #e5e0d5;
  --border-subtle: #eeeae0;
  --guide-line: #e2ddd2;
  --guide-line-hover: #c5bdb0;

  --text-primary: #1f1d1a;
  --text-secondary: #5c564e;
  --text-muted: #8f887d;
  --text-done: #9b9489;

  --accent: #d45236;
  --accent-soft: #fdf0ec;
  --accent-border: #f4c8bc;
  --accent-hover: #b84228;

  --green: #2c7a5b;
  --green-soft: #e9f5ef;
  --green-border: #b8dfc9;

  --link: #365d8f;
  --link-soft: #eef3fa;
  --link-bracket: #9bb1cc;

  --tag-bg: #efe9dc;
  --tag-text: #6d5a3b;

  --ref-bar: #5b829e;
  --ref-bg: rgba(91, 130, 158, 0.06);

  --shadow-sm: 0 1px 2px rgba(31, 29, 26, 0.05);
  --shadow-md: 0 5px 16px rgba(31, 29, 26, 0.09), 0 1px 2px rgba(31, 29, 26, 0.05);
  --shadow-lg: 0 14px 38px rgba(31, 29, 26, 0.16), 0 2px 6px rgba(31, 29, 26, 0.07);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-pill: 999px;

  --topbar-h: 36px;
  --left-rail-w: 184px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-canvas: #0f171a;
  --bg-rail: #131e22;
  --bg-surface: #172429;
  --bg-surface-hover: #1d2d33;
  --bg-subtle: #1c2b31;
  --bg-input: #111a1e;
  --bg-active-block: #1b2c32;

  --border: #24373e;
  --border-subtle: #1c2b31;
  --guide-line: #22343b;
  --guide-line-hover: #3d5d67;

  --text-primary: #e4eef0;
  --text-secondary: #9eb5bd;
  --text-muted: #68828c;
  --text-done: #58727b;

  --accent: #3ec4ab;
  --accent-soft: rgba(62, 196, 171, 0.14);
  --accent-border: rgba(62, 196, 171, 0.36);
  --accent-hover: #53d4bc;

  --green: #4ad092;
  --green-soft: rgba(74, 208, 146, 0.14);
  --green-border: rgba(74, 208, 146, 0.36);

  --link: #70b7ee;
  --link-soft: rgba(112, 183, 238, 0.13);
  --link-bracket: #4a789c;

  --tag-bg: #182e34;
  --tag-text: #7ed0c6;

  --ref-bar: #4ea2b8;
  --ref-bg: rgba(78, 162, 184, 0.085);

  --shadow-sm: 0 1px 2px rgba(4, 10, 12, 0.32);
  --shadow-md: 0 6px 20px rgba(4, 10, 12, 0.42);
  --shadow-lg: 0 18px 44px rgba(4, 10, 12, 0.62);
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body[data-resizing="true"] {
  user-select: none;
  cursor: col-resize;
}

body[data-block-selecting="true"] {
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

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

button {
  cursor: pointer;
}

.boot-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: var(--text-muted);
  font-size: 13px;
}

/* Icons */
.icon,
.icon-sm,
.icon-xs,
.icon-xxs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon svg { width: 16px; height: 16px; }
.icon-sm svg { width: 14px; height: 14px; }
.icon-xs svg { width: 12.5px; height: 12.5px; }
.icon-xxs svg { width: 10px; height: 10px; }
.muted-ico { color: var(--text-muted); }

/* ==========================================================================
   App Shell Layout
   ========================================================================== */

#app,
.app-shell {
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workspace-body {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.pane-slot {
  display: contents;
}

.mobile-rail-backdrop {
  display: none;
}

/* ==========================================================================
   Compact Topbar & Pomodoro Focus Dock
   ========================================================================== */

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  background: var(--bg-rail);
  border-bottom: 1px solid var(--border);
  gap: 5px;
  z-index: 20;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.sync-dev-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 1px 4px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-muted);
  user-select: none;
}

.sync-dot-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  border-radius: var(--radius-xs);
  padding: 0;
}

.sync-dot-btn:hover {
  background: var(--bg-subtle);
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.sync-dot-btn.is-synced .sync-dot {
  background: var(--green);
  box-shadow: 0 0 0 2px var(--green-soft);
}

.sync-dot-btn.is-connecting .sync-dot {
  background: var(--link);
  opacity: 0.7;
}

.sync-dot-btn.is-offline .sync-dot {
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.topbar-center {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  padding: 0;
  transition: background 0.1s, color 0.1s;
}

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

.icon-btn.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.topbar-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.topbar-pill-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--guide-line-hover);
}

.topbar-pill-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
}

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

/* Idle Pomodoro Launcher */
.pomo-idle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  max-width: 100%;
}

.pomo-idle-icon {
  color: var(--accent);
}

.pomo-idle-text {
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.pomo-quick-btn {
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  color: var(--text-primary);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  padding: 1px 6px;
  line-height: 1.3;
  transition: all 0.1s;
}

.pomo-quick-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Engaged Live Pomodoro Dock */
.pomo-dock {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px 2px 5px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--accent-border);
  max-width: 100%;
  min-width: 0;
  transition: all 0.15s ease;
}

.pomo-dock.is-running.mode-focus {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.pomo-dock.mode-break {
  background: var(--green-soft);
  border-color: var(--green-border);
}

.pomo-ring-wrap,
.pomo-ring {
  width: 17px;
  height: 17px;
}

.pomo-ring-bg {
  stroke: var(--border);
}

.pomo-ring-fg {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s linear;
}

.pomo-dock.mode-break .pomo-ring-fg {
  stroke: var(--green);
}

.pomo-dock-time {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  min-width: 40px;
}

.pomo-mode-pill {
  border: none;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.pomo-mode-pill:hover {
  background: var(--border);
  color: var(--text-primary);
}

.pomo-dock-label {
  border: none;
  background: transparent;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 170px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 1px 3px;
  border-radius: 3px;
}

.pomo-dock-label:hover {
  background: var(--bg-subtle);
}

.pomo-ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 21px;
  min-width: 21px;
  padding: 0 4px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

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

.pomo-ctrl-btn.is-primary {
  background: var(--accent);
  color: #fff;
}

.pomo-ctrl-btn.is-primary:hover {
  background: var(--accent-hover);
}

.pomo-dock.mode-break .pomo-ctrl-btn.is-primary {
  background: var(--green);
}

.pomo-ctrl-btn.is-finish {
  color: var(--green);
}

.pomo-ctrl-btn.is-finish:hover {
  background: var(--green-soft);
}

/* ==========================================================================
   Tight Left Navigation Rail
   ========================================================================== */

.left-rail {
  width: var(--left-rail-w);
  flex-shrink: 0;
  background: var(--bg-rail);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 4px;
  overflow-y: auto;
  gap: 6px;
}

.left-rail.is-collapsed {
  display: none;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 4px 2px;
}

.brand-mark,
.brand-mark svg {
  width: 17px;
  height: 17px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.rail-item,
.rail-page-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
}

.rail-item:hover,
.rail-page-item:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.rail-item.is-active,
.rail-page-item.is-active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.rail-item-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-page-ico {
  color: var(--text-muted);
}

.rail-count-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 0 5px;
  height: 15px;
  line-height: 15px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
}

.rail-count-muted {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* Compact Mini Calendar */
.mini-cal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 4px 4px;
}

.mini-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
  padding: 0 1px;
}

.mini-cal-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
}

.mini-cal-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 3px;
  padding: 0;
}

.mini-cal-nav:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.mini-cal-weekdays,
.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
}

.mini-cal-wd {
  text-align: center;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding-bottom: 2px;
}

.mini-cal-day {
  position: relative;
  height: 21px;
  border: none;
  background: transparent;
  border-radius: 4px;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.mini-cal-day:hover {
  background: var(--bg-subtle);
}

.mini-cal-day.is-outside {
  color: var(--text-muted);
  opacity: 0.4;
}

.mini-cal-day.is-today {
  font-weight: 700;
  color: var(--accent);
}

.mini-cal-day.is-selected {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.mini-cal-dot {
  position: absolute;
  bottom: 1px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
}

.mini-cal-day.is-selected .mini-cal-dot {
  background: #fff;
}

/* Rail Section */
.rail-section {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.rail-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 2px 6px;
}

.rail-spacer {
  flex: 1;
}

.rail-footer {
  border-top: 1px solid var(--border);
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rail-sync-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--bg-subtle);
  font-size: 10px;
  color: var(--text-secondary);
}

.sync-dot {
  width: 5.5px;
  height: 5.5px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.rail-footer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   Main Center Pane — Edge-to-Edge Dense Workspace
   ========================================================================== */

.main-pane {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background: var(--bg-canvas);
  padding: 5px 5px 32px 2px;
}

.page-container {
  max-width: 100%;
  margin: 0;
}

.zoom-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 4px;
  padding-left: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.crumb-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11.5px;
}

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

.crumb-sep {
  color: var(--text-muted);
}

.crumb-current {
  font-weight: 600;
  color: var(--text-primary);
  padding: 1px 3px;
}

.page-header {
  margin-bottom: 6px;
  padding: 0 2px 5px 4px;
  border-bottom: 1px solid var(--border-subtle);
}

.page-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.page-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 6px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.daily-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  padding: 0;
}

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

.daily-today-pill {
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
}

.daily-today-pill.is-today {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
  font-weight: 600;
}

.daily-today-pill:hover {
  border-color: var(--accent);
}

.subtle-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

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

.subtle-action-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

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

.page-kind-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.page-title,
.page-title-input {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary);
  margin: 0;
  min-width: 0;
}

.page-title.is-zoomed {
  font-size: 18px;
}

.page-title-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  padding: 0;
}

.page-stats-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 5px;
}

.stats-progress-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stats-progress-track {
  width: 68px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  overflow: hidden;
}

.stats-progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--green);
  transition: width 0.2s ease;
}

.stats-text {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.stats-pomo-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Dense Outliner Tree & Blocks
   ========================================================================== */

.outliner-tree {
  display: flex;
  flex-direction: column;
}

.block-node {
  position: relative;
}

.block-node.is-section-root {
  margin-top: 7px;
}

.block-node.is-section-root:first-child {
  margin-top: 0;
}

.block-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 1px 3px 1px 0;
  border-radius: var(--radius-xs);
  transition: background 0.08s;
  min-height: 22px;
}

.block-node.is-dragging {
  opacity: 0.42;
}

.block-row.drop-before::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 2px;
  top: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  pointer-events: none;
  z-index: 5;
}

.block-row.drop-after::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 2px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  pointer-events: none;
  z-index: 5;
}

.block-row.drop-inside {
  background: var(--accent-soft);
}

.block-row.drop-inside::after {
  content: "";
  position: absolute;
  left: 24px;
  right: 2px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  pointer-events: none;
  z-index: 5;
}

.block-node.is-editing > .block-row {
  background: var(--bg-active-block);
}

.block-node.is-pomo-active > .block-row {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

.block-node.is-selected,
.embed-node.is-selected {
  background: rgba(54, 93, 143, 0.12);
  border-radius: var(--radius-xs);
}

[data-theme="dark"] .block-node.is-selected,
[data-theme="dark"] .embed-node.is-selected {
  background: rgba(127, 170, 224, 0.16);
}

.block-node.is-selected > .block-row,
.embed-node.is-selected > .block-row {
  background: transparent;
}

.block-node.is-query-node > .block-row > .block-collapse,
.block-node.is-query-node > .block-row > .block-bullet-btn {
  display: none;
}

.block-collapse {
  width: 10px;
  height: 19px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.1s;
}

.block-row:hover .block-collapse.has-children,
.block-collapse.has-children.is-collapsed {
  opacity: 1;
}

.block-collapse:hover {
  color: var(--text-primary);
}

.block-bullet-btn {
  width: 14px;
  height: 19px;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-right: 4px;
  flex-shrink: 0;
  border-radius: 50%;
  cursor: grab;
}

.block-bullet-btn:active {
  cursor: grabbing;
}

.block-bullet-dot {
  width: 4.5px;
  height: 4.5px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.1s, background 0.1s, box-shadow 0.1s;
}

.block-bullet-btn:hover .block-bullet-dot {
  background: var(--text-primary);
  transform: scale(1.25);
  box-shadow: 0 0 0 3px var(--bg-subtle);
}

.block-bullet-btn.has-hidden-children .block-bullet-dot {
  background: var(--text-primary);
  box-shadow: 0 0 0 3px var(--border);
}

.block-bullet-btn.is-heading-bullet .block-bullet-dot {
  background: var(--accent);
  opacity: 0.75;
}

.block-body {
  flex: 1;
  min-width: 0;
  padding-top: 0;
}

.block-children {
  margin-left: 10px;
  padding-left: 3px;
  border-left: 1px solid var(--guide-line);
}

.block-children:hover {
  border-left-color: var(--guide-line-hover);
}

/* Resting rich block display */
.block-display {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  min-height: 19px;
  cursor: text;
  word-break: break-word;
}

.block-display.is-h1 {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
}

.block-display.is-h2 {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.block-display.is-h3 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.block-display.is-done .block-rich-text {
  color: var(--text-done);
  text-decoration: line-through;
  text-decoration-color: var(--border);
}

.block-display.is-done .wiki-link,
.block-display.is-done .inline-tag {
  opacity: 0.72;
}

.block-display.is-live-ref {
  padding: 1px 4px 1px 5px;
  border-left: 2px solid var(--ref-bar);
  border-radius: 2px;
  background: var(--ref-bg);
}

.block-rich-text {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
}

.block-placeholder {
  color: var(--text-muted);
  opacity: 0.42;
  font-style: italic;
  font-size: 12.5px;
}

/* Editing Textarea (Raw Syntax Mode — right-click or ⌘E) */
.block-editor {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  padding: 0;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-primary);
  display: block;
}

.block-editor.is-h2 {
  font-weight: 700;
}

.block-editor.is-h3 {
  font-weight: 600;
}

.raw-mode-badge {
  height: 16px;
  padding: 0 5px;
  margin-left: 4px;
  margin-top: 2px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  line-height: 1;
}

.raw-mode-badge:hover {
  background: var(--accent);
  color: #fff;
}

/* WYSIWYG ContentEditable Editor (default left-click mode) */
.block-wysiwyg-wrap {
  min-height: 19px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
}

.block-wysiwyg-wrap.is-h1 {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
}

.block-wysiwyg-wrap.is-h2 {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.block-wysiwyg-wrap.is-h3 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.block-wysiwyg-wrap.is-done .block-wysiwyg {
  color: var(--text-done);
  text-decoration: line-through;
  text-decoration-color: var(--border);
}

.block-wysiwyg {
  display: inline;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  caret-color: var(--accent);
}

.block-wysiwyg:empty {
  display: inline-block;
  min-width: 140px;
}

.block-wysiwyg:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  opacity: 0.42;
  font-style: italic;
  font-weight: 400;
  font-size: 12.5px;
  pointer-events: none;
}

/* Interactive Checkbox (also acts as bullet & drag handle on TODO blocks) */
.todo-checkbox {
  width: 14px;
  height: 14px;
  margin-top: 2.5px;
  border-radius: 3.5px;
  border: 1.5px solid var(--guide-line-hover);
  background: var(--bg-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.12s ease;
}

.todo-checkbox.is-bullet-handle {
  margin: 2.5px 4px 0 0;
  cursor: pointer;
}

.todo-checkbox.is-bullet-handle:active {
  cursor: grabbing;
}

.todo-checkbox:hover {
  border-color: var(--green);
}

.todo-checkbox.is-done {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.todo-checkbox.is-doing {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.check-svg svg {
  width: 10px;
  height: 10px;
  stroke-width: 2.8;
}

.doing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* Inline Syntax Tokens */
.wiki-link {
  display: inline;
  color: var(--link);
  cursor: pointer;
  border-radius: 2px;
  padding: 0 1px;
}

.wiki-link:hover {
  background: var(--link-soft);
  text-decoration: underline;
}

.wiki-bracket {
  color: var(--link-bracket);
  font-size: 0.88em;
}

.inline-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 0 4.5px;
  margin: 0 1px;
  border-radius: var(--radius-pill);
  background: var(--tag-bg);
  color: var(--tag-text);
  cursor: pointer;
  line-height: 1.38;
}

.inline-tag:hover {
  filter: brightness(0.94);
}

.inline-tag.is-today-tag {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.inline-code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.inline-strike {
  text-decoration: line-through;
  color: var(--text-muted);
}

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

.block-ref-inline {
  display: inline;
}

.block-ref-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  margin-left: 3px;
  padding: 0 3px;
  border-radius: 3px;
  color: var(--ref-bar);
  background: var(--link-soft);
  cursor: pointer;
  vertical-align: middle;
}

.block-ref-badge:hover {
  background: var(--link);
  color: #fff;
}

.block-ref-missing {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* Inline Pomodoro Widget */
.inline-pomo {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
  margin: 0 2px;
  padding: 0 5px 0 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  line-height: 1.45;
  text-decoration: none !important;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.12s ease;
}

.inline-pomo:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.inline-pomo.is-active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}

.inline-pomo.is-running {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.pomo-btn-icon svg {
  width: 9px;
  height: 9px;
}

.pomo-done-pill {
  font-size: 9.5px;
  font-weight: 600;
  padding: 0 3px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .pomo-done-pill {
  background: rgba(255, 255, 255, 0.12);
}

.inline-pomo.is-running .pomo-done-pill {
  background: rgba(255, 255, 255, 0.25);
}

/* Hover Block Actions */
.block-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
  flex-shrink: 0;
}

.block-row:hover .block-actions,
.block-node.is-editing > .block-row .block-actions,
.block-actions.has-pinned-pill {
  opacity: 1;
}

.block-row:hover .block-actions button,
.block-node.is-editing > .block-row .block-actions button,
.block-actions.has-pinned-pill .block-action-pill {
  pointer-events: auto;
}

.block-actions.has-pinned-pill .block-action-icon {
  opacity: 0;
}

.block-row:hover .block-actions.has-pinned-pill .block-action-icon {
  opacity: 1;
}

.block-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 3px;
  padding: 0;
}

.block-action-icon:hover {
  background: var(--bg-subtle);
  color: var(--accent);
}

.block-action-pill {
  height: 17px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  white-space: nowrap;
  line-height: 1;
}

.block-action-pill.is-today-off:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.block-action-pill.is-today-on {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.block-action-pill.is-today-on:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ==========================================================================
   Live Query / Filtered Embed Blocks ({{query: ...}})
   ========================================================================== */

.query-embed {
  position: relative;
  border-left: 2px solid var(--ref-bar);
  background: var(--ref-bg);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  padding: 2px 2px 2px 3px;
  margin: 1px 0 0;
}

.query-embed-tools {
  position: absolute;
  top: -8px;
  right: 2px;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 0 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: 3;
}

.query-embed:hover > .query-embed-tools {
  opacity: 1;
}

.query-filter-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  cursor: context-menu;
  border-radius: 2px;
}

.query-filter-dot:hover {
  background: var(--bg-subtle);
}

.query-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 4px;
  font-size: 11.5px;
}

.query-empty-add {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  padding: 0 6px;
  height: 18px;
  border-radius: var(--radius-xs);
}

.query-empty-add:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-soft);
}

.query-below-catcher {
  position: relative;
  height: 8px;
  margin-top: 1px;
  display: flex;
  align-items: center;
  cursor: text;
}

.query-below-line {
  flex: 1;
  height: 1.5px;
  border-radius: 1px;
  background: transparent;
  transition: background 0.12s ease;
}

.query-below-hint {
  position: absolute;
  right: 2px;
  top: -4px;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--bg-surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-xs);
  padding: 0 5px;
  line-height: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 2;
}

.query-below-catcher:hover .query-below-line {
  background: var(--accent);
  opacity: 0.6;
}

.query-below-catcher:hover .query-below-hint {
  opacity: 1;
}

@media (hover: none) {
  .query-below-catcher {
    height: 14px;
  }
  .query-below-hint {
    opacity: 0.55;
    top: 0;
  }
}

.query-embed-hdr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 1px;
}

.query-embed-hdr {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 1px 4px 1px 2px;
  border-radius: var(--radius-xs);
  transition: background 0.1s;
  min-width: 0;
}

.query-embed-hdr:hover {
  background: var(--bg-subtle);
}

.query-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  padding: 0;
  flex-shrink: 0;
}

.query-add-btn:hover {
  background: var(--bg-subtle);
  color: var(--accent);
}

.embed-node.is-editing > .block-row {
  background: var(--bg-active-block);
}

.embed-node.is-pomo-active > .block-row {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

.embed-node .block-children {
  margin-left: 9px;
  padding-left: 2px;
}

.query-ico {
  color: var(--ref-bar);
}

.query-expr {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-secondary);
}

.query-count {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.query-results {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.query-result-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0;
  padding: 1px 2px 1px 0;
  border-radius: var(--radius-xs);
}

.query-result-row.is-pomo-active {
  background: var(--accent-soft);
}

.query-result-row > .block-display {
  flex: 1;
  min-width: 0;
}

.query-result-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
}

.query-result-row:hover .query-result-actions {
  opacity: 1;
}

.query-result-row:hover .query-result-actions button {
  pointer-events: auto;
}

.query-src-link {
  border: none;
  background: transparent;
  color: var(--ref-bar);
  font-size: 11px;
  font-weight: 600;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.query-src-link:hover {
  background: var(--link-soft);
  color: var(--link);
}

.query-empty {
  font-size: 11.5px;
  font-style: italic;
  padding: 1px 3px;
}

.outliner-tail-click {
  min-height: 36px;
  cursor: text;
}

/* ==========================================================================
   Linked References (Backlinks)
   ========================================================================== */

.backlinks-section {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.backlinks-header {
  margin-bottom: 6px;
}

.backlinks-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.backlinks-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.backlink-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
}

.backlink-source {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 2px;
  font-size: 11px;
}

.backlink-page-link {
  border: none;
  background: transparent;
  padding: 0;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--link);
}

.backlink-page-link:hover {
  text-decoration: underline;
}

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

/* ==========================================================================
   Compact Right Split Pane — Persistent Long-Term Todos & Reference Sidebar
   ========================================================================== */

.right-pane {
  position: relative;
  flex-shrink: 0;
  display: flex;
  background: var(--bg-rail);
  border-left: 1px solid var(--border);
  min-width: 210px;
  max-width: calc(100vw - 260px);
}

.right-pane.is-collapsed {
  display: none;
}

.split-resize-handle {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 10;
  transition: background 0.12s;
}

.split-resize-handle:hover {
  background: var(--accent);
  opacity: 0.45;
}

.right-pane-inner {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.right-tabbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 5px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-rail);
  overflow-x: auto;
}

.right-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: none;
  max-width: 170px;
  margin-bottom: -1px;
}

.right-tab:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.right-tab.is-active {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
  font-weight: 600;
}

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

.tab-ico {
  color: var(--accent);
}

.tab-count {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.tab-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  padding: 1px;
  border-radius: 3px;
}

.tab-close:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.right-tab-action {
  margin-left: auto;
  margin-bottom: 2px;
}

.right-pane-body {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-surface);
  padding: 4px 4px 24px 1px;
}

.right-pane-body .block-children {
  margin-left: 9px;
  padding-left: 2px;
}

/* ==========================================================================
   All Pages & Templates Studio
   ========================================================================== */

.all-pages-toolbar {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.all-pages-search {
  flex: 1;
  min-width: 0;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--radius-xs);
  font-size: 12.5px;
  outline: none;
}

.all-pages-search:focus {
  border-color: var(--accent);
}

.pages-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  overflow: hidden;
}

.pages-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 9px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  gap: 8px;
}

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

.pages-row:hover {
  background: var(--bg-surface-hover);
}

.pages-row-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.pages-row-title {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pages-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.meta-stat {
  color: var(--text-secondary);
}

.mini-pill {
  font-family: var(--font-mono);
  font-size: 9.5px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.mini-pill.accent {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Templates Studio */
.template-auto-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.template-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.template-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.template-tab.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text-primary);
}

.template-tab.is-add {
  border-style: dashed;
}

.template-editor-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 10px;
}

.template-editor-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.template-name-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
}

.template-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 5px 8px;
  margin-bottom: 8px;
}

/* ==========================================================================
   Floating Slash / Link Autocomplete Menus
   ========================================================================== */

.floating-menu {
  position: fixed;
  z-index: 80;
  width: 260px;
  max-width: calc(100vw - 16px);
  max-height: 270px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 3px;
}

.floating-menu-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 3px 7px;
}

.floating-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 7px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 12.5px;
}

.floating-menu-item.is-selected,
.floating-menu-item:hover {
  background: var(--accent-soft);
}

.fm-label {
  font-weight: 500;
  color: var(--text-primary);
}

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

/* ==========================================================================
   Modals (Cmd+K Palette & Shortcuts) + Toasts
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 18, 16, 0.42);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8vh;
}

.cmd-modal {
  width: 500px;
  max-width: 94vw;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.cmd-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

.cmd-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
  color: var(--text-primary);
}

.cmd-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}

.cmd-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.cmd-row.is-selected,
.cmd-row:hover {
  background: var(--accent-soft);
}

.cmd-row-block {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cmd-row-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-row-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.cmd-row-hint {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cmd-footer {
  padding: 5px 10px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-rail);
  font-size: 11px;
  color: var(--text-muted);
}

/* Shortcuts Modal */
.shortcuts-modal {
  width: 480px;
  max-width: 94vw;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.shortcuts-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.shortcuts-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
}

.shortcuts-body {
  padding: 10px 12px 14px;
  max-height: 72vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shortcut-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3.5px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12.5px;
  gap: 8px;
}

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

.shortcut-key {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  white-space: nowrap;
}

/* Pomodoro Completion Banner & Toast */
.pomo-complete-banner {
  position: fixed;
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1.5px solid var(--green);
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  font-weight: 500;
  max-width: 94vw;
}

.pomo-banner-btn {
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  color: var(--text-primary);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  white-space: nowrap;
}

.pomo-banner-btn.is-primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.toast-pill {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--text-primary);
  color: var(--bg-canvas);
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  white-space: nowrap;
}

.selection-bar {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 92;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--link);
  box-shadow: var(--shadow-lg);
  max-width: 96vw;
}

.selection-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--link);
  margin-right: 2px;
  white-space: nowrap;
}

.sel-bar-btn {
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  color: var(--text-primary);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.sel-bar-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--guide-line-hover);
}

.sel-bar-btn.is-danger {
  color: var(--accent);
}

.sel-bar-btn.is-danger:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.sel-bar-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  padding: 0;
}

.sel-bar-close:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

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

/* Scrollbar polish */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--guide-line-hover);
}

/* ==========================================================================
   Compact Side-Window (Ultrawide Dock) & Phone Responsive Rules
   ========================================================================== */

/* Compact side-dock & narrow windows (<= 920px): left rail overlays cleanly so Daily Note + Backlog never get crushed */
@media (max-width: 920px) {
  .topbar-btn-label,
  .kbd-hint {
    display: none;
  }

  .pomo-dock-label {
    max-width: 110px;
  }

  .mobile-rail-backdrop {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: rgba(20, 18, 16, 0.28);
    z-index: 55;
  }

  .left-rail {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    width: 210px;
    z-index: 60;
    box-shadow: var(--shadow-lg);
  }
}

/* Touch devices: keep quick actions gently visible without needing hover */
@media (hover: none) {
  .block-actions,
  .query-result-actions {
    opacity: 0.85;
  }
}

/* Phone / Z Fold cover screen (<= 680px): full-height Today | Todos switcher */
@media (max-width: 680px) {
  .workspace-body {
    flex-direction: row;
  }

  .main-pane {
    flex: 1;
    width: 100%;
    padding: 8px 10px 72px 6px;
  }

  .workspace-body.mobile-show-right > .main-pane-slot,
  .workspace-body.mobile-show-right > #main-pane-scroll,
  .workspace-body.mobile-show-right .main-pane {
    display: none;
  }

  .right-pane {
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    flex: 1;
    height: auto;
    border-left: none;
    box-shadow: none;
  }

  .right-pane.is-collapsed {
    display: none;
  }

  .right-pane-body {
    padding-bottom: 72px;
  }

  .split-resize-handle {
    display: none;
  }

  .page-title,
  .page-title-input {
    font-size: 19px;
  }

  .action-label {
    display: none;
  }

  .pomo-idle-text,
  .pomo-mode-pill,
  .pomo-dock-label {
    display: none;
  }

  .block-actions,
  .query-result-actions {
    opacity: 0.85;
  }

  .block-children {
    margin-left: 10px;
    padding-left: 2px;
  }
}

/* Mobile / Touch Keyboard Accessory Toolbar */
.mobile-kbd-toolbar {
  display: none;
}

@media (max-width: 768px), (pointer: coarse) {
  button,
  .todo-checkbox,
  .block-bullet-btn,
  .block-collapse {
    touch-action: manipulation;
  }

  .mobile-kbd-toolbar {
    display: flex;
    align-items: center;
    gap: 5px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--kbd-inset, 0px) + env(safe-area-inset-bottom, 0px));
    z-index: 800;
    padding: 6px 8px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mkbd-btn {
    flex-shrink: 0;
    height: 34px;
    min-width: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mkbd-btn.is-active {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--accent);
  }

  .mkbd-btn.mkbd-done {
    margin-left: auto;
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
  }
}

@media (pointer: coarse) {
  .todo-checkbox {
    width: 18px;
    height: 18px;
  }

  .block-wysiwyg,
  .block-editor {
    font-size: 15px;
  }
}

/* Roam-style inline yellow highlight (^^...^^) */
.inline-hl {
  background: rgba(253, 224, 71, 0.58);
  color: inherit;
  padding: 0 3px;
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

[data-theme="dark"] .inline-hl {
  background: rgba(250, 204, 21, 0.28);
  color: #fef9c3;
}

/* Horizontal rule block ("---") rendered without bullet dot */
.block-bullet-btn.is-hr-bullet {
  width: 0;
  min-width: 0;
  margin-right: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.block-display.is-hr {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 16px;
  padding: 5px 0;
  cursor: pointer;
}

.block-hr {
  border: none;
  border-top: 1px solid var(--border);
  width: 100%;
  margin: 0;
  opacity: 0.9;
}

.block-display.is-hr:hover .block-hr {
  border-top-color: var(--text-muted);
}

/* Initial Automerge sync loading screen (replaces flashing demo todos) */
.boot-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-canvas);
  color: var(--text-primary);
}

.boot-loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 28px;
}

.boot-loading-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.boot-loading-logo {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.boot-loading-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.boot-loading-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.boot-loading-status.is-error {
  color: var(--danger);
  font-weight: 500;
}

.boot-loading-detail {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  max-width: 360px;
  text-align: center;
}

.boot-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: boot-spin 0.75s linear infinite;
}

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

.boot-login-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: min(320px, 86vw);
  margin-top: 6px;
}

.boot-login-input {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-mono);
  outline: none;
}

.boot-login-input:focus {
  border-color: var(--accent);
}

.boot-login-btn {
  height: 38px;
  justify-content: center;
  font-size: 13.5px;
}

.boot-login-error {
  min-height: 16px;
  font-size: 12px;
  color: var(--danger);
  text-align: center;
}
