/* ================= design tokens =================
 * The shadcn-style HSL token system ported from the workflow app: a light base
 * in `:root`, a shared dark palette under `[data-mode="dark"]` and (for System
 * mode) `@media (prefers-color-scheme: dark)`. Each theme re-tints its own
 * surfaces in the themes section at the bottom. */
:root {
  /* surfaces */
  --background: 240 20% 99%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-2: 240 20% 97.5%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 4% 44%;
  --accent: 240 4.8% 95.5%;
  --border: 240 6% 92.5%;
  --border-strong: 240 6% 85%;
  --input: 240 6% 83%;

  /* brand */
  --primary: 238 72% 56%;
  --primary-hover: 238 72% 50%;
  --primary-foreground: 0 0% 100%;
  --primary-muted: 238 60% 96%;
  --ring: 238 72% 56%;

  /* semantic */
  --destructive: 0 72% 48%;
  --destructive-foreground: 0 0% 100%;
  --success: 145 55% 38%;
  --warning: 32 90% 44%;

  /* radius scale */
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-md: calc(var(--radius) - 2px);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-full: 999px;

  /* elevation scale */
  --shadow-sm: 0 1px 2px hsl(240 8% 12% / 0.05);
  --shadow-md: 0 4px 12px hsl(240 8% 12% / 0.08), 0 1px 3px hsl(240 8% 12% / 0.05);
  --shadow-lg: 0 12px 32px hsl(240 8% 12% / 0.12), 0 2px 8px hsl(240 8% 12% / 0.06);

  /* type */
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* shared dark tokens (explicit dark mode) */
[data-mode="dark"] {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 6.5%;
  --card-2: 240 10% 8.5%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 65%;
  --accent: 240 3.7% 15.9%;
  --border: 240 4% 18%;
  --border-strong: 240 4% 26%;
  --input: 240 4% 24%;
  --primary: 234 89% 74%;
  --primary-hover: 234 89% 80%;
  --primary-foreground: 240 10% 8%;
  --primary-muted: 234 40% 22%;
  --ring: 234 89% 74%;
  --destructive: 0 72% 62%;
  --success: 145 55% 58%;
  --warning: 38 92% 62%;
  --shadow-sm: 0 1px 2px hsl(0 0% 0% / 0.5);
  --shadow-md: 0 2px 6px hsl(0 0% 0% / 0.55), 0 8px 24px hsl(0 0% 0% / 0.35);
  --shadow-lg: 0 12px 32px hsl(0 0% 0% / 0.6);
}
/* shared dark tokens (System mode following the OS) */
@media (prefers-color-scheme: dark) {
  [data-mode="system"] {
    --background: 240 10% 3.9%; --foreground: 0 0% 98%;
    --card: 240 10% 6.5%; --card-2: 240 10% 8.5%;
    --muted: 240 3.7% 15.9%; --muted-foreground: 240 5% 65%; --accent: 240 3.7% 15.9%;
    --border: 240 4% 18%; --border-strong: 240 4% 26%; --input: 240 4% 24%;
    --primary: 234 89% 74%; --primary-hover: 234 89% 80%; --primary-foreground: 240 10% 8%;
    --primary-muted: 234 40% 22%; --ring: 234 89% 74%;
    --destructive: 0 72% 62%; --success: 145 55% 58%; --warning: 38 92% 62%;
    --shadow-sm: 0 1px 2px hsl(0 0% 0% / 0.5);
    --shadow-md: 0 2px 6px hsl(0 0% 0% / 0.55), 0 8px 24px hsl(0 0% 0% / 0.35);
    --shadow-lg: 0 12px 32px hsl(0 0% 0% / 0.6);
  }
}

/* ================= base ================= */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: hsl(var(--primary)); }

