/* Eregion Brain dashboard. No external resources; light and dark via prefers-color-scheme. */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e8ebf0;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #101828;
  --text-2: #475467;
  --text-3: #667085;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #e5f4f1;
  --accent-text: #ffffff;
  --danger: #b42318;
  --danger-hover: #912018;
  --danger-soft: #fdeceb;
  --warn: #b54708;
  --warn-soft: #fef3e6;
  --ok: #067647;
  --ok-soft: #e6f6ed;
  --focus: #2563eb;
  --star: #d97706;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, 0.28);
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  --kind-bg-l: 94%;
  --kind-fg-l: 30%;
  --kind-border-l: 84%;
  --kind-bg-s: 80%;
  --kind-fg-s: 65%;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b0f14;
    --surface: #121821;
    --surface-2: #17202b;
    --surface-3: #1e2935;
    --border: #232e3b;
    --border-strong: #334255;
    --text: #e7edf3;
    --text-2: #b4c0cd;
    --text-3: #8b99a8;
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-soft: rgba(45, 212, 191, 0.12);
    --accent-text: #032621;
    --danger: #f97066;
    --danger-hover: #fda29b;
    --danger-soft: rgba(249, 112, 102, 0.13);
    --warn: #fdb022;
    --warn-soft: rgba(253, 176, 34, 0.12);
    --ok: #47cd89;
    --ok-soft: rgba(71, 205, 137, 0.12);
    --focus: #60a5fa;
    --star: #fbbf24;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
    --kind-bg-l: 17%;
    --kind-fg-l: 78%;
    --kind-border-l: 27%;
    --kind-bg-s: 40%;
    --kind-fg-s: 85%;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 { margin: 0; line-height: 1.3; font-weight: 650; }
h1 { font-size: 22px; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.noscript { padding: 24px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }

/* ------------------------------------------------------------ icons and buttons */

.icon { flex: none; vertical-align: -3px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 30px; padding: 5px 10px; font-size: 13px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ------------------------------------------------------------ forms */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label, fieldset.field > legend { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
fieldset.field { margin: 0; padding: 0; border: 0; }
.hint { font-size: 12px; color: var(--text-3); }

input, select, textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-3); }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent); }
input[type="file"] { padding: 6px; }

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-message { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.form-message.error { background: var(--danger-soft); color: var(--danger); }
.form-message.warn { background: var(--warn-soft); color: var(--warn); }
.form-message.ok { background: var(--ok-soft); color: var(--ok); }

/* ------------------------------------------------------------ sign-in */

.signin { display: grid; min-height: 100vh; place-items: center; padding: 24px 16px; }
.signin-card { width: min(440px, 100%); padding: 32px; }
.signin-card h1 { margin-top: 20px; font-size: 24px; }
.signin-card .lead { margin: 8px 0 22px; color: var(--text-2); }
.signin-card .form { gap: 16px; }
.input-with-button { display: flex; gap: 6px; }
.input-with-button input { flex: 1; font-family: var(--mono); }
.signin-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); }
.warn-text { font-size: 12px; color: var(--warn); }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--text-3); }

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

.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100vh;
  padding: 18px 12px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
}
.sidebar .brand { padding: 4px 8px 18px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 550;
  text-decoration: none;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); display: flex; flex-direction: column; gap: 6px; }

.main-col { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
}
.topbar-title { font-weight: 650; color: var(--text-2); }
.topbar .brand { display: none; }
.menu-btn { display: none; }
.whoami { display: flex; align-items: center; gap: 8px; min-width: 0; }
.whoami .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }

