/* ─── Journal Timeline ──────────────────────────────────────── */
.journal-timeline {
  margin-bottom: 2rem;
}

.journal-day {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.journal-day:last-child {
  border-bottom: none;
}

.journal-date-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.journal-date-header a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}
.journal-date-header a:hover {
  text-decoration: underline;
}

.load-more {
  text-align: center;
  padding: 1.5rem 0;
}
.load-more button {
  background: var(--bg-alt);
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 0.5rem 1.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.load-more button:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--accent-dim);
}

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #ffffff;
  --bg-alt:    #f5f5f7;
  --bg-hover:  #eaeaee;
  --text:      #1a1a2e;
  --text-dim:  #6b6b80;
  --text-faint:#9999aa;
  --accent:    #6354d0;
  --accent-dim:#4a3f8e;
  --border:    #d8d8e0;
  --green:     #3d8b3d;
  --orange:    #d4872e;
  --radius:    8px;
  --sidebar-w: 280px;
  --compose-h: 120px;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Layout ──────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
}

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 3rem var(--compose-h);
  padding-bottom: calc(var(--compose-h) + 1rem);
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar-header {
  padding: 1.25rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.stats {
  display: block;
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 0.15rem;
}

.search-box {
  padding: 0.75rem 1rem;
}

.search-box input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ─── Sidebar Journal Button ────────────────────────────── */
.sidebar-journal-btn {
  padding: 0.35rem 0.75rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-journal-btn button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s ease;
  text-align: left;
}

.sidebar-journal-btn button:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--accent-dim);
}

.sidebar-journal-btn button.active {
  background: rgba(124, 110, 240, 0.08);
  color: var(--accent);
  border-color: var(--accent-dim);
  font-weight: 500;
}

/* ─── Smart Sidebar Sections ────────────────────────────────── */
#sidebar-nav {
  overflow-y: visible;
}

.sb-section {
  border-bottom: 1px solid var(--border);
}
.sb-section:last-child {
  border-bottom: none;
}

.sb-header {
  display: flex;
  align-items: center;
  padding: 0.45rem 1rem;
  cursor: pointer;
  user-select: none;
  gap: 0.35rem;
  transition: background 0.1s;
}
.sb-header:hover {
  background: var(--bg-hover);
}

.sb-chevron {
  font-size: 0.55rem;
  color: var(--text-faint);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  width: 1em;
  text-align: center;
  line-height: 1;
}
.sb-section.collapsed .sb-chevron {
  transform: rotate(-90deg);
}

.sb-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  flex: 1;
}

.sb-count {
  font-size: 0.65rem;
  color: var(--text-faint);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: auto;
  min-width: 1.2em;
  text-align: right;
}

.sb-body {
  max-height: 100000px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  opacity: 1;
}
.sb-section.collapsed .sb-body {
  max-height: 0;
  opacity: 0;
}

/* Pinned empty state */
.sb-empty {
  padding: 0.5rem 1rem 0.7rem;
  font-size: 0.78rem;
  color: var(--text-faint);
  font-style: italic;
}

/* Page items */
.sb-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sb-page-item {
  position: relative;
  display: flex;
  align-items: center;
}

.sb-page-link {
  display: block;
  width: 100%;
  padding: 0.3rem 1rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.1s ease;
  line-height: 1.35;
  /* ~30px row: 0.3rem top+bottom + font ~21px = ~30px */
}

.sb-page-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Active page: left border accent + brighter text */
.sb-page-link.active {
  color: var(--text);
  font-weight: 500;
  border-left: 2px solid var(--accent);
  padding-left: calc(1rem - 2px);
  background: rgba(124, 110, 240, 0.06);
}

/* Relative time (recent pages) */
.sb-page-time {
  font-size: 0.7rem;
  color: var(--text-faint);
  margin-left: 0.35rem;
  flex-shrink: 0;
}

/* Recent page: subtle weight gradient based on freshness */
.sb-page-link.recent-fresh {
  font-weight: 500;
  color: var(--text);
}

