/* MosAIc — base aesthetic. Calm, lean, hairline-driven. Theme via the vars below. */

/* Palette "smalti & stone" — drawn from the mosaic's own materials: a warm stone ground,
   deep verdigris glass (the accent), and one touch of gold leaf (--gilt, spent on the
   logo's single gilded tessera). Display face: Marcellus — Roman inscriptional letterforms,
   the lettering carved beside the floors these surfaces are named for. */
:root {
  --bg:        #f2f1ec;   /* stone ground */
  --panel:     #fbfaf8;
  --ink:       #23262b;
  --ink-soft:  #565b60;
  --ink-faint: #8d9196;
  --line:      #e2e0d8;
  --line-soft: #eceae3;
  --accent:    #136a5e;   /* verdigris — oxidized-copper glass */
  --accent-soft:#e3efeb;
  --gilt:      #a57e2f;   /* gold leaf — one tessera only */
  --warn:      #9a5b16;
  --warn-soft: #f6ebda;
  --ok:        #2f7d4f;
  --ok-soft:   #e6f2e9;
  --code-bg:   #20262a;   /* code-slab bg; darkened in dark theme to stay distinct from --panel */
  color-scheme: light;
  --sidebar-w: 280px;
  --max-read:  760px;
  --max-wide:  1120px;
  --radius:    10px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --display: "Bricolage Grotesque", var(--sans);
}

  /* Dark theme — the night wall: same materials, lamplit. Toggled by data-theme on <html>. */
  :root[data-theme="dark"] {
    --bg: #16191b;  --panel: #1e2226;
    --ink: #e8e7e2; --ink-soft: #afb2ae; --ink-faint: #7c807d;
    --line: #2e3336; --line-soft: #262b2e;
    --accent: #4fb3a4; --accent-soft: #1c2e2b;
    --gilt: #c7a257;
    --warn: #dca453; --warn-soft: #2e2517;
    --ok: #6fbe8d;   --ok-soft: #1a2b20;
    --code-bg: #101416;   /* darker than --panel so code slabs stay distinct */
    color-scheme: dark;
  }
  /* the command bar bg is hardcoded light (for its blur) — it needs a dark value too */
  :root[data-theme="dark"] .cmdbar { background: rgba(22, 25, 27, .82); }
  html { transition: background-color .2s ease, color .2s ease; } 

  /* far right of the command bar (the flex-grow prompt pushes it there) */
  .theme-toggle {
    flex: 0 0 auto;
    font: inherit; font-size: 12.5px; color: var(--ink-faint);
    background: none; border: 1px solid var(--line); border-radius: 999px;
    padding: 5px 12px; cursor: pointer;
  }
  .theme-toggle:hover { color: var(--ink); border-color: var(--ink-faint); }

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 22px 18px; overflow-y: auto;
  position: relative; transition: margin-left .18s ease;
}
.brand { margin-bottom: 26px; }
.brand-title { font-family: var(--display); font-weight: 700; font-size: 23px; letter-spacing: -0.015em; }
.brand-sub  { color: var(--ink-faint); font-size: 12.5px; margin-top: 3px; }

.nav-group-label {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); margin: 18px 0 8px;
}
.nav-item {
  display: flex; align-items: baseline; gap: 8px; width: 100%;
  padding: 7px 9px; border-radius: 8px; cursor: pointer;
  color: var(--ink-soft); font-size: 14px; text-align: left;
  border: 0; background: none; font-family: inherit;
  animation: navIn .26s ease both; animation-delay: calc(var(--i, 0) * 22ms);
}
.nav-item:hover  { background: var(--line-soft); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
@keyframes navIn { from { opacity: 0; transform: translateX(-5px); } to { opacity: 1; transform: none; } }

/* ── Main + command bar ──────────────────────────────────── */
#main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

.cmdbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap;
  padding: 11px 24px;
  background: rgba(242, 241, 236, .82);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
/* sidebar-collapse toggle — lives here so it's reachable when the sidebar is hidden */
.cmd-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink-soft); cursor: pointer;
}
.cmd-icon:hover { color: var(--ink); border-color: var(--ink-faint); }
/* the chevron rolls 180° in sync with the sidebar slide (same .18s) */
.sb-chev { display: inline-block; font-size: 19px; line-height: 1; transition: transform .18s ease; }
#app.sb-collapsed .sb-chev { transform: rotate(180deg); }
.cmd-mark { display: block; flex: 0 0 auto; transform-origin: 50% 50%; }
.cmd-mark rect { fill: var(--accent); }
.cmd-mark rect:nth-child(2), .cmd-mark rect:nth-child(3) { opacity: .42; }
.cmd-mark rect:nth-child(4) { fill: var(--gilt); }   /* the one gilded tessera */

