/* ─────────────────────────────────────────────────────────────
   Lab Book v2 — production CSS
   Adapted from Claude design prototype.
   Agora integration + .lb design system.
   ────────────────────────────────────────────────────────────── */

/* ── AGORA INTEGRATION ──────────────────────────────────────── */
.agora .ag-main.labbook-v2 {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#labbook-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body[data-page="labbook"] .ag-workspace,
body[data-page="labbook"] .ag-main {
  padding: 0;
  overflow: hidden;
}
body[data-page="labbook"] .ag-sidebar {
  z-index: 10;
  transition:
    transform 520ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity 420ms cubic-bezier(0.4, 0, 0.2, 1);
}
body[data-page="labbook"] .agora:has(.lb-shell.focused) {
  grid-template-columns: 0 minmax(0, 1fr);
  transition: grid-template-columns 520ms cubic-bezier(0.4, 0, 0.2, 1);
}
body[data-page="labbook"] .agora:has(.lb-shell.focused) .ag-sidebar {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-100%);
}
body[data-page="labbook"]:has(.lb-shell.focused) .aspis-ai-chat__launcher {
  display: none;
}

/* ── LOADING STATE ─────────────────────────────────────────── */
.lb-loading {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 0%, oklch(0.22 0.014 250), oklch(0.135 0.012 250) 70%);
  color: var(--chrome-muted);
  font-family: 'Geist Mono', monospace;
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
}
.lb-loading .pulse {
  width: 40px; height: 40px; border-radius: 12px;
  background: color-mix(in oklab, var(--teal) 20%, transparent);
  animation: lb-pulse 1.2s ease-in-out infinite;
  margin-bottom: 16px;
}
@keyframes lb-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* ── ERROR STATE ───────────────────────────────────────────── */
.lb-error {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  background: radial-gradient(ellipse at 50% 0%, oklch(0.22 0.014 250), oklch(0.135 0.012 250) 70%);
  color: var(--chrome-text);
  font-family: 'Geist', sans-serif;
  text-align: center; padding: 24px;
}
.lb-error .code {
  font-family: 'Geist Mono', monospace;
  font-size: 11px; color: var(--chrome-muted); letter-spacing: 0.06em;
}
.lb-error button {
  margin-top: 8px; padding: 10px 22px;
  background: var(--teal-strong); color: #061417;
  border: 0; border-radius: 8px;
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}

/* ── EMPTY STATE ───────────────────────────────────────────── */
.lb-empty-book {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  color: var(--chrome-muted);
  font-family: 'Geist', sans-serif;
}
.lb-empty-book .ico {
  font-family: 'Caveat', cursive;
  font-size: 56px; color: var(--chrome-muted);
  opacity: 0.5; margin-bottom: 8px;
}
.lb-empty-book h2 {
  margin: 0; font-size: 18px; font-weight: 500;
  color: var(--chrome-text); letter-spacing: -0.01em;
}
.lb-empty-book p {
  margin: 0; font-size: 13px; color: var(--chrome-muted);
  max-width: 280px; text-align: center; line-height: 1.5;
}
.lb-empty-book button {
  margin-top: 12px; padding: 10px 22px;
  background: var(--teal-strong); color: #061417;
  border: 0; border-radius: 8px;
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}

/* ── BROWSER UNSUPPORTED ───────────────────────────────────── */
.lb-unsupported {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  background: oklch(0.15 0.012 250);
  color: var(--chrome-text);
  font-family: 'Geist', sans-serif;
  text-align: center; padding: 24px;
}
.lb-unsupported h2 { margin: 0; font-size: 16px; }
.lb-unsupported p { margin: 0; font-size: 13px; color: var(--chrome-muted); max-width: 320px; line-height: 1.5; }

/* ─────────────────────────────────────────────────────────────
   Lab Book — paper notebook for bench scientists
   Scoped under .lb so nothing leaks into canvas chrome.
   ────────────────────────────────────────────────────────────── */

.lb {
  /* ensure children can use height:100% reliably (this is the React root
     of every artboard). min-height:0 prevents the flex parent (#labbook-root)
     from growing past viewport when the sidebar entry list gets long. */
  width: 100%; height: 100%;
  min-height: 0; min-width: 0;
  display: flex; flex-direction: column;
  /* ink */
  --ink:           oklch(0.22 0.04 250);   /* main pen ink (deep blue-black) */
  --ink-2:         oklch(0.36 0.05 250);
  --ink-dim:       oklch(0.55 0.04 250);
  --ink-faint:     oklch(0.70 0.03 250);
  --pencil:        oklch(0.40 0.01 250);
  --highlight:     oklch(0.92 0.16 95 / 0.55);  /* yellow highlighter */
  --redline:       oklch(0.62 0.18 25 / 0.65);  /* margin red line */
  --teal:          oklch(0.55 0.13 195);
  --teal-strong:   oklch(0.62 0.16 195);

  /* paper */
  --paper:         oklch(0.965 0.012 85);  /* warm cream */
  --paper-edge:    oklch(0.92 0.018 85);
  --paper-deep:    oklch(0.88 0.022 80);
  --paper-shadow:  oklch(0.78 0.025 75);
  --grid:          oklch(0.86 0.015 230 / 0.55);  /* faint blue grid */
  --rule:          oklch(0.82 0.020 230 / 0.45);

  /* chrome (workspace around the book) */
  --chrome-bg:     oklch(0.165 0.012 250);
  --chrome-panel:  oklch(0.205 0.012 250);
  --chrome-raised: oklch(0.245 0.014 250);
  --chrome-border: oklch(0.30 0.012 250);
  --chrome-text:   oklch(0.965 0.005 250);
  --chrome-muted:  oklch(0.62 0.012 250);

  font-family: 'Geist', 'Geist Sans', system-ui, sans-serif;
  color: var(--chrome-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}
.lb, .lb * { box-sizing: border-box; }

.lb .hand {
  font-family: 'Caveat', 'Bradley Hand', 'Comic Sans MS', cursive;
  font-weight: 600;
  letter-spacing: 0.005em;
}
.lb .mono {
  font-family: 'Geist Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-feature-settings: 'zero', 'ss01';
}

/* ── DESKTOP SHELL ─────────────────────────────────────────── */
.lb-shell {
  width: 100%; height: 100%;
  min-height: 0; flex: 1;
  display: grid;
  /* minmax(0, 1fr) stops the row from auto-growing with overflowing content
     in the .lb-main grid; without it a long sidebar list pushes the layout
     past viewport height and the "New page" footer disappears. */
  grid-template-rows: 44px minmax(0, 1fr);
  background:
    radial-gradient(ellipse at 50% 0%, oklch(0.22 0.014 250), oklch(0.135 0.012 250) 70%);
  color: var(--chrome-text);
  overflow: hidden;
}
.lb-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--chrome-border);
  background: var(--chrome-panel);
  font-size: 12.5px;
}
.lb-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; letter-spacing: -0.01em;
}
.lb-brand-mark {
  width: 20px; height: 20px; border-radius: 6px;
  background:
    linear-gradient(135deg, oklch(0.78 0.16 195) 0%, oklch(0.5 0.12 220) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), 0 1px 2px rgba(0,0,0,.4);
  display: grid; place-items: center;
  font-family: 'Caveat', cursive; font-size: 13px; color: #061417; font-weight: 700;
}
.lb-crumb {
  display: flex; align-items: center; gap: 6px; color: var(--chrome-muted);
  font-size: 12px;
}
.lb-crumb b { color: var(--chrome-text); font-weight: 500; }
.lb-crumb .sep { opacity: .4; }
.lb-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.lb-icon-btn {
  width: 28px; height: 28px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--chrome-muted); cursor: pointer;
  border: 1px solid transparent;
}
.lb-icon-btn:hover { background: var(--chrome-raised); color: var(--chrome-text); }
.lb-icon-btn.on { background: var(--chrome-raised); color: var(--teal-strong); border-color: var(--chrome-border); }

.lb-segmented {
  display: inline-flex; padding: 2px;
  background: var(--chrome-raised); border: 1px solid var(--chrome-border);
  border-radius: 8px; font-size: 11.5px;
}
.lb-segmented button {
  padding: 4px 10px; border: 0; background: transparent; cursor: pointer;
  color: var(--chrome-muted); border-radius: 6px; font: inherit;
  display: inline-flex; align-items: center; gap: 6px;
}
.lb-segmented button.on {
  background: var(--chrome-bg); color: var(--chrome-text);
  box-shadow: inset 0 0 0 1px var(--chrome-border);
}
.lb-segmented button:disabled {
  opacity: .45;
  cursor: default;
}

.lb-main {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 296px;
  min-height: 0; height: 100%;
  overflow: hidden;
  transition: grid-template-columns 520ms cubic-bezier(0.4, 0, 0.2, 1);
}
.lb-shell.focused .lb-main {
  grid-template-columns: 0 minmax(0, 1fr) 0;
  height: calc(100dvh - 44px);
}

/* ── SIDEBARS ─────────────────────────────────────────────── */
.lb-side {
  background: var(--chrome-panel);
  border-right: 1px solid var(--chrome-border);
  display: flex; flex-direction: column; min-height: 0;
  font-size: 12.5px;
  min-width: 0;
  overflow: hidden;
  will-change: transform, opacity;
  transition:
    transform 520ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity 420ms cubic-bezier(0.4, 0, 0.2, 1);
}
.lb-side.right { border-right: 0; border-left: 1px solid var(--chrome-border); }
.lb-shell.focused .lb-side {
  opacity: 0;
  pointer-events: none;
}
.lb-shell.focused .lb-side.left { transform: translateX(-100%); }
.lb-shell.focused .lb-side.right { transform: translateX(100%); }
.lb-side-head {
  padding: 12px 14px 8px;
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--chrome-muted);
}
.lb-side-head .count { margin-left: auto; color: oklch(0.48 0.012 250); font-weight: 500; }