/* Pin icon (hover/tap for mobile) */
.sb-pin-btn {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.15rem;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}
.sb-page-item:hover .sb-pin-btn {
  opacity: 0.7;
}
.sb-pin-btn:hover {
  opacity: 1 !important;
  color: var(--accent);
}
/* Always show pin icon on pinned items */
.sb-page-item.is-pinned .sb-pin-btn {
  opacity: 0.5;
}

/* Tags list (reuses sb-list) */
#sidebar-nav .tag-item a {
  display: flex;
  justify-content: space-between;
}

#sidebar-nav .tag-item .tag-count {
  color: var(--text-faint);
  font-size: 0.75rem;
}

/* Sub-section inside All Pages (Journals) */
.sb-subsection .sb-header {
  padding-left: 1.5rem;
}

.sb-subsection .sb-chevron {
  font-size: 0.5rem;
}

.sb-subsection .sb-page-link {
  padding-left: 1.5rem;
}

/* ─── Context Menu ──────────────────────────────────────────── */
.ctx-menu {
  position: fixed;
  z-index: 500;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  padding: 0.25rem 0;
  min-width: 150px;
}
.ctx-menu.hidden {
  display: none;
}
.ctx-menu-item {
  display: block;
  width: 100%;
  padding: 0.4rem 0.85rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.ctx-menu-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.ctx-menu-item.hidden {
  display: none;
}
.ctx-menu-item-danger {
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  margin-top: 0.15rem;
  padding-top: 0.5rem;
}
.ctx-menu-item-danger:hover {
  background: #5c1a1a;
  color: #f87171;
}

/* ─── Page View ───────────────────────────────────────────── */
.page-view {
  max-width: 720px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.page-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.page-tag {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  background: var(--accent-dim);
  border-radius: 4px;
  color: var(--text);
}

.page-properties {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

/* ─── Blocks ──────────────────────────────────────────────── */
.blocks {
  list-style: none;
}

.block {
  padding: 0.2rem 0;
  color: var(--text);
}

/* Indentation by level — tight */
.block-level-0 { margin-left: 0; }
.block-level-1 { margin-left: 0.6rem; }
.block-level-2 { margin-left: 1.2rem; }
.block-level-3 { margin-left: 1.8rem; }
.block-level-4 { margin-left: 2.4rem; }

/* Indentation guide lines */
.block-level-1 { border-left: 2px solid var(--border); padding-left: 0.25rem; }
.block-level-2 { border-left: 2px solid var(--border); padding-left: 0.25rem; }
.block-level-3 { border-left: 2px solid var(--border); padding-left: 0.25rem; }
.block-level-4 { border-left: 2px solid var(--border); padding-left: 0.25rem; }
.block-level-1:hover,
.block-level-2:hover,
.block-level-3:hover,
.block-level-4:hover { border-left-color: var(--accent-dim); }

/* Deep-link highlight */
.block-highlight {
  background: rgba(99, 102, 241, 0.12);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4), 0 0 20px rgba(99, 102, 241, 0.15);
  border-radius: 8px;
  scroll-margin-top: 80px;
  scroll-margin-bottom: 160px; /* extra to clear compose bar */
  padding: 0.5rem;
  margin: 0.25rem -0.5rem;
  transition: background 0.2s, box-shadow 0.2s;
}

/* ─── Block Content (no bullet rail) ─────────────────────── */
.block-content {
  /* content fills the block width — no bullet or action chrome */
}

/* ─── Property Zone ────────────────────────────────────── */
.block-props {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.5rem;
  margin-top: 0.15rem;
  font-size: 0.7rem;
  color: var(--text-faint);
  font-family: monospace;
}
.block-prop {
  opacity: 0.7;
}
.prop-sep {
  margin: 0 0.15rem;
  opacity: 0.5;
}

/* ─── Markdown: Code Blocks ────────────────────────────── */
.code-block {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 0.6rem 0.8rem;
  overflow-x: auto;
  font-size: 0.85rem;
  margin: 0.3rem 0;
}
.code-block code {
  font-family: monospace;
  white-space: pre;
  color: var(--text);
}
.code-lang {
  float: right;
  font-size: 0.65rem;
  color: var(--text-faint);
  text-transform: uppercase;
}

/* ─── Markdown: Blockquotes ────────────────────────────── */
.block-quote {
  display: block;
  border-left: 2px solid var(--border);
  padding-left: 0.6rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ─── Markdown: Horizontal Rule ────────────────────────── */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.4rem 0;
}

/* ─── Markdown: Images ────────────────────────────────── */
.block-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.25rem;
  margin: 0.3rem 0;
}

/* ─── Interstitial + Divider ────────────────────────────── */
.block-insert {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 0;
  opacity: 0;
  transition: opacity 0.1s, height 0.1s;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.block-insert::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed transparent;
  transition: border-color 0.1s;
}

.block-insert:hover,
.block-insert:active {
  opacity: 1;
  height: 1.4rem;
}

.block-insert:hover::before,
.block-insert:active::before {
  border-color: var(--accent-dim);
}

.block-insert span {
  font-size: 0.75rem;
  color: var(--text-faint);
  background: var(--bg);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  border: 1px dashed var(--border);
  z-index: 1;
  transition: all 0.1s;
}

.block-insert:hover span {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--bg-alt);
}