/* ── Header bar ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  padding-top: calc(0.6rem + env(safe-area-inset-top));
  background: hsl(var(--background) / 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid hsl(var(--border));
}
.brand {
  color: hsl(var(--foreground));
  font-weight: 680;
  font-size: 1.15rem;
  text-decoration: none;
}
.nav { display: flex; align-items: center; gap: 1rem; }
.nav a { color: hsl(var(--muted-foreground)); text-decoration: none; }
.nav a:hover { color: hsl(var(--foreground)); }
.nav--desktop { margin-left: auto; }
/* text-style nav actions (a secondary action, or a submit button) */
.nav .navlink {
  padding: 0;
  background: none;
  border: none;
  font: inherit;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  cursor: pointer;
}
.nav .navlink:hover { color: hsl(var(--foreground)); }
.nav .navlink:disabled { opacity: 0.6; cursor: default; }
.nav--desktop .btn { padding: 0.4rem 0.85rem; font-size: 0.9rem; }

/* The folding-menu machinery is inert (hidden) on desktop. */
.nav-toggle { display: none; }
.hamburger { display: none; }
.nav-overlay { display: none; }
.nav--drawer { display: none; }

/* ── Content ────────────────────────────────────────────────────────────── */
.content {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.5rem 1rem 5rem;
}
.grow { margin-right: auto; }
.page-title { margin-top: 0; line-height: 1.2; }
.muted { color: hsl(var(--muted-foreground)); }

.toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

/* Base button; each theme restyles `.btn` / `.btn.ghost` below. */
.btn {
  display: inline-block;
  padding: 0.5rem 0.95rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: hsl(var(--primary-hover)); }
.btn.ghost {
  background: transparent;
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border-strong));
}
.btn.ghost:hover { background: hsl(var(--accent)); }

/* ── Entry list ─────────────────────────────────────────────────────────── */
.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  background: hsl(var(--card));
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.entry-list a {
  display: block;
  padding: 0.45rem 0.85rem;
  color: hsl(var(--foreground));
  text-decoration: none;
  border-top: 1px solid hsl(var(--border));
}
.entry-list li:first-child a { border-top: 0; }
.entry-list a:hover { background: hsl(var(--muted)); }

/* ── Journal timeline (year/month rail + grouped entries) ───────────────── */
.journal-layout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1.75rem;
  align-items: start;
}
.timeline {
  position: sticky;
  top: calc(3.4rem + env(safe-area-inset-top));
  align-self: start;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-right: 1.1rem;
  border-right: 1px solid hsl(var(--border));
}
.tl-year { display: flex; flex-direction: column; gap: 0.2rem; }
.tl-year-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: hsl(var(--foreground));
  text-decoration: none;
}
.tl-year-label:hover { color: hsl(var(--primary)); }
.tl-months {
  list-style: none;
  margin: 0;
  padding: 0.1rem 0 0 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  border-left: 1px solid hsl(var(--border));
}
.tl-month {
  display: block;
  padding: 0.12rem 0.45rem;
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.tl-month:hover { color: hsl(var(--foreground)); background: hsl(var(--muted)); }

.year-group { scroll-margin-top: 4.5rem; }
.month-group { scroll-margin-top: 4.5rem; }
.month-group + .month-group,
.year-group + .year-group { margin-top: 1.25rem; }
.month-head {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}

@media (max-width: 640px) {
  /* Keep the timeline as a real left rail, just narrower and tighter so the
     entry column still has room on a phone. */
  .journal-layout { gap: 0.9rem; }
  .timeline { padding-right: 0.7rem; gap: 0.7rem; }
  .tl-year-label { font-size: 0.9rem; }
  .tl-months { padding-left: 0.5rem; }
  .tl-month { padding: 0.12rem 0.3rem; font-size: 0.78rem; }
}

/* ── Locations (machine-readable frontmatter, shown as a list) ──────────── */
.locations { margin: 0 0 1.5rem; }
.locations h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.loc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.loc-list li {
  padding: 0.5rem 0.7rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  background: hsl(var(--card));
}
.loc-list a { font-family: var(--mono); font-size: 0.9rem; text-decoration: none; }
.loc-list a:hover { text-decoration: underline; }


/* ── Forms ──────────────────────────────────────────────────────────────── */
.settings-form { max-width: 34rem; }
.saved-note { color: hsl(var(--success)); font-weight: 600; }
.field { display: block; margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.field input,
.field textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font: inherit;
  font-size: 1rem;
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border-strong));
  border-radius: var(--radius-md);
}
.field input:focus,
.field textarea:focus {
  outline: 2px solid hsl(var(--ring) / 0.5);
  outline-offset: 1px;
  border-color: hsl(var(--ring));
}
.editor textarea {
  min-height: 60vh;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.5;
  tab-size: 2;
}

