/* Context Layer: Tessera's design system (shadcn-svelte "vega", neutral oklch greys,
   two-tier surfaces, Inter, 0.625rem radius). Tessera is blue, Tessera Events is green;
   this app's brand is violet. Dark mode is the default, as in both Tessera apps. */

:root {
  --background: oklch(0.975 0.002 250);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --sidebar: oklch(0.99 0 0);
  --muted: oklch(0.945 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --radius: 0.625rem;
  --brand: #7c3aed;
  --brand-fg: #6d28d9;
  --brand-light: #c4b5fd;
  --brand-soft: color-mix(in oklch, #7c3aed 10%, transparent);
  --ok: #0f9d52;
  --ok-soft: color-mix(in oklch, #10b45c 12%, transparent);
  --no-soft: color-mix(in oklch, oklch(0.577 0.245 27.325) 10%, transparent);
  --warn: #b45309;
  --warn-soft: color-mix(in oklch, #f59e0b 14%, transparent);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 3px rgb(0 0 0 / 0.04);
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; /* graph: one color per top folder */
  color-scheme: light;
}

.dark {
  --background: oklch(0.13 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --sidebar: oklch(0.165 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --destructive: oklch(0.704 0.191 22.216);
  --brand-fg: #b49bfc;
  --brand-light: #5b3fa8;
  --brand-soft: color-mix(in oklch, #8b5cf6 18%, transparent);
  --ok: #4ade80;
  --ok-soft: color-mix(in oklch, #10b45c 16%, transparent);
  --no-soft: color-mix(in oklch, oklch(0.704 0.191 22.216) 14%, transparent);
  --warn: #fbbf24;
  --warn-soft: color-mix(in oklch, #f59e0b 14%, transparent);
  --shadow: none;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  color-scheme: dark;
}

/* ---- base ---------------------------------------------------------------- */
* { box-sizing: border-box; }
html { font-family: "Inter", system-ui, sans-serif; font-feature-settings: "cv11", "calt" 0; /* calt off: Inter turns "4x24" into "4×24" */ -webkit-font-smoothing: antialiased; }
body { margin: 0; background: var(--background); color: var(--foreground); font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
code, kbd, pre, .mono { font-family: var(--mono); }
.muted { color: var(--muted-foreground); font-size: 13px; }
.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.i.big { width: 28px; height: 28px; stroke-width: 1.5; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 35%, transparent); }

/* Tessera mark */
.mark { width: 20px; height: 20px; flex-shrink: 0; }
.mark .b, .hero-mark .b { fill: var(--brand); }
.mark .l, .hero-mark .l { fill: var(--brand-light); }
.mark .e, .hero-mark .e { fill: none; stroke: var(--brand-light); stroke-width: 3px; }
.mark.xl { width: 56px; height: 56px; }

/* ---- controls -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 12px; border-radius: calc(var(--radius) * 0.8);
  border: 1px solid var(--border); background: var(--card); color: var(--foreground);
  font: inherit; font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer;
  box-shadow: var(--shadow); transition: background-color .15s, color .15s;
}
.btn:hover { background: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: transparent; color: #fff; box-shadow: 0 1px 2px color-mix(in oklch, var(--brand) 30%, transparent); }
.btn.primary:hover { background: color-mix(in oklch, var(--brand) 86%, black); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--muted); }
.btn.danger { background: var(--no-soft); color: var(--destructive); border-color: transparent; box-shadow: none; }
.btn.danger:hover { background: color-mix(in oklch, var(--destructive) 20%, transparent); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 40px; }
.iconbtn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 8px; background: none; color: var(--foreground); cursor: pointer;
}
.iconbtn:hover { background: var(--muted); }

.input {
  width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--input);
  border-radius: calc(var(--radius) * 0.8); background: transparent; color: var(--foreground);
  font: inherit; font-size: 14px; font-weight: 400; transition: border-color .15s, box-shadow .15s;
}
.dark .input { background: color-mix(in oklch, var(--input) 30%, transparent); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 22%, transparent); }
select.input option { background: var(--card); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.field small { font-weight: 400; color: var(--muted-foreground); font-size: 12px; }
.field > label, .field > span:not(.lab) { display: flex; flex-direction: column; gap: 6px; }
.field .lab { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; } /* hint on the label's line */

.pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--muted); color: var(--muted-foreground); white-space: nowrap;
}
.pill.brand { background: var(--brand-soft); color: var(--brand-fg); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.no { background: var(--no-soft); color: var(--destructive); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.tag { font-size: 12px; color: var(--muted-foreground); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.avatar {
  width: 28px; height: 28px; border-radius: 999px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand-fg); font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.avatar.sm { width: 20px; height: 20px; font-size: 9px; }
.avatar.lg { width: 36px; height: 36px; font-size: 13px; }

.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--brand-fg); }
.section { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--brand-fg); margin: 32px 0 12px; }

.callout {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; margin: 0 0 16px;
  border-radius: var(--radius); font-size: 13px; border: 1px solid transparent;
}
.callout .i { margin-top: 2px; }
.callout pre { margin: 0; white-space: pre-wrap; font-size: 12px; }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in oklch, var(--warn) 25%, transparent); }
.callout.warn .i { color: var(--warn); }
.callout.info { background: var(--brand-soft); border-color: color-mix(in oklch, var(--brand) 25%, transparent); }
.callout.info .i { color: var(--brand-fg); }
.callout.ok { background: var(--ok-soft); border-color: color-mix(in oklch, var(--ok) 25%, transparent); }
.callout.ok .i { color: var(--ok); }
.callout.no { background: var(--no-soft); border-color: color-mix(in oklch, var(--destructive) 25%, transparent); color: var(--destructive); }

/* The vault changed while the page was open. Bottom center, so nothing on the page moves. */
.stale-bar {
  position: fixed; z-index: 60; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 16px; border-radius: calc(var(--radius) + 4px); font-size: 13px;
  background: var(--card); color: var(--foreground); box-shadow: var(--shadow);
  border: 1px solid color-mix(in oklch, var(--brand) 45%, transparent);
}
.stale-bar .iconbtn { font-size: 18px; line-height: 1; }

/* ---- shell --------------------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 30; height: 48px; display: flex; align-items: center; gap: 16px;
  padding: 0 16px; border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--background) 82%, transparent); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.navs { display: flex; gap: 2px; font-size: 13px; }
.navs a { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 6px; font-weight: 500; color: var(--muted-foreground); }
.navs a:hover { background: var(--muted); color: var(--foreground); }
.navs a.on { background: var(--muted); color: var(--foreground); }
.count { background: var(--brand); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; line-height: 18px; font-weight: 600; }
.hsearch { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
.hsearch .i { position: absolute; left: 10px; top: 50%; translate: 0 -50%; color: var(--muted-foreground); pointer-events: none; }
.hsearch input {
  width: 100%; height: 32px; padding: 0 34px; border: 1px solid var(--border); border-radius: 8px;
  background: color-mix(in oklch, var(--muted) 50%, transparent); color: var(--foreground); font: inherit; font-size: 13px;
}
.hsearch input:focus { outline: none; border-color: var(--brand); background: var(--card); }
.hsearch kbd {
  position: absolute; right: 8px; top: 50%; translate: 0 -50%; font-size: 11px; color: var(--muted-foreground);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; line-height: 16px;
}
.right { display: flex; align-items: center; gap: 6px; }
#theme .moon { display: none; }
.dark #theme .sun { display: block; }
html:not(.dark) #theme .sun { display: none; }
html:not(.dark) #theme .moon { display: block; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; display: flex; border-radius: 999px; }
.menu summary::-webkit-details-marker { display: none; }
.menu .pop {
  position: absolute; right: 0; top: 40px; min-width: 260px; padding: 4px; z-index: 40;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgb(0 0 0 / .22);
}
.pop-head { display: flex; gap: 10px; align-items: center; padding: 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.pop-head div { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; min-width: 0; }
.pop-head span:not(.pill) { font-size: 12px; color: var(--muted-foreground); word-break: break-all; }
.pop > a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; font-size: 13px; }
.pop > a:hover { background: var(--muted); }

/* "Suggest addition": a button that opens a two-item menu. */
.add-menu > summary { border-radius: calc(var(--radius) * 0.8); }
.add-menu .pop > a { align-items: flex-start; padding: 9px 10px; }
.add-menu .pop > a .i { margin-top: 2px; color: var(--brand-fg); }
.add-menu .pop span { display: flex; flex-direction: column; gap: 1px; }
.add-menu .pop small { color: var(--muted-foreground); font-size: 12px; }
.page-head .add-menu .pop { top: 44px; }
/* Home: search, then "Suggest addition", in one row. The hero clips overflow, so the menu opens upward. */
.hero-actions { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.hero-actions .big-search { flex: 1 1 420px; }
.hero-add { height: 44px; padding: 0 16px; }
.hero .add-menu .pop { top: auto; bottom: calc(100% + 6px); }
.top-folders { margin-top: 32px; }

/* Proposal kinds: Edit, New note, New folder. */
.kind { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.kind.k-edit { background: var(--muted); color: var(--foreground); }
.kind.k-note { background: var(--brand-soft); color: var(--brand-fg); }
.kind.k-folder { background: var(--warn-soft); color: var(--warn); }
.row .kind { height: 18px; padding: 0 7px; font-size: 11px; margin-left: 8px; vertical-align: 1px; }
.grow { flex: 1; }
/* The first submit button in the form: Enter in a field saves the draft, never "Remove" or "Send". */
.default-submit { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.row .btn.sm { flex-shrink: 0; }

/* Folder picker: the chosen folder, and a tree with a search box under it. */
.picker { position: relative; }
.picker > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.picker > summary::-webkit-details-marker { display: none; }
.picker > summary .i { width: 16px; height: 16px; color: var(--brand-fg); }
.picker > summary .chev { margin-left: auto; color: var(--muted-foreground); transform: rotate(90deg); transition: transform .15s; }
.picker[open] > summary .chev { transform: rotate(-90deg); }
.picker-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-pop {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; min-width: 280px; padding: 6px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: 0 12px 32px rgb(0 0 0 / .22);
}
.picker-tree { max-height: 300px; overflow: auto; margin-top: 6px; }
.pick-row { display: flex; align-items: center; gap: 2px; padding-left: calc(var(--d) * 16px); }
.pick-row[hidden] { display: none; }
.pick-tog { flex: 0 0 24px; height: 24px; display: inline-grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted-foreground); cursor: pointer; }
button.pick-tog:hover { background: var(--muted); }
.pick-tog .i { width: 14px; height: 14px; transition: transform .15s; }
.pick-tog[aria-expanded="true"] .i { transform: rotate(90deg); }
.pick-row label { flex: 1; display: flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 8px; border-radius: 6px; font-size: 13px; font-weight: 400; cursor: pointer; }
.pick-row label:hover { background: var(--muted); }
.pick-row label .i { width: 14px; height: 14px; color: var(--brand-fg); opacity: .85; }
.pick-row input { position: absolute; opacity: 0; pointer-events: none; }
.pick-row label:has(input:checked) { background: var(--brand-soft); color: var(--brand-fg); font-weight: 500; }
.pick-row label:has(input:focus-visible) { box-shadow: 0 0 0 2px var(--brand); }

.app { display: grid; grid-template-columns: var(--sidebar-w, 272px) 0 minmax(0, 1fr); min-height: calc(100svh - 48px); }
/* The grip sits on the sidebar's right edge; drag it to resize. */
.sidebar-grip { position: sticky; top: 48px; height: calc(100svh - 48px); width: 8px; margin-left: -4px; z-index: 5; cursor: col-resize; }
.sidebar-grip:hover, .sidebar-grip:focus-visible, .resizing .sidebar-grip { background: linear-gradient(90deg, transparent 3px, var(--brand) 3px 5px, transparent 5px); outline: none; }
.resizing { cursor: col-resize; user-select: none; }
/* Notes in the folder list: "⋯" shows on hover or focus. */
.tree .leaf { position: relative; }
.tree .leaf > a { padding-right: 30px; }
.leaf-more {
  position: absolute; right: 2px; top: 2px; width: 24px; height: 24px; display: inline-grid; place-items: center;
  border: 0; border-radius: 6px; background: none; color: var(--muted-foreground); cursor: pointer; opacity: 0;
}
.leaf-more .i { width: 16px; height: 16px; }
.tree .leaf:hover .leaf-more, .leaf-more:focus-visible { opacity: 1; }
.leaf-more:hover { background: color-mix(in oklch, var(--foreground) 10%, transparent); color: var(--foreground); }
.leaf-menu {
  position: fixed; z-index: 50; min-width: 220px; max-width: 360px; padding: 4px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 32px rgb(0 0 0 / .22);
}
.leaf-menu button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--foreground); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.leaf-menu button:hover, .leaf-menu button:focus-visible { background: var(--muted); outline: none; }
.leaf-menu small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted-foreground); font-family: var(--mono); font-size: 11px; }
.sidebar {
  position: sticky; top: 48px; height: calc(100svh - 48px); overflow-y: auto;
  background: var(--sidebar); border-right: 1px solid var(--border); padding: 12px 8px 32px;
}
.sidebar .eyebrow { padding: 16px 8px 6px; }
.tree-home, .tree a, .tree summary {
  display: flex; align-items: center; gap: 7px; min-height: 28px; padding: 0 8px; border-radius: 6px;
  font-size: 13px; color: var(--muted-foreground); cursor: pointer;
}
.tree-home:hover, .tree > a:hover, .tree div > a:hover, .tree summary:hover { background: var(--muted); color: var(--foreground); }
.tree-home.on, .tree a.on, .tree summary.on { background: var(--brand-soft); color: var(--brand-fg); font-weight: 500; }
.tree summary { list-style: none; color: var(--foreground); font-weight: 500; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary a { display: inline; min-height: 0; padding: 0; flex: 1; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree summary a:hover { background: none; text-decoration: underline; text-underline-offset: 3px; }
.tree summary .i:not(.chev) { color: var(--brand-fg); opacity: .85; }
.tree .chev { width: 14px; height: 14px; transition: transform .15s; color: var(--muted-foreground); }
.tree details[open] > summary .chev { transform: rotate(90deg); }
.tree details > div { margin-left: 14px; padding-left: 8px; border-left: 1px solid var(--border); }
.tree a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree a .i { width: 14px; height: 14px; opacity: .7; }
.tree .n { font-size: 11px; color: var(--muted-foreground); font-weight: 400; }

.main { min-width: 0; }
.content { max-width: 1240px; margin: 0 auto; padding: 24px 32px 80px; }
.content.with-rail { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 28px; }
.col { min-width: 0; }
.rail { position: sticky; top: 72px; align-self: start; display: flex; flex-direction: column; gap: 12px; padding-top: 34px; }

/* ---- ambient tiles (app pages) ------------------------------------------- */
.ambient { position: fixed; inset: 0; z-index: -10; overflow: hidden; perspective: 1000px; pointer-events: none; }
.flip { position: absolute; border-radius: 18%; background: var(--brand); opacity: 0; animation: ambient-flip 3200ms cubic-bezier(.2, 0, 0, 1) forwards; }
@keyframes ambient-flip {
  0% { transform: rotateY(90deg); opacity: 0; }
  22% { transform: rotateY(0); opacity: .13; }
  72% { transform: rotateY(0); opacity: .13; }
  100% { transform: rotateY(-90deg); opacity: 0; }
}

/* ---- page parts ------------------------------------------------------------ */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13px; color: var(--muted-foreground); margin-bottom: 14px; }
.crumbs a { display: inline-flex; align-items: center; padding: 2px 4px; border-radius: 4px; }
.crumbs a:hover { color: var(--foreground); background: var(--muted); }
.crumbs > .i { width: 14px; height: 14px; opacity: .5; }
.crumbs span { color: var(--foreground); }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 20px; }
.title { font-size: 30px; line-height: 1.2; font-weight: 650; letter-spacing: -0.025em; margin: 10px 0 8px; text-wrap: balance; }
.lede { font-size: 15px; color: var(--muted-foreground); max-width: 72ch; line-height: 1.6; }
.lede a { color: var(--brand-fg); font-weight: 500; }
.byline { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; color: var(--muted-foreground); }
.byline b { color: var(--foreground); font-weight: 500; }
.head-actions { display: flex; gap: 8px; flex-shrink: 0; padding-top: 30px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 8px; padding: 14px 16px 0; font-size: 13px; font-weight: 600; }
.card-h .i { color: var(--brand-fg); width: 15px; height: 15px; }
.card-h.flush { padding: 0 0 12px; }
.card-b { padding: 12px 16px 16px; }
.card + .card, .card + .callout, .callout + .card { margin-top: 12px; }
.rail .card + .card, .stats .card + .card, .grid .card + .card { margin-top: 0; }
.outline a, .links a { display: flex; align-items: center; gap: 8px; padding: 4px 6px; margin: 0 -6px; border-radius: 6px; font-size: 13px; color: var(--muted-foreground); }
.outline a:hover, .links a:hover { background: var(--muted); color: var(--foreground); }
.outline a.lvl3 { padding-left: 20px; }
.outline a.lvl1 { font-weight: 500; color: var(--foreground); }
.links a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.links .i { width: 14px; height: 14px; opacity: .7; }
.help { background: linear-gradient(160deg, var(--brand-soft), transparent 70%), var(--card); }
.help p { font-size: 13px; color: var(--muted-foreground); margin-bottom: 12px; }

.doc { padding: 36px 44px 44px; }

/* ---- folder and list views -------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.fcard { display: flex; flex-direction: column; gap: 8px; padding: 16px; transition: border-color .15s, transform .15s; }
.fcard:hover { border-color: color-mix(in oklch, var(--brand) 55%, var(--border)); transform: translateY(-1px); }
.fcard .ico, .row .ico {
  width: 32px; height: 32px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-fg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.fcard h3 { font-size: 15px; font-weight: 600; margin-top: 4px; }
.fcard p { font-size: 13px; color: var(--muted-foreground); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fcard .n { margin-top: auto; font-size: 12px; color: var(--muted-foreground); }

.rows { overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background-color .15s; }
.row:last-child { border-bottom: 0; }
.row:hover { background: color-mix(in oklch, var(--muted) 55%, transparent); }
.row .ico { width: 30px; height: 30px; background: var(--muted); color: var(--muted-foreground); }
.row:hover .ico { background: var(--brand-soft); color: var(--brand-fg); }
.row .mid { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row .t { font-weight: 500; display: flex; gap: 8px; align-items: baseline; }
.row .d { font-size: 13px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.where { font-size: 12px; font-weight: 400; color: var(--muted-foreground); }
.when { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-foreground); white-space: nowrap; }

.tabs { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.tabs a { padding: 4px 12px; border-radius: 6px; font-weight: 500; color: var(--muted-foreground); }
.tabs a span { font-size: 12px; opacity: .7; margin-left: 2px; }
.tabs a.on { background: var(--muted); color: var(--foreground); }

.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 56px 24px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }
.empty .i { color: var(--brand-fg); }
.empty h2 { font-size: 16px; font-weight: 600; }
.empty p { color: var(--muted-foreground); }

.hits { display: flex; flex-direction: column; gap: 10px; }
.hit { display: block; padding: 16px; transition: border-color .15s; }
.hit:hover { border-color: color-mix(in oklch, var(--brand) 55%, var(--border)); }
.hit h3 { font-size: 15px; font-weight: 600; margin: 8px 0 4px; }
.hit p { font-size: 13px; color: var(--muted-foreground); }

/* ---- home ------------------------------------------------------------------ */
.hero {
  position: relative; overflow: hidden; padding: 40px; border-radius: calc(var(--radius) * 1.8);
  border: 1px solid var(--border);
  background:
    radial-gradient(ellipse 60% 90% at 100% 0%, color-mix(in oklch, var(--brand) 24%, transparent), transparent 70%),
    var(--card);
}
.hero h1 { font-size: 38px; line-height: 1.1; font-weight: 700; letter-spacing: -0.035em; margin: 12px 0 10px; }
.hero .lede { max-width: 56ch; }
.hero-mark { position: absolute; right: -28px; top: -28px; width: 240px; height: 240px; opacity: .16; transform: rotate(-8deg); }
.big-search { position: relative; display: flex; gap: 8px; max-width: 620px; margin-top: 24px; }
.big-search .i { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--muted-foreground); }
.big-search input {
  flex: 1; height: 44px; padding: 0 14px 0 40px; border: 1px solid var(--input); border-radius: var(--radius);
  background: var(--background); color: var(--foreground); font: inherit; font-size: 15px;
}
.big-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 22%, transparent); }
.big-search .btn { height: 44px; padding: 0 18px; }
/* ---- graph ---- */
.graph-card { position: relative; overflow: hidden; }
#graph { height: calc(100svh - 250px); min-height: 420px; }
.legend { position: absolute; top: 12px; left: 14px; z-index: 1; display: flex; gap: 14px; font-size: 12px; color: var(--muted-foreground); pointer-events: none; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--muted-foreground); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat span { font-size: 12px; color: var(--muted-foreground); }
.stat b { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; font-feature-settings: "tnum"; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.step { display: flex; gap: 12px; padding: 16px; border: 1px dashed color-mix(in oklch, var(--brand) 35%, var(--border)); border-radius: var(--radius); }
.step .num {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}
.step h3 { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.step p { font-size: 13px; color: var(--muted-foreground); }

/* ---- editor -------------------------------------------------------------- */
.editor { display: flex; flex-direction: column; gap: 12px; }
.editor .card + .card { margin-top: 0; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fields .wide { grid-column: 1 / -1; }
/* Write pane alone by default; the Preview toggle adds the second column. */
.split { display: grid; grid-template-columns: minmax(0, 1fr); }
.split.previewing { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.split > div + div { border-left: 1px solid var(--border); }
.pane-h {
  display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-foreground);
}
.pane-h small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.pane-h .preview-toggle { margin-left: auto; text-transform: none; letter-spacing: 0; }
.preview-toggle[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-fg); }

/* Markdown help: hover, focus or click the (i). */
.md-help { position: relative; display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; }
.tip-btn { width: 24px; height: 24px; }
.tip-btn .i { width: 14px; height: 14px; }
.tip {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: min(340px, 80vw); padding: 10px 12px;
  border: 1px solid color-mix(in oklch, var(--brand) 40%, var(--border)); border-radius: var(--radius); background: var(--card);
  box-shadow: 0 8px 24px rgb(0 0 0 / .25); color: var(--foreground); font-size: 12.5px; font-weight: 400; line-height: 1.55;
  letter-spacing: 0; text-transform: none; visibility: hidden; opacity: 0; transition: opacity .12s;
}
.tip-codes { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 8px; }
.tip-codes code { padding: 1px 6px; border-radius: 4px; background: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.md-help:hover .tip, .tip-btn:focus-visible + .tip, .md-help.open .tip { visibility: visible; opacity: 1; }

/* Tags: chips plus a searchable list of the vault's tags. */
.tagbox { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 38px; padding: 4px 6px; cursor: text; }
.tagbox:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 22%, transparent); }
.tagbox input { flex: 1; min-width: 120px; border: 0; background: transparent; color: var(--foreground); font: inherit; font-size: 13px; padding: 4px; }
.tagbox input:focus { outline: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-fg); font-size: 12px; font-weight: 500; }
.chip.new { background: var(--warn-soft); color: var(--foreground); }
.chip button { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; }
.chip button:hover { background: color-mix(in oklch, currentColor 15%, transparent); }
.tag-list {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: -1px; right: -1px; max-height: 260px; overflow: auto; margin: 0; padding: 4px;
  list-style: none; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
}
.tag-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; border-radius: 6px; font-size: 13px; font-weight: 400; cursor: pointer; }
.tag-list li span { color: var(--muted-foreground); font-size: 12px; }
.tag-list li.active { background: var(--muted); }
.tag-list li.add { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; color: var(--brand-fg); font-weight: 500; }
.tag-list li.none { cursor: default; color: var(--muted-foreground); }