/* Mobile: always-visible thin interstitial */
@media (max-width: 768px) {
  .block-insert {
    opacity: 1;
    height: 0.35rem;
    pointer-events: all;
  }
  .block-insert::before {
    border-color: transparent;
  }
  .block-insert:hover {
    height: 1.4rem;
  }
}

.block-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  background: var(--bg-alt);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

/* Page links [[link]] */
.page-ref {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.page-ref:hover {
  text-decoration: underline;
}

/* Tags #tag */
.inline-tag {
  color: var(--orange);
  font-size: 0.85em;
  cursor: pointer;
  text-decoration: none;
}
.inline-tag:hover {
  text-decoration: underline;
}

/* Linked References (tag pages) */
.linked-references {
  margin-top: 2rem;
}
.linked-refs-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.linked-ref {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--bg-alt);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.linked-ref:hover {
  border-color: var(--accent);
}
.linked-ref-page {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 0.35rem;
  cursor: pointer;
}
.linked-ref-page:hover {
  text-decoration: underline;
}
.linked-ref-content {
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* TODO states */
.todo-TODO { color: var(--orange); font-weight: 500; }
.todo-DONE { color: var(--green); text-decoration: line-through; }
.todo-DOING { color: var(--accent); font-weight: 500; }

/* ─── Inline Components ─────────────────────────────────────── */
.component {
  margin: 0.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Event Card */
.component-event {
  background: var(--bg-alt);
}

.component-event.event-past {
  opacity: 0.55;
}

.event-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-hover);
}

.event-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.event-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.event-badge-upcoming {
  background: var(--accent);
  color: white;
}

.event-badge-past {
  background: var(--bg);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.event-badge-default {
  background: var(--accent-dim);
  color: var(--text);
}

.event-body {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.event-date {
  color: var(--text);
}

.event-countdown {
  color: var(--accent);
  font-weight: 500;
}

.event-countdown-soon {
  color: var(--green);
  font-weight: 600;
}

.event-location {
  color: var(--text-dim);
}

.event-tasks {
  padding: 0.5rem 1rem 0.75rem;
  border-top: 1px solid var(--border);
}

.event-task {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
  font-size: 0.85rem;
  cursor: default;
}

.event-task input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: default;
}

.event-task-done span {
  color: var(--text-faint);
  text-decoration: line-through;
}

/* ─── Ask Card ──────────────────────────────────────────────── */
.component-ask {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
}

.ask-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}

.ask-question {
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.ask-badge {
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.ask-badge-pending {
  background: rgba(240, 160, 80, 0.15);
  color: var(--orange);
  border: 1px solid rgba(240, 160, 80, 0.3);
}

.ask-badge-answered {
  background: rgba(92, 184, 92, 0.15);
  color: var(--green);
  border: 1px solid rgba(92, 184, 92, 0.3);
}

.ask-answer {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.5;
}

.ask-answer-icon {
  color: var(--green);
  font-weight: 700;
  margin-right: 0.25rem;
}

/* ─── Search Results ──────────────────────────────────────── */
.search-results {
  max-width: 720px;
  margin: 0 auto;
}

.search-result {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color 0.1s ease;
}

.search-result:hover {
  border-color: var(--accent);
}

.search-result .result-page {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.search-result .result-content {
  margin-top: 0.25rem;
}

/* ─── Empty State ─────────────────────────────────────────── */
.empty-state {
  max-width: 400px;
  margin: 4rem auto;
  text-align: center;
  color: var(--text-dim);
}

.empty-state h2 {
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

/* ─── Compose Bar (fixed bottom) ──────────────────────────── */
#compose-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  z-index: 50;
  transition: transform 0.2s ease;
}

#compose-bar.hidden {
  transform: translateY(100%);
}

.compose-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Top row: write-toggle (left) + type-selector (right) */
.compose-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.write-toggle {
  display: flex;
  gap: 0.3rem;
}

.write-pill {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.write-pill:hover:not(.active):not(:disabled) {
  border-color: var(--text-dim);
  color: var(--text);
}

.write-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.write-pill:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Block type selector */
.type-selector {
  display: flex;
  gap: 0.3rem;
}

.type-pill {
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.type-pill:hover:not(.active) {
  border-color: var(--text-dim);
  color: var(--text);
}

.type-pill.active {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--bg);
  font-weight: 600;
}

/* Schema fields (events) */
#write-schema-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

#write-schema-fields:empty {
  display: none;
}

.schema-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 110px;
}

.schema-field-start, .schema-field-end {
  flex: 1 1 45%;
}
.schema-field-location {
  flex: 1 1 100%;
}
.schema-field-status {
  flex: 0 0 auto;
  min-width: 100px;
}

.schema-label {
  font-size: 0.65rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.schema-label .required {
  color: var(--orange);
}

.schema-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 0.35rem;
}

.schema-input:focus {
  outline: none;
  border-color: var(--accent);
}

.date-time-group {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.date-time-group .schema-input {
  flex: 1;
}
.time-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.68rem;
  padding: 0.3rem 0.4rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.time-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.time-toggle.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

/* Bottom row: title + textarea + send */
.compose-bottom {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.write-title-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.5rem;
}

.write-title-input:focus {
  outline: none;
  border-color: var(--accent);
}

.compose-textarea-wrap {
  position: relative;
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
}

#compose-bar textarea {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.5rem;
  resize: none;
  min-height: 36px;
  max-height: 120px;
  overflow-y: auto;
}

#compose-bar textarea:focus {
  outline: none;
  border-color: var(--accent);
}

#journal-submit {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1.2rem;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

#journal-submit:hover {
  background: var(--accent-dim);
}