.lb-search {
  margin: 0 12px 10px;
  display: flex; align-items: center; gap: 8px;
  background: var(--chrome-bg);
  border: 1px solid var(--chrome-border);
  border-radius: 8px; padding: 7px 10px;
}
.lb-search input {
  flex: 1; background: transparent; border: 0; outline: 0; color: var(--chrome-text);
  font: inherit; font-size: 12px;
}
.lb-search input::placeholder { color: oklch(0.48 0.012 250); }
.lb-search kbd {
  font-family: 'Geist Mono', monospace; font-size: 10px;
  background: var(--chrome-raised); padding: 1px 4px; border-radius: 3px;
  color: var(--chrome-muted); border: 1px solid var(--chrome-border);
}

.lb-pill-row {
  padding: 0 12px 10px; display: flex; flex-wrap: wrap; gap: 4px;
}
.lb-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 99px;
  font-size: 10.5px; color: var(--chrome-muted);
  background: var(--chrome-raised);
  border: 1px solid var(--chrome-border);
  cursor: pointer;
}
.lb-pill.on { background: color-mix(in oklab, var(--teal) 18%, transparent); color: var(--teal-strong); border-color: color-mix(in oklab, var(--teal) 30%, var(--chrome-border)); }

.lb-entries {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 8px 8px;
  /* Firefox scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--chrome-raised) transparent;
}

/* Pinned sidebar footer — "New page" must always be visible, no matter how
   long the entry list gets. flex-shrink:0 keeps it out of the scroll area. */
.lb-side-foot {
  flex: 0 0 auto;
  padding: 8px 14px 14px;
  border-top: 1px solid var(--chrome-border);
  background: var(--chrome-panel);
}
.lb-newpage-btn {
  width: 100%;
  padding: 9px 0;
  border-radius: 8px;
  background: var(--teal-strong);
  color: #061417;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: filter .12s;
}
.lb-newpage-btn:hover { filter: brightness(1.08); }
.lb-newpage-btn:active { transform: translateY(1px); }
.lb-entries::-webkit-scrollbar { width: 8px; }
.lb-entries::-webkit-scrollbar-thumb { background: var(--chrome-raised); border-radius: 4px; }

.lb-entry {
  position: relative;
  padding: 8px 10px 9px 22px; border-radius: 8px;
  cursor: pointer; transition: background .12s;
  border: 1px solid transparent;
}
.lb-entry:hover { background: var(--chrome-raised); }
.lb-entry.active { background: var(--chrome-raised); border-color: var(--chrome-border); }
.lb-entry.active::before {
  content: ''; position: absolute; left: 8px; top: 12px; bottom: 12px; width: 2px;
  background: var(--teal); border-radius: 2px;
}
.lb-entry .date {
  font-family: 'Geist Mono', monospace; font-size: 9.5px; letter-spacing: 0.06em;
  color: var(--chrome-muted); text-transform: uppercase;
}
.lb-entry .title { font-size: 12.5px; font-weight: 500; margin-top: 2px; color: var(--chrome-text); }
.lb-entry .prev { font-size: 11px; color: oklch(0.55 0.012 250); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.lb-entry .meta {
  margin-top: 5px; display: flex; gap: 8px; align-items: center;
  font-family: 'Geist Mono', monospace; font-size: 9.5px; color: var(--chrome-muted);
}
.lb-entry .meta .tag { color: var(--teal-strong); }
.lb-entry .meta .att { color: oklch(0.65 0.10 75); }

/* divider with month label */
.lb-month {
  padding: 18px 12px 6px;
  display: flex; align-items: center; gap: 10px;
  font-family: 'Geist Mono', monospace; font-size: 10px; letter-spacing: 0.08em;
  color: var(--chrome-muted); text-transform: uppercase;
}
.lb-month::after {
  content: ''; flex: 1; height: 1px; background: var(--chrome-border);
}

/* right rail */
.lb-rail-section { padding: 14px 14px 4px; }
.lb-rail-h {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--chrome-muted);
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.lb-rail-h .grow { flex: 1; }
.lb-rail-h .add {
  font-size: 14px; line-height: 14px; color: var(--chrome-muted);
  width: 18px; height: 18px; border-radius: 4px;
  display: grid; place-items: center; cursor: pointer;
}
.lb-rail-h .add:hover { background: var(--chrome-raised); color: var(--chrome-text); }

.lb-callable {
  background: var(--chrome-raised);
  border: 1px solid var(--chrome-border);
  border-radius: 9px;
  padding: 9px 10px;
  display: grid; grid-template-columns: 24px 1fr auto;
  gap: 10px; align-items: center;
  cursor: pointer; transition: background .12s, transform .04s;
  margin-bottom: 6px;
}
.lb-callable:hover { background: oklch(0.27 0.014 250); }
.lb-callable:active { transform: translateY(0.5px); }
.lb-callable .ico {
  width: 24px; height: 24px; border-radius: 6px;
  display: grid; place-items: center;
  background: color-mix(in oklab, var(--teal) 18%, transparent);
  color: var(--teal-strong);
}
.lb-callable .lbl { font-size: 11.5px; font-weight: 500; color: var(--chrome-text); }
.lb-callable .sub { font-size: 10px; color: var(--chrome-muted); margin-top: 1px; }
.lb-callable .shortcut {
  font-family: 'Geist Mono', monospace; font-size: 9.5px; color: var(--chrome-muted);
  background: var(--chrome-bg); border: 1px solid var(--chrome-border);
  padding: 1px 5px; border-radius: 4px;
}
.lb-callable.recent .ico { background: color-mix(in oklab, oklch(0.7 0.14 75) 18%, transparent); color: oklch(0.78 0.16 75); }
.lb-callable.is-disabled { opacity: .4; pointer-events: none; cursor: default; }

.lb-result-row {
  display: grid; grid-template-columns: 22px 1fr auto;
  gap: 8px; align-items: center;
  padding: 6px 4px;
  font-size: 11.5px;
  border-bottom: 1px dashed var(--chrome-border);
}
.lb-result-row:last-child { border-bottom: 0; }
.lb-result-row .swatch {
  width: 22px; height: 16px; border-radius: 3px;
  background:
    linear-gradient(180deg, transparent 50%, oklch(0.45 0.04 240 / .6) 51%, transparent 52%);
  box-shadow: inset 0 0 0 1px var(--chrome-border);
}
.lb-result-row .swatch.gel {
  background:
    linear-gradient(90deg, transparent, oklch(0.9 0.16 145 / .85), transparent),
    oklch(0.18 0.03 240);
}
.lb-result-row .swatch.calc {
  background: var(--chrome-bg);
  display: grid; place-items: center;
  font-family: 'Geist Mono', monospace; font-size: 8px;
  color: var(--teal-strong);
}
.lb-result-row .swatch.seq {
  background:
    repeating-linear-gradient(90deg,
      oklch(0.78 0.16 145) 0 2px,
      oklch(0.78 0.16 75) 2px 4px,
      oklch(0.78 0.16 25) 4px 6px,
      oklch(0.78 0.16 255) 6px 8px);
}
.lb-result-row .ttl { font-weight: 500; color: var(--chrome-text); }
.lb-result-row .sub { font-size: 10px; color: var(--chrome-muted); font-family: 'Geist Mono', monospace; }
.lb-result-row .add-btn {
  font-size: 10px; padding: 3px 7px; border-radius: 5px;
  background: transparent; color: var(--teal-strong);
  border: 1px solid color-mix(in oklab, var(--teal) 25%, var(--chrome-border));
  cursor: pointer; font: inherit; font-size: 10px;
}
.lb-result-row .add-btn:hover { background: color-mix(in oklab, var(--teal) 16%, transparent); }

.lb-storage {
  margin: 14px; padding: 10px 12px;
  background: var(--chrome-raised);
  border: 1px solid var(--chrome-border);
  border-radius: 9px;
  font-size: 11px;
}
.lb-storage .row { display: flex; align-items: center; gap: 8px; }
.lb-storage .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); }
.lb-storage .lbl { color: var(--chrome-text); font-weight: 500; }
.lb-storage .sub { font-size: 10px; color: var(--chrome-muted); margin-top: 4px; font-family: 'Geist Mono', monospace; }
.lb-storage .bar {
  margin-top: 7px; height: 3px; border-radius: 2px;
  background: var(--chrome-bg); overflow: hidden; position: relative;
}
.lb-storage .bar > i { display: block; height: 100%; background: var(--teal); border-radius: 2px; }

/* ── DESK / BOOK STAGE ─────────────────────────────────────── */
.lb-stage {
  min-height: 0; min-width: 0;
  position: relative;
  display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 0%, oklch(0.22 0.014 250) 0%, oklch(0.13 0.012 250) 75%);
  overflow: hidden;
  transform-origin: center center;
  transition: transform 520ms cubic-bezier(0.4, 0, 0.2, 1);
}
.lb-shell.focused .lb-stage {
  height: calc(100dvh - 44px);
  max-height: calc(100dvh - 44px);
  transform: translateZ(0);
}

/* faux desk surface — felt + a faint vignette */
.lb-stage.felt {
  background:
    radial-gradient(ellipse at 50% 30%, oklch(0.28 0.04 200) 0%, oklch(0.16 0.025 230) 70%);
}
.lb-stage::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle, oklch(0.85 0.02 220 / .02) 1px, transparent 1px);
  background-size: 6px 6px;
  pointer-events: none;
}