/* the prompt — the main driver. Type a task; signed in, a model emits an overlay. */
.cmd-prompt-wrap { position: relative; flex: 1 1 240px; min-width: 150px; display: flex; align-items: center; }
.cmd-prompt {
  width: 100%; font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 32px 7px 14px; outline: none; transition: border-color .15s;
}
.cmd-prompt::placeholder { color: var(--ink-faint); }
.cmd-prompt:focus { border-color: var(--accent); }
.cmd-form.thinking .cmd-prompt { opacity: .55; }
.cmd-spinner {
  position: absolute; right: 12px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* example suggestions — instant, no sign-in (shown when the prompt is empty + focused) */
.cmd-suggest {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: max(300px, 100%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .14); padding: 6px;
}
.cmd-suggest[hidden] { display: none; }
.suggest-head {
  font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-faint); padding: 6px 10px 5px;
}
.suggest-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%;
  text-align: left; padding: 7px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; font: inherit;
}
.suggest-item:hover { background: var(--accent-soft); }
.suggest-label { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.suggest-hint { font-size: 12px; color: var(--ink-faint); }

/* account / sign-in */
.cmd-account {
  font: inherit; font-size: 12.5px; padding: 6px 12px; flex: 0 0 auto; cursor: pointer;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink-soft);
}
.cmd-account:hover { border-color: var(--ink-faint); color: var(--ink); }
.cmd-account.in { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.cmd-reset {
  font-family: inherit; font-size: 12.5px; padding: 6px 11px; margin-left: 2px;
  border: 1px dashed var(--line); background: none; color: var(--ink-faint);
  border-radius: 999px; cursor: pointer;
}
.cmd-reset:hover { color: var(--ink-soft); border-color: var(--ink-faint); }
.cmd-btn {
  font-family: inherit; font-size: 13px; padding: 6px 13px; flex: 0 0 auto;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-soft);
  border-radius: 999px; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.cmd-btn:hover { border-color: var(--accent); color: var(--accent); }

#view { width: 100%; max-width: var(--max-wide); margin: 0 auto; padding: 36px 48px 96px; }
.view-inner.layout-stack { max-width: var(--max-read); margin: 0 auto; }

#app.sb-collapsed #sidebar { margin-left: calc(-1 * var(--sidebar-w)); }

/* ── View heading ────────────────────────────────────────── */
.view-head { margin-bottom: 24px; }
.doc-title { font-family: var(--display); font-weight: 600; font-size: 31px; letter-spacing: -0.02em; margin: 0 0 6px; }
.doc-sub   { color: var(--ink-faint); margin: 0; }

/* ── Tessera grid + layouts ──────────────────────────────── */
.tessera-grid { display: grid; gap: 18px; }
.layout-stack .tessera-grid { display: flex; flex-direction: column; }
.layout-grid  .tessera-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.layout-split .tessera-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.layout-grid  .tessera, .layout-split .tessera { grid-column: span var(--span, 1); }

/* ── Tessera (the tile) ──────────────────────────────────── */
.tessera {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  position: relative;   /* anchors the corner resize handle */
  animation: tIn .34s cubic-bezier(.2, .7, .3, 1) both;
  animation-delay: calc(var(--i, 0) * 36ms);
}
@keyframes tIn { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
.tessera-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line-soft);
}
.tessera-title { font-family: var(--sans); font-weight: 500; font-size: 13.5px; letter-spacing: 0; }
.tessera-tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-faint); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
}
.tessera-body { padding: 16px 18px; }
.tessera-body > .md > :first-child,
.note > :first-child { margin-top: 0; }
.tessera-body > .md > :last-child,
.note > :last-child { margin-bottom: 0; }

/* ── Markdown / doc surface ──────────────────────────────── */
#view h1, #view h2, #view h3, .md-h {
  font-family: var(--display); font-weight: 600; letter-spacing: -0.01em;
  line-height: 1.3; margin: 26px 0 10px;
}
.md-h1 { font-size: 22px; } .md-h2 { font-size: 20px; } .md-h3 { font-size: 16px; } .md-h4 { font-size: 14px; color: var(--ink-soft); }
#view p { margin: 0 0 13px; }
#view a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
#view a:hover { border-color: var(--accent); }
#view ul, #view ol { margin: 0 0 13px; padding-left: 22px; }
#view li { margin: 4px 0; }