#journal-submit:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ─── Mobile ──────────────────────────────────────────────── */
.menu-toggle { display: none; }

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    height: 100dvh;
    height: 100vh; /* fallback */
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #sidebar-nav {
    -webkit-overflow-scrolling: touch;
  }

  #content {
    padding: 3rem 1rem 1rem;
    width: 100%;
    padding-bottom: calc(var(--compose-h) + 1rem);
  }

  /* Backdrop when sidebar is open */
  #sidebar.open ~ #content::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }

  .menu-toggle {
    display: block;
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 101;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  }

  /* Compose bar: full width on mobile */
  #compose-bar {
    left: 0;
  }

  .compose-inner {
    padding: 0.4rem 0.75rem;
  }

  /* Tighter type pills on mobile */
  .compose-top {
    gap: 0.3rem;
  }

  .write-pill, .type-pill {
    font-size: 0.68rem;
    padding: 0.18rem 0.5rem;
  }

  #journal-submit {
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
    border-radius: 8px;
  }

  .compose-cancel {
    width: 48px;
    height: 48px;
    font-size: 1.1rem;
    border-radius: 8px;
  }

  .block-level-1 { margin-left: 0.5rem; border-left: 2px solid var(--border); padding-left: 0.2rem; }
  .block-level-2 { margin-left: 1rem; border-left: 2px solid var(--border); padding-left: 0.2rem; }
  .block-level-3 { margin-left: 1.5rem; border-left: 2px solid var(--border); padding-left: 0.2rem; }
}