.lb-stage-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--chrome-border);
  background: color-mix(in oklab, var(--chrome-panel) 80%, transparent);
  backdrop-filter: blur(8px);
  font-size: 11.5px; color: var(--chrome-muted);
  position: relative; z-index: 2;
}
.lb-stage-bar .spacer { flex: 1; }
.lb-stage-bar .info { color: var(--chrome-text); font-weight: 500; }
.lb-stage-bar .info b { color: var(--chrome-text); }
.lb-stage-bar .pen-tools {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--chrome-raised); border: 1px solid var(--chrome-border);
  border-radius: 7px;
}
.lb-stage-bar .pen-tools button {
  width: 24px; height: 22px; border: 0; background: transparent;
  border-radius: 5px; cursor: pointer;
  display: grid; place-items: center; color: var(--chrome-muted);
}
.lb-stage-bar .pen-tools button.on { background: var(--chrome-bg); color: var(--chrome-text); box-shadow: inset 0 0 0 1px var(--chrome-border); }

.lb-book-area {
  flex: 1; min-height: 0; min-width: 0;
  position: relative;
  display: grid; place-items: center;
  padding: 26px 26px 32px;
  transition: padding 520ms cubic-bezier(0.4, 0, 0.2, 1);
}
.lb-shell:not(.focused) .lb-book-area { cursor: zoom-in; }
.lb-shell.focused .lb-book-area {
  padding: 18px 40px 34px;
}
.lb-focus-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 8;
  width: 44px;
  height: 44px;
  border-radius: 9px;
  border: 1px solid var(--chrome-border);
  background: color-mix(in oklab, var(--chrome-panel) 86%, transparent);
  color: var(--chrome-text);
  cursor: pointer;
  display: grid;
  place-items: center;
  font: inherit;
  font-size: 15px;
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition:
    opacity 220ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 520ms cubic-bezier(0.4, 0, 0.2, 1),
    background .12s;
}
.lb-focus-close:hover { background: var(--chrome-raised); }
.lb-shell.focused .lb-focus-close {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* page navigation arrows */
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 38px; height: 56px; border-radius: 10px;
  display: grid; place-items: center;
  background: color-mix(in oklab, var(--chrome-panel) 80%, transparent);
  border: 1px solid var(--chrome-border);
  color: var(--chrome-text); cursor: pointer;
  font-size: 18px;
  backdrop-filter: blur(8px);
  z-index: 5;
}
.lb-nav:hover { background: var(--chrome-raised); }
.lb-nav.prev { left: 14px; }
.lb-nav.next { right: 14px; }
.lb-nav:disabled { opacity: .4; cursor: not-allowed; }

.lb-page-label {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  font-family: 'Geist Mono', monospace; font-size: 10.5px;
  color: var(--chrome-muted);
  letter-spacing: 0.06em;
  z-index: 5;
}

/* ── THE BOOK ─────────────────────────────────────────────── */
.lb-book {
  position: relative;
  perspective: 2200px;
  filter: drop-shadow(0 30px 50px rgba(0,0,0,.45));
  width: min(var(--book-w, 1040px), calc(100vw - 84px));
  transition: transform 520ms cubic-bezier(0.4, 0, 0.2, 1), filter 520ms cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
.lb-shell.focused .lb-book {
  width: min(var(--book-w, 1080px), calc(100vw - 84px), calc((100dvh - 148px) * 1.5));
  transform: translateY(4px);
  filter: drop-shadow(0 42px 70px rgba(0,0,0,.55));
}

@media (prefers-reduced-motion: reduce) {
  body[data-page="labbook"] .ag-sidebar,
  body[data-page="labbook"] .agora:has(.lb-shell.focused),
  .lb-main,
  .lb-side,
  .lb-stage,
  .lb-book-area,
  .lb-book,
  .lb-focus-close {
    transition: none !important;
  }

  .lb-shell.focused .lb-stage,
  .lb-shell.focused .lb-book {
    transform: none;
  }
}

/* spread (left + right page) */
.lb-spread {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  height: auto;
  aspect-ratio: var(--book-ratio, 1.5);
  background:
    linear-gradient(180deg, var(--paper-deep) 0%, var(--paper) 6%, var(--paper) 94%, var(--paper-deep) 100%);
  border-radius: 4px;
  box-shadow:
    inset 0 0 0 1px var(--paper-shadow),
    inset 0 0 30px oklch(0.85 0.018 70 / .35);
  position: relative;
}

/* leather/cloth cover behind paper edge */
.lb-spread::before, .lb-spread::after {
  content: ''; position: absolute; top: -8px; bottom: -8px; width: 14px;
  background:
    linear-gradient(180deg, oklch(0.30 0.04 30) 0%, oklch(0.22 0.04 30) 50%, oklch(0.30 0.04 30) 100%);
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px oklch(0.15 0.03 30);
}
.lb-spread::before { left: -8px; }
.lb-spread::after { right: -8px; }

.lb-page-half {
  position: relative;
  background: var(--paper);
  overflow: hidden;
}
.lb-page-half.left {
  box-shadow:
    inset -14px 0 24px -10px oklch(0.78 0.025 75 / .8),
    inset -1px 0 0 oklch(0.82 0.025 75);
}
.lb-page-half.right {
  box-shadow:
    inset 14px 0 24px -10px oklch(0.78 0.025 75 / .8),
    inset 1px 0 0 oklch(0.82 0.025 75);
}

/* turning page — absolute overlay on top of right half */
.lb-flip {
  position: absolute; top: 0; right: 0; width: 50%; height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.85s cubic-bezier(0.6, 0, 0.4, 1);
  pointer-events: none;
}
.lb-flip.flipping { pointer-events: auto; }
.lb-flip .face {
  position: absolute; inset: 0;
  background: var(--paper);
  backface-visibility: hidden;
  overflow: hidden;
}
.lb-flip .face.back {
  transform: rotateY(180deg);
  background: var(--paper);
}
.lb-flip.turning { transform: rotateY(-180deg); }

/* page surface variants — applied to .lb-surface inside a page */
.lb-surface {
  position: absolute; inset: 0;
  padding: 38px 52px 56px 60px;
  overflow-y: auto;
}
.lb-surface.left-page { padding-left: 38px; padding-right: 64px; }
.lb-surface.right-page { padding-left: 64px; padding-right: 38px; }

.lb-paper--ruled {
  background-image:
    linear-gradient(transparent 0, transparent calc(var(--rule-h, 30px) - 1px), var(--rule) calc(var(--rule-h, 30px) - 1px), var(--rule) var(--rule-h, 30px));
  background-size: 100% var(--rule-h, 30px);
  background-position: 0 0;
}
.lb-paper--dot {
  background-image:
    radial-gradient(circle, oklch(0.72 0.02 230 / .65) 0.9px, transparent 1px);
  background-size: 20px 20px;
  background-position: 0 0;
}
.lb-paper--grid {
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
}
.lb-paper--plain {
  background-image: none;
}

/* red margin on left edge of a page */
.lb-margin {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: var(--redline);
  box-shadow: 1.5px 0 0 var(--redline);
}
.lb-margin.left { left: 44px; }
.lb-margin.right { right: 44px; }

/* punch holes on inside edge */
.lb-holes {
  position: absolute; width: 16px; top: 0; bottom: 0;
  display: flex; flex-direction: column; justify-content: space-around;
  padding: 80px 0;
  pointer-events: none;
}
.lb-holes.right-edge { right: 4px; }
.lb-holes.left-edge { left: 4px; }
.lb-holes i {
  width: 9px; height: 9px; border-radius: 50%;
  background: oklch(0.85 0.018 75);
  box-shadow:
    inset 0 1px 2px oklch(0.62 0.025 75),
    inset 0 -1px 1px oklch(0.95 0.012 85);
  margin: 0 auto;
}

/* page number bottom */
.lb-page-num {
  position: absolute; bottom: 14px;
  font-family: 'Geist Mono', monospace;
  font-size: 11px; color: var(--ink-faint);
  letter-spacing: 0.1em;
}
.lb-page-num.left { left: 60px; }
.lb-page-num.right { right: 60px; }

/* ── INK / WRITING ─────────────────────────────────────────── */
.lb-date {
  font-family: 'Caveat', cursive; font-weight: 600;
  font-size: 22px; color: var(--ink);
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 6px;
}
.lb-date .underline {
  flex: 1; height: 6px; align-self: center;
  background:
    linear-gradient(90deg, var(--ink) 0%, var(--ink) 60%, transparent 100%);
  opacity: .25; border-radius: 3px;
}
.lb-date .day {
  font-family: 'Geist Mono', monospace; font-size: 11px;
  letter-spacing: 0.08em; color: var(--ink-dim); text-transform: uppercase;
  font-weight: 500;
}

.lb-title {
  font-family: 'Caveat', cursive; font-weight: 700;
  font-size: 34px; color: var(--ink);
  margin: 2px 0 14px;
  display: flex; align-items: center; gap: 12px;
  text-wrap: balance;
}
.lb-title .tape {
  display: inline-block;
  padding: 1px 8px; transform: rotate(-2deg);
  font-family: 'Geist Mono', monospace; font-size: 9.5px;
  font-weight: 500; letter-spacing: 0.12em;
  color: oklch(0.32 0.05 60);
  background: oklch(0.92 0.07 88 / .8);
  border: 1px dashed oklch(0.74 0.10 80 / .5);
  text-transform: uppercase;
}

.lb-prose {
  font-family: 'Caveat', cursive;
  font-size: 22px; line-height: 30px;
  color: var(--ink);
  letter-spacing: 0.005em;
}
.lb-prose p { margin: 0 0 6px; }
.lb-prose .marker {
  background: var(--highlight); padding: 0 2px; box-decoration-break: clone;
}
.lb-prose .pencil { color: var(--pencil); font-size: 18px; }
.lb-prose strong { font-weight: 700; color: oklch(0.18 0.07 25); }
.lb-prose em { font-style: italic; color: var(--ink-2); }

/* bullet list with hand-drawn marker */
.lb-list { padding: 0; margin: 6px 0; list-style: none; }
.lb-list li {
  font-family: 'Caveat', cursive; font-size: 21px; line-height: 30px;
  color: var(--ink);
  display: grid; grid-template-columns: 22px 1fr; gap: 6px;
  align-items: baseline;
}
.lb-list li::before {
  content: '–'; color: var(--ink-dim); font-weight: 700;
  transform: translateY(-3px);
}
.lb-list li.done {
  color: var(--ink-dim);
  text-decoration: line-through;
  text-decoration-color: var(--ink-dim);
  text-decoration-thickness: 1.5px;
}
.lb-list li.done::before { content: '✓'; color: oklch(0.55 0.13 145); font-family: 'Geist', sans-serif; font-size: 16px; transform: translateY(-2px); }
.lb-list li.cross {
  color: var(--ink-dim);
  text-decoration: line-through;
  text-decoration-color: oklch(0.55 0.18 25);
}

/* margin annotation (small angled note) */
.lb-margin-note {
  position: absolute; right: 8px;
  font-family: 'Caveat', cursive; font-size: 16px;
  color: oklch(0.55 0.18 25);
  transform: rotate(2deg);
  max-width: 110px;
  line-height: 18px;
}
.lb-margin-note::before {
  content: '↰'; display: inline-block;
  margin-right: 4px; font-size: 14px;
  color: oklch(0.55 0.18 25);
}

/* hand-drawn arrow */
.lb-arrow {
  position: absolute;
  pointer-events: none;
}

/* ── CARDS GLUED / TAPED IN ────────────────────────────────── */
.lb-card {
  position: relative;
  background: var(--paper);
  border-radius: 4px;
  box-shadow:
    0 1px 0 oklch(0.78 0.025 70),
    0 8px 14px -8px oklch(0.4 0.03 70 / .35),
    0 2px 4px -2px oklch(0.4 0.03 70 / .2);
  margin: 12px 0;
  overflow: hidden;
  transform-origin: center;
}
.lb-card.tilt-l { transform: rotate(-0.6deg); }
.lb-card.tilt-r { transform: rotate(0.8deg); }
.lb-card .tape-top {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%) rotate(-1.5deg);
  width: 80px; height: 22px;
  background: oklch(0.92 0.04 80 / .82);
  border-left: 1px dashed oklch(0.76 0.06 75 / .5);
  border-right: 1px dashed oklch(0.76 0.06 75 / .5);
  box-shadow: 0 1px 2px oklch(0.5 0.03 70 / .15);
  z-index: 2;
}