code { font-family: var(--mono); font-size: 0.88em; background: var(--line-soft); padding: 1px 5px; border-radius: 5px; }
pre  { background: var(--code-bg); color: #f2f2f2; padding: 16px 18px; border-radius: var(--radius); overflow-x: auto; line-height: 1.5; margin: 0 0 14px; }
pre code { background: none; color: inherit; padding: 0; font-size: 13px; }
.code-block pre { margin: 0 0 14px; }

.md-quote { border-left: 3px solid var(--accent); margin: 0 0 14px; padding: 2px 0 2px 16px; color: var(--ink-soft); }
.md-hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

/* OKF concept provenance — a description subtitle + the trust strip. */
.tessera-sub { margin: -4px 0 12px; color: var(--ink-soft); font-size: 13.5px; line-height: 1.45; }
.okf-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line-soft);
  font-size: 12px; color: var(--ink-faint); }
.okf-dot { opacity: .5; }
.okf-badge { font-weight: 600; }
.okf-sourced { color: var(--ok); }
.okf-unsourced { color: var(--warn); }
.okf-link { color: var(--accent); text-decoration: none; }
.okf-link:hover { text-decoration: underline; }
.okf-when { color: var(--ink-faint); }
.okf-tags { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.okf-tag { background: var(--line-soft); border: 1px solid var(--line); border-radius: 999px;
  padding: 1px 9px; font-size: 11px; color: var(--ink-soft); }
.okf-search { width: 160px; padding: 6px 11px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--ink); font: inherit; font-size: 13px; }
.okf-search::placeholder { color: var(--ink-faint); }
.okf-search:focus { outline: none; border-color: var(--accent); }

.md-table { border-collapse: collapse; width: 100%; margin: 0; font-size: 14px; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 8px 11px; text-align: left; vertical-align: top; }
.md-table th { background: var(--line-soft); font-weight: 600; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px; margin: 0 0 18px;
}