/* ─── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--compose-h) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-alt);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  z-index: 200;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toast-in 0.25s ease;
  max-width: 90vw;
}

.toast.hidden {
  display: none;
}

.toast .toast-icon {
  color: var(--green);
  font-weight: 700;
}

.toast .toast-link {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
}

.toast .toast-link:hover {
  text-decoration: underline;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.sidebar-footer {
  padding: 0.5rem 0.75rem;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.github-link {
  display: inline-flex;
  align-items: center;
  color: var(--text-dim);
  transition: color 0.15s;
}

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

.ghost-page-notice {
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  color: var(--text-dim, #666);
  font-style: italic;
  border-left: 3px solid var(--border, #333);
}

/* ── Push notification button ── */
.sb-push-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border, #2a2a35);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim, #666);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: auto; /* push to right of github link */
}

.sb-push-btn:hover {
  background: var(--bg-hover, rgba(255,255,255,0.04));
  border-color: var(--accent, #7c6ef0);
  color: var(--text, #e0e0e0);
}

.sb-push-btn.active {
  color: var(--accent, #7c6ef0);
  border-color: var(--accent, #7c6ef0);
  background: rgba(124, 110, 240, 0.08);
}

/* ─── Block editing mode ──────────────────────────────────── */
.block-editing {
  background: rgba(124, 110, 240, 0.08);
  border-left: 3px solid var(--accent, #7c6ef0);
  border-radius: 4px;
  padding-left: 0.5rem;
  margin-left: -0.5rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.editing-indicator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.editing-label {
  font-size: 0.65rem;
  color: var(--accent, #7c6ef0);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.edit-close {
  cursor: pointer;
  opacity: 0.5;
  font-size: 0.8rem;
  padding: 0 0.3rem;
}

.edit-close:hover {
  opacity: 1;
}

.compose-cancel {
  background: var(--bg-alt);
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}

.compose-cancel:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Edit mode: strip compose bar to just textarea + cancel + confirm */
#compose-bar.edit-mode .compose-top,
#compose-bar.edit-mode #write-schema-fields,
#compose-bar.edit-mode #write-title {
  display: none !important;
}

/* ─── Ghost Block ──────────────────────────────────────────── */
.ghost-block {
  border: 1px dashed var(--accent-dim);
  border-radius: var(--radius);
  background: var(--bg-alt);
  animation: ghost-pulse 2s infinite;
}
.ghost-block textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  outline: none;
  padding: 0.25rem 0;
}
.ghost-block .ghost-content {
  position: relative;
}
.ghost-level {
  position: absolute;
  right: 0.25rem;
  top: 0.25rem;
  font-size: 0.65rem;
  color: var(--text-faint);
}
@keyframes ghost-pulse {
  0%, 100% { border-color: var(--accent-dim); }
  50% { border-color: var(--accent); }
}

/* ─── Slash Command Menu ──────────────────────────────────── */
/* Floats above the compose textarea; clears the on-screen keyboard. */
.slash-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  max-height: 264px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 60;
  padding: 0.25rem;
  animation: slash-in 0.14s ease;
}

.slash-menu.hidden {
  display: none;
}

.slash-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.65rem;
  border-radius: 7px;
  cursor: pointer;
  min-height: 36px;
  transition: background 0.1s ease, color 0.1s ease;
}

.slash-item:hover {
  background: var(--bg-hover);
}

.slash-item.selected {
  background: var(--accent);
  color: #fff;
}

.slash-item-name {
  font-size: 0.88rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slash-item-page {
  font-size: 0.72rem;
  color: var(--text-faint);
  flex-shrink: 0;
}

.slash-item.selected .slash-item-page {
  color: rgba(255,255,255,0.82);
}

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

@media (max-width: 768px) {
  .slash-menu {
    max-height: 240px;
  }
  .slash-item {
    min-height: 44px;
    padding: 0.5rem 0.7rem;
  }
}

/* ── New Page Wizard Modal ── */
.modal.hidden { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(2px);
}
.modal-content {
  position: relative; z-index: 1;
  background: var(--bg-main, #1a1b26);
  border: 1px solid var(--border-color, #2a2b3d);
  border-radius: 12px;
  width: 90%; max-width: 440px;
  max-height: 85vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color, #2a2b3d);
}
.modal-header h2 { margin: 0; font-size: 1.1rem; }
.modal-close {
  background: none; border: none; color: var(--text-faint, #6c6f85);
  font-size: 1.4rem; cursor: pointer; padding: 0 0.25rem; line-height: 1;
}
.modal-close:hover { color: var(--text, #c0caf5); }
.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-color, #2a2b3d);
  display: flex; justify-content: flex-end; gap: 0.5rem;
}

/* Wizard fields */
.wizard-field { margin-bottom: 1rem; }
.wizard-field label {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: var(--text-faint, #6c6f85); margin-bottom: 0.35rem;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.wizard-field .hint {
  text-transform: none; font-weight: 400; letter-spacing: 0;
  color: var(--text-dim, #4a4d60);
}
.wizard-field input[type="text"],
.wizard-field select {
  width: 100%; padding: 0.6rem 0.75rem;
  background: var(--bg-secondary, #16161e);
  border: 1px solid var(--border-color, #2a2b3d);
  border-radius: 6px; color: var(--text, #c0caf5);
  font-size: 0.9rem; font-family: inherit;
  box-sizing: border-box;
}
.wizard-field input:focus,
.wizard-field select:focus {
  outline: none;
  border-color: var(--accent, #7aa2f7);
  box-shadow: 0 0 0 2px rgba(122,162,247,0.15);
}
.wizard-field select option { background: var(--bg-secondary, #16161e); }

/* Property rows */
.prop-row {
  display: flex; gap: 0.4rem; margin-bottom: 0.4rem; align-items: center;
}
.prop-row input {
  flex: 1; padding: 0.45rem 0.6rem;
  background: var(--bg-secondary, #16161e);
  border: 1px solid var(--border-color, #2a2b3d);
  border-radius: 6px; color: var(--text, #c0caf5);
  font-size: 0.85rem; font-family: inherit;
}
.prop-row input.prop-key { flex: 0.8; }
.prop-row input.prop-val { flex: 1.2; }
.prop-row input:focus {
  outline: none;
  border-color: var(--accent, #7aa2f7);
}
.prop-row .prop-remove {
  background: none; border: none; color: var(--text-dim, #4a4d60);
  cursor: pointer; font-size: 1.1rem; padding: 0 0.25rem;
  flex-shrink: 0;
}
.prop-row .prop-remove:hover { color: var(--red, #f7768e); }
.wizard-add-prop {
  background: none; border: 1px dashed var(--border-color, #2a2b3d);
  border-radius: 6px; color: var(--text-faint, #6c6f85);
  padding: 0.35rem 0.6rem; font-size: 0.8rem;
  cursor: pointer; font-family: inherit; width: 100%;
  transition: all 0.15s;
}
.wizard-add-prop:hover {
  border-color: var(--accent, #7aa2f7);
  color: var(--accent, #7aa2f7);
}

/* Buttons */
.btn-primary {
  padding: 0.5rem 1.2rem; border-radius: 6px;
  background: var(--accent, #7aa2f7); color: #1a1b26;
  font-weight: 600; font-size: 0.9rem; border: none;
  cursor: pointer; font-family: inherit;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-secondary {
  padding: 0.5rem 1.2rem; border-radius: 6px;
  background: transparent; color: var(--text-faint, #6c6f85);
  font-weight: 500; font-size: 0.9rem;
  border: 1px solid var(--border-color, #2a2b3d);
  cursor: pointer; font-family: inherit;
  transition: all 0.15s;
}
.btn-secondary:hover {
  border-color: var(--text-faint, #6c6f85);
  color: var(--text, #c0caf5);
}
.wizard-error {
  background: rgba(247,118,142,0.1); color: var(--red, #f7768e);
  border: 1px solid rgba(247,118,142,0.3); border-radius: 6px;
  padding: 0.5rem 0.75rem; font-size: 0.85rem; margin-top: 0.5rem;
}
.wizard-error.hidden { display: none; }

/* ═══ Library & Graph views (v0.0.36) ═════════════════════════ */

.sidebar-journal-btn {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.lib-count {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
}

.lib-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 4px 0 8px;
}

.lib-sort {
  display: flex;
  gap: 4px;
}

.sort-pill {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sort-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.lib-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 14px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover { border-color: var(--accent); color: var(--accent); }

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip.active .chip-n {
  color: rgba(255, 255, 255, 0.75);
}

.chip-n {
  color: var(--text-faint);
  font-size: 10px;
  margin-left: 2px;
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  padding-bottom: 40px;
}

.lib-card {
  border: 1px solid var(--border);
  border-radius: var(--radius, 10px);
  background: var(--bg-alt);
  padding: 14px 14px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 110px;
}

.lib-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.lib-card-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.lib-snippet {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  flex: 1;
}

.lib-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

.lib-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  overflow: hidden;
}

.tag-chip {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10.5px;
  cursor: pointer;
  white-space: nowrap;
}

.tag-chip:hover { text-decoration: underline; }

.lib-time {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Graph ── */

.graph-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius, 10px);
  overflow: hidden;
  height: calc(100vh - 220px);
  min-height: 420px;
  background: #0f1116;
}

#graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.graph-hint {
  position: absolute;
  bottom: 10px;
  left: 12px;
  font-size: 11px;
  font-family: "JetBrains Mono", monospace;
  color: rgba(224, 224, 230, 0.4);
  pointer-events: none;
  user-select: none;
}

@media (max-width: 768px) {
  .lib-grid { grid-template-columns: 1fr; }
  .graph-wrap { height: calc(100vh - 260px); }
  .lib-snippet { -webkit-line-clamp: 2; }
}

/* library — text filter + letter groups */
.lib-filter {
  flex: 1 1 160px; min-width: 120px; max-width: 260px;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 13px; background: var(--bg-alt); color: var(--text); outline: none;
  transition: border-color .15s, background .15s;
}
.lib-filter:focus { border-color: var(--accent-dim); background: var(--bg); }
.lib-letter {
  grid-column: 1 / -1;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  margin: 16px 0 6px; padding-bottom: 3px;
  border-bottom: 1px solid var(--border);
}
.lib-letter:first-child { margin-top: 4px; }
.lib-letter-n { color: var(--text-faint); font-weight: 400; font-size: 11px; margin-left: 6px; }

/* ═══ Quick Capture (/capture) ═══════════════════════════════ */
.capture-wrap {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
}
.capture-head { display: flex; align-items: center; gap: .75rem; padding-bottom: .75rem; }
.capture-back { font-size: 1.4rem; color: var(--text-dim); text-decoration: none; padding: .25rem .6rem .25rem 0; }
.capture-title { font-weight: 600; letter-spacing: .02em; }
.capture-clock { margin-left: auto; color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: .85rem; }
.capture-stage { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.capture-input {
  flex: 1;
  width: 100%;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-alt);
  color: var(--text);
  font: inherit;
  font-size: 1.15rem;
  line-height: 1.5;
  padding: 1rem;
}
.capture-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.capture-foot { display: flex; align-items: center; gap: 1rem; padding-top: .75rem; }
.capture-status { color: var(--text-dim); font-size: .9rem; min-height: 1.2em; }
.capture-send {
  margin-left: auto;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 1.05rem;
  padding: .9rem 1.6rem;
  min-height: 48px;
  min-width: 112px;
}
.capture-send:active { transform: scale(.97); }
.capture-queued {
  margin-top: .75rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: .6rem .8rem;
  font-size: .85rem;
  color: var(--text-dim);
}
.capture-queued-head { font-weight: 600; margin-bottom: .3rem; }
.capture-queued-item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.capture-flush {
  margin-top: .5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: .4rem .8rem;
  font: inherit;
  font-size: .85rem;
}

/* One composer, from a journal-sized invitation to focused writing. */
#compose-bar { border-radius: 18px 18px 0 0; box-shadow: 0 -8px 28px rgba(0,0,0,.05); }
#compose-bar .compose-inner { padding: 16px 20px max(12px, env(safe-area-inset-bottom)); gap: 10px; }
.composer-heading, .composer-size-controls, .composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.composer-heading label { font-size: .95rem; font-weight: 600; }
.composer-size-controls button, .ghost-actions button { font: inherit; color: var(--text-dim); background: transparent; border: 1px solid var(--border); border-radius: 8px; min-height: 44px; padding: 8px 12px; cursor: pointer; }
.composer-size-controls button[hidden] { display: none; }
.composer-footer { color: var(--text-dim); font-size: .75rem; }
#compose-bar #journal-input { min-height: 88px; max-height: 100%; font-size: 1rem; line-height: 1.55; padding: 12px; border-radius: 12px; }
#compose-bar #journal-submit { width: auto; min-width: 82px; height: 48px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
#compose-bar[data-size="writing"] { height: min(52dvh, 540px); height: min(calc(var(--writing-viewport, 100dvh) * .58), 540px); }
#compose-bar[data-size="full"] { left: 0; height: var(--writing-viewport, 100dvh); z-index: 200; border-radius: 0; }
#compose-bar[data-size="writing"] .compose-inner, #compose-bar[data-size="full"] .compose-inner { height: 100%; box-sizing: border-box; }
#compose-bar[data-size="writing"] .compose-bottom, #compose-bar[data-size="full"] .compose-bottom { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#compose-bar[data-size="writing"] .compose-textarea-wrap, #compose-bar[data-size="full"] .compose-textarea-wrap { flex: 1; min-height: 0; }
#compose-bar[data-size="writing"] #journal-input, #compose-bar[data-size="full"] #journal-input { height: 100% !important; min-height: 48px; }
#compose-bar[data-size="full"] .compose-inner { padding-top: max(16px, env(safe-area-inset-top)); }
#compose-bar .capture-queued { max-height: 100px; overflow: auto; margin: 0; }
#compose-bar button:focus-visible, .ghost-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.composer-size-controls button:hover { color: var(--accent); border-color: var(--accent); }
.ghost-block { margin-top: 12px; border: 1px solid var(--accent); border-radius: 12px; padding: 12px; animation: none; }
.ghost-content label { display: block; font-size: .85rem; color: var(--text-dim); }
.ghost-block textarea { display: block; width: 100%; min-height: 96px; box-sizing: border-box; font: inherit; line-height: 1.5; margin-top: 8px; }
.ghost-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; }
.ghost-status { flex: 1; font-size: .8rem; color: var(--text-dim); }
.ghost-actions [data-save] { color: white; background: var(--accent); border-color: var(--accent); }
#journal-submit:disabled, .ghost-actions button:disabled { opacity: .5; cursor: wait; }
@media (max-width: 768px) {
  #compose-bar .compose-inner { padding: 10px 12px max(10px, env(safe-area-inset-bottom)); gap: 8px; }
  .composer-heading label { font-size: .85rem; }
  .composer-size-controls button { padding: 6px 10px; }
  .composer-size-controls span { display: none; }
  #compose-bar #journal-input { min-height: 72px; font-size: 16px; }
  #compose-bar[data-size="writing"] { height: calc(var(--writing-viewport, 100dvh) * .7); }
  #compose-bar[data-size="writing"] .composer-footer { display: none; }
  #compose-bar .write-pill, #compose-bar .type-pill { min-height: 36px; font-size: .75rem; }
  #compose-bar[data-size="writing"][data-block-type="note"] #write-title:placeholder-shown { display: none; }
}
@media (prefers-reduced-motion: reduce) { #compose-bar { transition: none; } }

.block-content > .block { margin-left: 20px; }
#compose-bar[data-size="compact"] #journal-input { height: 88px !important; max-height: 88px; }
#compose-bar .capture-queued.hidden { display: none; }
#compose-bar[data-size="writing"] .compose-top, #compose-bar[data-size="full"] .compose-top,
#compose-bar .composer-heading, #compose-bar .composer-footer { flex-shrink: 0; }
@media (max-width: 768px) {
  #compose-bar[data-size="compact"] #journal-input { height: 72px !important; max-height: 72px; }
}

/* Download page as markdown — title-row action button */
.page-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.page-dl-btn {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.page-dl-btn:hover {
  color: var(--text);
  border-color: var(--text-faint);
}

@media (max-width: 768px) {
  .page-dl-btn { padding: 0.45rem 0.85rem; } /* keep 44px touch target */
}