.lb-card-h {
  background: oklch(0.97 0.014 220);
  border-bottom: 1px solid oklch(0.86 0.018 220);
  padding: 9px 14px;
  display: flex; align-items: center; gap: 10px;
  font-family: 'Geist', sans-serif;
}
.lb-card-h .badge {
  font-family: 'Geist Mono', monospace; font-size: 9.5px;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--teal); font-weight: 600;
  padding: 2px 7px 2px 5px;
  background: color-mix(in oklab, var(--teal) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--teal) 22%, transparent);
  border-radius: 99px;
  display: inline-flex; align-items: center; gap: 5px;
}
.lb-card-h .badge .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--teal); }
.lb-card-h .stamp {
  margin-left: auto;
  font-family: 'Geist Mono', monospace; font-size: 9.5px; color: var(--ink-faint);
  letter-spacing: 0.05em;
}
.lb-card-h h4 {
  margin: 0; font-size: 13px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.005em;
}

.lb-card-body { padding: 12px 14px 14px; font-family: 'Geist', sans-serif; color: var(--ink); }

/* gel result card */
.lb-gel {
  display: grid; grid-template-columns: 1fr 1.1fr; gap: 14px; align-items: stretch;
}
.lb-gel .img {
  position: relative;
  background: oklch(0.13 0.018 240);
  border-radius: 4px;
  min-height: 110px;
  overflow: hidden;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 6px;
  gap: 4px;
}
.lb-gel .lane {
  position: relative;
  border-right: 1px dashed oklch(0.32 0.03 230 / .35);
}
.lb-gel .lane:last-child { border-right: 0; }
.lb-gel .well {
  position: absolute; top: 4px; left: 50%; transform: translateX(-50%);
  width: 70%; height: 5px; border-radius: 1px;
  background: oklch(0.20 0.025 240); box-shadow: inset 0 0 0 1px oklch(0.30 0.03 240);
}
.lb-gel .band {
  position: absolute; left: 8%; right: 8%; height: 6px; border-radius: 2px;
  background:
    linear-gradient(180deg, transparent, oklch(0.92 0.20 145 / .9), transparent);
  filter: blur(0.4px);
}
.lb-gel .band.b500 { top: 48%; }
.lb-gel .band.b400 { top: 60%; }
.lb-gel .ladder {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(transparent, oklch(0.5 0.05 60 / .5), transparent);
  background-size: 100% 1.5px;
}
.lb-gel .ladder i {
  position: absolute; right: 4px;
  font-family: 'Geist Mono', monospace; font-size: 8.5px;
  color: oklch(0.65 0.04 230);
}
.lb-gel .roi {
  position: absolute;
  border: 1.5px solid oklch(0.84 0.18 75 / .7);
  border-radius: 3px;
}
.lb-gel .results {
  display: grid; gap: 4px;
  font-family: 'Geist Mono', monospace;
  font-size: 11.5px; color: var(--ink);
}
.lb-gel .results .row {
  display: grid; grid-template-columns: 60px 1fr 30px;
  align-items: center; gap: 8px;
  padding: 3px 0;
  border-bottom: 1px dotted oklch(0.82 0.025 230);
}
.lb-gel .results .row:last-child { border-bottom: 0; }
.lb-gel .results .lane-l { color: var(--ink-dim); font-size: 10.5px; }
.lb-gel .results .bp { color: var(--ink); font-weight: 500; }
.lb-gel .results .ok { color: oklch(0.55 0.13 145); text-align: right; }
.lb-gel .results .warn { color: oklch(0.62 0.18 60); text-align: right; }
.lb-gel .results h5 {
  margin: 0 0 4px; font-size: 10.5px; font-family: 'Geist Mono', monospace;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-dim); font-weight: 600;
}
.lb-gel .verdict {
  margin-top: 8px; padding: 7px 9px;
  background: color-mix(in oklab, var(--teal) 8%, transparent);
  border-left: 2px solid var(--teal);
  font-family: 'Geist', sans-serif; font-size: 11.5px; color: var(--ink);
  line-height: 1.4;
}
.lb-gel .verdict em { font-style: normal; color: var(--teal); font-weight: 500; }

/* bench math card */
.lb-math .formula {
  font-family: 'Geist Mono', monospace; font-size: 14px; color: var(--ink);
  padding: 6px 0;
}
.lb-math .formula em { font-style: italic; color: oklch(0.45 0.06 280); }
.lb-math .answer {
  font-family: 'Geist Mono', monospace; font-size: 16px; font-weight: 600;
  color: var(--teal); padding: 6px 0;
}
.lb-math .recipe {
  margin-top: 6px; padding: 8px 10px;
  background: oklch(0.96 0.02 80);
  border: 1px dashed oklch(0.78 0.04 80);
  border-radius: 4px;
  font-family: 'Geist Mono', monospace; font-size: 12px; color: var(--ink);
}

/* attached photo with washi tape */
.lb-photo {
  position: relative;
  background: oklch(0.85 0.02 90);
  border-radius: 2px;
  box-shadow:
    0 1px 0 oklch(0.6 0.04 70),
    0 12px 18px -8px oklch(0.3 0.03 70 / .4);
  margin: 14px 0;
  padding: 8px 8px 28px;
  transform: rotate(-1.2deg);
}
.lb-photo .img {
  position: relative;
  height: 160px; border-radius: 2px; overflow: hidden;
  background:
    repeating-linear-gradient(45deg,
      oklch(0.72 0.04 240) 0 6px,
      oklch(0.68 0.04 240) 6px 12px);
}
.lb-photo .img::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 30% 30%, oklch(0.5 0.08 200 / .35), transparent 50%),
    radial-gradient(circle at 70% 70%, oklch(0.4 0.12 300 / .3), transparent 50%);
  mix-blend-mode: screen;
}
.lb-photo .caption {
  position: absolute; bottom: 6px; left: 12px; right: 12px;
  font-family: 'Caveat', cursive; font-size: 17px; color: var(--ink-2);
  text-align: center;
}
.lb-photo .washi {
  position: absolute; top: -12px; width: 70px; height: 22px;
  background:
    repeating-linear-gradient(45deg,
      oklch(0.85 0.14 195 / .82) 0 6px,
      oklch(0.78 0.14 195 / .82) 6px 12px);
  box-shadow: 0 1px 2px oklch(0.4 0.03 70 / .25);
}
.lb-photo .washi.tl { left: 14px; transform: rotate(-12deg); }
.lb-photo .washi.tr { right: 14px; transform: rotate(8deg); }
.lb-photo .label {
  position: absolute; bottom: -14px; right: 12px;
  transform: rotate(2deg);
  font-family: 'Caveat', cursive; font-size: 16px; color: oklch(0.55 0.18 25);
}

/* sticky note */
.lb-sticky {
  position: absolute;
  width: 140px; min-height: 110px;
  background: oklch(0.92 0.14 95);
  padding: 12px 12px 14px;
  font-family: 'Caveat', cursive; font-size: 17px; color: oklch(0.20 0.05 80);
  line-height: 22px;
  box-shadow: 0 8px 16px -6px oklch(0.4 0.06 90 / .45);
  transform: rotate(3deg);
}
.lb-sticky::after {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 60px; height: 16px;
  background: oklch(0.96 0.04 100 / .55);
}
.lb-sticky.pink { background: oklch(0.90 0.11 0); color: oklch(0.22 0.05 0); transform: rotate(-2deg); }