/* ── Tile: code ──────────────────────────────────────────── */
.t-code .tessera-body { padding: 0; }
.code { position: relative; }
.code-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px 7px 16px; background: #161616; border-bottom: 1px solid #000;
}
.code-name { font-family: var(--mono); font-size: 12px; color: #e6e6e6; flex: 1; }
.code-lang { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #9a9a9a; }
.code pre { border-radius: 0; margin: 0; }
.t-code .tessera-head + .tessera-body .code pre { border-radius: 0; }
.t-copy {
  font-family: var(--mono); font-size: 11px; color: #cfcfcf;
  background: #2a2a2a; border: 1px solid #3a3a3a; border-radius: 6px;
  padding: 2px 9px; cursor: pointer;
}
.t-copy:hover { color: #fff; border-color: #555; }
.t-copy.did { color: var(--accent); }
.t-copy-float { position: absolute; top: 10px; right: 10px; z-index: 2; }

/* ── Tile: diagram (mermaid) ─────────────────────────────── */
.t-diagram { display: flex; flex-direction: column; }   /* let the body fill the tile height */
.t-diagram .tessera-body { flex: 1; display: flex; align-items: center; justify-content: center; }
.mermaid {
  width: 100%; margin: 0; text-align: center;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5; color: var(--ink-soft);
  white-space: pre; overflow-x: auto;
}
/* fill the tile — override Mermaid's intrinsic-width cap so the diagram isn't tiny */
.mermaid svg { width: 100% !important; max-width: 100% !important; height: auto; }
.mermaid-fallback {
  text-align: left; background: var(--line-soft);
  padding: 12px 14px; border-radius: 8px; width: 100%;
}

/* ── Tile: note (callout) ────────────────────────────────── */
.note { border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px; padding: 12px 15px; }
.note-info   { background: var(--line-soft);   border-left-color: var(--ink-faint); }
.note-accent { background: var(--accent-soft);  border-left-color: var(--accent); }
.note-warn   { background: var(--warn-soft);    border-left-color: var(--warn); }
.note-ok     { background: var(--ok-soft);      border-left-color: var(--ok); }

/* ── Tile: tasks (checklist) ─────────────────────────────── */
.tasks { list-style: none; margin: 0; padding: 0; }
.task-item { display: flex; gap: 10px; align-items: flex-start; padding: 6px 2px; cursor: pointer; border-radius: 6px; }
.task-item:hover { background: var(--line-soft); }
.task-box {
  width: 16px; height: 16px; flex: 0 0 auto; margin-top: 2px;
  border: 1.5px solid var(--line); border-radius: 5px; position: relative; transition: all .15s;
}
.task-item:hover .task-box { border-color: var(--accent); }
.task-item.done .task-box { background: var(--accent); border-color: var(--accent); }
.task-item.done .task-box::after {
  content: ""; position: absolute; left: 4.5px; top: 1.5px;
  width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.task-text { font-size: 14px; }
.task-item.done .task-text { color: var(--ink-faint); text-decoration: line-through; }

/* ── Composer drawer (a command-bar driver, not a tessera) ─── */
.composer-drawer { position: fixed; inset: 0; z-index: 50; visibility: hidden; }
.composer-drawer.open { visibility: visible; }
.composer-scrim {
  position: absolute; inset: 0; background: rgba(0, 0, 0, .34);
  opacity: 0; transition: opacity .2s ease;
}
.composer-drawer.open .composer-scrim { opacity: 1; }
.composer-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: min(540px, 94vw);
  display: flex; flex-direction: column; gap: 12px; padding: 20px 22px 22px;
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -18px 0 50px rgba(0, 0, 0, .16);
  transform: translateX(100%); transition: transform .24s cubic-bezier(.2, .7, .3, 1);
}
.composer-drawer.open .composer-panel { transform: none; }
.composer-panel-head { display: flex; align-items: center; justify-content: space-between; }
.composer-panel-title { font-family: var(--sans); font-weight: 500; font-size: 15px; }
.composer-panel-hint { color: var(--ink-faint); font-size: 12.5px; margin: 0; }
.composer-close {
  width: 28px; height: 28px; flex: 0 0 auto; line-height: 1; font-size: 14px;
  border: 1px solid var(--line); border-radius: 7px; background: none; color: var(--ink-faint); cursor: pointer;
}
.composer-close:hover { color: var(--ink); border-color: var(--ink-faint); }

/* the editor itself — shared styling, used inside the drawer */
.composer-input {
  width: 100%; min-height: 210px; resize: vertical;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 13px;
}
.composer-input:focus { outline: none; border-color: var(--accent); background: var(--panel); }
.composer-row { display: flex; align-items: center; gap: 10px; margin-top: 11px; }
.composer-apply {
  font: inherit; font-size: 13px; font-weight: 500; padding: 7px 15px;
  background: var(--accent); color: #fff; border: 0; border-radius: 8px; cursor: pointer;
}
.composer-apply:hover { filter: brightness(1.08); }
.composer-reset {
  font: inherit; font-size: 13px; padding: 7px 13px;
  background: none; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.composer-reset:hover { border-color: var(--ink-faint); }
.composer-msg { font-size: 12.5px; }
.composer-msg.ok  { color: var(--ok); }
.composer-msg.err { color: #c0392b; font-family: var(--mono); font-size: 12px; }
.composer-panel .composer-input { flex: 1; min-height: 0; }   /* fill the drawer height */

/* ── ◆ Set — snapshots drawer ────────────────────────────── */
.snap-drawer .composer-panel { display: flex; flex-direction: column; }
.snap-saverow { display: flex; gap: 8px; margin: 4px 0 2px; }
.snap-input {
  flex: 1; font: inherit; font-size: 13px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px;
}
.snap-input:focus { outline: none; border-color: var(--accent); background: var(--panel); }
.snap-save {
  font: inherit; font-size: 13px; font-weight: 500; padding: 7px 15px; white-space: nowrap;
  background: var(--accent); color: #fff; border: 0; border-radius: 8px; cursor: pointer;
}
.snap-save:hover { filter: brightness(1.08); }
.snap-listwrap { flex: 1; overflow-y: auto; margin: 6px 0; min-height: 60px; }
.snap-empty { color: var(--ink-faint); font-size: 13px; margin: 12px 2px; }
.snap-list { list-style: none; margin: 0; padding: 0; }
.snap-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px;
  border-bottom: 1px solid var(--line-soft);
}
.snap-name { font-weight: 500; font-size: 13.5px; flex: 0 1 auto; }
.snap-when { color: var(--ink-faint); font-size: 11.5px; margin-left: auto; }
.snap-acts { display: flex; gap: 6px; }
.snap-restore {
  font: inherit; font-size: 12px; padding: 4px 11px; cursor: pointer;
  background: none; color: var(--accent); border: 1px solid var(--accent-soft); border-radius: 999px;
}
.snap-restore:hover { border-color: var(--accent); background: var(--accent-soft); }
.snap-del {
  font: inherit; font-size: 12px; width: 24px; height: 24px; cursor: pointer;
  background: none; color: var(--ink-faint); border: 1px solid var(--line); border-radius: 999px;
}
.snap-del:hover { color: #c0392b; border-color: #c0392b; }
.snap-io { border-top: 1px solid var(--line-soft); padding-top: 12px; }
.snap-export, .snap-import {
  font: inherit; font-size: 12.5px; padding: 6px 12px; cursor: pointer;
  background: none; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 8px;
}
.snap-export:hover, .snap-import:hover { border-color: var(--ink-faint); color: var(--ink); }

/* ── Reshape signals ─────────────────────────────────────── */
#app.reshaping .cmd-mark { animation: markSpin .6s cubic-bezier(.3, .8, .3, 1); }
@keyframes markSpin { from { transform: rotate(0); } to { transform: rotate(90deg); } }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 14px);
  background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 500;
  padding: 9px 17px; border-radius: 999px; z-index: 60; opacity: 0;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .2); transition: opacity .3s ease, transform .3s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 860px) {
  .layout-grid .tessera-grid, .layout-split .tessera-grid { grid-template-columns: 1fr; }
  .layout-grid .tessera, .layout-split .tessera { grid-column: auto; }
}
@media (max-width: 720px) {
  #view { padding: 26px 20px 80px; }
  .cmdbar { padding: 10px 16px; }
  .cmd-prompt-wrap { flex-basis: 100%; order: 1; }   /* prompt takes its own row */
  :root { --sidebar-w: 230px; }
}

@media (prefers-reduced-motion: reduce) {
  .tessera, .nav-item, .cmd-mark, #app.reshaping .cmd-mark { animation: none !important; }
  .composer-scrim, .composer-panel { transition: none !important; }
  .toast { transition: opacity .2s ease; }
}

/* ── tile resize — drag the corner to change span; click toggles 1↔2 ── */
.tessera-resize { position:absolute; right:3px; bottom:3px; width:14px; height:14px; cursor:nwse-resize; opacity:0; border-right:2px solid var(--ink-faint); border-bottom:2px solid var(--ink-faint); border-radius:0 0 5px 0; transition:opacity .15s; touch-action:none; }
.tessera:hover .tessera-resize { opacity:.55; }
.tessera.resizing { outline:1.5px dashed var(--accent); outline-offset:2px; }
.layout-stack .tessera-resize { display:none; }   /* span is a no-op in one column */

/* ── tile drag-reorder — while dragging, every tile shows a faint SLOT outline ("where
   things could go"); the hovered target gets an accent INSERTION EDGE telling the truth
   about the landing side (left/above = before it, right/below = after it). ── */
.tessera.dragging { opacity:.45; }
.tessera-grid.drag-active .tessera:not(.dragging) { outline:1.5px dashed var(--line); outline-offset:3px; }
.tessera.drop-target { outline:1.5px dashed var(--accent) !important; outline-offset:3px; position:relative; }
.tessera.drop-target::after { content:''; position:absolute; background:var(--accent); border-radius:2px; z-index:3; }
/* the edge sits INSIDE the tile (tiles clip overflow) — grid/split flow left→right: vertical edge */
.layout-grid .tessera.drop-target.drop-before::after,
.layout-split .tessera.drop-target.drop-before::after { left:0; top:0; bottom:0; width:4px; }
.layout-grid .tessera.drop-target.drop-after::after,
.layout-split .tessera.drop-target.drop-after::after { right:0; top:0; bottom:0; width:4px; }
/* stack flows top→bottom: horizontal edge */
.layout-stack .tessera.drop-target.drop-before::after { top:0; left:0; right:0; height:4px; }
.layout-stack .tessera.drop-target.drop-after::after { bottom:0; left:0; right:0; height:4px; }

/* ── sticky TOC — pinned tile-title strip on panels with ≥4 tiles ── */
.view-toc { position:sticky; top:0; z-index:5; display:flex; flex-wrap:wrap; gap:6px; padding:10px 0; margin-bottom:10px; background:var(--bg); border-bottom:1px solid var(--line); }
.toc-item { border:1px solid var(--line); background:var(--panel); color:var(--ink-soft); font-size:12px; border-radius:999px; padding:3px 11px; cursor:pointer; max-width:180px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-family:inherit; }
.toc-item:hover { color:var(--accent); border-color:var(--accent); }

/* ── subject rail — the active view's related views/concepts, ranked, strongest on top ── */
#subject-rail { margin-top:14px; padding-top:10px; border-top:1px solid var(--line); }
.srail-head { display:flex; align-items:center; gap:8px; font-size:11px; letter-spacing:.08em; text-transform:uppercase; color:var(--ink-faint); padding:0 9px 6px; }
.srail-label { flex:1; }
.srail-scorer { font-family:var(--mono); font-size:10px; text-transform:none; }
.srail-rerank { border:1px solid var(--line); background:transparent; color:var(--ink-soft); font-size:10px; border-radius:6px; padding:2px 7px; cursor:pointer; text-transform:none; font-family:inherit; }
.srail-rerank:hover { color:var(--accent); border-color:var(--accent); }
.srail-row { display:flex; flex-direction:column; gap:3px; width:100%; text-align:left; background:transparent; border:0; border-left:2px solid transparent; padding:6px 9px; cursor:pointer; color:var(--ink-soft); font:inherit; border-radius:0 8px 8px 0; }
.srail-row:hover { color:var(--ink); border-left-color:var(--accent); background:var(--line-soft); }
.srail-title { font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.srail-meta { display:flex; align-items:center; gap:8px; }
.srail-kind { font-size:9.5px; letter-spacing:.06em; text-transform:uppercase; color:var(--ink-faint); flex:0 0 auto; }
/* strength as laid tesserae — small squares fill by score, not a continuous bar */
.srail-bar { flex:1; height:5px; background:transparent; overflow:hidden; }
.srail-bar > i { display:block; height:100%; opacity:.85;
  background:repeating-linear-gradient(90deg, var(--accent) 0 5px, transparent 5px 8px); }
.srail-more { display:block; width:100%; text-align:left; background:transparent; border:0; color:var(--ink-faint); font-size:11.5px; padding:6px 9px; cursor:pointer; font-family:inherit; }
.srail-more:hover { color:var(--accent); }

/* ── tile collapse — fold to the title bar; persists via reshape deltas ── */
.t-fold { border:0; background:transparent; color:var(--ink-faint); font-size:11px; line-height:1; padding:2px 4px; cursor:pointer; border-radius:4px; flex:0 0 auto; }
.t-fold:hover { color:var(--accent); background:var(--line-soft); }
.tessera.collapsed .tessera-body, .tessera.collapsed .okf-meta, .tessera.collapsed .tessera-sub, .tessera.collapsed .tessera-resize { display:none; }
.tessera.collapsed .tessera-head { border-bottom:0; }

/* ── OKF concept views — grid (so resize works) but with a reading measure ── */
.view-inner.layout-grid.view-okf { max-width: 980px; margin: 0 auto; }

/* ── layout chip — the model proposes a layout; the human owns it (cycles, persists) ── */
.view-head { position: relative; }
.layout-toggle { position:absolute; right:0; top:4px; font-family:var(--mono); font-size:11px;
  border:1px solid var(--line); background:var(--panel); color:var(--ink-soft);
  border-radius:999px; padding:3px 10px; cursor:pointer; }
.layout-toggle:hover { color:var(--accent); border-color:var(--accent); }
/* ＋ blank chip — sits just left of the layout chip; inserts a spacer tile */
.blank-add { position:absolute; right:96px; top:4px; font-family:var(--mono); font-size:11px;
  border:1px dashed var(--line); background:var(--panel); color:var(--ink-faint);
  border-radius:999px; padding:3px 10px; cursor:pointer; }
.blank-add:hover { color:var(--accent); border-color:var(--accent); }

/* ── spacer tile — a deliberate empty cell (a gap you place, drag, resize, remove) ── */
.tessera.t-spacer { background:transparent; border:1.5px dashed var(--line);
  min-height:96px; display:flex; align-items:center; justify-content:center; }
.tessera.t-spacer .spacer-mark { font-family:var(--mono); font-size:11px; letter-spacing:.06em;
  text-transform:uppercase; color:var(--ink-faint); opacity:.5; }
.tessera.t-spacer .t-del { position:absolute; top:6px; right:8px; width:20px; height:20px;
  border:none; background:none; color:var(--ink-faint); font-size:15px; line-height:1;
  cursor:pointer; opacity:0; transition:opacity .15s; }
.tessera.t-spacer:hover { border-color:var(--ink-faint); }
.tessera.t-spacer:hover .t-del { opacity:.7; }
.tessera.t-spacer .t-del:hover { color:var(--accent); opacity:1; }
