/* Perigee — muted, nocturnal, terminal-adjacent.
   All colours are CSS variables; re-theme by editing :root. */

:root {
  --bg:         #14161b;
  --bg-side:    #101218;
  --bg-elev:    #1b1e25;
  --bg-hover:   #20242d;
  --line:       #272b34;
  --line-soft:  #1d212a;

  --margin-line:        #2c313b;   /* dashed page-margin guide */
  --margin-line-active: #3b424e;   /* brighter on the active page */

  --text:       #c6cbd4;
  --text-dim:   #868d99;
  --text-faint: #5b626d;

  --accent:     #8fb6ae;   /* muted sage-cyan, used sparingly */
  --accent-dim: #56726c;
  --danger:     #c98a87;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code",
          "Fira Code", Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 8px;
  --col: 70ch;        /* width of the centred writing column */
  --side: 264px;      /* sidebar width */
}

* { box-sizing: border-box; }

/* The hidden attribute must outrank the explicit `display` rules below.
   `.editor { display:block }` is an author rule and beats the UA
   `[hidden]{display:none}` rule, so without this the editor never hides
   in Read mode and the two views look identical. */
[hidden] { display: none !important; }

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

body {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background:
    radial-gradient(120% 90% at 50% -10%, #181b22 0%, #121419 55%, #101217 100%)
    fixed;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-dim); color: #0e1014; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a2f39; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #353b46; background-clip: content-box; }

/* ---------- layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--side) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ---------- sidebar ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 16px 16px 12px;
}
.brand .mark { color: var(--accent); display: inline-flex; }
.brand .name { font-weight: 500; letter-spacing: 0.04em; color: var(--text); }
.brand .new {
  margin-left: auto;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-size: 18px; line-height: 1;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.brand .new:hover { color: var(--accent); border-color: var(--accent-dim); background: var(--bg-hover); }

/* ---------- calendar ---------- */
.cal {
  padding: 2px 14px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.cal-title { font-size: 13px; color: var(--text); letter-spacing: .02em; }
.cal-nav {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  font-size: 16px; line-height: 1;
  color: var(--text-dim);
  background: transparent; border: 0; border-radius: 6px;
  cursor: pointer;
  transition: color .12s, background .12s;
}
.cal-nav:hover { color: var(--accent); background: var(--bg-hover); }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-dow {
  text-align: center;
  font-size: 10.5px; color: var(--text-faint);
  letter-spacing: .04em;
  padding-bottom: 4px;
}
.cal-day {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid; place-items: center;
  font-size: 12px; color: var(--text-dim);
  border-radius: 6px;
}
.cal-day.other { color: var(--text-faint); opacity: .4; }
.cal-day:not(.other) { cursor: pointer; }
.cal-day:not(.other):not(.today):hover { background: var(--bg-hover); }

/* three independent states that can stack */
.cal-day.has::after {                       /* dot: this day holds entries */
  content: '';
  position: absolute; bottom: 3px; left: 50%;
  width: 3px; height: 3px; margin-left: -1.5px;
  border-radius: 50%;
  background: var(--accent);
}
.cal-day.sel {                              /* ring: the selected day */
  box-shadow: inset 0 0 0 1.5px var(--accent-dim);
  color: var(--text);
}
.cal-day.today {                            /* marker: today */
  background: var(--accent); color: #0e1014; font-weight: 500;
}
.cal-day.today.has::after { background: #0e1014; }
.cal-day.today.sel { box-shadow: inset 0 0 0 1.5px #0e1014; }

.cal-today {
  display: block; margin: 10px auto 0;
  font: inherit; font-size: 11.5px;
  color: var(--accent-dim);
  background: none; border: 0; cursor: pointer;
}
.cal-today:hover { color: var(--accent); }

/* ---------- toast (backdated-creation notice) ---------- */
.toast {
  position: absolute; left: 50%; bottom: 22px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 9px 15px;
  font-size: 12.5px; color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .4);
  z-index: 6;
}
.toast .sep { color: var(--text-faint); }
.toast-act {
  font: inherit; font-size: 12.5px;
  color: var(--accent);
  background: none; border: 0; padding: 0; cursor: pointer;
}
.toast-act:hover { text-decoration: underline; }

.search { padding: 10px 12px; }
.search input {
  width: 100%;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus { border-color: var(--accent-dim); }

.entries {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 12px;
}
.entry {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  margin-bottom: 2px;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  font: inherit;
  transition: background .12s;
}
.entry:hover { background: var(--bg-hover); }
.entry.active { background: var(--bg-elev); box-shadow: inset 2px 0 0 var(--accent); }
.entry .etitle {
  font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.entry.active .etitle { color: #dfe3ea; }
.entry .edate { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

.no-results { padding: 14px 12px; font-size: 13px; color: var(--text-faint); }

.sidebar-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  font-size: 11.5px; color: var(--text-faint);
  border-top: 1px solid var(--line-soft);
}
.sidebar-foot .local { color: var(--accent-dim); letter-spacing: .04em; }

/* ---------- overlay (mobile) ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(8, 9, 12, .55);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
  z-index: 5;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* ---------- main ---------- */
.main {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
}

.topbar {
  position: relative; z-index: 10;     /* lift above the stage (5/6) and toolbar (7/9) so the switcher menu shows */
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(20, 22, 27, .55);
  backdrop-filter: blur(6px);
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-center { display: flex; justify-content: center; }
.meta {
  flex: 1; min-width: 0;
  font-size: 12.5px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.actions { display: flex; align-items: center; gap: 8px; justify-self: end; }

/* ---- product switcher (the five-app vision) ---- */
.switcher { position: relative; }
.switcher-btn { display: inline-flex; align-items: center; gap: 9px; font: inherit; font-size: 13px;
  color: var(--text); background: var(--bg-elev); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 8px 6px 14px; cursor: pointer; transition: border-color .15s; }
.switcher-btn:hover { border-color: var(--margin-line, #3b424e); }
.switcher-btn .chev { color: var(--text-faint); font-size: 10px; transition: transform .18s; }
.switcher-btn.open .chev { transform: rotate(180deg); }
.switcher-scrim { position: fixed; inset: 0; z-index: 30; }
.switcher-menu { position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 31;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px;
  min-width: 210px; box-shadow: 0 16px 44px rgba(0,0,0,.5); }
.switcher-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%;
  background: transparent; border: 0; border-radius: 6px; padding: 9px 12px; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--text-dim); text-align: left; }
.switcher-item:hover { background: var(--bg-hover); color: var(--text); }
.switcher-item.on { color: var(--text); }
.switcher-item.on .name::before { content: "\2192\00a0"; color: var(--accent); }
.switcher-item.prod.on .name::before { content: none; }
.pic { flex: 0 0 auto; }
.switcher-btn .pic { color: var(--text-dim); }
.switcher-item.prod { justify-content: flex-start; gap: 11px; }
.switcher-item.prod.soon { opacity: .5; }
.switcher-item.prod.on .pic { color: var(--accent); }

/* ---- coming-soon stage for aspirational products ---- */
.soon-stage { flex: 1; min-height: 60vh; display: grid; place-items: center; padding: 40px; }
.soon-card { text-align: center; max-width: 380px; }
.soon-mark { width: 42px; height: 42px; margin: 0 auto 20px; border-radius: 50%; border: 2px solid var(--accent-dim);
  position: relative; opacity: .85; }
.soon-mark::after { content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-dim); top: -4px; left: 50%; transform: translateX(-50%); }
.soon-card h2 { font-size: 22px; color: var(--text); margin: 0 0 10px; }
.soon-card p { color: var(--text-dim); font-size: 14px; margin: 0 0 20px; line-height: 1.6; }
.soon-pill { display: inline-block; font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--accent-dim); border-radius: 999px; padding: 4px 12px; }

.toggle {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.seg {
  padding: 5px 12px;
  font: inherit; font-size: 12.5px;
  color: var(--text-dim);
  background: transparent; border: 0; cursor: pointer;
  transition: color .12s, background .12s;
}
.seg.on { color: #0e1014; background: var(--accent); }
.seg:not(.on):hover { color: var(--text); }
.seg:disabled { opacity: .4; cursor: default; }

.icon {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-size: 15px; line-height: 1;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.icon:hover { color: var(--text); background: var(--bg-hover); }
.icon.danger:hover { color: var(--danger); border-color: var(--danger); }
.icon:disabled { opacity: .35; cursor: default; }
.icon.menu { display: none; }

/* ---------- page strip ---------- */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.track {
  position: relative;
  height: 100%;
  display: flex;
  align-items: stretch;
  gap: 40px;
  will-change: transform;
  transition: transform .42s cubic-bezier(.22, .61, .36, 1);
}

.page {
  position: relative;
  flex: 0 0 var(--page-w, 640px);
  width: var(--page-w, 640px);
  height: 100%;
  padding: 14px 6px;
}
.page.dim { cursor: pointer; }

.page-inner {
  height: 100%;
  overflow-y: auto;
  padding: 46px 48px 40vh;
  border: 1px dashed var(--margin-line);
  border-radius: 3px;
  transition: opacity .3s, border-color .3s;
}
.page.active .page-inner { border-color: var(--margin-line-active); }
.page.dim   .page-inner { opacity: .4; pointer-events: none; }

/* the textarea fills the page's margin box */
.editor {
  display: block;
  width: 100%;
  min-height: 50vh;
  font: inherit;
  line-height: 1.75;
  color: var(--text);
  background: transparent;
  border: 0; outline: none; resize: none;
  overflow: hidden;          /* height is driven by JS autosize */
}
.editor::placeholder { color: var(--text-faint); }

/* large + glued to the active page's right edge, drawn over the peeking
   neighbour — both stay clickable (+ creates, the neighbour centres) */
.add-page {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 54px; height: 54px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 26px; line-height: 1;
  color: var(--text-dim);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  cursor: pointer;
  z-index: 5;
  transition: color .15s, border-color .15s, background .15s, transform .12s;
}
.add-page:hover  { color: var(--accent); border-color: var(--accent-dim); background: var(--bg-hover); }
.add-page:active { transform: translateY(-50%) scale(.93); }

/* ---------- empty state ---------- */
.empty {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center;
  text-align: center;
}
.empty p { color: var(--text-dim); margin: 0 0 16px; }
.ghost {
  padding: 9px 16px; font: inherit; font-size: 13px;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius); cursor: pointer;
  transition: background .15s;
}
.ghost:hover { background: var(--bg-hover); }

/* ---------- rendered markdown ---------- */
.markdown { line-height: 1.75; }
.markdown > :first-child { margin-top: 0; }
.markdown h1, .markdown h2, .markdown h3,
.markdown h4, .markdown h5, .markdown h6 {
  font-weight: 500; line-height: 1.3; color: #dfe3ea;
  margin: 1.6em 0 .6em;
}
.markdown h1 { font-size: 1.7em; letter-spacing: -.01em; }
.markdown h2 { font-size: 1.35em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.markdown h3 { font-size: 1.12em; }
.markdown h4 { font-size: 1em; color: var(--text-dim); }
.markdown p { margin: 0 0 1em; }
.markdown a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-dim); }
.markdown a:hover { border-bottom-color: var(--accent); }
.markdown strong { color: #dfe3ea; font-weight: 500; }
.markdown em { color: #d4d9e1; }
.markdown del { color: var(--text-faint); }
.markdown ul, .markdown ol { margin: 0 0 1em; padding-left: 1.5em; }
.markdown li { margin: .25em 0; }
.markdown li::marker { color: var(--accent-dim); }
.markdown blockquote {
  margin: 1.2em 0; padding: .2em 1em;
  color: var(--text-dim);
  border-left: 2px solid var(--accent-dim);
}
.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.markdown img { max-width: 100%; border-radius: var(--radius); }
.markdown .dim { color: var(--text-faint); }

.markdown :not(.code) > code {
  font-family: var(--mono);
  font-size: .88em;
  padding: .12em .4em;
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
}

/* fenced code block */
.markdown .code {
  margin: 1.4em 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.markdown .code figcaption {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px;
  font-size: 11.5px; color: var(--text-faint);
  background: rgba(255, 255, 255, .015);
  border-bottom: 1px solid var(--line);
}
.markdown .code .lang { letter-spacing: .06em; }
.markdown .code .copy {
  font: inherit; font-size: 11.5px;
  color: var(--text-dim);
  background: transparent; border: 0; cursor: pointer;
  padding: 0; transition: color .12s;
}
.markdown .code .copy:hover { color: var(--accent); }
.markdown .code pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.markdown .code pre code {
  font-family: var(--mono);
  font-size: .9em; line-height: 1.6;
  color: #cdd3dc;
}

/* ---------- todo lists ---------- */
.markdown .todo {
  margin: 1.4em 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.markdown .todo-title {
  padding: 8px 14px;
  font-size: .9em; color: var(--text); letter-spacing: .02em;
  background: rgba(255, 255, 255, .015);
  border-bottom: 1px solid var(--line);
}
.markdown .todo-items { list-style: none; margin: 0; padding: 6px 0; }
.markdown .todo-item {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 0; padding: 5px 14px;
}
.markdown .todo-check {
  flex: 0 0 auto;
  width: 16px; height: 16px; margin-top: 2px;
  display: grid; place-items: center;
  padding: 0;
  background: transparent;
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.markdown .todo-check:hover { border-color: var(--accent); }
.markdown .todo-item.done .todo-check { background: var(--accent); border-color: var(--accent); }
.markdown .todo-item.done .todo-check::after {
  content: '\2713'; color: #0e1014; font-size: 11px; line-height: 1;
}
.markdown .todo-text { color: var(--text); }
.markdown .todo-item.done .todo-text { color: var(--text-faint); text-decoration: line-through; }

/* ---------- callouts (#IMPORTANT / #WARNING / #ERROR) ---------- */
.markdown .callout {
  margin: 1.4em 0;
  padding: 12px 16px;
  background: rgba(201, 138, 135, .08);
  border: 1px solid var(--danger);
  border-radius: 10px;
}
.markdown .callout-title {
  color: var(--danger);
  font-weight: 500; letter-spacing: .02em;
  margin-bottom: 4px;
}
.markdown .callout-body { color: var(--text); }
.markdown .callout-body :first-child { margin-top: 0; }
.markdown .callout-body :last-child { margin-bottom: 0; }

/* ---------- hashtags ---------- */
.markdown .hashtags { display: flex; flex-wrap: wrap; gap: 8px; margin: 1.4em 0; }
.markdown .hashtag {
  font-size: .85em; line-height: 1.5;
  color: var(--accent);
  background: rgba(143, 182, 174, .08);
  border: 1px solid var(--accent-dim);
  border-radius: 999px; padding: 2px 11px;
  cursor: pointer; text-decoration: none;
  transition: background .12s, color .12s;
}
.markdown .hashtag:hover { background: rgba(143, 182, 174, .18); color: #a9cfc7; }
.page.dim .markdown .hashtag { cursor: default; }

/* ---------- tables ---------- */
.markdown .md-table { margin: 1.4em 0; overflow-x: auto; }
.markdown .md-table table { border-collapse: collapse; width: 100%; font-size: .92em; }
.markdown .md-table th, .markdown .md-table td {
  border: 1px solid var(--line); padding: 7px 11px; text-align: left; vertical-align: top;
}
.markdown .md-table th { background: rgba(255,255,255,.022); color: #dfe3ea; font-weight: 500; }
.markdown .md-table tr:hover td { background: rgba(255,255,255,.012); }
/* on the active read page, tables are clickable to edit */
.page.active .markdown .md-table { cursor: pointer; border-radius: var(--radius); }
.page.active .markdown .md-table:hover table { outline: 1px solid var(--accent-dim); outline-offset: 2px; }

/* ---------- bottom toolbar ---------- */
.toolbar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; gap: 8px; z-index: 7;
}
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; font: inherit; font-size: 13px;
  color: var(--text); background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 6px 22px rgba(0,0,0,.35);
  cursor: pointer; transition: color .12s, border-color .12s, background .12s;
}
.tool-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent-dim); }
.tool-btn:disabled { opacity: .4; cursor: default; }
.insert-wrap { position: relative; }

/* insert popover + grid picker */
.picker {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  padding: 12px; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.picker-label { font-size: 11.5px; color: var(--text-dim); margin-bottom: 8px; text-align: center; white-space: nowrap; }
.picker-grid { display: grid; grid-template-columns: repeat(8, 18px); gap: 3px; }
.pick-cell { width: 18px; height: 18px; border: 1px solid var(--line); border-radius: 3px; cursor: pointer; }
.pick-cell.on { background: var(--accent-dim); border-color: var(--accent); }

/* ---------- table overlay editor ---------- */
.ov-back {
  position: fixed; inset: 0; z-index: 9;
  background: rgba(8,9,12,.6); display: grid; place-items: center; padding: 24px;
}
.ov {
  width: min(760px, 96vw); max-height: 88vh; overflow: auto;
  background: var(--bg-side); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 60px rgba(0,0,0,.5); padding: 20px;
}
.ov-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.ov-head h3 { margin: 0; font-size: 1.05em; font-weight: 500; color: #dfe3ea; }
.ov-gridwrap { overflow-x: auto; }
.ov-grid { display: grid; gap: 6px; }
.ov-cell {
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; min-width: 110px; width: 100%;
}
.ov-cell:focus { outline: none; border-color: var(--accent-dim); }
.ov-cell.head { color: #dfe3ea; background: rgba(255,255,255,.03); }
.ov-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ov-tool {
  font: inherit; font-size: 12px; color: var(--text-dim);
  background: transparent; border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; transition: color .12s, border-color .12s;
}
.ov-tool:hover { color: var(--accent); border-color: var(--accent-dim); }
.ov-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.ov-actions .primary { color: #0e1014; background: var(--accent); border-color: var(--accent); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: min(82vw, var(--side));
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 6;
  }
  .sidebar.open { transform: translateX(0); }
  .icon.menu { display: grid; }
  .page { padding: 10px 4px; }
  .page-inner { padding: 28px 24px 40vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ===================== sync badge + settings panel ===================== */
.sync { display:inline-flex; align-items:center; gap:6px; font:inherit; font-size:12px;
  color:var(--text-dim); background:transparent; border:1px solid var(--line);
  border-radius:999px; padding:3px 10px; cursor:pointer; white-space:nowrap;
  max-width:220px; overflow:hidden; text-overflow:ellipsis; }
.sync:hover { color:var(--text); border-color:var(--margin-line); }
.sync-dot { width:7px; height:7px; border-radius:50%; background:var(--text-faint); flex:none; }
.sync.connected .sync-dot { background:var(--accent); }
.sync.connecting .sync-dot { background:var(--accent-dim); }
.sync.disconnected .sync-dot { background:var(--danger); }

.modal-backdrop { position:fixed; inset:0; background:rgba(0,0,0,0.45);
  display:flex; align-items:center; justify-content:center; z-index:50; }
.sync-panel { background:var(--bg-elev); border:1px solid var(--line); border-radius:var(--radius);
  width:min(440px, calc(100vw - 32px)); padding:20px; box-shadow:0 16px 48px rgba(0,0,0,0.5); }
.sync-panel h2 { margin:0 0 4px; font-size:16px; color:var(--text); }
.sync-panel .hint { margin:0 0 16px; font-size:12px; line-height:1.5; color:var(--text-dim); }
.sync-panel label { display:block; font-size:12px; color:var(--text-dim); margin-bottom:12px; }
.sync-panel input { display:block; width:100%; margin-top:4px; box-sizing:border-box;
  background:var(--bg); border:1px solid var(--line); border-radius:6px; padding:8px 10px;
  color:var(--text); font:inherit; font-size:13px; }
.sync-panel input:focus { outline:none; border-color:var(--accent-dim); }
.sync-actions { display:flex; align-items:center; gap:8px; margin-top:4px; }
.sync-actions .spacer { flex:1; }
.sync-panel button { font:inherit; font-size:13px; border-radius:6px; padding:7px 14px;
  cursor:pointer; border:1px solid transparent; }
.sync-panel .ghost { background:transparent; border-color:var(--line); color:var(--text-dim); }
.sync-panel .ghost:hover { color:var(--text); border-color:var(--margin-line); }
.sync-panel .ghost.danger:hover { color:var(--danger); border-color:var(--danger); }
.sync-panel .primary { background:var(--accent-dim); border-color:var(--accent-dim); color:var(--bg); font-weight:500; }
.sync-panel .primary:hover { background:var(--accent); border-color:var(--accent); }

/* how-to link styled to match the icon buttons */
.icon.howto { text-decoration: none; font-weight: 600; }

/* ===================== auth gate (sign in / pick workspace) ===================== */
.gate { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); padding: 24px; }
.gate-card { width: min(380px, 100%); background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 32px 28px; text-align: center; }
.gate-card.wide { width: min(440px, 100%); text-align: left; }
.gate-mark { width: 34px; height: 34px; margin: 0 auto 14px; border-radius: 50%;
  border: 2px solid var(--accent); position: relative; }
.gate-mark::after { content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); top: -4px; left: 50%; transform: translateX(-50%); }
.gate-card h1 { margin: 0 0 6px; font-size: 20px; color: var(--text); }
.gate-card p { margin: 0 0 20px; font-size: 13px; color: var(--text-dim); }
.gate-card .primary { width: 100%; padding: 10px; font-size: 14px; border-radius: 6px; cursor: pointer;
  background: var(--accent-dim); border: 1px solid var(--accent-dim); color: var(--bg); font-weight: 600; }
.gate-card .primary:hover { background: var(--accent); border-color: var(--accent); }
.gate-field { display: flex; gap: 8px; margin: 10px 0; }
.gate-field input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; color: var(--text); font: inherit; font-size: 13px; }
.gate-field input:focus { outline: none; border-color: var(--accent-dim); }
.gate-field .ghost { background: transparent; border: 1px solid var(--line); color: var(--text-dim);
  border-radius: 6px; padding: 0 14px; cursor: pointer; font: inherit; font-size: 13px; }
.gate-field .ghost:hover { color: var(--text); border-color: var(--margin-line); }
.gate-field .ghost:disabled { opacity: .4; cursor: default; }
.ws-list { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; }
.ws-item { display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px;
  cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.ws-item:hover { border-color: var(--accent-dim); background: var(--bg-hover); }
.ws-name { font-size: 14px; } .ws-meta { font-size: 11px; color: var(--text-faint); }
.link-btn { display: inline-block; margin-top: 14px; background: none; border: none; cursor: pointer;
  color: var(--text-faint); font: inherit; font-size: 12px; text-decoration: underline; }
.link-btn:hover { color: var(--text-dim); }

/* account panel extras */
.acct-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 10px; font-size: 13px; color: var(--text-dim); }
.acct-row .ghost { background: transparent; border: 1px solid var(--line); color: var(--text-dim);
  border-radius: 6px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 12px; }
.acct-row .ghost:hover { color: var(--text); border-color: var(--margin-line); }
.invite-code { width: 100%; box-sizing: border-box; margin: 0 0 12px; background: var(--bg);
  border: 1px solid var(--accent-dim); border-radius: 6px; padding: 8px 10px; color: var(--accent);
  font: inherit; font-size: 13px; letter-spacing: .04em; }

/* ===================== flowchart editor ===================== */
.flow-wrap { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.flow-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--line);
  background: rgba(20,22,27,.5); }
.flow-toolbar button { font: inherit; font-size: 12.5px; color: var(--text-dim); background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 11px; cursor: pointer; transition: color .12s, border-color .12s; }
.flow-toolbar button:hover { color: var(--text); border-color: var(--accent-dim); }
.flow-toolbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 2px; }
.flow-hint { font-size: 11.5px; color: var(--text-faint); margin-left: 6px; }
.flow-canvas { flex: 1; width: 100%; min-height: 0; display: block; background: var(--bg);
  touch-action: none; user-select: none; cursor: default; }
.flow-port { fill: var(--accent); stroke: var(--bg); stroke-width: 1.5; cursor: crosshair; }
.flow-port:hover { r: 6; }
.flow-empty { position: absolute; top: 52%; left: 0; right: 0; text-align: center; color: var(--text-faint);
  font-size: 13px; pointer-events: none; }
.flow-label-input { position: absolute; box-sizing: border-box; text-align: center; color: var(--text);
  background: var(--bg-elev); border: 1.5px solid var(--accent); border-radius: 7px; font-family: var(--mono);
  outline: none; padding: 0 6px; z-index: 15; }

.fm-scrim { position: fixed; inset: 0; z-index: 19; }
.flow-menu { position: absolute; z-index: 20; min-width: 168px; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 5px; box-shadow: 0 14px 40px rgba(0,0,0,.55); }
.fm-item { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 12px;
  font: inherit; font-size: 13px; color: var(--text-dim); background: transparent; border: 0; border-radius: 5px;
  padding: 7px 10px; cursor: pointer; text-align: left; }
.fm-item:hover { background: var(--bg-hover); color: var(--text); }
.fm-item.danger:hover { color: var(--danger); }
.fm-arrow { color: var(--text-faint); }
.fm-sub { margin: 2px 4px 4px; padding-left: 6px; border-left: 1px solid var(--line); }
.fm-sub .fm-item { font-size: 12.5px; }
.fm-colors { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; }
.fm-swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); cursor: pointer; padding: 0; }
.fm-swatch.none { background: var(--bg); position: relative; }
.fm-swatch.none::after { content: ""; position: absolute; left: 2px; right: 2px; top: 8px; height: 1px; background: var(--danger); transform: rotate(-45deg); }
.fm-swatch:hover { transform: scale(1.15); border-color: var(--text-dim); }
.flow-label-input::placeholder { color: var(--text-faint); }

/* ===================== syntax highlighting (highlight.js, muted theme) ===================== */
.markdown code.hljs { color: var(--text); background: transparent; padding: 0; }
.markdown .hljs-comment, .markdown .hljs-quote { color: var(--text-faint); font-style: italic; }
.markdown .hljs-keyword, .markdown .hljs-selector-tag, .markdown .hljs-literal,
.markdown .hljs-section, .markdown .hljs-doctag, .markdown .hljs-link { color: #a98cc0; }       /* plum */
.markdown .hljs-string, .markdown .hljs-attr, .markdown .hljs-attribute,
.markdown .hljs-addition, .markdown .hljs-meta .hljs-string { color: #8fb6ae; }                 /* sage */
.markdown .hljs-number, .markdown .hljs-built_in, .markdown .hljs-symbol,
.markdown .hljs-bullet, .markdown .hljs-type, .markdown .hljs-class .hljs-title { color: #c2a06a; } /* amber */
.markdown .hljs-title, .markdown .hljs-title.function_, .markdown .hljs-function .hljs-title { color: #6fb0bf; } /* teal */
.markdown .hljs-name { color: #c98a87; }                                                        /* rose (tags) */
.markdown .hljs-variable, .markdown .hljs-template-variable, .markdown .hljs-params { color: var(--text); }
.markdown .hljs-regexp, .markdown .hljs-deletion { color: #c98a87; }                            /* rose */
.markdown .hljs-meta, .markdown .hljs-comment.hljs-meta { color: #8893a4; }                     /* slate */
.markdown .hljs-emphasis { font-style: italic; }
.markdown .hljs-strong { font-weight: 600; }

/* ===================== AI (optional, bring-your-own-key) ===================== */
.ai-btn { color: var(--accent); }
.ai-btn:hover:not(:disabled) { color: #a6c8c0; }

.ai-settings { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.ai-toggle { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text); cursor: pointer; }
.ai-toggle input { accent-color: var(--accent); width: 15px; height: 15px; }
.ai-config { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.ai-key { width: 100%; box-sizing: border-box; background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; color: var(--text); font-family: var(--mono); font-size: 13px; outline: none; }
.ai-key:focus { border-color: var(--accent-dim); }
.ai-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-dim); }
.ai-row select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; color: var(--text);
  font-family: var(--mono); font-size: 13px; padding: 6px 8px; }
.ai-getkey { font-size: 12.5px; color: var(--accent); }
.ai-getkey:hover { text-decoration: underline; }

.ai-panel { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; width: min(440px, 92vw); box-shadow: 0 24px 60px rgba(0,0,0,.55); }
.ai-panel h2 { font-size: 16px; margin: 0 0 10px; color: var(--text); }
.ai-loading { color: var(--text-dim); font-size: 13px; }
.ai-error { color: var(--danger); font-size: 13px; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.ai-chip { font: inherit; font-size: 13px; color: var(--text-dim); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; transition: all .12s; }
.ai-chip:hover { color: var(--text); }
.ai-chip.on { color: #10130f; background: var(--accent); border-color: var(--accent); }
.ai-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.ai-actions .spacer { flex: 1; }
.ai-cred { font-size: 10.5px; color: var(--text-faint); }

/* ===================== Mental Model ===================== */
.mm-btn { font: inherit; font-size: 12.5px; color: var(--accent); background: transparent;
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; white-space: nowrap; transition: all .12s; }
.mm-btn:hover:not(:disabled) { border-color: var(--accent-dim); background: rgba(143,182,174,.08); }
.mm-btn:disabled { opacity: .4; cursor: default; }

/* the "Mental Model" bucket control, hovering off the document's top-right corner */
.mm-corner { position: absolute; top: 4px; right: -8px; z-index: 6; }
@media (max-width: 760px) { .mm-corner { right: 8px; top: 8px; } }
.mm-float { background: var(--bg-elev); box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.mm-float:hover:not(:disabled) { background: rgba(143,182,174,.12); }
.mm-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 7; min-width: 210px;
  display: flex; flex-direction: column; padding: 4px; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.5); }
.mm-menu button { font: inherit; font-size: 13px; text-align: left; color: var(--text); background: transparent;
  border: 0; border-radius: 6px; padding: 8px 10px; cursor: pointer; white-space: nowrap; }
.mm-menu button:hover { background: rgba(143,182,174,.1); color: var(--accent); }
.menu-backdrop { position: fixed; inset: 0; z-index: 6; background: transparent; }

/* the footer the model writes into the document */
.markdown .mentalmodel { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 8px; background: rgba(143,182,174,.05); }
.markdown .mentalmodel .mm-label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 6px; }
.markdown .mentalmodel .mm-summary { margin: 0 0 10px; color: var(--text); }
.markdown .mentalmodel .mm-summary em { color: var(--text-dim); }
.markdown .mentalmodel .hashtags { margin: 0; }

/* "Forming Mental Model…" modal */
.mm-modal { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 26px; width: min(360px, 90vw); box-shadow: 0 24px 60px rgba(0,0,0,.55); }
.mm-forming { display: flex; align-items: center; gap: 12px; color: var(--text); font-size: 14px; }
.mm-spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line);
  border-top-color: var(--accent); animation: mm-spin .8s linear infinite; flex: none; }
@keyframes mm-spin { to { transform: rotate(360deg); } }

/* ===================== Semantic Backlinks ===================== */
.markdown .backlinks { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 8px; background: rgba(143,182,174,.05); }
.markdown .backlinks .bl-label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 8px; }
.markdown .backlinks ul { margin: 0; padding-left: 18px; }
.markdown .backlinks li { margin: 3px 0; }
.markdown .backlinks .backlink { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--accent-dim); }
.markdown .backlinks .backlink:hover { color: var(--accent); border-bottom-color: var(--accent); }
.page.dim .markdown .backlink { pointer-events: none; }

/* ===================== Mental Model graph ===================== */
.mmg-wrap { position:relative; flex:1; min-height:0; overflow:hidden; background:
  radial-gradient(900px 600px at 60% 40%, rgba(143,182,174,.05), transparent 60%); }
.mmg-svg { width:100%; height:100%; display:block; cursor:grab; touch-action:none; user-select:none; }
.mmg-svg:active { cursor:grabbing; }

.gedge { stroke:var(--accent-dim); stroke-width:1.1; opacity:.4; transition:opacity .2s; }
.gedge.mutual { stroke:var(--accent); stroke-width:1.8; opacity:.6; }
.gedge.dim { opacity:.07; }
.mm-arrowhead { fill:var(--accent-dim); opacity:.6; }
.mm-arrowhead-m { fill:var(--accent); }

.gnode { cursor:pointer; }
.gnode .dot { fill:var(--node, var(--accent)); transition:fill .2s; }
.gnode .ring { fill:none; stroke:var(--node, var(--accent)); stroke-width:1; opacity:0; pointer-events:none; transition:opacity .2s; }
.gnode text { fill:var(--text-dim); font-family:var(--mono); font-size:11px; text-anchor:middle; pointer-events:none; transition:opacity .2s; }
.gnode:hover .ring, .gnode.sel .ring { opacity:.5; }
.gnode.sel .dot { fill:#d3e6e1; }
.gnode.sel .ring { opacity:.8; }
.gnode.dim { opacity:.22; }

.mmg-legend { position:absolute; left:16px; bottom:14px; font-family:var(--mono); font-size:11px; color:var(--text-faint); pointer-events:none; }
.mmg-hint { position:absolute; left:50%; bottom:16px; transform:translateX(-50%); max-width:min(560px,80%);
  font-size:13px; color:var(--text); background:var(--bg-elev); border:1px solid var(--line); border-radius:8px;
  padding:8px 14px; box-shadow:0 8px 24px rgba(0,0,0,.4); pointer-events:none; text-align:center; }
.mmg-panel { position:absolute; top:16px; right:16px; width:min(300px,80%); background:var(--bg-elev);
  border:1px solid var(--line); border-left:3px solid var(--accent); border-radius:10px; padding:16px 18px; box-shadow:0 16px 40px rgba(0,0,0,.5); }
.mmg-panel-x { position:absolute; top:8px; right:10px; background:none; border:0; color:var(--text-faint); font-size:18px; cursor:pointer; line-height:1; }
.mmg-panel-x:hover { color:var(--text); }
.mmg-panel-title { font-family:var(--display); font-size:17px; color:var(--text); margin-bottom:8px; padding-right:16px; }
.mmg-panel-summary { font-size:13px; color:var(--text-dim); line-height:1.6; margin:0 0 10px; }
.mmg-panel-meta { font-size:11px; letter-spacing:.08em; text-transform:uppercase; color:var(--accent-dim); margin-bottom:14px; }
.btn-mini { font:inherit; font-size:13px; color:var(--accent); background:transparent; border:1px solid var(--accent-dim);
  border-radius:6px; padding:7px 12px; cursor:pointer; transition:all .15s; }
.btn-mini:hover { background:rgba(143,182,174,.1); }

.mmg-empty { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; padding:24px; gap:6px; }
.mmg-empty-mark { width:46px; height:46px; border-radius:50%; border:1.5px solid var(--accent-dim); position:relative; margin-bottom:14px; opacity:.7; }
.mmg-empty-mark::after { content:""; position:absolute; width:7px; height:7px; border-radius:50%; background:var(--accent); top:-4px; left:50%; transform:translateX(-50%); box-shadow:0 0 8px var(--accent); }
.mmg-empty h2 { font-family:var(--display); font-weight:600; font-size:24px; color:var(--text); margin:0; }
.mmg-empty p { color:var(--text-dim); max-width:42ch; font-size:14px; line-height:1.6; margin:4px 0 14px; }

/* ---- workspace switcher (sits beside the product switcher) ---- */
.tb-center { gap: 8px; }
.ws-switcher .switcher-btn.ws { color: var(--text-dim); background: transparent; }
.ws-switcher .switcher-btn.ws:hover { color: var(--text); }
.ws-glyph { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--accent-dim);
  display: inline-block; position: relative; }
.ws-glyph::after { content: ""; position: absolute; inset: 3px; border-radius: 1px; background: var(--accent-dim); opacity: .55; }
.switcher-item .ws-count { color: var(--text-faint); font-size: 11px; }
.switcher-item.add { border-top: 1px solid var(--line-soft); color: var(--text-dim); }
.switcher-item.add:hover { color: var(--accent); }
.switcher-item.add .name { font-size: 12px; }

/* ---- People page ---- */
.people-stage { flex: 1; min-height: 60vh; display: flex; justify-content: center; padding: 48px 24px; overflow-y: auto; }
.people-card { width: 100%; max-width: 520px; }
.people-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding-bottom: 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.people-head h2 { font-size: 20px; color: var(--text); margin: 0; }
.people-count { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.people-list { list-style: none; margin: 0; padding: 0; }
.person { display: flex; align-items: center; gap: 13px; padding: 12px 4px; border-bottom: 1px solid var(--line-soft); }
.person:last-child { border-bottom: none; }
.avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--accent);
  background: var(--bg-elev); border: 1px solid var(--line); }
.person-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.person-name { color: var(--text); font-size: 14px; }
.person-name .you { color: var(--accent-dim); font-size: 12px; }
.person-sub { color: var(--text-faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-tag { flex: none; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent-dim); border: 1px solid var(--accent-dim); border-radius: 999px; padding: 2px 8px; }
.people-foot { margin: 18px 4px 0; font-size: 12px; line-height: 1.6; }
.people-empty { text-align: center; max-width: 360px; margin: 8vh auto 0; }
.people-mark { width: 42px; height: 42px; margin: 0 auto 20px; border-radius: 50%;
  border: 2px solid var(--accent-dim); position: relative; }
.people-mark::after { content: ""; position: absolute; left: 50%; top: 9px; transform: translateX(-50%);
  width: 11px; height: 11px; border-radius: 50%; background: var(--accent-dim); }
.people-mark::before { content: ""; position: absolute; left: 50%; bottom: 7px; transform: translateX(-50%);
  width: 22px; height: 11px; border-radius: 11px 11px 0 0; border: 2px solid var(--accent-dim); border-bottom: none; }
.people-empty h2 { font-size: 19px; color: var(--text); margin: 0 0 10px; }
.people-empty p { color: var(--text-dim); font-size: 14px; line-height: 1.6; margin: 0; }

/* ---- People: add member, invite confirmation, pending list ---- */
.people-head { align-items: center; }
.people-title { display: flex; align-items: baseline; gap: 12px; }
.add-member { font: inherit; font-size: 12px; color: var(--accent); background: transparent;
  border: 1px solid var(--accent-dim); border-radius: 7px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.add-member:hover { background: var(--bg-hover); border-color: var(--accent); }
.invite-sent { margin: 14px 0 4px; padding: 12px 14px; border: 1px solid var(--line);
  border-left: 2px solid var(--accent-dim); border-radius: 8px; background: var(--bg-elev); }
.invite-sent p { margin: 0 0 8px; font-size: 13px; color: var(--text-dim); line-height: 1.55; }
.invite-sent .link-btn { font-size: 12px; }
.invite-link { width: 100%; box-sizing: border-box; font: 12px/1.4 var(--mono, ui-monospace, monospace);
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; margin: 0 0 8px; }
.pending { margin-top: 22px; }
.pending h3 { font-size: 12px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-faint); margin: 0 0 4px; font-weight: 600; }
.pending-row .person-name { color: var(--text-dim); }
.avatar.ghost { color: var(--text-faint); background: transparent; border-style: dashed; font-size: 14px; }
.revoke { flex: none; font: inherit; font-size: 18px; line-height: 1; color: var(--text-faint);
  background: transparent; border: none; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.revoke:hover { color: #c98b8b; background: var(--bg-hover); }
.gate-note { font-size: 12px; color: var(--text-faint); line-height: 1.55; margin: 4px 0 0; }

/* ---- corner: stack the Mental Model + Mention buttons ---- */
.mm-corner { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.mm-stack-item { position: relative; }

/* ---- Mentions footer (rendered #MENTIONFROM) ---- */
.markdown .mentions { margin-top: 18px; padding: 12px 16px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg-side); }
.markdown .mentions .mn-label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 8px; }
.markdown .mentions .mn-body { font-size: 13.5px; color: var(--text-dim); line-height: 1.9; }
.markdown .mentions .mention-from { color: var(--text); font-weight: 500; }
.markdown .mention-chip { display: inline-block; font-size: 12px; color: var(--accent);
  background: rgba(143,182,174,.1); border: 1px solid var(--accent-dim); border-radius: 999px;
  padding: 2px 10px; margin: 0 4px 2px 0; }

/* ---- Mention picker modal ---- */
.mention-panel { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; width: 100%; max-width: 380px; max-height: 80vh; display: flex; flex-direction: column; }
.mention-panel h2 { margin: 0 0 14px; font-size: 16px; color: var(--text); }
.mention-picked { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.mention-chip.pick { font: inherit; font-size: 12px; color: var(--accent); cursor: pointer;
  background: rgba(143,182,174,.12); border: 1px solid var(--accent-dim); border-radius: 999px; padding: 4px 11px; }
.mention-chip.pick:hover { background: rgba(143,182,174,.2); color: #a9cfc7; }
.mention-search { font: inherit; font-size: 13px; width: 100%; box-sizing: border-box; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
.mention-search:focus { outline: none; border-color: var(--accent-dim); }
.mention-list { list-style: none; margin: 0 0 4px; padding: 0; overflow-y: auto; flex: 1; min-height: 60px; }
.mention-item { display: flex; align-items: center; gap: 10px; width: 100%; font: inherit; text-align: left;
  background: transparent; border: none; border-radius: 7px; padding: 7px 8px; cursor: pointer; color: var(--text); }
.mention-item:hover { background: var(--bg-hover); }
.avatar.small { width: 26px; height: 26px; font-size: 10px; }
.mention-item .person-name { font-size: 13.5px; }
.mention-none { color: var(--text-faint); font-size: 13px; padding: 10px 8px; }

/* ===================== Wiki ===================== */
.app.wiki { grid-template-columns: 320px 1fr; }

/* wider tree sidebar */
.wiki-side .brand .name { color: var(--text); }
.wiki-tree { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 4px 12px; }
.wiki-empty { color: var(--text-faint); font-size: 12.5px; line-height: 1.6; padding: 14px 12px; margin: 0; }

.wiki-row { display: flex; align-items: center; gap: 1px; border-radius: 6px; margin: 1px 2px; }
.wiki-row:hover { background: var(--bg-hover); }
.wiki-row.on { background: var(--bg-hover); }
.wiki-caret { flex: none; width: 18px; background: transparent; border: none; cursor: pointer;
  color: var(--text-faint); font-size: 10px; padding: 5px 0; line-height: 1; }
.wiki-caret.leaf { cursor: default; color: var(--line); font-size: 7px; }
.wiki-title { flex: 1; min-width: 0; text-align: left; font: inherit; font-size: 13px; cursor: pointer;
  background: transparent; border: none; color: var(--text-dim); padding: 5px 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wiki-row:hover .wiki-title, .wiki-row.on .wiki-title { color: var(--text); }
.wiki-add { flex: none; width: 22px; background: transparent; border: none; cursor: pointer; opacity: .45;
  color: var(--text-faint); font-size: 14px; line-height: 1; border-radius: 5px; padding: 4px 0; }
.wiki-row:hover .wiki-add, .wiki-row.on .wiki-add { opacity: 1; }
.wiki-add:hover { color: var(--accent); background: rgba(143,182,174,.12); }

.wiki-foot { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.wiki-newroot { font: inherit; font-size: 13px; width: 100%; cursor: pointer; color: var(--accent);
  background: transparent; border: 1px solid var(--accent-dim); border-radius: 7px; padding: 8px 12px; }
.wiki-newroot:hover { background: rgba(143,182,174,.1); border-color: var(--accent); }
.wiki-count { font-size: 11px; color: var(--text-faint); text-align: center; }

/* wide single-page stage (no carousel, no add button) */
.wiki-stage { flex: 1; min-height: 0; overflow: hidden; position: relative; }
.wiki-stage.empty { display: grid; place-items: center; }
.wiki-stage .page { flex: none; width: 100%; max-width: 920px; height: 100%; margin: 0 auto; padding: 14px 24px; }
@media (max-width: 760px) {
  .app.wiki { grid-template-columns: 1fr; }
  .wiki-stage .page { padding: 10px 4px; }
}

/* auto-appended page navigation (rendered, never written to the document body) */
.wiki-nav { margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 18px; }
.wiki-nav .wn-label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 7px; }
.wiki-nav .wn-children { list-style: none; margin: 0; padding: 0; }
.wiki-nav .wn-children li { padding: 3px 0; }
.wiki-nav .wn-link { color: var(--accent); cursor: pointer; text-decoration: none; font-size: 14px;
  border-bottom: 1px solid transparent; }
.wiki-nav .wn-link:hover { color: #a9cfc7; border-bottom-color: var(--accent-dim); }
.wiki-nav .wn-parent { display: inline-block; }

/* ===================== Board (swim lanes) ===================== */
/* sidebar board list (reuses wiki-foot / wiki-newroot) */
.board-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.board-item { font: inherit; font-size: 13px; text-align: left; cursor: pointer; color: var(--text-dim);
  background: transparent; border: none; border-radius: 6px; padding: 8px 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-item:hover { background: var(--bg-hover); color: var(--text); }
.board-item.on { background: var(--bg-hover); color: var(--text); }

/* the board itself */
.board-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.board-stage.empty { display: grid; place-items: center; }
.board-head { padding: 14px 22px 8px; }
.board-title { font: inherit; font-size: 18px; font-weight: 600; color: var(--text); background: transparent;
  border: none; border-bottom: 1px solid transparent; padding: 4px 2px; width: min(520px, 80%); }
.board-title:hover { border-bottom-color: var(--line); }
.board-title:focus { outline: none; border-bottom-color: var(--accent-dim); }

.lanes { flex: 1; min-height: 0; display: flex; align-items: flex-start; gap: 14px;
  overflow-x: auto; overflow-y: hidden; padding: 8px 22px 22px; }
.lane { flex: 0 0 280px; max-height: 100%; display: flex; flex-direction: column;
  background: var(--bg-side); border: 1px solid var(--line); border-radius: 10px; }
.lane.over { border-color: var(--accent-dim); background: rgba(143,182,174,.04); }
.lane-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px; border-bottom: 1px solid var(--line-soft); }
.lane-name { flex: 1; min-width: 0; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lane-count { font-size: 11px; color: var(--text-faint); }
.lane-del { flex: none; background: transparent; border: none; cursor: pointer; color: var(--text-faint);
  font-size: 15px; line-height: 1; padding: 2px 4px; border-radius: 5px; opacity: 0; }
.lane:hover .lane-del { opacity: 1; }
.lane-del:hover { color: #c98b8b; background: var(--bg-hover); }
.lane-cards { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 7px; }

.bcard { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 7px; padding: 10px 12px;
  font-size: 13.5px; line-height: 1.45; color: var(--text); cursor: pointer; white-space: pre-wrap;
  word-break: break-word; box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.bcard:hover { border-color: var(--accent-dim); }
.bcard:active { cursor: grabbing; }
.card-add { font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; color: var(--text-faint);
  background: transparent; border: 1px dashed var(--line); border-radius: 7px; padding: 8px 10px; }
.card-add:hover { color: var(--accent); border-color: var(--accent-dim); }
.card-new { font: inherit; font-size: 13.5px; line-height: 1.45; color: var(--text); background: var(--bg-elev);
  border: 1px solid var(--accent-dim); border-radius: 7px; padding: 9px 11px; resize: none; width: 100%; box-sizing: border-box; }
.card-new:focus { outline: none; }
.lane-add { flex: 0 0 220px; align-self: flex-start; margin-top: 2px; font: inherit; font-size: 13px;
  cursor: pointer; color: var(--text-dim); background: transparent; border: 1px dashed var(--line);
  border-radius: 10px; padding: 12px 14px; }
.lane-add:hover { color: var(--accent); border-color: var(--accent-dim); }

/* a card opened as a document */
.board-card-open { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bco-bar { padding: 10px 22px 0; }
.bco-bar .back { font: inherit; font-size: 13px; cursor: pointer; color: var(--text-dim);
  background: transparent; border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; }
.bco-bar .back:hover { color: var(--text); border-color: var(--accent-dim); }

@media (max-width: 760px) {
  .lane { flex-basis: 78vw; }
  .lanes { padding: 8px 12px 18px; }
}

/* ---- card metadata: points badge + color/heft via inline border ---- */
.bcard { display: flex; flex-direction: column; gap: 6px; }
.bcard-head { display: flex; align-items: flex-start; gap: 8px; }
.bcard-text { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.bcard-points { flex: none; font-size: 11px; font-weight: 600; color: var(--text-dim);
  background: var(--bg-side); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; min-width: 16px; text-align: center; }

/* ---- right-click card context menu ---- */
.cm-backdrop { position: fixed; inset: 0; z-index: 49; }
.card-menu { position: fixed; z-index: 50; width: 200px; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.cm-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); margin: 10px 2px 5px; }
.cm-label:first-child { margin-top: 2px; }
.cm-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-swatch { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); cursor: pointer; padding: 0; }
.cm-swatch:hover { transform: scale(1.12); }
.cm-swatch.on { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 3px var(--text-dim); }
.cm-swatch.none { background: var(--bg); position: relative; }
.cm-swatch.none::after { content: ""; position: absolute; left: 2px; right: 2px; top: 9px; height: 1px; background: var(--danger); transform: rotate(-45deg); }
.cm-row { display: flex; flex-wrap: wrap; gap: 5px; }
.cm-chip { font: inherit; font-size: 12px; min-width: 26px; cursor: pointer; color: var(--text-dim);
  background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 4px 7px; }
.cm-chip.wide { flex: 1; }
.cm-chip:hover { color: var(--text); border-color: var(--accent-dim); }
.cm-chip.on { color: var(--accent); border-color: var(--accent-dim); background: rgba(143,182,174,.1); }
.cm-delete { width: 100%; margin-top: 12px; font: inherit; font-size: 12.5px; cursor: pointer; color: #c98a87;
  background: transparent; border: 1px solid var(--line); border-radius: 7px; padding: 7px; }
.cm-delete:hover { border-color: #c98a87; background: rgba(201,138,135,.08); }

/* ---- Extract task modal ---- */
.extract-panel { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; width: 100%; max-width: 400px; max-height: 80vh; display: flex; flex-direction: column; }
.extract-panel h2 { margin: 0 0 12px; font-size: 16px; color: var(--text); }
.extract-preview { margin: 0 0 16px; padding: 10px 12px; font-size: 13px; line-height: 1.5; color: var(--text-dim);
  background: var(--bg); border: 1px solid var(--line); border-left: 2px solid var(--accent-dim); border-radius: 6px;
  max-height: 120px; overflow-y: auto; white-space: pre-wrap; }
.extract-boards { list-style: none; margin: 0 0 4px; padding: 0; overflow-y: auto; }
.extract-board { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%;
  font: inherit; text-align: left; cursor: pointer; color: var(--text); background: transparent;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; }
.extract-board:hover { border-color: var(--accent-dim); background: var(--bg-hover); }
.extract-board .eb-name { font-size: 14px; }
.extract-board .eb-lane { font-size: 11px; color: var(--text-faint); white-space: nowrap; }

/* ---- lane reorder controls ---- */
.lane-ctrls { display: flex; align-items: center; gap: 1px; opacity: 0; transition: opacity .15s; }
.lane:hover .lane-ctrls { opacity: 1; }
.lane-ctrls .lane-del { opacity: 1; }   /* visibility now governed by the group */
.lane-move { flex: none; background: transparent; border: none; cursor: pointer; color: var(--text-faint);
  font-size: 16px; line-height: 1; padding: 2px 5px; border-radius: 5px; }
.lane-move:hover:not(:disabled) { color: var(--accent); background: var(--bg-hover); }
.lane-move:disabled { opacity: .25; cursor: default; }

/* ---- Views product: query bar + list layout ---- */
.view-stage { flex: 1; overflow-y: auto; padding: 24px clamp(16px, 5vw, 56px); }
.view-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; max-width: 920px; margin: 0 auto 18px; }
.view-search { flex: 1; min-width: 180px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.view-search:focus { outline: none; border-color: var(--accent-dim); }
.view-ctl { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-faint); }
.view-ctl select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; }
.view-dir { font: inherit; color: var(--text-dim); background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; width: 32px; height: 32px; cursor: pointer; }
.view-dir:hover { color: var(--text); border-color: var(--accent-dim); }
.view-count { font-size: 12px; color: var(--text-faint); margin-left: auto; }
.view-layouts { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view-layout { font: inherit; font-size: 13px; color: var(--text-dim); background: transparent; border: none;
  padding: 6px 12px; cursor: pointer; }
.view-layout.on { color: var(--bg); background: var(--accent); }

.view-list { list-style: none; margin: 0 auto; padding: 0; max-width: 920px; }
.view-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.view-row:hover { border-color: var(--accent-dim); background: var(--bg-hover); }
.vr-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.vr-title { color: var(--text); font-size: 15px; }
.vr-snippet { color: var(--text-faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vr-meta { flex: none; display: flex; align-items: center; gap: 10px; }
.vr-date { font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.vr-type { font-size: 10px; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px;
  border-radius: 999px; border: 1px solid var(--line); color: var(--text-dim); }
.vr-type.t-card  { color: #8fb6ae; border-color: #8fb6ae55; }
.vr-type.t-wiki  { color: #a98cc0; border-color: #a98cc055; }
.vr-type.t-board { color: #c2a06a; border-color: #c2a06a55; }
.vr-type.t-note  { color: #8893a4; border-color: #8893a455; }
.view-empty { max-width: 920px; margin: 40px auto; text-align: center; }

/* ===== Spreadsheets ===== */
.sheet-stage { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; }
.sheet-stage .board-head { display: flex; align-items: center; gap: 12px; }
.sheet-del { margin-left: auto; font-size: 12px; color: var(--text-faint); }
.sheet-del:hover { color: #d2918a; }
.sheet-scroll { flex: 1; overflow: auto; padding: 0 18px 60px; }
table.sheet { table-layout: fixed; border-collapse: collapse; font-size: 13px; color: var(--text); }
.sheet th, .sheet td { border: 1px solid var(--line); padding: 0; vertical-align: middle; box-sizing: border-box; }
.sheet-corner, .sheet-rownum { width: 44px; min-width: 44px; background: var(--bg-hover); }
.sheet-addcol, .sheet-pad { width: 46px; min-width: 46px; }
.sheet-addcol button { width: 100%; min-height: 34px; background: transparent; border: 0; color: var(--text-faint); cursor: pointer; font-size: 16px; }
.sheet-addcol button:hover { color: var(--accent); background: var(--bg-hover); }
.sheet-th { position: relative; background: var(--bg-hover); height: 36px; text-align: left; }
.th-name { display: flex; flex-direction: column; gap: 1px; width: 100%; height: 100%; padding: 5px 9px; background: transparent; border: 0; cursor: pointer; text-align: left; font: inherit; color: var(--text); overflow: hidden; }
.th-name:hover { background: var(--bg, #1b1e24); }
.th-text { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-type { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }
.col-resize { position: absolute; top: 0; right: -3px; width: 7px; height: 100%; cursor: col-resize; z-index: 2; }
.col-resize:hover { background: var(--accent-dim, #3a5a54); }
body.col-resizing { cursor: col-resize; user-select: none; }
.sheet-td { vertical-align: top; overflow: hidden; }
.sheet-td .cellview { display: block; padding: 6px 9px; min-height: 20px; white-space: normal; overflow-wrap: anywhere; word-break: break-word; cursor: text; }
.sheet-td.t-number .cellview, .sheet-td.t-number .cellinput { text-align: right; }
.sheet-td.editing { padding: 0; }
.cellinput { width: 100%; height: 100%; box-sizing: border-box; padding: 6px 9px; border: 0; outline: 2px solid var(--accent); outline-offset: -2px; background: var(--bg, #1b1e24); color: var(--text); font: inherit; }
.sheet-td.invalid .cellview { color: #d2918a; text-decoration: underline wavy #d2918a; text-underline-offset: 2px; }
.sheet-td.t-checkbox { text-align: center; }
.cellbox { width: 18px; height: 18px; margin: 0 auto; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--accent); cursor: pointer; font-size: 12px; }
.cellbox.on { background: var(--accent); color: var(--bg, #1b1e24); border-color: var(--accent); }
.cellsel { width: 100%; height: 100%; border: 0; background: transparent; color: var(--text); font: inherit; padding: 5px 7px; cursor: pointer; }
.cellsel.invalid { color: #d2918a; }
.sheet-rownum { position: relative; text-align: center; color: var(--text-faint); font-size: 11px; padding: 0; }
.sheet-rownum .rn-btn { display: block; width: 100%; min-height: 28px; padding: 6px 0; border: 0; background: transparent; color: var(--text-faint); font: inherit; font-size: 11px; cursor: pointer; }
.sheet-rownum .rn-btn:hover { background: var(--bg-elev, #2a2f37); color: var(--text); }
.sheet-addrow { margin: 8px 0; padding: 6px 14px; background: transparent; border: 1px dashed var(--line); border-radius: 6px; color: var(--text-dim); cursor: pointer; font: inherit; font-size: 12px; }
.sheet-addrow:hover { color: var(--accent); border-color: var(--accent-dim, #3a5a54); }
.sheet-colmenu { width: 232px; }
.colname-input { width: 100%; box-sizing: border-box; padding: 6px 8px; margin-bottom: 8px; background: var(--bg, #1b1e24); border: 1px solid var(--line); border-radius: 5px; color: var(--text); font: inherit; }
.colopts { width: 100%; box-sizing: border-box; margin-top: 4px; padding: 6px 8px; background: var(--bg, #1b1e24); border: 1px solid var(--line); border-radius: 5px; color: var(--text); font: inherit; font-size: 12px; resize: vertical; }
.cm-row.wrap { flex-wrap: wrap; }
.cm-hint { margin-top: 7px; font-size: 11px; line-height: 1.5; color: var(--text-faint); }
.cm-hint em { color: var(--text-dim); font-style: normal; }
.cm-swatches { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.cm-swatch { padding: 1px 8px; border-radius: 10px; font-size: 10px; }
.sheet-td.t-enum .cellsel.colored { border-radius: 4px; margin: 3px; width: calc(100% - 6px); height: calc(100% - 6px); padding: 3px 6px; }

/* board card: assignee + due meta — stacked on their own lines below the title */
.bcard-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.bcard-assignee, .bcard-due { font-size: 11px; line-height: 1.3; white-space: nowrap; }
.bcard-assignee { color: var(--accent); }
.bcard-assignee::before { content: "@"; opacity: 0.6; }
.bcard-due { color: var(--text-dim); }
.bcard-due::before { content: "due "; opacity: 0.55; }
.bcard-due.overdue { color: #d2918a; }
.bcard-due.overdue::before { content: "overdue "; opacity: 0.7; }
.cm-input { width: 100%; box-sizing: border-box; padding: 5px 8px; background: var(--bg, #1b1e24); border: 1px solid var(--line); border-radius: 5px; color: var(--text); font: inherit; font-size: 12px; }
.cm-row .cm-input { width: auto; flex: 1; }
.cm-pickbtn { display: flex; align-items: center; gap: 6px; width: 100%; box-sizing: border-box; padding: 5px 8px; background: var(--bg, #1b1e24); border: 1px solid var(--line); border-radius: 5px; color: var(--text); font: inherit; font-size: 12px; cursor: pointer; text-align: left; }
.cm-pickbtn:hover { border-color: var(--accent-dim, #3a5a54); }
.cm-pick-cur { color: var(--accent); }
.cm-pick-empty { color: var(--text-faint); }
.cm-pick-caret { margin-left: auto; color: var(--text-faint); }
.mention-item.on { background: var(--accent-dim, #3a5a54); }
.person-current { margin-left: auto; font-size: 10px; color: var(--text-faint); }

/* ===== 30k Foot View ===== */
.ov-side-hint { padding: 14px 16px; font-size: 12px; line-height: 1.55; color: var(--text-faint); }
.ov-stage { height: 100%; overflow: auto; padding: 22px 26px 60px; max-width: 1100px; margin: 0 auto; }
.ov-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.ov-date { font-size: 22px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.ov-time { margin-top: 3px; font-size: 14px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ov-tickets { text-align: right; }
.ov-tickets-n { font-size: 34px; font-weight: 700; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.ov-tickets-l { margin-top: 4px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.ov-setname { margin: 0 0 18px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; color: var(--text-dim); background: var(--bg-hover); }
.ov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.ov-wide { grid-column: 1 / -1; }
.ov-panel { border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elev); padding: 16px 16px 8px; }
.ov-panel h3 { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.ov-none { margin: 4px 0 12px; font-size: 13px; color: var(--text-faint); }
.ov-list { list-style: none; margin: 0; padding: 0; }
.ov-item { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%; padding: 8px 8px; margin: 0 -8px; background: transparent; border: 0; border-left: 3px solid transparent; border-radius: 6px; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.ov-item.tinted { padding-left: 9px; }
.ov-item:hover { background: var(--bg-hover); }
.ov-item-main { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-item-meta { flex: none; display: flex; align-items: baseline; gap: 8px; font-size: 11px; }
.ov-lane, .ov-type { color: var(--text-faint); }
.ov-rel { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.ov-due { color: var(--text-dim); }
.ov-due.overdue { color: #d2918a; }
.ov-todos { list-style: none; margin: 0; padding: 0; }
.ov-todo { display: flex; align-items: baseline; gap: 9px; padding: 7px 8px; margin: 0 -8px; border-radius: 6px; }
.ov-todo:hover { background: var(--bg-hover); }
.ov-todo-box { flex: none; width: 15px; height: 15px; border: 1px solid var(--line); border-radius: 4px; font-size: 10px; line-height: 14px; text-align: center; color: var(--accent); align-self: center; }
.ov-todo.done .ov-todo-box { background: var(--accent); color: var(--bg-elev); border-color: var(--accent); }
.ov-todo-text { flex: 1; min-width: 0; font-size: 13px; color: var(--text); }
.ov-todo.done .ov-todo-text { color: var(--text-faint); text-decoration: line-through; }
.ov-todo-src { flex: none; background: transparent; border: 0; color: var(--text-faint); font: inherit; font-size: 11px; cursor: pointer; max-width: 40%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-todo-src:hover { color: var(--accent); }
@media (max-width: 720px) { .ov-grid { grid-template-columns: 1fr; } }

/* flowchart title + delete in the toolbar */
.flow-title { font: inherit; font-size: 13px; font-weight: 600; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 5px; padding: 3px 8px; min-width: 90px; max-width: 220px; }
.flow-title:hover { border-color: var(--line); }
.flow-title:focus { border-color: var(--accent-dim); background: var(--bg, #1b1e24); outline: none; }
.flow-toolbar button.flow-arrange { margin-left: auto; }
.flow-toolbar button.flow-del { color: var(--text-faint); }
.flow-toolbar button.flow-del:hover { color: #d2918a; border-color: #5a3033; }

/* flow page wrapper so the editor fills and the box can overlay */
.flow-page { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* Mental Model corner box (sheets + flow) */
.mm-box { position: absolute; left: 16px; bottom: 16px; z-index: 6; width: 244px; max-width: calc(100% - 32px);
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,.28); font-size: 12px; }
.mm-box-head { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 8px; }
.mm-box-actions { display: flex; gap: 6px; }
.mm-box-actions button { flex: 1; font: inherit; font-size: 12px; padding: 5px 8px; color: var(--text-dim);
  background: var(--bg, #1b1e24); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.mm-box-actions button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent-dim, #3a5a54); }
.mm-box-actions button:disabled { opacity: .45; cursor: default; }
.mm-box-status { font-size: 12px; color: var(--accent); padding: 3px 0; }
.mm-box-error { margin-top: 7px; font-size: 11px; color: #d2918a; line-height: 1.4; }
.mm-box-summary { margin-top: 9px; font-size: 12px; line-height: 1.5; color: var(--text); font-style: italic; }
.mm-box-links { margin-top: 9px; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 8px; }
.mm-box-link { text-align: left; background: transparent; border: 0; padding: 2px 0; font: inherit; font-size: 11.5px;
  color: var(--accent); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-box-link:hover { text-decoration: underline; }

/* mental model: per-type legend + panel badge */
.mmg-types { position: absolute; left: 14px; bottom: 38px; display: flex; flex-wrap: wrap; gap: 10px;
  padding: 6px 10px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 8px; max-width: calc(100% - 28px); }
.mmg-type { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.mmg-swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.mmg-panel-type { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 8px; font-size: 11px; color: var(--text-faint); }
.mmg-panel-type .mmg-swatch { width: 8px; height: 8px; }

/* full-width menu item (row menu) */
.cm-item { display: block; width: 100%; text-align: left; padding: 6px 9px; margin: 1px 0; background: transparent; border: 0; border-radius: 5px; color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
.cm-item:hover { background: var(--bg-hover); }
.sheet-rowmenu { width: 184px; }

/* formula cells: computed result right-aligned, a small corner marker, errors in red */
.sheet-td.t-formula { position: relative; }
.sheet-td.t-formula .cellview { display: block; text-align: right; }
.sheet-td.t-formula::before { content: ''; position: absolute; top: 0; left: 0;
  border-style: solid; border-width: 4px 4px 0 0; border-color: var(--accent) transparent transparent transparent; opacity: .55; }
.sheet-td.t-formula.invalid .cellview { color: #d2918a; text-align: right; }

/* ---- projects: topbar picker + new-project modal ---- */
.proj-pick { font: inherit; font-size: 12px; color: var(--text-dim); background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 22px 3px 9px; cursor: pointer;
  max-width: 168px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23868d99'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; }
.proj-pick:hover { color: var(--text); border-color: var(--margin-line); }
.proj-pill { font-size: 12px; color: var(--text-dim); background: var(--bg-elev);
  border: 1px dashed var(--margin-line); border-radius: 6px; padding: 3px 9px; max-width: 168px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  width: min(440px, calc(100vw - 32px)); padding: 20px; box-shadow: 0 16px 48px rgba(0,0,0,0.5); }
.proj-modal h3 { margin: 0 0 14px; font-weight: 500; color: var(--text); }
.proj-modal .fld { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }
.proj-modal .fld-in { display: block; width: 100%; margin-top: 5px; font: inherit; font-size: 14px;
  color: var(--text); background: var(--bg-side); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.proj-modal .fld-in:focus { outline: none; border-color: var(--accent-dim); }
.proj-modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.proj-modal .primary { background: var(--accent-dim); border: 1px solid var(--accent-dim); color: var(--bg);
  font: inherit; font-weight: 500; border-radius: 6px; padding: 7px 14px; cursor: pointer; }
.proj-modal .primary:hover { background: var(--accent); border-color: var(--accent); }
.proj-modal .primary:disabled { opacity: .45; cursor: default; }

/* wiki page context menu */
.wiki-menu { width: 200px; }
.cm-item:disabled { opacity: .4; cursor: default; }
.cm-item:disabled:hover { background: transparent; }

/* ===== 30k Foot View: per-project blocks ===== */
.ov-projects { margin-top: 30px; }
.ov-section { margin: 0 0 14px; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.ov-proj { border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elev); padding: 16px 18px; margin-bottom: 16px; }
.ov-proj-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); }
.ov-proj-head h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.ov-proj-sub { font-size: 11px; color: var(--text-faint); }
.ov-proj-metrics { display: flex; gap: 28px; margin-bottom: 16px; }
.ov-metric-n { font-size: 26px; font-weight: 700; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.ov-metric-l { margin-top: 4px; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.ov-proj-charts { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 22px; align-items: start; }
.ov-proj-label { font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 9px; }
.ov-proj-charts .ov-proj-col:nth-child(2) { padding-left: 60px; }

.ov-bars { display: flex; flex-direction: column; gap: 7px; }
.ov-bar-row { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.ov-bar-label { flex: 0 0 84px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-bar-track { flex: 1; height: 8px; background: var(--bg-hover); border-radius: 4px; overflow: hidden; }
.ov-bar-fill { display: block; height: 100%; background: var(--accent-dim); border-radius: 4px; }
.ov-bar-n { flex: none; min-width: 22px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }

.ov-pie { display: flex; align-items: center; gap: 14px; }
.ov-pie-svg { width: 88px; height: 88px; flex: none; }
.ov-legend { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--text-dim); }
.ov-legend li { display: flex; align-items: center; gap: 7px; margin: 3px 0; text-transform: capitalize; }
.ov-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.ov-legend-n { margin-left: auto; padding-left: 10px; color: var(--text); font-variant-numeric: tabular-nums; }

.ov-proj-big { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.ov-pts { color: var(--accent); font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .ov-proj-charts { grid-template-columns: 1fr; } .ov-proj-charts .ov-proj-col:nth-child(2) { padding-left: 0; } .ov-proj-metrics { gap: 18px; } }

/* secondary footer action (Import CSV) */
.wiki-newroot.ghost-foot { color: var(--text-dim); }
.wiki-newroot.ghost-foot:hover { color: var(--text); background: var(--bg-hover); border-color: var(--margin-line); }

/* Mental Model mode toggle (Semantic / Projects) */
.mmg-mode { position: absolute; top: 14px; left: 16px; z-index: 4; display: flex; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg-elev); }
.mmg-mode-btn { font: inherit; font-size: 12px; padding: 5px 12px; background: transparent; border: 0; color: var(--text-dim); cursor: pointer; }
.mmg-mode-btn + .mmg-mode-btn { border-left: 1px solid var(--line); }
.mmg-mode-btn:hover { background: var(--bg-hover); color: var(--text); }
.mmg-mode-btn.on { background: var(--accent-dim); color: var(--text); }

/* Link… modal — search documents and toggle in-app backlinks */
.link-modal { position: fixed; z-index: 60; top: 14vh; left: 50%; transform: translateX(-50%);
  width: min(560px, 92vw); max-height: 70vh; display: flex; flex-direction: column;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.5); overflow: hidden; }
.link-modal-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px; border-bottom: 1px solid var(--line-soft); }
.link-search { flex: 1; font: inherit; font-size: 14px; padding: 9px 11px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.link-search:focus { outline: none; border-color: var(--accent); }
.link-results { overflow: auto; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.link-result { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; font-size: 13px;
  padding: 8px 10px; background: transparent; border: 0; border-radius: 7px; color: var(--text); cursor: pointer; }
.link-result:hover { background: var(--bg-hover); }
.link-result.on { background: rgba(143,182,174,.08); }
.link-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.link-result-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-result-type { flex: none; font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint); }
.link-result-state { flex: none; min-width: 58px; text-align: right; font-size: 11.5px; color: var(--text-dim); }
.link-result.on .link-result-state { color: var(--accent); }
.link-empty { padding: 18px 12px; color: var(--text-faint); font-size: 13px; text-align: center; }
.link-foot { padding: 9px 12px; border-top: 1px solid var(--line-soft); font-size: 11px; color: var(--text-faint); }

/* Research modal */
.research-heading { font-size: 14px; font-weight: 600; color: var(--text); }
.research-status { padding: 26px 16px; text-align: center; color: var(--text-dim); font-size: 13px; }
.research-status.err { color: var(--rose, #c98a87); }
.research-hint { padding: 10px 14px; font-size: 11.5px; color: var(--text-faint); border-bottom: 1px solid var(--line-soft); }
.research-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.research-item:hover { background: var(--bg-hover); }
.research-item.on { background: rgba(143,182,174,.08); }
.research-check { flex: none; width: 16px; height: 16px; margin-top: 2px; border: 1px solid var(--line); border-radius: 4px;
  display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--accent); }
.research-item.on .research-check { border-color: var(--accent); }
.research-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.research-link { font-size: 13px; color: var(--accent); text-decoration: none; }
.research-link:hover { text-decoration: underline; }
.research-url { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.research-note { font-size: 12px; color: var(--text-dim); }
.research-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.research-foot .primary { font: inherit; font-size: 12.5px; padding: 6px 12px; border-radius: 7px; cursor: pointer;
  background: var(--accent-dim); color: var(--text); border: 1px solid var(--line); }
.research-foot .primary:disabled { opacity: .5; cursor: default; }

/* rendered #RESEARCH footer in a document */
.research { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.rsrch-label { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 6px; }
.research ul { list-style: none; margin: 0; padding: 0; }
.research li { margin: 4px 0; font-size: 13.5px; }
.rsrch-link { color: var(--accent); text-decoration: none; }
.rsrch-link:hover { text-decoration: underline; }
.rsrch-note { color: var(--text-faint); font-size: 12px; }

/* Ask-a-question modal */
.ask-modal { max-height: 76vh; }
.ask-thread { flex: 1; overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; min-height: 120px; }
.ask-empty { color: var(--text-faint); font-size: 13px; margin: 8px 2px; }
.ask-pair { display: flex; flex-direction: column; gap: 6px; }
.ask-q { align-self: flex-end; max-width: 85%; background: var(--accent-dim); color: var(--text); font-size: 13px; padding: 7px 11px; border-radius: 12px 12px 3px 12px; white-space: pre-wrap; }
.ask-a { align-self: flex-start; max-width: 90%; background: var(--bg-hover); color: var(--text); font-size: 13.5px; line-height: 1.5; padding: 9px 12px; border-radius: 12px 12px 12px 3px; white-space: pre-wrap; }
.ask-a.pending { color: var(--text-faint); font-style: italic; }
.ask-input { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line-soft); }
.ask-box { flex: 1; font: inherit; font-size: 13.5px; resize: none; padding: 8px 10px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.ask-box:focus { outline: none; border-color: var(--accent); }
.ask-input .primary { font: inherit; font-size: 13px; padding: 8px 16px; border-radius: 8px; cursor: pointer; background: var(--accent-dim); color: var(--text); border: 1px solid var(--line); }
.ask-input .primary:disabled { opacity: .5; cursor: default; }

/* Instructions-for-Claude modal (shared by flow / wiki / sheets) + flow import-error modal */
.claude-help-modal { max-height: 82vh; }
.claude-help-text { flex: 1; min-height: 320px; margin: 12px 14px; padding: 12px; resize: none; font-family: var(--mono); font-size: 12px; line-height: 1.5;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; white-space: pre; overflow: auto; }
.flow-err { font-size: 12.5px; color: var(--text); padding: 7px 10px; border-left: 2px solid var(--rose, #c98a87); background: var(--bg-hover); border-radius: 0 6px 6px 0; margin: 3px 0; }