/* sequence table (RNA-seq) */
.lb-rnaseq table { width: 100%; border-collapse: separate; border-spacing: 0; font-family: 'Geist Mono', monospace; font-size: 11px; }
.lb-rnaseq th {
  text-align: left; padding: 5px 8px;
  font-weight: 600; color: var(--ink-dim);
  font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
  border-bottom: 1px solid oklch(0.86 0.018 220);
}
.lb-rnaseq td {
  padding: 5px 8px;
  border-bottom: 1px dotted oklch(0.82 0.025 230);
  color: var(--ink);
}
.lb-rnaseq td.up { color: oklch(0.55 0.18 25); }
.lb-rnaseq td.dn { color: oklch(0.50 0.16 235); }
.lb-rnaseq .right { text-align: right; }

/* qPCR chart */
.lb-chart {
  position: relative;
  height: 130px;
  background: oklch(0.985 0.01 220);
  border: 1px solid oklch(0.88 0.018 220);
  border-radius: 4px;
  padding: 8px 10px 18px 32px;
}
.lb-chart svg { width: 100%; height: 100%; display: block; }
.lb-chart .axis {
  position: absolute; left: 6px; top: 6px;
  font-family: 'Geist Mono', monospace; font-size: 9px; color: var(--ink-faint);
}
.lb-chart .axis-x {
  position: absolute; bottom: 4px; left: 32px; right: 6px;
  display: flex; justify-content: space-between;
  font-family: 'Geist Mono', monospace; font-size: 9px; color: var(--ink-faint);
}
.lb-chart .legend {
  position: absolute; right: 8px; top: 6px;
  display: flex; flex-direction: column; gap: 3px;
  font-family: 'Geist Mono', monospace; font-size: 9.5px; color: var(--ink-dim);
}
.lb-chart .legend i {
  display: inline-block; width: 10px; height: 2px; margin-right: 5px; vertical-align: middle;
}

/* ── COVER PAGE ─────────────────────────────────────────── */
.lb-cover {
  position: absolute; inset: 0;
  background:
    linear-gradient(135deg, oklch(0.35 0.05 30) 0%, oklch(0.24 0.05 30) 100%);
  color: oklch(0.92 0.04 80);
  display: flex; flex-direction: column;
  padding: 60px 60px;
  font-family: 'Geist', sans-serif;
}
.lb-cover::before {
  content: ''; position: absolute; inset: 24px;
  border: 1px solid oklch(0.6 0.08 60 / .35);
  border-radius: 2px;
  pointer-events: none;
}
.lb-cover .label {
  font-family: 'Geist Mono', monospace; font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: oklch(0.78 0.06 80); opacity: .8;
}
.lb-cover h1 {
  font-family: 'Caveat', cursive;
  font-size: 64px; font-weight: 700;
  margin: 18px 0 12px;
  color: oklch(0.94 0.06 75);
  line-height: 1.05;
}
.lb-cover .name {
  font-family: 'Caveat', cursive; font-size: 26px;
  color: oklch(0.86 0.06 75);
}
.lb-cover .meta {
  margin-top: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  font-family: 'Geist Mono', monospace; font-size: 10.5px;
  letter-spacing: 0.06em;
  color: oklch(0.78 0.06 80 / .8);
}
.lb-cover .meta .l { color: oklch(0.65 0.06 75); }
.lb-cover .crest {
  width: 64px; height: 64px; border-radius: 50%;
  border: 1px solid oklch(0.7 0.10 75 / .55);
  display: grid; place-items: center;
  font-family: 'Caveat', cursive; font-size: 30px;
  color: oklch(0.85 0.10 75);
  margin-bottom: 30px;
}
.lb-cover .crest-img {
  width: 64px; height: 64px; border-radius: 50%;
  border: 1px solid oklch(0.7 0.10 75 / .55);
  object-fit: cover; margin-bottom: 30px;
  cursor: pointer; transition: opacity .15s;
}
.lb-cover .crest-img:hover { opacity: .8; }
.lb-cover h1[contenteditable]:focus {
  background: oklch(0.30 0.04 30 / 0.4);
  border-radius: 4px; padding: 2px 6px; margin: -2px -6px;
}

/* TOC */
.lb-toc { display: grid; gap: 4px; margin-top: 8px; font-family: 'Caveat', cursive; }
.lb-toc .row {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 8px;
  font-size: 22px; color: var(--ink);
  align-items: baseline;
}
.lb-toc .row .n { color: var(--ink-faint); font-family: 'Geist Mono', monospace; font-size: 11px; padding-top: 4px; }
.lb-toc .row .dots {
  border-bottom: 2px dotted var(--ink-faint);
  position: relative; bottom: 5px;
}
.lb-toc .row .pg { font-family: 'Geist Mono', monospace; font-size: 11px; color: var(--ink-dim); padding-top: 4px; }

/* ── MOBILE (phone) ─────────────────────────────────────── */
.lb-m {
  width: 100%; height: 100%;
  background: oklch(0.16 0.02 230);
  color: var(--chrome-text);
  font-family: 'Geist', sans-serif;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.lb-m-head {
  padding: 10px 18px 14px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
}
.lb-m-head .brand-tile {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, oklch(0.78 0.16 195), oklch(0.5 0.12 220));
  display: grid; place-items: center;
  font-family: 'Caveat', cursive; font-size: 22px; color: #061417; font-weight: 700;
}
.lb-m-head .ttl { font-weight: 600; font-size: 16px; letter-spacing: -0.005em; }
.lb-m-head .sub { font-size: 11px; color: var(--chrome-muted); margin-top: 2px; }
.lb-m-head .icon-btn { margin-left: auto; }

.lb-m-stage {
  flex: 1;
  position: relative;
  padding: 8px 16px 12px;
  display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 0%, oklch(0.24 0.025 220) 0%, oklch(0.13 0.018 230) 80%);
  min-height: 0;
}

.lb-m-book {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid; place-items: stretch;
  filter: drop-shadow(0 18px 30px rgba(0,0,0,.45));
}
.lb-m-page {
  position: relative;
  background: var(--paper);
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 1px var(--paper-shadow),
    inset 0 0 24px oklch(0.85 0.018 70 / .35);
  overflow: hidden;
}
.lb-m-page.swiping { transition: transform 0.4s ease; }
.lb-m-surface {
  position: absolute; inset: 0;
  padding: 22px 22px 50px 26px;
  overflow: hidden;
}

.lb-m-foot {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px 8px;
  font-family: 'Geist Mono', monospace; font-size: 11px;
  color: var(--chrome-muted);
}
.lb-m-foot .dots {
  display: flex; gap: 6px; align-items: center; flex: 1; justify-content: center;
}
.lb-m-foot .dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--chrome-border);
}
.lb-m-foot .dots i.on { background: var(--teal); width: 14px; border-radius: 99px; }

.lb-m-tab {
  display: flex; gap: 4px;
  background: oklch(0.18 0.02 230);
  padding: 10px 14px 22px;
  border-top: 1px solid var(--chrome-border);
}
.lb-m-tab button {
  flex: 1; background: transparent; border: 0; cursor: pointer;
  color: var(--chrome-muted); font: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 0; font-size: 10.5px;
}
.lb-m-tab button .ico {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 8px;
}
.lb-m-tab button.on { color: var(--teal-strong); }
.lb-m-tab button.on .ico { background: color-mix(in oklab, var(--teal) 18%, transparent); }

/* mobile FAB */
.lb-m-fab {
  position: absolute; bottom: 14px; right: 18px;
  width: 52px; height: 52px; border-radius: 50%;
  background: oklch(0.94 0.06 75);
  color: oklch(0.22 0.04 30);
  display: grid; place-items: center;
  font-family: 'Caveat', cursive; font-size: 32px; font-weight: 700;
  box-shadow: 0 14px 24px -8px rgba(0,0,0,.5), inset 0 0 0 1px oklch(0.82 0.05 75);
  cursor: pointer;
  z-index: 10;
}

/* mobile mini callable sheet (peek from bottom) */
.lb-m-sheet {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  background: oklch(0.21 0.018 230);
  border: 1px solid var(--chrome-border);
  border-radius: 18px;
  padding: 14px 14px 8px;
  box-shadow: 0 -10px 30px -8px rgba(0,0,0,.5);
  z-index: 20;
}
.lb-m-sheet .grab {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--chrome-border);
  margin: -4px auto 8px;
}
.lb-m-sheet h5 {
  margin: 0 0 8px; font-size: 11px; color: var(--chrome-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}

/* ── PRINT/INK-LIKE small components ─────────────────────────── */
.lb-tape-line {
  height: 14px; margin: 8px 0;
  background:
    repeating-linear-gradient(90deg,
      oklch(0.92 0.07 88 / .55) 0 6px,
      transparent 6px 9px);
  border-radius: 1px;
}
.lb-hr {
  height: 1px;
  background: var(--ink-faint);
  opacity: .35;
  margin: 10px 0;
}

/* "doodle" sketches embedded in margin */
.lb-doodle {
  font-family: 'Caveat', cursive; color: var(--ink-2);
  opacity: .85;
  transform: rotate(-3deg);
}

/* spine connector centerline on spread */
.lb-spine {
  position: absolute; left: 50%; top: 0; bottom: 0;
  width: 30px; transform: translateX(-50%);
  background:
    linear-gradient(90deg,
      transparent 0%,
      oklch(0.72 0.025 70 / .45) 30%,
      oklch(0.55 0.03 60 / .65) 50%,
      oklch(0.72 0.025 70 / .45) 70%,
      transparent 100%);
  pointer-events: none;
  z-index: 1;
}
.lb-spine::after {
  content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px;
  transform: translateX(-50%);
  background: oklch(0.40 0.04 60 / .55);
}

/* ── INK overlay flourishes — give pages slight warmth ── */
.lb-paper-warmth::after {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 0% 100%, oklch(0.78 0.04 75 / .12), transparent 40%),
    radial-gradient(ellipse at 100% 0%, oklch(0.78 0.04 75 / .12), transparent 50%);
}