/* Sources: one row per document. */
.card-h small { font-weight: 400; color: var(--muted-foreground); font-size: 12px; }
.source-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px; margin-bottom: 8px; }
#new-type { margin-top: 6px; }
.split textarea {
  display: block; width: 100%; height: 560px; resize: vertical; border: 0; padding: 16px 18px;
  background: transparent; color: var(--foreground); font-family: var(--mono); font-size: 13px; line-height: 1.7;
}
.split textarea:focus { outline: none; box-shadow: inset 0 0 0 2px color-mix(in oklch, var(--brand) 35%, transparent); }
.split .prose { height: 560px; overflow: auto; padding: 16px 22px; font-size: 14px; }
.bar {
  position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 14px 0 4px;
  background: linear-gradient(transparent, var(--background) 40%);
}

/* ---- proposal ------------------------------------------------------------- */
.diffstat { margin-left: auto; font-family: var(--mono); font-size: 12px; }
.diffstat .plus { color: var(--ok); } .diffstat .minus { color: var(--destructive); }
.diff { margin-top: 12px; border-top: 1px solid var(--border); overflow-x: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.65; padding: 6px 0; }
.diff div { padding: 0 16px 0 2.4em; text-indent: -1.4em; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff .add { background: var(--ok-soft); box-shadow: inset 3px 0 var(--ok); }
.diff .del { background: var(--no-soft); box-shadow: inset 3px 0 var(--destructive); }
.diff .gap { height: 0; margin: 8px 0; border-top: 1px dashed var(--border); }
.review { margin-top: 12px; border-color: color-mix(in oklch, var(--brand) 45%, var(--border)); }
.review .stack { display: flex; flex-direction: column; gap: 12px; }
.review p { font-size: 13.5px; line-height: 1.6; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.decline { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
/* On a git branch: the commands to copy, and what went wrong when the branch was made. */
.cmd, .branch-log { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--muted); font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.branch-log { max-height: 220px; overflow: auto; font-size: 12px; }
details.more summary { cursor: pointer; font-size: 13px; color: var(--brand-fg); font-weight: 500; }
details.more[open] summary { margin-bottom: 10px; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted-foreground); }
.row .badges { display: flex; gap: 6px; flex-shrink: 0; }
.who { display: flex; gap: 10px; align-items: center; }
.who div { display: flex; flex-direction: column; min-width: 0; }
.who span { font-size: 12px; color: var(--muted-foreground); word-break: break-all; }
blockquote { margin: 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--brand); color: var(--muted-foreground); font-size: 13px; }

/* ---- rendered Markdown ------------------------------------------------------ */
.prose { font-size: 15px; line-height: 1.75; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: 1.6em; font-weight: 650; letter-spacing: -0.02em; margin: 1.4em 0 .5em; }
.prose h2 { font-size: 1.25em; font-weight: 600; letter-spacing: -0.015em; margin: 1.9em 0 .6em; padding-bottom: .35em; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.05em; font-weight: 600; margin: 1.6em 0 .4em; }
.prose p, .prose ul, .prose ol { margin: .75em 0; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: .3em 0; }
.prose li::marker { color: color-mix(in oklch, var(--brand-fg) 70%, var(--muted-foreground)); }
.prose a { color: var(--brand-fg); text-decoration: underline; text-decoration-color: color-mix(in oklch, var(--brand-fg) 35%, transparent); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: currentColor; }
.prose strong { font-weight: 600; }
.prose code { font-size: .85em; background: var(--muted); padding: .15em .4em; border-radius: 5px; }
.prose pre { background: color-mix(in oklch, var(--muted) 55%, transparent); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.6; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; font-size: 14px; margin: 1.2em 0; }
.prose th { background: color-mix(in oklch, var(--muted) 60%, transparent); font-weight: 600; text-align: left; }
.prose th, .prose td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose tr:last-child td { border-bottom: 0; }
.prose blockquote { margin: 1em 0; font-size: inherit; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose img { max-width: 100%; border-radius: 8px; }
.prose .mermaid { display: flex; justify-content: center; padding: 20px; margin: 1.2em 0; border: 1px solid var(--border); border-radius: 8px; background: color-mix(in oklch, var(--muted) 30%, transparent); overflow-x: auto; }
.doc .prose { max-width: 76ch; }

/* ---- sign-in --------------------------------------------------------------- */
.login-body { min-height: 100svh; overflow: hidden; }
.login { position: relative; z-index: 1; min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 24px; }
/* No backdrop-filter here: over 224 moving tiles the browser re-blurs every frame,
   which froze the sign-in page on a slow PC (2026-11-28). A more solid panel looks the same. */
.glass { background: color-mix(in oklch, var(--background) 88%, transparent); border-radius: 1.1rem; }
.hero-glass { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 28px; text-align: center; }
.hero-glass h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
.hero-glass p { max-width: 34ch; font-size: 14px; color: var(--muted-foreground); }
.signin { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 340px; padding: 18px; border: 1px solid var(--border); }
.signin .fine { font-size: 12px; color: var(--muted-foreground); text-align: center; }
.login .callout { margin: 0; }

.tile-wave {
  position: fixed; inset: 0; z-index: 0; display: grid; grid-template-columns: repeat(16, 1fr); gap: 10px; padding: 10px;
  align-content: start; perspective: 1200px; overflow: hidden; pointer-events: none; opacity: .01; transition: opacity .9s ease-out;
}
.tile-wave.visible { opacity: 1; }
.tile { position: relative; aspect-ratio: 1; transform-style: preserve-3d; }  /* no will-change: 224 permanent layers */
.tile-wave.animate .tile { animation: tile-flip 9s cubic-bezier(.2, 0, 0, 1) infinite; }
.tile::before, .tile::after { content: ""; position: absolute; inset: 0; border-radius: 18%; backface-visibility: hidden; }
.tile::before { border: 1px solid color-mix(in oklch, var(--foreground) 8%, transparent); }
.tile.em::before { background: var(--brand); border: none; box-shadow: 0 0 8px color-mix(in oklch, var(--brand) 55%, transparent); }
.tile::after { transform: rotateY(180deg); border: 1px solid color-mix(in oklch, var(--brand) 25%, transparent); }
.tile.strong::after { background: var(--brand); border: none; opacity: .55; }
.tile.light::after { background: var(--brand-light); border: none; opacity: .28; }
@keyframes tile-flip {
  0% { transform: rotateY(0); } 9% { transform: rotateY(180deg); } 46% { transform: rotateY(180deg); }
  55% { transform: rotateY(360deg); } 100% { transform: rotateY(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .flip, .tile { animation: none !important; }
}

/* ---- narrow screens ----------------------------------------------------------- */
.only-sm { display: none; }
@media (max-width: 1100px) {
  .content.with-rail { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; padding-top: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .only-sm { display: inline-flex; }
  .hide-sm, .navs, .hsearch kbd { display: none; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar-grip { display: none; }
  .leaf-more { opacity: 1; } /* no hover on a touch screen */
  .sidebar { position: fixed; top: 48px; left: 0; bottom: 0; width: 290px; z-index: 25; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgb(0 0 0 / .3); }
  .nav-open .sidebar { transform: none; }
  .content { padding: 16px 16px 64px; }
  .page-head { flex-direction: column; gap: 12px; }
  .head-actions { padding-top: 0; }
  .doc { padding: 20px; }
  .hero { padding: 24px; }
  .hero h1 { font-size: 28px; }
  .steps, .fields, .split, .split.previewing { grid-template-columns: minmax(0, 1fr); }
  .source-row { grid-template-columns: minmax(0, 1fr) auto; }
  .source-row input:not([name="source_url"]) { grid-column: 1; }
  .split > div + div { border-left: 0; border-top: 1px solid var(--border); }
  .big-search .btn { display: none; }
  .row .when { display: none; }
}