/* ── Rendered markdown ──────────────────────────────────────────────────── */
.md { overflow-wrap: break-word; }
.md h1, .md h2, .md h3 { line-height: 1.25; }
.md img { max-width: 100%; height: auto; }
.md pre {
  background: hsl(var(--muted));
  padding: 1rem;
  border-radius: var(--radius-md);
  overflow: auto;
}
.md code {
  font-family: var(--mono);
  background: hsl(var(--muted));
  padding: 0.12em 0.35em;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}
.md pre code { padding: 0; background: none; }
.md blockquote {
  margin: 0;
  padding: 0.25rem 1rem;
  border-left: 3px solid hsl(var(--border-strong));
  color: hsl(var(--muted-foreground));
}
.md table { border-collapse: collapse; }
.md th, .md td { border: 1px solid hsl(var(--border)); padding: 0.4rem 0.6rem; }

/* ── Sign-in page ───────────────────────────────────────────────────────── */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.login-card {
  width: min(24rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1.6rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.login-brand { font-family: var(--font-head); font-weight: 680; font-size: 1.25rem; }
.login-input {
  padding: 0.6rem 0.7rem;
  font: inherit;
  font-size: 1rem;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border-strong));
  border-radius: var(--radius-md);
}
.login-error { color: hsl(var(--destructive)); margin: 0; font-size: 0.9rem; }
.subtitle { color: hsl(var(--muted-foreground)); margin: 0; }

/* ================= themes × light/dark =================
 * `data-theme` (journal|studio|console) picks the identity — fonts, button
 * style, accent; `data-mode` (system|light|dark) picks the palette. */