/* tap target hover for "callable" experiment chips in left rail
   (browser sidebar) */
.lb-add-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px 4px 6px; border-radius: 99px;
  background: color-mix(in oklab, var(--teal) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--teal) 25%, transparent);
  color: var(--teal-strong);
  font-size: 10.5px; font-family: 'Geist Mono', monospace;
  cursor: pointer; user-select: none;
}
.lb-add-chip:hover { background: color-mix(in oklab, var(--teal) 20%, transparent); }
.lb-add-chip .plus { font-size: 13px; line-height: 13px; }

/* ───────────────────────────────────────────────────────────
   MOBILE — proper 3D book (object with thickness on the desk)
   ─────────────────────────────────────────────────────────── */

.lb-m-stage.book3d {
  background:
    radial-gradient(ellipse at 50% 0%, oklch(0.30 0.04 200) 0%, oklch(0.14 0.022 230) 75%);
  padding: 0;
  perspective: 1600px;
  perspective-origin: 50% 30%;
}

/* horizontal "quick-call" rail above the page (today's experiments) */
.lb-m-rail {
  display: flex; gap: 8px;
  padding: 10px 14px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.lb-m-rail::-webkit-scrollbar { display: none; }
.lb-m-rail .chip {
  flex-shrink: 0;
  background: oklch(0.22 0.02 230 / .85);
  border: 1px solid var(--chrome-border);
  border-radius: 14px;
  padding: 8px 12px 8px 10px;
  display: flex; align-items: center; gap: 8px;
  color: var(--chrome-text);
  font-size: 11.5px; font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.lb-m-rail .chip .ico {
  width: 26px; height: 26px; border-radius: 7px;
  background: color-mix(in oklab, var(--teal) 18%, transparent);
  color: var(--teal-strong);
  display: grid; place-items: center;
}
.lb-m-rail .chip.recent .ico { background: color-mix(in oklab, oklch(0.78 0.16 75) 18%, transparent); color: oklch(0.84 0.18 75); }
.lb-m-rail .chip.recent .ico { background: color-mix(in oklab, oklch(0.78 0.16 75) 18%, transparent); color: oklch(0.84 0.18 75); }
.lb-m-rail .chip .meta { font-size: 9.5px; color: var(--chrome-muted); font-family: 'Geist Mono', monospace; }

/* The book itself — a 3D object with visible thickness */
.lb-m-book3d {
  flex: 1;
  position: relative;
  margin: 4px 14px 0;
  transform-style: preserve-3d;
  transform: rotateX(2deg);
  min-height: 0;
}

/* paper "stack" — fanned page edges visible behind the live page */
.lb-m-stack {
  position: absolute;
  inset: 0;
  border-radius: 6px 18px 18px 6px;
  pointer-events: none;
}
.lb-m-stack i {
  position: absolute;
  border-radius: 6px 18px 18px 6px;
  background: linear-gradient(180deg, var(--paper-deep) 0%, var(--paper) 8%, var(--paper) 92%, var(--paper-deep) 100%);
  box-shadow: inset 0 0 0 1px oklch(0.82 0.025 75);
  inset: 0;
}
.lb-m-stack i:nth-child(1) { transform: translate(4px, 4px); opacity: 0.55; filter: brightness(0.92); }
.lb-m-stack i:nth-child(2) { transform: translate(8px, 8px); opacity: 0.42; filter: brightness(0.84); }
.lb-m-stack i:nth-child(3) { transform: translate(11px, 11px); opacity: 0.30; filter: brightness(0.78); }

/* leather spine + cover slab on the LEFT edge */
.lb-m-binding {
  position: absolute;
  left: -10px; top: -6px; bottom: -6px; width: 22px;
  background:
    linear-gradient(180deg, oklch(0.30 0.05 30) 0%, oklch(0.21 0.05 30) 50%, oklch(0.30 0.05 30) 100%);
  border-radius: 4px 0 0 4px;
  box-shadow:
    inset -2px 0 4px oklch(0.10 0.04 30 / .7),
    inset 1px 0 0 oklch(0.50 0.08 40 / .35),
    -2px 0 10px oklch(0.08 0.03 30 / .55);
  z-index: 2;
}
.lb-m-binding::after {
  /* stitching */
  content: '';
  position: absolute;
  left: 4px; top: 14px; bottom: 14px;
  width: 1px;
  background:
    repeating-linear-gradient(180deg,
      oklch(0.65 0.10 70 / .55) 0 4px,
      transparent 4px 9px);
}
.lb-m-binding-label {
  position: absolute; left: -8px; top: 50%;
  transform: rotate(-90deg) translateX(50%);
  transform-origin: left center;
  font-family: 'Caveat', cursive; font-size: 13px;
  color: oklch(0.78 0.08 80 / .7);
  letter-spacing: 0.04em;
  white-space: nowrap;
  z-index: 3;
  pointer-events: none;
}

/* the active page — sits on the stack */
.lb-m-page3d {
  position: absolute;
  inset: 0;
  border-radius: 6px 18px 18px 6px;
  transform-origin: left center;
  transform-style: preserve-3d;
  will-change: transform;
}
.lb-m-page3d.behind { z-index: 1; }
.lb-m-page3d.prev   { z-index: 2; }
.lb-m-page3d.front  { z-index: 3; }

.lb-m-page3d .face {
  position: absolute; inset: 0;
  background: var(--paper);
  border-radius: inherit;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-shadow:
    inset 14px 0 24px -10px oklch(0.78 0.025 75 / .8),
    inset 1px 0 0 oklch(0.82 0.025 75),
    0 14px 24px -10px rgba(0,0,0,.45);
}
.lb-m-page3d .face.back {
  transform: rotateY(180deg);
  /* mirrored shadow — light comes from the OTHER side */
  box-shadow:
    inset -14px 0 24px -10px oklch(0.78 0.025 75 / .8),
    inset -1px 0 0 oklch(0.82 0.025 75);
}
/* Soft gradient on the back side to suggest "you're seeing the wrong side
   of the paper" — like real ink-bleed-through but very faint. */
.lb-m-page3d .face.back::after {
  content: '';
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(
      transparent 0,
      transparent calc(var(--rule-h, 30px) - 1px),
      oklch(0.82 0.020 230 / .25) calc(var(--rule-h, 30px) - 1px),
      oklch(0.82 0.020 230 / .25) var(--rule-h, 30px)
    ),
    radial-gradient(ellipse at 70% 30%, oklch(0.78 0.025 75 / .15), transparent 60%);
  pointer-events: none;
}

/* corner peel hint — a soft triangle on bottom-right */
.lb-m-corner {
  position: absolute; right: 0; bottom: 0;
  width: 28px; height: 28px;
  background:
    linear-gradient(135deg, transparent 50%, oklch(0.86 0.022 80) 50%, oklch(0.78 0.025 75) 100%);
  border-bottom-right-radius: 18px;
  z-index: 4;
  pointer-events: none;
  filter: drop-shadow(-2px -2px 4px oklch(0.40 0.03 70 / .4));
  transition: width 0.2s, height 0.2s;
}
.lb-m-corner::after {
  content: '';
  position: absolute; right: 3px; bottom: 3px;
  width: 8px; height: 8px;
  border-bottom: 1.5px solid oklch(0.55 0.04 70 / .5);
  border-right: 1.5px solid oklch(0.55 0.04 70 / .5);
  border-bottom-right-radius: 6px;
  opacity: 0.7;
}

.lb-m-page3d .lb-m-surface {
  inset: 0;
  border-radius: inherit;
}

/* responsive overrides inside a mobile page surface — stack cards vertically */
.lb-m-surface .lb-card { margin: 10px 0; }
.lb-m-surface .lb-card-h h4 { font-size: 12px; }
.lb-m-surface .lb-gel {
  grid-template-columns: 1fr;
  gap: 8px;
}
.lb-m-surface .lb-gel .img { min-height: 96px; }
.lb-m-surface .lb-prose { font-size: 19px; line-height: 26px; }
.lb-m-surface .lb-title { font-size: 28px; margin-bottom: 8px; }
.lb-m-surface .lb-date { font-size: 18px; }
.lb-m-surface .lb-list li { font-size: 18px; line-height: 26px; }
.lb-m-surface .lb-photo { margin: 10px 0; }
.lb-m-surface .lb-photo .img { height: 130px; }
.lb-m-surface .lb-chart { height: 110px; }
.lb-m-surface .lb-margin-note { font-size: 14px; max-width: 84px; line-height: 16px; right: 4px; }
.lb-m-surface .lb-sticky { width: 110px; min-height: 88px; font-size: 14px; line-height: 18px; padding: 8px 10px; }
.lb-m-surface .lb-rnaseq table { font-size: 10.5px; }
.lb-m-surface .lb-rnaseq th, .lb-m-surface .lb-rnaseq td { padding: 4px 6px; }
.lb-m-surface .lb-toc .row { font-size: 20px; }

/* footer (page counter + flip hint) */
.lb-m-foot3d {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px 4px;
  font-family: 'Geist Mono', monospace; font-size: 10.5px;
  color: var(--chrome-muted);
}
.lb-m-foot3d .pageno {
  display: inline-flex; align-items: center; gap: 6px;
  background: oklch(0.22 0.02 230 / .8);
  border: 1px solid var(--chrome-border);
  border-radius: 99px;
  padding: 3px 9px;
}
.lb-m-foot3d .pageno b { color: var(--chrome-text); }
.lb-m-foot3d .hint { display: inline-flex; align-items: center; gap: 6px; opacity: .8; }

/* tap zones for flipping when not dragging */
.lb-m-tap {
  position: absolute; top: 30px; bottom: 50px; width: 22%;
  z-index: 5; opacity: 0;
}
.lb-m-tap.left { left: 14px; }
.lb-m-tap.right { right: 14px; }

/* tags on a page */
.lb-tags { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.lb-tags .t {
  font-family: 'Geist Mono', monospace; font-size: 11px;
  padding: 2px 8px 2px 6px; border-radius: 99px;
  background: color-mix(in oklab, var(--teal) 10%, transparent);
  color: var(--teal); border: 1px dashed color-mix(in oklab, var(--teal) 35%, transparent);
}
.lb-tags .t::before { content: '#'; opacity: .6; margin-right: 2px; }

/* ───────────────────────────────────────────────────────────
   MOBILE — Write composer (clean iOS form, no fancy paper)
   The 3D book is for BROWSING; this is for actually writing notes
   at the bench. Native-feeling, big touch targets, fast typing.
   ─────────────────────────────────────────────────────────── */
.lb-m-write {
  position: absolute; inset: 0;
  background: oklch(0.13 0.018 240);
  color: var(--chrome-text);
  display: flex; flex-direction: column;
  z-index: 80;
  font-family: -apple-system, system-ui, 'Geist', sans-serif;
}
.lb-m-write-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--chrome-border);
}
.lb-m-write-head .cancel {
  background: transparent; border: 0; color: var(--teal-strong);
  font: inherit; font-size: 15px; cursor: pointer; padding: 4px 0;
}
.lb-m-write-head .meta {
  flex: 1; text-align: center;
  font-size: 11px; color: var(--chrome-muted);
  font-family: 'Geist Mono', monospace; letter-spacing: 0.04em;
}
.lb-m-write-head .save {
  background: var(--teal-strong); color: #061417;
  border: 0; border-radius: 99px;
  padding: 7px 16px; font-size: 14px; font-weight: 600;
  font: inherit; font-weight: 600;
  cursor: pointer;
}

.lb-m-write-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 18px 18px 12px;
}
.lb-m-write-title {
  width: 100%; background: transparent; border: 0; outline: 0;
  color: var(--chrome-text);
  font: inherit; font-size: 26px; font-weight: 600;
  letter-spacing: -0.01em; line-height: 1.15;
  padding: 0; margin: 0 0 6px;
}
.lb-m-write-title::placeholder { color: oklch(0.45 0.012 250); }

