/* lore web UI — design from the "Lore Web UI wireframes" canvas.
 * Tokens on :root, redefined for dark mode. No framework. */

:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --sunk: #f6f6f5;
  --ink: #111111;
  --muted: #5c5c5c;
  --line: #e3e3e1;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-ink: #ffffff;
  --hot: #f97316;
  --bar: #111111;
  --bar-ink: #ffffff;
  --bar-muted: #b5b5b5;
  --bar-field: #232323;
  --err: #b42318;
  --err-bg: #fdf0ee;
  --warn-bg: #fff4e8;
  --ok: #1f7a3a;
  --ok-bg: #ecf6ef;
  --mark: #ffe0c7;
  --rule-bg: #fff1e6;
  --rule-ink: #9a3412;
  --rule-line: #fbc9a4;
  --knowledge-bg: #111111;
  --knowledge-ink: #ffffff;
  /* Connections map ([Tags 05]): one distinct, visible colour per node kind. */
  --map-page: #c2410c;
  --map-tag: #7c3aed;
  --map-file: #2563eb;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d;
    --panel: #161616;
    --sunk: #1d1d1d;
    --ink: #f3f3f3;
    --muted: #a8a8a8;
    --line: #2c2c2c;
    --accent: #fb8a3c;
    --accent-hover: #fdba8c;
    --accent-ink: #111111;
    --hot: #fb8a3c;
    --bar: #000000;
    --bar-muted: #9a9a9a;
    --bar-field: #1d1d1d;
    --err: #f28b82;
    --err-bg: #2c1614;
    --warn-bg: #2a1d10;
    --ok: #7fd49a;
    --ok-bg: #132419;
    --mark: #5a2d0c;
    --rule-bg: #3a1f0c;
    --rule-ink: #fdba8c;
    --rule-line: #6b3a17;
    --knowledge-bg: #f3f3f3;
    --knowledge-ink: #111111;
    --map-page: #fb8a3c;
    --map-tag: #c4b5fd;
    --map-file: #93c5fd;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* `hidden` must win over any component's display rule. */
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 10; background: var(--panel); padding: 8px 12px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.display { font-family: var(--font-display); letter-spacing: -0.02em; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.rule-h { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ------------------------------------------------------------ top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 60px;
  padding: 0 32px;
  background: var(--bar);
  color: var(--bar-ink);
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.03em;
  color: var(--bar-ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { color: var(--bar-ink); text-decoration: none; }
.brand i { display: block; width: 10px; height: 10px; border-radius: 2px; background: var(--hot); }
.topbar .search {
  flex: 1;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--bar-field);
  color: var(--bar-muted);
}
.topbar .search:focus-within { box-shadow: 0 0 0 2px var(--hot); }
.topbar .search input {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: #ffffff;
  flex: 1;
  outline: none;
  min-width: 0;
}
.topbar .search input::placeholder { color: #9a9a9a; }
.nav { display: flex; gap: 24px; margin-left: auto; align-items: center; }
.nav a, .nav .linkish { color: var(--bar-muted); font-size: 14px; font-weight: 500; }
.nav a:hover { color: #ffffff; text-decoration: none; }
.nav a.on { color: #ffffff; box-shadow: inset 0 -2px 0 var(--hot); padding-bottom: 4px; }

.account { position: relative; }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--hot);
  color: #111111;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
}
.menu {
  position: absolute;
  right: 0;
  top: 44px;
  min-width: 220px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 8px;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.menu[hidden] { display: none; }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu a, .menu button {
  display: block;
  text-align: left;
  padding: 10px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--sunk); text-decoration: none; }

/* ------------------------------------------------------------ layout */

main { flex-grow: 1; }
.page { padding: 40px 80px; display: flex; flex-direction: column; gap: 28px; max-width: 1440px; }
.page.tight { padding-top: 28px; gap: 20px; }
.crumbs { font-size: 13px; color: var(--muted); }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 40px; font-weight: 700; line-height: 1.1; }
.head .sub { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 6px; }

/* ------------------------------------------------------------ controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--ink); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.outline { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; height: 44px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.danger { background: transparent; color: var(--err); border-color: var(--err); }
.btn.danger:hover { background: var(--err-bg); color: var(--err); border-color: var(--err); }
.btn.danger-fill { background: var(--err); border-color: var(--err); color: var(--bg); }
.btn.danger-fill:hover { color: var(--bg); border-color: var(--err); }

.input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}
.input.lg { height: 44px; font-size: 15px; }
.input.bad { border-color: var(--err); box-shadow: 0 0 0 1px var(--err); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field .hint, .hint { font-size: 13px; font-weight: 400; color: var(--muted); margin: 0; }
.errmsg { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--err); margin: 0; }
.banner { margin: 0; padding: 12px 14px; border-radius: 8px; background: var(--err-bg); color: var(--err); font-size: 14px; font-weight: 500; }
.banner.info { background: var(--sunk); color: var(--ink); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.banner-actions .btn { background: var(--panel); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  background: var(--sunk);
  color: var(--ink);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.knowledge { background: var(--knowledge-bg); color: var(--knowledge-ink); border-color: var(--knowledge-bg); }
.chip.rule { background: var(--rule-bg); color: var(--rule-ink); border-color: var(--rule-line); }
.chip.record { background: var(--sunk); color: var(--muted); }
.chip.progress { background: transparent; color: var(--muted); border-style: dashed; }
/* Tags ([Tags 02]): link chips; `on` marks a tag chosen in the Tags tab. */
.chip.tag { text-decoration: none; background: transparent; color: var(--muted); }
.chip.tag:hover { color: var(--ink); border-color: var(--ink); }
.chip.tag.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.tag.on .muted { color: inherit; opacity: .7; }
.chip.hand { background: #111111; color: #f97316; border-color: #111111; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }

.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); }
.tabs a { color: var(--muted); font-weight: 600; font-size: 14px; padding: 10px 0; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--hot); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg a {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a[aria-current="true"] { background: var(--ink); color: var(--bg); }

/* ------------------------------------------------------------ home */

.handoff-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 22px;
  border-color: #111111;
  background: var(--warn-bg);
}
.handoff-banner .icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #111111;
  color: #f97316;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.repo-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 20px;
}
.repo-card { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.repo-card .name { font-size: 22px; font-weight: 700; color: var(--ink); }
.repo-stats { gap: 24px; font-size: 14px; }

/* ------------------------------------------------------------ repository */

.split { display: flex; gap: 32px; flex-grow: 1; }
.filters { width: 220px; flex-shrink: 0; display: flex; flex-direction: column; gap: 22px; }
.filters fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.filters legend { margin-bottom: 8px; padding: 0; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; min-height: 32px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.listing { flex-grow: 1; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .title { font-weight: 600; color: var(--ink); }

/* ------------------------------------------------------------ page */

.page-split { display: flex; gap: 56px; }
.page-split article { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.page-split aside { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 28px; }
.side { display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.side ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.details { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.details .row { justify-content: space-between; gap: 12px; }
.details .row > :last-child { text-align: right; overflow-wrap: anywhere; }

.prose { overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--font-display); letter-spacing: -0.01em; margin: 28px 0 8px; }
.prose h1 { font-size: 28px; }
.prose h2 { font-size: 22px; }
.prose h3 { font-size: 18px; }
.prose p { margin: 0 0 14px; }
.prose ul { margin: 0 0 14px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose code { font-family: var(--font-mono); font-size: 13px; background: var(--sunk); padding: 1px 5px; border-radius: 4px; }
.prose pre {
  background: #111111;
  color: #f3f3f3;
  border-radius: 10px;
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 14px;
  overflow-x: auto;
}
.prose pre code { background: transparent; padding: 0; color: inherit; }

/* ------------------------------------------------------------ editor */

.page-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.page-actions { gap: 8px; flex-shrink: 0; }
.editor-meta {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 180px minmax(0, 1.4fr) auto;
  gap: 16px;
  align-items: end;
}
.editor-meta .pin { height: 40px; }
.editor-panes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.pane { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; background: var(--panel); }
.pane-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--sunk);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.pane textarea {
  flex-grow: 1;
  min-height: 520px;
  border: 0;
  resize: vertical;
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  background: var(--panel);
  color: var(--ink);
  outline: none;
}
.pane textarea:focus-visible { box-shadow: inset 0 0 0 2px var(--hot); }
.prev { padding: 16px 22px; min-height: 520px; }
.editor-tabs { display: none; align-self: flex-start; }
/* Edit with AI: the page beside the instruction, scrolling on its own. */
.ai-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.ai-page { position: sticky; top: 16px; max-height: calc(100vh - 32px); }
.ai-page .pane-h { text-transform: none; letter-spacing: 0; font-size: 13px; gap: 12px; }
.ai-page-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 22px; }
.ai-page-source { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; }
.seg-sm button { height: 28px; padding: 0 10px; font-size: 12px; }
.seg button {
  height: 36px;
  padding: 0 14px;
  border: 0;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
dialog.confirm {
  width: min(480px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
}
dialog.confirm::backdrop { background: rgba(0, 0, 0, 0.5); }

/* ------------------------------------------------------------ history */

.history-split { display: flex; gap: 28px; align-items: flex-start; }
.version-list { list-style: none; margin: 0; padding: 0; width: 340px; flex-shrink: 0; overflow: hidden; }
.version-list li + li .ver { border-top: 1px solid var(--line); }
.ver { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; padding: 14px 16px; color: var(--ink); }
.ver:hover { text-decoration: none; background: var(--sunk); }
.ver.on { background: var(--sunk); box-shadow: inset 3px 0 0 var(--hot); }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); margin-top: 6px; }
.dot.cur { background: var(--hot); border-color: var(--hot); }
.history-main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.history-bar { justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.meta-changes { margin: 0; padding: 12px 14px 12px 32px; border-radius: 8px; background: var(--sunk); font-size: 14px; }
.diff { padding: 10px 0; font-family: var(--font-mono); font-size: 13px; line-height: 1.75; overflow-x: auto; }
.ln { display: grid; grid-template-columns: 44px 20px minmax(0, 1fr); padding: 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ln .n { color: var(--muted); }
.ln.add { background: var(--ok-bg); color: var(--ok); }
.ln.del { background: var(--err-bg); color: var(--err); text-decoration: line-through; text-decoration-thickness: 1px; }
.ln.fold { color: var(--muted); font-style: italic; }
.diff-raw { margin: 0; padding: 14px 16px; font-family: var(--font-mono); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ team workspaces (S5) */

.new-repo { padding: 20px 22px; margin-bottom: 18px; }
.new-repo .cmd { white-space: pre; margin: 0; }
.ws-strip { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px; }
.ws-card { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; min-width: 160px; color: var(--ink); }
.ws-card:hover { text-decoration: none; border-color: var(--ink); }
.ws-repos { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.marker-snippet { margin: 0; padding: 12px 16px; font-family: var(--font-mono); font-size: 13px; background: var(--sunk); overflow-x: auto; }
.sharing-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* ------------------------------------------------------------ search */

.hits { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.hit { display: flex; flex-direction: column; gap: 6px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.hit .title { font-size: 18px; font-weight: 600; }
.hit p { margin: 0; }
.hit mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 2px; }
.aside-notes { width: 260px; flex-shrink: 0; display: flex; flex-direction: column; gap: 12px; padding-top: 56px; font-size: 14px; }
.aside-notes p { margin: 0; }

/* ------------------------------------------------------------ sessions */

.sess-list { width: 380px; flex-shrink: 0; overflow: hidden; align-self: flex-start; }
.sess { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--ink); }
.sess:last-child { border-bottom: 0; }
.sess:hover { text-decoration: none; background: var(--sunk); }
.sess.on { background: var(--sunk); box-shadow: inset 3px 0 0 var(--hot); }
.cap {
  display: grid;
  grid-template-columns: 64px 130px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.cap:last-child { border-bottom: 0; }
.cap .body { overflow-wrap: anywhere; white-space: pre-wrap; }
.handoff-card { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; background: var(--warn-bg); border-color: #111111; }
.handoff-card ul, .handoff-card ol { margin: 6px 0 0; padding-left: 18px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; font-size: 14px; }

/* ------------------------------------------------------------ states */

.state-card {
  max-width: 640px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.state-card h2 { margin: 0; font-size: 22px; }
.state-card p { margin: 0; }
.state-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.state-icon.err { background: var(--err-bg); color: var(--err); }
.state-icon.neutral { background: var(--sunk); color: var(--ink); }
.state-icon.warn { background: var(--warn-bg); color: var(--accent); }
.state-icon.ok { background: var(--ok-bg); color: var(--ok); }
.tag { align-self: flex-start; font-family: var(--font-mono); font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 4px; background: var(--knowledge-bg); color: var(--knowledge-ink); }
.loading { display: flex; align-items: center; gap: 12px; padding: 40px 80px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--hot); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ------------------------------------------------------------ auth screens */

body.auth .topbar, body.auth .foot { display: none; }
.auth-split { display: flex; min-height: 100vh; }
.auth-hero {
  width: 560px;
  flex-shrink: 0;
  background: #111111;
  color: #ffffff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
}
.auth-hero .logo { font-family: var(--font-display); font-weight: 700; font-size: 26px; display: flex; align-items: center; gap: 10px; color: #ffffff; }
.auth-hero .logo:hover { text-decoration: none; color: #ffffff; }
.auth-hero .logo i { display: block; width: 12px; height: 12px; border-radius: 2px; background: #f97316; }
.auth-hero h1 { margin: 0; font-size: 48px; font-weight: 700; line-height: 1.05; }
.auth-hero h1 em { font-style: normal; color: #f97316; }
.auth-hero p { margin: 0; color: #c9c9c9; font-size: 16px; max-width: 400px; }
.auth-hero .domain { color: #9a9a9a; }
.auth-form { flex-grow: 1; display: flex; align-items: center; justify-content: center; padding: 56px; }
.auth-form form, .auth-form .done { width: 380px; max-width: 100%; display: flex; flex-direction: column; gap: 20px; }
.auth-form h2 { margin: 0; font-size: 30px; font-weight: 700; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex-grow: 1; height: 1px; background: var(--line); }
.meter { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.meter span { height: 4px; border-radius: 2px; background: var(--line); }
.meter span.on { background: var(--hot); }
.meter span.low { background: var(--err); }
.badge { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--ok-bg); color: var(--ok); }

/* ------------------------------------------------------------ docs + foot */

.docs { max-width: 760px; }
.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 80px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

/* ------------------------------------------------------------ page tabs and peek ([Phase 09] 33) */

:root { --peek-w: min(46vw, 760px); }

.pagetabs {
  display: flex;
  gap: 2px;
  padding: 6px 32px 0;
  background: var(--sunk);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.pagetabs[hidden] { display: none; }
.pagetab {
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: 220px;
  padding: 6px 6px 6px 12px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
  flex-shrink: 0;
}
.pagetab a { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pagetab a:hover { color: var(--ink); text-decoration: none; }
.pagetab.on { background: var(--bg); border-color: var(--line); margin-bottom: -1px; }
.pagetab.on a { color: var(--ink); font-weight: 600; }
/* Reordering ([Phase 09] 41): the tab being dragged fades; a line marks
   where it will land. */
.pagetab[draggable="true"] { cursor: grab; }
.pagetab.dragging { opacity: 0.45; }
.pagetab.drop-before { box-shadow: inset 2px 0 0 var(--hot); }
.pagetab.drop-after { box-shadow: inset -2px 0 0 var(--hot); }
.pagetab .x {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.pagetab .x:hover { background: var(--line); color: var(--ink); }

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--sunk); color: var(--ink); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

/* Side peek shares the screen: what you came from stays readable beside it. */
body.peek-side main { margin-right: var(--peek-w); }
/* A full page under a side peek has half the width: one column, like the peek. */
body.peek-side main .page-split { flex-direction: column; gap: 28px; }
body.peek-side main .page-split aside { width: auto; }
body.peek-side main .page-top { flex-direction: column; }
.peek-layer { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.peek-backdrop { display: none; }
.peek-layer.center .peek-backdrop { display: block; position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); pointer-events: auto; }
.peek-panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  pointer-events: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.peek-layer.side .peek-panel { top: 0; right: 0; bottom: 0; width: var(--peek-w); border-left: 1px solid var(--line); }
.peek-layer.center .peek-panel {
  top: 6vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(960px, calc(100vw - 48px));
  height: 88vh;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.peek-head { display: flex; align-items: center; gap: 4px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.peek-where { margin-left: auto; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peek-mode { position: relative; }
.peek-menu { left: 0; right: auto; top: 36px; min-width: 240px; }
.peek-menu button { display: flex; align-items: center; gap: 10px; width: 100%; }
.peek-menu svg { color: var(--muted); flex-shrink: 0; }
.peek-menu .tick { margin-left: auto; color: var(--ink); }
.peek-menu .eyebrow { padding: 6px 10px 2px; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }
.peek-body { flex: 1; overflow-y: auto; padding: 28px 40px 48px; }
.peek-body .page-split { flex-direction: column; gap: 32px; }
.peek-body .page-split aside { width: auto; }
.peek-body h1.display { font-size: 32px !important; }

/* ------------------------------------------------------------ narrow screens */

@media (max-width: 960px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 12px; }
  .topbar .search { order: 3; flex-basis: 100%; max-width: none; }
  .page, .loading { padding: 24px 16px; }
  .foot { padding: 18px 16px; }
  .head h1 { font-size: 32px; }
  .repo-grid { grid-template-columns: 1fr; }
  .split, .page-split { flex-direction: column; }
  .filters, .page-split aside, .sess-list, .aside-notes { width: auto; padding-top: 0; }
  .auth-split { flex-direction: column; }
  .auth-hero { width: auto; padding: 32px 16px; }
  .auth-hero h1 { font-size: 34px; }
  .auth-form { padding: 32px 16px; }
  .two-col { grid-template-columns: 1fr; }
  .cap { grid-template-columns: 56px minmax(0, 1fr); }
  .cap .kind { display: none; }
  .listing .row { flex-wrap: wrap; }
  .listing .row .input { width: 100% !important; flex: 1 1 100%; }
  .tbl th:nth-child(2), .tbl td:nth-child(2) { display: none; }
  .tbl th:nth-child(3), .tbl td:nth-child(3) { width: 110px !important; }
  .tbl th, .tbl td { padding: 10px 12px; }
  .tbl .mono, .hit .mono { overflow-wrap: anywhere; }
  .tabs { gap: 20px; overflow-x: auto; }
  .head > div { width: 100%; }
  .head .input { width: 100% !important; }
  .handoff-banner { flex-wrap: wrap; }
  .handoff-banner .stack { flex-basis: calc(100% - 60px); }
  .handoff-banner .btn { width: 100%; }
  .page-top { flex-direction: column; }
  .page-actions { width: 100%; }
  /* No room to share: both peeks become a full-screen sheet. */
  body.peek-side main { margin-right: 0; }
  .peek-layer.side .peek-panel, .peek-layer.center .peek-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    transform: none;
    border: 0;
    border-radius: 0;
  }
  .peek-body { padding: 20px 16px 40px; }
  .pagetabs { padding: 6px 16px 0; }
  .page-actions .btn { flex: 1; }
  .editor-meta { grid-template-columns: 1fr; }
  .history-split { flex-direction: column; align-items: stretch; }
  .version-list { width: auto; max-height: 280px; overflow-y: auto; }
  .editor-meta .pin { height: auto; }
  .editor-tabs { display: inline-flex; }
  .ai-split { grid-template-columns: 1fr; }
  .ai-page { position: static; max-height: 45vh; }
  .editor-panes { grid-template-columns: 1fr; }
  .editor-panes[data-show="write"] .preview-pane,
  .editor-panes[data-show="preview"] .write-pane { display: none; }
  .pane textarea, .prev { min-height: 360px; }
}

/* ---------------------------------------------------------------- account (sign-up, welcome, keys) */
.turnstile { min-height: 65px; }
.welcome { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 48px; align-items: start; }
.steps { display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step .num { width: 32px; height: 32px; border-radius: 50%; background: #111111; color: #f97316; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.cmd { margin: 8px 0 0; padding: 10px 12px; border-radius: 8px; background: #111111; color: #f3f3f3; overflow-x: auto; white-space: pre; }
.token-box { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--ok); border-radius: 12px; background: var(--ok-bg); }
.token-box .cmd { margin: 0; user-select: all; }
.key-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.key-form .field { flex: 1; min-width: 200px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .step .num { background: #f3f3f3; color: #c2410c; }
}
@media (max-width: 760px) {
  .welcome { grid-template-columns: minmax(0, 1fr); gap: 28px; }
}

/* ---------------------------------------------------------------- members */
.input.sm { height: 32px; padding: 0 8px; font-size: 13px; }
.role-help { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; font-size: 13px; }
@media (max-width: 520px) {
  /* On a phone the uses column goes too, so Revoke stays on screen. */
  .tbl.invites-tbl th:nth-child(3), .tbl.invites-tbl td:nth-child(3) { display: none; }
}
.invite-new { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.invite-new .input { flex: 1; min-width: 0; font-size: 13px; }
.suggest-wrap { position: relative; }
.suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 220px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  z-index: 20;
  font-weight: 400;
}
.suggest li { padding: 7px 10px; border-radius: 6px; font-size: 14px; }
.suggest li[role="option"] { cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.suggest li[role="option"]:hover, .suggest li.on { background: var(--sunk); box-shadow: inset 3px 0 0 var(--hot); }
.suggest .who { display: flex; justify-content: space-between; gap: 10px; }
.suggest .sub { font-size: 12px; color: var(--muted); }
.suggest li.empty { color: var(--muted); font-size: 13px; }
@media (max-width: 960px) {
  /* The narrow-screen table rule hides column 2; here that is the level an
     admin changes, so the grant date goes instead. */
  .tbl.members-tbl th:nth-child(2), .tbl.members-tbl td:nth-child(2) { display: table-cell; }
  .tbl.members-tbl th:nth-child(3), .tbl.members-tbl td:nth-child(3) { display: none; }
  /* Likewise for invites: keep who a link is for, drop when it expires. */
  .tbl.invites-tbl th:nth-child(2), .tbl.invites-tbl td:nth-child(2) { display: table-cell; }
  .tbl.invites-tbl th:nth-child(4), .tbl.invites-tbl td:nth-child(4) { display: none; }
  .role-help { grid-template-columns: 1fr; gap: 8px; }
}

/* Delete account (lore S6): set apart from the rest of the account page. */
.danger-zone { border-top: 1px solid var(--line); padding-top: 24px; margin-top: 8px; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 14px; }

/* ------------------------------------------------------------ AI editing (Phase D) */

.banner.warn { background: var(--sunk); color: var(--ink); box-shadow: inset 3px 0 0 var(--hot); }
.ai-instruction { min-height: 96px; resize: vertical; font: inherit; }
.ai-result p { overflow-wrap: anywhere; }
.ai-edits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 22px; }
.ai-edit { display: flex; flex-direction: column; gap: 10px; }
.ai-edit-head { align-items: flex-start; gap: 10px; }
.ai-edit-head input { margin-top: 4px; }
.card.ai-result { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.leave-section { border-top: 1px solid var(--line); padding-top: 20px; }

/* ------------------------------------------------------------ activity (task 25) */

.act-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.act-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; overflow-wrap: anywhere; }
@media (max-width: 640px) { .act-row { grid-template-columns: 1fr; gap: 2px; } }

/* Root admin panel (lore). */
.admin-grid { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 28px; align-items: start; }
.admin-nav { display: grid; gap: 2px; position: sticky; top: 16px; }
.admin-nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.admin-nav a.on, .admin-nav a:hover { background: var(--sunk); color: var(--ink); }
.admin-body { display: grid; gap: 28px; min-width: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; display: grid; gap: 4px; }
.stat-value { font-size: 26px; font-weight: 700; }
@media (max-width: 760px) {
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-nav { position: static; display: flex; flex-wrap: wrap; }
}
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bars .bar { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 3px; }
.bars .bar span { display: block; width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; }

/* ------------------------------------------------------------ connect a computer (task 29) */

.connect-card { padding: 28px; max-width: 620px; margin: 24px auto; }
.connect-code { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; padding: 14px 16px; border-radius: 8px; background: var(--sunk); }
.code-big { font-size: 28px; font-weight: 700; letter-spacing: 0.08em; }

/* ------------------------------------------------------------ admin: server logs (Admin 11) */

.logs-view { margin: 0; padding: 12px 14px; max-height: 60vh; overflow: auto; font-family: var(--font-mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Connections map ([Tags 05]). */
.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; align-items: start; }
.map-wrap canvas { width: 100%; height: min(70vh, 640px); border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: grab; touch-action: none; }
.map-side { padding: 14px; max-height: min(70vh, 640px); overflow: auto; font-size: 14px; }
.map-list { margin: 0; padding-left: 18px; }
.map-list li { margin: 2px 0; overflow-wrap: anywhere; }
.map-pages { list-style: none; padding-left: 0; }
.map-pages li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.map-key { display: inline-block; flex: none; width: 10px; height: 10px; padding: 0; border-radius: 50%; vertical-align: middle; margin: 0 4px 0 10px; }
.map-key-page { background: var(--map-page); }
.map-key-tag { background: var(--map-tag); }
.map-key-file { background: var(--map-file); }
@media (max-width: 860px) { .map-wrap { grid-template-columns: 1fr; } }

/* [Shared memory] 2: pages shared into a repository. */
.shared-here { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
button.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
button.linkish:hover { text-decoration: underline; }

/* [Phase 09] 43: the repository filter heads the list and stays in view
   while it scrolls. */
.repo-list-head {
  position: sticky;
  top: 0;
  z-index: 2;
  gap: 16px;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 10px 0;
  background: var(--bg);
}
.repo-list-head .input { flex: 1; max-width: 420px; min-width: 200px; }