/* self-hosted variable faces */
@font-face { font-family: 'Inter'; src: url('/static/inter.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Newsreader'; src: url('/static/serif.woff2') format('woff2'); font-weight: 200 800; font-style: normal; font-display: swap; }

/* type hooks — each theme points these at the faces it wants */
:root { --font-ui: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --font-head: var(--font-ui); --font-prose: var(--font-ui); }
body { font-family: var(--font-ui); }
h1, h2, h3, .brand, .login-brand { font-family: var(--font-head); }
.content { font-family: var(--font-prose); }

/* keep native controls (scrollbars, form widgets) in step */
[data-mode="light"] { color-scheme: light; }
[data-mode="dark"] { color-scheme: dark; }
[data-mode="system"] { color-scheme: light dark; }

/* the theme + mode switchers (share this styling) */
.theme-switch { display: inline-flex; gap: 2px; padding: 2px; background: hsl(var(--muted)); border: 1px solid hsl(var(--border)); border-radius: var(--radius-full); }
.theme-switch .tsw { display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: var(--radius-full); font-size: .72rem; font-weight: 650; color: hsl(var(--muted-foreground)); text-decoration: none; }
.theme-switch .tsw:hover { color: hsl(var(--foreground)); }
.theme-switch .tsw.on { background: hsl(var(--card)); color: hsl(var(--foreground)); box-shadow: var(--shadow-sm); }
.theme-switch.wide { }
.theme-switch.wide .tsw { width: auto; height: auto; padding: .34rem .62rem; font-size: .78rem; }
/* labeled 'Theme'/'Mode' rows in the drawer */
.menu-theme { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .25rem; }
.menu-theme-label { font-size: .82rem; font-weight: 600; color: hsl(var(--muted-foreground)); }

/* ---- JOURNAL — editorial serif, ink/cream pill buttons, warm paper ---- */
[data-theme="journal"] {
  --background: 38 30% 98.5%; --card: 38 30% 99.3%; --card-2: 38 22% 96.5%;
  --foreground: 30 12% 14%; --muted-foreground: 34 8% 40%;
  --muted: 38 18% 95.5%; --accent: 38 22% 94%;
  --border: 34 16% 88%; --border-strong: 34 16% 80%;
  --primary: 8 56% 44%; --primary-hover: 8 56% 38%; --primary-foreground: 38 30% 98%;
  --primary-muted: 8 50% 95%; --ring: 8 56% 44%;
  --jbtn: 28 22% 16%; --jbtn-fg: 38 30% 97%;
  --radius: .5rem; --radius-lg: .7rem;
  --font-head: 'Newsreader', Georgia, serif; --font-prose: 'Newsreader', Georgia, serif;
}
[data-theme="journal"] h1 { font-weight: 560; letter-spacing: -.008em; }
[data-theme="journal"] .content { font-size: 1.06rem; line-height: 1.8; }
[data-theme="journal"] main { max-width: 42rem; }
[data-theme="journal"] .btn { background: hsl(var(--jbtn)); color: hsl(var(--jbtn-fg)); border: 1px solid hsl(var(--jbtn)); border-radius: var(--radius-full); box-shadow: var(--shadow-sm); font-weight: 600; }
[data-theme="journal"] .btn:hover { filter: brightness(1.3); background: hsl(var(--jbtn)); }
[data-theme="journal"] .btn.ghost { background: transparent; color: hsl(var(--foreground)); border: 1px solid hsl(var(--border-strong)); box-shadow: none; filter: none; }
[data-theme="journal"] .btn.ghost:hover { background: hsl(var(--card-2)); border-color: hsl(var(--foreground)); }

/* ---- STUDIO — cool-neutral surfaces, magenta accent, flat cards ---- */
[data-theme="studio"] {
  --background: 240 12% 96.5%; --card: 0 0% 100%; --card-2: 250 14% 94%;
  --foreground: 250 17% 13%; --muted-foreground: 247 9% 42%;
  --muted: 250 13% 94%; --accent: 250 13% 92%;
  --border: 246 14% 89%; --border-strong: 247 11% 80%;
  --primary: 327 74% 48%; --primary-hover: 327 77% 42%; --primary-muted: 327 62% 95%; --primary-foreground: 0 0% 100%; --ring: 327 74% 48%;
  --success: 150 45% 37%; --warning: 32 82% 47%;
  --radius: .5rem; --radius-lg: .8rem;
}

/* ---- CONSOLE — vibrant violet gradient buttons, glow (light base) ---- */
[data-theme="console"] {
  --background: 240 20% 98.5%; --card: 0 0% 100%; --card-2: 240 22% 97%;
  --foreground: 240 14% 12%; --muted-foreground: 240 6% 45%;
  --muted: 240 8% 95%; --accent: 240 8% 95%; --input: 240 8% 84%;
  --border: 240 8% 90%; --border-strong: 240 8% 84%;
  --primary: 255 82% 60%; --primary-hover: 255 82% 54%; --primary-foreground: 0 0% 100%;
  --primary-muted: 255 70% 96%; --ring: 255 82% 60%;
  --radius-lg: .9rem;
}
[data-theme="console"] .btn { background: linear-gradient(135deg, hsl(258 90% 66%), hsl(240 90% 60%)); color: #fff; border: none; box-shadow: 0 4px 14px hsl(255 90% 55% / .35), inset 0 1px 0 hsl(0 0% 100% / .2); }
[data-theme="console"] .btn:hover { filter: brightness(1.07); background: linear-gradient(135deg, hsl(258 90% 66%), hsl(240 90% 60%)); }
[data-theme="console"] .btn.ghost { background: hsl(var(--card-2)); color: hsl(var(--foreground)); border: 1px solid hsl(var(--border)); box-shadow: none; }
[data-theme="console"] .btn.ghost:hover { background: hsl(var(--accent)); }
[data-theme="console"] .theme-switch .tsw.on { color: hsl(var(--primary)); }

/* ============ per-theme DARK surface tints ============
 * Applied for explicit dark mode and for System mode under OS dark (duplicated,
 * since a rule cannot be shared across the media boundary). */
[data-mode="dark"][data-theme="journal"] {
  --background: 28 14% 10%; --card: 28 13% 13%; --card-2: 28 12% 16.5%;
  --foreground: 38 22% 89%; --muted-foreground: 34 10% 63%;
  --muted: 28 10% 17%; --accent: 28 10% 18%;
  --border: 30 9% 23%; --border-strong: 30 9% 32%;
  --primary: 8 72% 65%; --primary-hover: 8 72% 71%; --primary-muted: 8 45% 22%; --ring: 8 72% 65%;
  --jbtn: 38 32% 90%; --jbtn-fg: 28 24% 12%;
}
[data-mode="dark"][data-theme="studio"] {
  --background: 240 16% 6%; --card: 246 17% 11%; --card-2: 250 16% 14%;
  --foreground: 250 14% 91%; --muted-foreground: 247 8% 60%;
  --muted: 250 15% 15%; --accent: 248 14% 19%; --input: 248 12% 22%;
  --border: 250 14% 17%; --border-strong: 248 12% 27%;
  --primary: 330 82% 66%; --primary-hover: 330 88% 73%; --primary-muted: 328 38% 20%; --primary-foreground: 335 30% 11%; --ring: 330 82% 66%;
}
[data-mode="dark"][data-theme="console"] {
  --background: 240 14% 8%; --card: 240 12% 11%; --card-2: 240 12% 13.5%;
  --foreground: 240 20% 96%; --muted-foreground: 240 8% 62%;
  --muted: 240 10% 16%; --accent: 240 10% 16%; --input: 240 10% 24%;
  --border: 240 10% 20%; --border-strong: 240 10% 28%;
  --primary: 255 90% 74%; --primary-hover: 255 90% 80%; --primary-muted: 255 55% 22%; --ring: 255 90% 74%;
  --destructive: 0 78% 66%; --success: 145 60% 58%;
}
@media (prefers-color-scheme: dark) {
  [data-mode="system"][data-theme="journal"] {
    --background: 28 14% 10%; --card: 28 13% 13%; --card-2: 28 12% 16.5%;
    --foreground: 38 22% 89%; --muted-foreground: 34 10% 63%;
    --muted: 28 10% 17%; --accent: 28 10% 18%;
    --border: 30 9% 23%; --border-strong: 30 9% 32%;
    --primary: 8 72% 65%; --primary-hover: 8 72% 71%; --primary-muted: 8 45% 22%; --ring: 8 72% 65%;
    --jbtn: 38 32% 90%; --jbtn-fg: 28 24% 12%;
  }
  [data-mode="system"][data-theme="studio"] {
    --background: 240 16% 6%; --card: 246 17% 11%; --card-2: 250 16% 14%;
    --foreground: 250 14% 91%; --muted-foreground: 247 8% 60%;
    --muted: 250 15% 15%; --accent: 248 14% 19%; --input: 248 12% 22%;
    --border: 250 14% 17%; --border-strong: 248 12% 27%;
    --primary: 330 82% 66%; --primary-hover: 330 88% 73%; --primary-muted: 328 38% 20%; --primary-foreground: 335 30% 11%; --ring: 330 82% 66%;
  }
  [data-mode="system"][data-theme="console"] {
    --background: 240 14% 8%; --card: 240 12% 11%; --card-2: 240 12% 13.5%;
    --foreground: 240 20% 96%; --muted-foreground: 240 8% 62%;
    --muted: 240 10% 16%; --accent: 240 10% 16%; --input: 240 10% 24%;
    --border: 240 10% 20%; --border-strong: 240 10% 28%;
    --primary: 255 90% 74%; --primary-hover: 255 90% 80%; --primary-muted: 255 55% 22%; --ring: 255 90% 74%;
    --destructive: 0 78% 66%; --success: 145 60% 58%;
  }
}

/* ── Full-viewport editor (CodeMirror, markdown highlighting) ───────────── */
/* Its actions (Save/View) live in the top nav, so the editor is nothing but the
   CodeMirror surface, filling all remaining space below the header. */
.content--full { max-width: none; padding: 0; }
.content--full .editor { display: block; }
/* Height budget: viewport minus the sticky header and the (open) property
   form (+ any top safe-area). */
:root { --editor-reserve: calc(12rem + env(safe-area-inset-top)); }

/* Collapsible Logseq-property form above the editor. */
.props { border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--card-2)); }
.props > summary {
  cursor: pointer;
  padding: 0.55rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
  list-style: none;
}
.props > summary::-webkit-details-marker { display: none; }
.props > summary::before { content: "▸ "; }
.props[open] > summary::before { content: "▾ "; }
.props-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 0.8rem;
  padding: 0.1rem 1rem 0.8rem;
}
.props-grid label { display: flex; flex-direction: column; gap: 0.2rem; }
.props-grid label span { font-family: var(--mono); font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.props-grid input {
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-size: 0.95rem;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border-strong));
  border-radius: var(--radius-md);
}
@media (max-width: 640px) { .props-grid { grid-template-columns: 1fr; } }