.lb-m-write-tagline {
  display: flex; gap: 8px; margin-bottom: 18px;
  font-family: 'Geist Mono', monospace; font-size: 11px;
  color: var(--chrome-muted); letter-spacing: 0.06em; text-transform: uppercase;
}
.lb-m-write-tagline .pill {
  background: oklch(0.21 0.018 230);
  padding: 3px 9px; border-radius: 99px;
  border: 1px solid var(--chrome-border);
  color: var(--chrome-text);
}

.lb-m-write-body {
  width: 100%; background: transparent; border: 0; outline: 0;
  color: var(--chrome-text);
  font: inherit; font-size: 16px; line-height: 24px;
  min-height: 180px; resize: none;
  padding: 0; margin: 0;
}
.lb-m-write-body::placeholder { color: oklch(0.42 0.012 250); }

/* "stuck in the page" cards rendered inline as the user inserts them */
.lb-m-write-card {
  margin: 14px 0;
  border: 1px solid var(--chrome-border);
  background: oklch(0.21 0.018 230);
  border-radius: 14px;
  overflow: hidden;
}
.lb-m-write-card .h {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: oklch(0.24 0.018 230);
  border-bottom: 1px solid var(--chrome-border);
  font-size: 11.5px; color: var(--chrome-text);
}
.lb-m-write-card .h .badge {
  font-family: 'Geist Mono', monospace; font-size: 9.5px;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--teal-strong); font-weight: 600;
  padding: 2px 7px 2px 5px;
  background: color-mix(in oklab, var(--teal) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--teal) 22%, transparent);
  border-radius: 99px;
  display: inline-flex; align-items: center; gap: 5px;
}
.lb-m-write-card .h .badge .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--teal); }
.lb-m-write-card .h .ttl { font-weight: 500; flex: 1; }
.lb-m-write-card .h .x {
  width: 22px; height: 22px; border-radius: 6px;
  border: 0; background: transparent; color: var(--chrome-muted); cursor: pointer;
  display: grid; place-items: center; font-size: 14px;
}
.lb-m-write-card .b {
  padding: 12px 14px;
  font-family: 'Geist Mono', monospace; font-size: 12px;
  color: var(--chrome-text);
  line-height: 1.5;
}
.lb-m-write-card .b .ans {
  color: var(--teal-strong); font-size: 16px; font-weight: 600; margin-top: 4px;
}

.lb-m-write-quickrow {
  position: sticky; bottom: 0;
  display: flex; gap: 8px; overflow-x: auto;
  padding: 10px 16px;
  background: color-mix(in oklab, oklch(0.16 0.018 240) 90%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--chrome-border);
  scrollbar-width: none;
}
.lb-m-write-quickrow::-webkit-scrollbar { display: none; }
.lb-m-write-quickrow .q {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 13px;
  background: oklch(0.22 0.018 230);
  border: 1px solid var(--chrome-border);
  border-radius: 99px;
  color: var(--chrome-text); font: inherit; font-size: 13px;
  cursor: pointer;
}
.lb-m-write-quickrow .q .ico {
  width: 18px; height: 18px;
  color: var(--teal-strong);
  display: grid; place-items: center;
}
.lb-m-write-quickrow .q.aspis {
  background: linear-gradient(135deg, color-mix(in oklab, var(--teal) 28%, oklch(0.22 0.018 230)), oklch(0.22 0.018 230));
  border-color: color-mix(in oklab, var(--teal) 35%, var(--chrome-border));
}

/* Tag chips inline at bottom of composer */
.lb-m-write-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--chrome-border);
}
.lb-m-write-tags .t {
  font-family: 'Geist Mono', monospace; font-size: 12px;
  padding: 4px 10px 4px 8px; border-radius: 99px;
  background: color-mix(in oklab, var(--teal) 14%, transparent);
  color: var(--teal-strong);
  border: 1px solid color-mix(in oklab, var(--teal) 28%, transparent);
}
.lb-m-write-tags .t::before { content: '#'; opacity: .6; margin-right: 2px; }
.lb-m-write-tags .add {
  font-size: 12px; color: var(--chrome-muted);
  padding: 4px 8px; border-radius: 99px;
  border: 1px dashed var(--chrome-border);
  background: transparent;
  cursor: pointer;
}

/* "Last result" pill above the keyboard (suggestion) */
.lb-m-write-suggest {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0 0;
  padding: 12px 14px;
  background: linear-gradient(135deg,
    color-mix(in oklab, var(--teal) 14%, oklch(0.21 0.018 230)),
    oklch(0.21 0.018 230) 70%);
  border: 1px solid color-mix(in oklab, var(--teal) 25%, var(--chrome-border));
  border-radius: 14px;
}
.lb-m-write-suggest .ico {
  width: 32px; height: 32px; border-radius: 9px;
  background: color-mix(in oklab, var(--teal) 18%, transparent);
  color: var(--teal-strong);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.lb-m-write-suggest .body { flex: 1; font-size: 12.5px; line-height: 1.4; }
.lb-m-write-suggest .body .sub { color: var(--chrome-muted); font-size: 10.5px; margin-top: 2px; font-family: 'Geist Mono', monospace; }
.lb-m-write-suggest .insert {
  background: var(--teal-strong); color: #061417;
  border: 0; border-radius: 99px;
  padding: 6px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; flex-shrink: 0;
}

/* Read-mode label on the book — clarifies it's a preview */
.lb-m-readlabel {
  position: absolute; top: 60px; right: 16px;
  background: color-mix(in oklab, oklch(0.13 0.018 240) 80%, transparent);
  border: 1px solid var(--chrome-border);
  border-radius: 99px;
  padding: 3px 9px 3px 7px;
  font-family: 'Geist Mono', monospace; font-size: 10px;
  color: var(--chrome-muted);
  letter-spacing: 0.06em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 5px;
  z-index: 8;
  backdrop-filter: blur(8px);
}
.lb-m-readlabel .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--teal); }

/* ── Conflict resolution UI ──────────────────────────────────── */

.lb-conflict-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 0px;
  vertical-align: middle;
  position: relative;
  top: -1px;
  opacity: 0.85;
}

.lb-conflict-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  margin: 0 10px 4px;
  background: color-mix(in oklab, oklch(0.55 0.18 40) 18%, oklch(0.18 0.012 240));
  border: 1px solid color-mix(in oklab, oklch(0.55 0.18 40) 30%, oklch(0.22 0.018 240));
  border-radius: 12px;
}

.lb-conflict-banner-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--chrome-text);
}

.lb-conflict-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #0a1216;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.lb-conflict-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.lb-conflict-banner-actions .lb-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 0;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.lb-conflict-banner-actions .lb-btn.is-accent {
  background: var(--accent);
  color: #0a1216;
}

.lb-conflict-banner-actions .lb-btn.is-muted {
  background: oklch(0.22 0.018 240);
  color: var(--chrome-text);
}

/* Conflict resolver overlay */
.lb-conflict-overlay {
  position: fixed; inset: 0;
  background: rgba(6, 20, 23, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.lb-conflict-resolver {
  background: oklch(0.16 0.012 240);
  border: 1px solid var(--chrome-border);
  border-radius: 18px;
  width: min(680px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lb-conflict-resolver-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--chrome-border);
}

.lb-conflict-resolver-head h3 {
  margin: 0;
  font-family: 'Geist', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--chrome-text);
}

.lb-conflict-resolver-body {
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lb-conflict-entry {
  background: oklch(0.20 0.015 240);
  border: 1px solid var(--chrome-border);
  border-radius: 14px;
  padding: 14px;
}

.lb-conflict-entry-head {
  margin-bottom: 10px;
}

.lb-conflict-kind {
  font-family: 'Geist Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in oklab, var(--accent) 12%, transparent);
  padding: 3px 10px;
  border-radius: 6px;
}

.lb-conflict-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lb-conflict-col {
  background: oklch(0.17 0.012 240);
  border-radius: 10px;
  padding: 12px;
}

.lb-conflict-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--chrome-muted);
  margin-bottom: 6px;
}