.health-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); flex: none; }
.health-dot.healthy { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.health-dot.degraded { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.health-dot.unhealthy { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.content { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px; }
.stack { display: flex; flex-direction: column; gap: 20px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; }
.page-head p { margin-top: 4px; color: var(--text-3); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.back { display: inline-flex; align-items: center; gap: 6px; width: fit-content; color: var(--text-2); font-weight: 550; }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: 58px;
    right: 0;
    left: 0;
    z-index: 30;
    display: none;
    height: auto;
    max-height: calc(100vh - 58px);
    border-right: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
  .sidebar .brand { display: none; }
  .app.nav-open .sidebar { display: flex; }
  .topbar { padding: 8px 16px; }
  .topbar .brand { display: flex; }
  .topbar .brand-sub, .topbar-title { display: none; }
  .menu-btn { display: inline-flex; }
  .whoami .name { max-width: 110px; }
  .content { padding: 18px 16px 32px; }
}

@media (max-width: 520px) {
  .whoami .role-label { display: none; }
  h1 { font-size: 20px; }
}

/* ------------------------------------------------------------ cards and content blocks */

.card { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.card.pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-body { padding: 14px 18px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile { padding: 16px 18px; }
.tile-label { font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.tile-value { margin-top: 6px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.tile-sub { margin-top: 2px; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile.tone-ok .tile-value { color: var(--ok); }
.tile.tone-warn .tile-value { color: var(--warn); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.bars { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.bars li { display: grid; grid-template-columns: 112px minmax(0, 1fr) 48px; align-items: center; gap: 10px; }
.bar-track { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; background: var(--accent); min-width: 4px; }
.bar-count { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

.feed { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.feed li { display: flex; flex-direction: column; gap: 3px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12px; color: var(--text-3); }
.feed-meta .agent { font-weight: 600; color: var(--text-2); }
.feed-text { overflow-wrap: anywhere; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 20px; text-align: center; color: var(--text-3); }
.empty h3 { color: var(--text); }
.empty p { max-width: 460px; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 60px 0; color: var(--text-3); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.callout { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.callout.warn { border-color: transparent; background: var(--warn-soft); color: var(--warn); }
.callout.ok { border-color: transparent; background: var(--ok-soft); color: var(--ok); }

/* ------------------------------------------------------------ badges, chips, pills */

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}
.badge.kind {
  border-color: hsl(var(--h) var(--kind-bg-s) var(--kind-border-l));
  background: hsl(var(--h) var(--kind-bg-s) var(--kind-bg-l));
  color: hsl(var(--h) var(--kind-fg-s) var(--kind-fg-l));
}
.kind-decision { --h: 262; }
.kind-fact { --h: 212; }
.kind-lesson { --h: 36; }
.kind-procedure { --h: 186; }
.kind-convention { --h: 232; }
.kind-preference { --h: 328; }
.kind-reference { --h: 199; }
.kind-note { --h: 220; --kind-bg-s: 14%; --kind-fg-s: 14%; }
.kind-handoff { --h: 14; }
.kind-document { --h: 146; }
.kind-other { --h: 220; --kind-bg-s: 10%; --kind-fg-s: 10%; }

.badge.status-active { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.badge.status-superseded { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.badge.status-archived { background: var(--surface-3); border-color: transparent; color: var(--text-3); }
.badge.role-admin { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.badge.role-writer { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.badge.role-reader { background: var(--surface-3); border-color: transparent; color: var(--text-2); }
.badge.neutral { background: var(--surface-2); color: var(--text-2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--h) 70% 50%); }

.chip-static { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-family: var(--mono); font-size: 11.5px; }
.chip-static.company { background: var(--accent-soft); color: var(--accent); }
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-size: 11.5px; font-weight: 600; }
.pill.action { font-family: var(--mono); font-weight: 500; }
.marker { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--text-3); font-size: 11px; }

.tags { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-size: 11.5px; }
a.tag:hover { background: var(--surface-3); text-decoration: none; }
.tag::before { content: "#"; color: var(--text-3); margin-right: 1px; }

.stars { font-size: 11px; letter-spacing: 1px; white-space: nowrap; }
.stars .on { color: var(--star); }
.stars .off { color: var(--border-strong); }

/* ------------------------------------------------------------ memory cards */

.list { display: flex; flex-direction: column; gap: 10px; }
.mem { display: flex; flex-direction: column; gap: 6px; padding: 14px 18px; color: inherit; text-decoration: none; transition: border-color 0.12s, box-shadow 0.12s; }
.mem:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.mem-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mem-head.big { margin-bottom: 8px; }
.mem-id { font-family: var(--mono); font-size: 12.5px; color: var(--text-3); }
.mem-title { flex: 1 1 260px; min-width: 0; font-weight: 650; color: var(--text); overflow-wrap: anywhere; }
.mem-h1 { overflow-wrap: anywhere; }
.mem-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12px; color: var(--text-3); }
.mem-snippet {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-2);
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.search-form { display: flex; flex-direction: column; gap: 14px; padding: 16px 18px; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; min-height: 42px; font-size: 15px; }
.search-row .btn { min-height: 42px; }
.filters { display: grid; grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) auto; align-items: end; gap: 14px; }
@media (max-width: 860px) { .filters { grid-template-columns: minmax(0, 1fr); } }
.result-meta { font-size: 13px; }

.filters-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 14px 18px; }
.filters-bar .field { flex: 1 1 150px; }
.filters-bar .check { min-height: 36px; }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.pager-btns { display: flex; gap: 8px; }

/* ------------------------------------------------------------ memory detail */

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 960px) { .detail-grid { grid-template-columns: minmax(0, 1fr); } }

.meta-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 14px; margin: 0; font-size: 13px; }
.meta-grid dt { color: var(--text-3); white-space: nowrap; }
.meta-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.link-list, .revision-list, .progress-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.link-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.link-list .rel { min-width: 110px; font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.revision-list > li { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.revision-head { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--text-3); }
.progress-list li { font-size: 13px; overflow-wrap: anywhere; }
.progress-list li.ok { color: var(--ok); }
.progress-list li.err { color: var(--danger); }

details > summary { cursor: pointer; font-weight: 600; list-style-position: inside; }
details.card > summary { padding: 14px 18px; }
details.card[open] > summary { border-bottom: 1px solid var(--border); }
details .details-body { padding: 14px 18px; }

/* ------------------------------------------------------------ rendered markdown (built with DOM APIs only) */

.md { overflow-wrap: anywhere; }
.md > * + * { margin-top: 10px; }
.md p { white-space: pre-wrap; }
.md h3, .md h4, .md h5, .md h6 { margin-top: 18px; }
.md h3 { font-size: 18px; }
.md h4 { font-size: 15px; }
.md h5, .md h6 { font-size: 14px; }
.md ul, .md ol { margin-bottom: 0; padding-left: 22px; }
.md li + li { margin-top: 4px; }
.md code { padding: 1px 5px; border-radius: 5px; background: var(--surface-2); }
.md pre { margin: 10px 0 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); overflow-x: auto; }
.md pre code { padding: 0; background: none; }
.md a.memref { font-family: var(--mono); font-size: 12.5px; }
.brief .md > h3:first-child { margin-top: 0; }

/* ------------------------------------------------------------ projects */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project { display: flex; flex-direction: column; gap: 8px; padding: 18px; }
.project.company { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.project-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.project-head h3 { overflow-wrap: anywhere; }
.project-desc { color: var(--text-2); display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow-wrap: anywhere; }
.project-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--text-3); }
.project-stats strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); color: var(--text-3); font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions .btn + .btn { margin-left: 6px; }

/* ------------------------------------------------------------ code blocks */

.code { position: relative; }
.code pre { margin: 0; padding: 14px 16px; padding-right: 92px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); overflow-x: auto; white-space: pre; line-height: 1.5; }
.code .btn { position: absolute; top: 8px; right: 8px; }
.connect-section { display: flex; flex-direction: column; gap: 10px; }
.connect-section h2 { font-size: 16px; }
.connect-section p { color: var(--text-2); }
.endpoint-list { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.endpoint-list dt { color: var(--text-3); }
.endpoint-list dd { margin: 0; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }

.key-reveal { display: flex; gap: 8px; }
.key-reveal input { flex: 1; font-family: var(--mono); font-size: 13px; }

.badge.owner { background: var(--warn-soft); border-color: transparent; color: var(--warn); margin-left: 4px; }
.connect-page { max-width: 680px; margin: 48px auto; padding: 0 16px; }
.connect-page h1 { margin: 8px 0 0; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 14px; }
.steps li { line-height: 1.5; min-width: 0; }
.steps .code { margin-top: 8px; }
.steps .code pre { white-space: pre-wrap; word-break: break-all; }
.setup-code-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.setup-code {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 8px 16px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  user-select: all;
}

/* ------------------------------------------------------------ dialogs and toasts */

dialog.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.modal.wide { width: min(760px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(10, 15, 25, 0.5); backdrop-filter: blur(2px); }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; overflow-wrap: anywhere; }
.modal-body { padding: 18px 20px 20px; overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 4px; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-3);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  overflow-wrap: anywhere;
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--accent); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .toast.leaving { transition: none; } }