/* Entry-page meta strip (from the Logseq properties). */
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  margin: 0 0 1.1rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.9rem;
}
.entry-meta .tag { color: hsl(var(--primary)); }
/* Plain-textarea fallback shown until CodeMirror mounts (or if JS is off). */
.content--full textarea#md {
  display: block;
  width: 100%;
  margin: 0;
  border: none;
  border-radius: 0;
  min-height: calc(100dvh - var(--editor-reserve));
  padding: 0.7rem 1rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.65;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  resize: none;
}
/* CodeMirror — scoped under `.content--full` so these beat cm.css regardless of
   load order. Colours use the app tokens, so every theme + light/dark follows;
   it grows with content and shares the page background for a seamless full bleed. */
.content--full .CodeMirror {
  height: auto;
  min-height: calc(100dvh - var(--editor-reserve));
  width: 100%;
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.65;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}
.content--full .CodeMirror-lines { padding: 0.7rem 0; }
.content--full .CodeMirror pre.CodeMirror-line,
.content--full .CodeMirror pre.CodeMirror-line-like { padding: 0 1rem; }
.content--full .CodeMirror-cursor { border-left-color: hsl(var(--foreground)); }
.content--full .CodeMirror-selected { background: hsl(var(--primary) / 0.18); }
.content--full .cm-s-default .cm-header { color: hsl(var(--foreground)); font-weight: 700; }
.content--full .cm-s-default .cm-header-1 { font-size: 1.35em; }
.content--full .cm-s-default .cm-header-2 { font-size: 1.2em; }
.content--full .cm-s-default .cm-quote { color: hsl(var(--muted-foreground)); font-style: italic; }
.content--full .cm-s-default .cm-link { color: hsl(var(--primary)); }
.content--full .cm-s-default .cm-url { color: hsl(var(--muted-foreground)); }
.content--full .cm-s-default .cm-strong { font-weight: 700; color: hsl(var(--foreground)); }
.content--full .cm-s-default .cm-em { font-style: italic; }
.content--full .cm-s-default .cm-comment { color: hsl(var(--success)); }  /* code spans / fences */
.content--full .cm-s-default .cm-variable-2 { color: hsl(var(--primary)); }  /* list markers */