.lb-conflict-timestamp {
  font-size: 10px;
  font-family: 'Geist Mono', monospace;
  color: var(--chrome-muted);
  margin-bottom: 8px;
}

.lb-conflict-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--chrome-text);
  margin-bottom: 4px;
}

.lb-conflict-body {
  font-size: 12px;
  color: var(--chrome-text);
  opacity: 0.85;
  max-height: 80px;
  overflow: hidden;
  margin-bottom: 6px;
  white-space: pre-wrap;
}

.lb-conflict-tags {
  font-size: 10.5px;
  font-family: 'Geist Mono', monospace;
  color: var(--teal-strong);
}

.lb-conflict-explain {
  font-size: 13px;
  color: var(--chrome-text);
  margin: 8px 0 12px;
  line-height: 1.5;
}

.lb-conflict-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.lb-conflict-actions .lb-btn {
  padding: 8px 16px;
  border-radius: 10px;
  border: 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}

.lb-conflict-actions .lb-btn.is-primary {
  background: oklch(0.28 0.02 240);
  color: var(--chrome-text);
  border: 1px solid var(--chrome-border);
}

.lb-conflict-actions .lb-btn.is-accent {
  background: var(--accent);
  color: #0a1216;
}

/* ── ASPIR HELPER DRAWER (Lab Book) ─────────────────────────────── */
.lb-helper-drawer {
  --lbh-text: #f8f0e6;
  --lbh-muted: #c7b7a7;
  --lbh-quiet: #8c8178;
  --lbh-amber: #f4d19a;
  --lbh-rose: #d4a9a0;
  --lbh-cyan: #87d8f7;
  --lbh-line: rgba(255, 255, 255, 0.12);
  --lbh-line-soft: rgba(255, 255, 255, 0.075);
  --lbh-surface: rgba(13, 14, 17, 0.92);
}

.lb-helper-backdrop {
  position: fixed; inset: 0; z-index: 39;
  border: 0; background: rgba(2, 4, 6, 0.54); cursor: pointer;
}
.lb-helper-backdrop[hidden] { display: none; }

.lb-helper-drawer {
  position: fixed; top: 44px; right: 0; bottom: 0; z-index: 40;
  width: min(468px, 100vw);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 0; padding: 0;
  border-left: 1px solid var(--lbh-line);
  border-top-left-radius: 34px;
  border-bottom-left-radius: 34px;
  background:
    linear-gradient(180deg, rgba(248, 226, 201, 0.09), transparent 36%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.055), transparent 48%),
    var(--lbh-surface);
  color: var(--lbh-text);
  box-shadow: -34px 0 90px rgba(0, 0, 0, 0.54);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  overflow: hidden;
  opacity: 0; pointer-events: none;
  transform: translateX(100%);
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1), opacity 180ms ease;
}
.lb-helper-drawer.is-open {
  opacity: 1; pointer-events: auto; transform: translateX(0);
}

.lb-helper-head {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--lbh-line);
}
.lb-helper-head-copy { min-width: 0; }
.lb-helper-brandmark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.54));
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  overflow: hidden; flex: 0 0 auto;
}
.lb-helper-brandmark img { width: 22px; height: 22px; object-fit: contain; opacity: 0.96; }
.lb-helper-head h2 { margin: 0; font-size: 18px; font-weight: 780; line-height: 1.1; color: var(--lbh-text); }
.lb-helper-head p { margin: 3px 0 0; color: var(--lbh-quiet); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lb-helper-close {
  margin-left: auto; width: 34px; height: 34px;
  border: 1px solid var(--lbh-line); border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.045); color: var(--lbh-muted);
  font-size: 18px; line-height: 1; cursor: pointer;
}

.lb-helper-stream {
  min-height: 0; display: flex; flex-direction: column;
  align-items: stretch; gap: 18px;
  padding: 20px 22px; overflow-y: auto;
}
.lb-helper-stream.scroll { scrollbar-width: thin; }

.lb-helper-message-row { display: grid; gap: 7px; }
.lb-helper-message-row .lb-helper-avatar { display: none; }
.lb-helper-message-text { min-width: 0; display: grid; gap: 7px; }
.lb-helper-message-text strong {
  display: block; font-size: 11px; font-weight: 760;
  text-transform: uppercase; letter-spacing: 0.02em; color: var(--lbh-quiet);
}
.lb-helper-message-text p {
  margin: 0; border: 1px solid var(--lbh-line-soft);
  border-radius: 24px; padding: 15px 16px;
  font-size: 13px; line-height: 1.54; color: var(--lbh-text);
}
.lb-helper-message-row[data-helper-message-role="assistant"] { padding-right: 12px; }
.lb-helper-message-row[data-helper-message-role="assistant"] .lb-helper-message-text p {
  border-top-left-radius: 10px;
  background:
    linear-gradient(155deg, rgba(248, 226, 201, 0.09), rgba(255, 255, 255, 0.03) 46%, rgba(135, 216, 247, 0.045)),
    rgba(16, 17, 20, 0.92);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.22);
}
.lb-helper-message-row[data-helper-message-role="user"] { padding-left: 62px; }
.lb-helper-message-row[data-helper-message-role="user"] .lb-helper-message-text p {
  border-top-right-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025)),
    rgba(35, 36, 42, 0.82);
}

.lb-helper-suggestions {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 20px 22px 0;
}
.lb-helper-suggestions button {
  border: 1px solid var(--lbh-line); border-radius: 999px;
  background: rgba(255, 255, 255, 0.055); color: var(--lbh-text);
  padding: 9px 12px; font-size: 12px; line-height: 1; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.lb-helper-suggestions button:disabled { opacity: 0.45; cursor: not-allowed; }
.lb-helper-suggestions button[hidden] { display: none; }

.lb-helper-compose {
  display: grid; grid-template-columns: minmax(0, 1fr) 44px;
  gap: 10px; padding: 16px 22px 22px;
  border-top: 1px solid var(--lbh-line);
  background: rgba(5, 6, 7, 0.48);
}
.lb-helper-compose input {
  min-width: 0; height: 44px;
  border: 1px solid var(--lbh-line); border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); color: var(--lbh-text);
  padding: 0 16px; font-size: 13px;
}
.lb-helper-compose input::placeholder { color: var(--lbh-quiet); }
.lb-helper-compose button {
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 999px;
  background: linear-gradient(145deg, #f8e2c9, #d4a9a0);
  color: #14100b; font-size: 17px; font-weight: 800; cursor: pointer;
  box-shadow: 0 14px 30px rgba(212, 169, 160, 0.22);
}
.lb-helper-compose input:disabled,
.lb-helper-compose button:disabled { opacity: 0.52; cursor: not-allowed; }


/* ── Typing indicator dots ─────────────────────────────────── */
.lb-helper-typing { display: flex; gap: 4px; padding: 4px 0; }
.lb-helper-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--lbh-muted, #c7b7a7);
  animation: lb-helper-dot 1.2s infinite ease-in-out;
}
.lb-helper-typing span:nth-child(2) { animation-delay: 0.2s; }
.lb-helper-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes lb-helper-dot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* ── Write-to-page action card ─────────────────────────────── */
.lb-helper-write-card {
  margin: 10px 22px;
  border: 1px solid var(--lbh-line, rgba(255,220,180,0.10));
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
}
.lb-helper-write-preview {
  padding: 14px 16px;
  max-height: 180px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--lbh-text, #f8f0e6);
  white-space: pre-wrap;
  font-family: var(--font-mono, "JetBrains Mono", ui-monospace, monospace);
  border-bottom: 1px solid var(--lbh-line, rgba(255,220,180,0.10));
}
.lb-helper-write-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.15);
}
.lb-helper-write-label {
  flex: 1;
  font-size: 11px;
  color: var(--lbh-muted, #c7b7a7);
}
.lb-helper-write-cancel {
  padding: 5px 10px; border-radius: 6px;
  border: 1px solid var(--lbh-line, rgba(255,220,180,0.10));
  background: transparent; color: var(--lbh-muted, #c7b7a7);
  font-size: 11px; cursor: pointer; font-family: inherit;
}
.lb-helper-write-cancel:hover { background: rgba(255,255,255,0.04); }
.lb-helper-write-btn {
  padding: 5px 12px; border-radius: 6px;
  border: 0;
  background: var(--teal, #5fd2bd); color: #061417;
  font-size: 11px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.lb-helper-write-btn:hover { filter: brightness(1.1); }
.lb-helper-write-btn:disabled { opacity: 0.5; cursor: not-allowed; }


.lb-helper-foot {
  margin: 0; padding: 14px 22px 22px;
  color: var(--lbh-quiet); font-size: 11px; line-height: 1.5;
}

/* ── BOOT SPINNER (pre-React, CSP-safe — no inline style attribute) ── */
.lb-boot {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-family: 'Geist', system-ui, sans-serif;
  color: var(--chrome-muted);
  font-size: 15px;
}
.lb-boot-inner { text-align: center; }
.lb-boot-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--chrome-border);
  border-top-color: var(--teal);
  animation: lb-boot-spin 0.8s linear infinite;
  margin: 0 auto 14px;
}
@keyframes lb-boot-spin {
  to { transform: rotate(360deg); }
}

/* ── NotebookSpread back-flip keyframe (moved out of runtime <style>) ── */
@keyframes lb-flip-back {
  from { transform: rotateY(180deg); }
  to   { transform: rotateY(0deg); }
}