/* ── Mobile: header nav folds into a bottom-right hamburger drawer ───────── */
@media (max-width: 640px) {
  .nav--desktop { display: none; }

  .hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 40;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    font-size: 1.7rem;
    line-height: 1;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    margin-bottom: env(safe-area-inset-bottom);
  }

  .nav--drawer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.1rem;
    position: fixed;
    right: 1rem;
    bottom: 5.25rem;
    z-index: 41;
    min-width: 240px;
    padding: 0.35rem;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(0.98);
    transform-origin: bottom right;
    transition: opacity 0.15s ease, transform 0.15s ease;
    margin-bottom: env(safe-area-inset-bottom);
  }
  .drawer-actions { display: flex; flex-direction: column; gap: 0.1rem; margin-bottom: 0.35rem; }
  .drawer-actions .btn { text-align: center; }
  .nav--drawer .navlink {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.7rem 0.6rem;
    border-radius: var(--radius-md);
    color: hsl(var(--foreground));
    text-decoration: none;
  }
  .nav--drawer .navlink:hover { background: hsl(var(--accent)); }
  .nav--drawer .menu-theme + .menu-theme { padding-top: 0; }

  .nav-toggle:checked ~ .nav--drawer {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }
  .nav-toggle:checked ~ .nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(0, 0, 0, 0.25);
  }
}
