/* Codebase Helper console.
   Design tokens are the only place colour, type, spacing, radius and elevation are defined;
   every component below (and updates.css) consumes them. Light values live on :root, dark
   values on :root[data-theme=dark] (set before first paint by shell.js). */

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url(/fonts/jetbrains-mono-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url(/fonts/jetbrains-mono-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --font: "JetBrains Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;

  --t-xs: 11.5px;
  --t-sm: 12.5px;
  --t-md: 13px;
  --t-lg: 15px;
  --t-xl: 18px;
  --t-2xl: 24px;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 48px;

  --r-ctl: 6px;
  --r-panel: 10px;
  --r-dialog: 12px;

  --canvas: #eef3f3;
  --surface: #ffffff;
  --surface-2: #f5f8f8;
  --field: #ffffff;
  --ink: #0f2a31;
  --muted: #4e6870;
  --line: #d3dfe1;
  --line-strong: #b5c7ca;
  --accent: #0e6b5c;
  --accent-hover: #0a5a4d;
  --accent-ink: #ffffff;
  --accent-soft: #e1f1eb;
  --focus: #1e9c7c;
  --ok: #157a57;
  --ok-soft: #e2f3ea;
  --warn: #8f5b00;
  --warn-soft: #fbf0da;
  --danger: #b3263e;
  --danger-soft: #fbe7ea;
  --info: #2b6cb0;
  --info-soft: #e5eef9;
  --overlay: rgb(9 30 36 / 45%);
  --shadow-overlay: 0 16px 48px rgb(9 30 36 / 20%), 0 2px 6px rgb(9 30 36 / 8%);

  /* The spine keeps the logo's deep teal in both themes. */
  --spine: #123942;
  --spine-hover: #1a4650;
  --spine-active: #1e505b;
  --spine-line: #25555f;
  --spine-ink: #c6dcd8;
  --spine-ink-strong: #f2faf7;
  --spine-muted: #8fb3ae;
  --mint: #7ddcb8;

  /* Project area tones: label colour plus an icon, never colour alone. */
  --tone-directory: #2c7a5e;
  --tone-code: #2f6daa;
  --tone-tools: #7a55a0;
  --tone-knowledge: #8a6a1f;

  /* JSON highlighting */
  --syntax-key: #2f6daa;
  --syntax-string: #157a57;
  --syntax-number: #9a4f00;
  --syntax-literal: #7a55a0;
}

:root[data-theme=dark] {
  color-scheme: dark;
  --canvas: #0d171b;
  --surface: #132228;
  --surface-2: #182c33;
  --field: #0f1d22;
  --ink: #e3eeee;
  --muted: #9db3b8;
  --line: #26404a;
  --line-strong: #37545f;
  --accent: #7ddcb8;
  --accent-hover: #9be6ca;
  --accent-ink: #0b2b24;
  --accent-soft: #173a35;
  --focus: #7ddcb8;
  --ok: #8fddbb;
  --ok-soft: #16352c;
  --warn: #e8b65a;
  --warn-soft: #362b15;
  --danger: #ff9aaa;
  --danger-soft: #3f1f26;
  --info: #8fbcf0;
  --info-soft: #1b2d44;
  --overlay: rgb(3 9 11 / 65%);
  --shadow-overlay: 0 16px 48px rgb(0 0 0 / 45%), 0 2px 6px rgb(0 0 0 / 30%);
  --spine: #123942;
  --tone-directory: #7ecaae;
  --tone-code: #82b8ed;
  --tone-tools: #c0a0e1;
  --tone-knowledge: #ddbd72;
  --syntax-key: #8fbcf0;
  --syntax-string: #8fddbb;
  --syntax-number: #f0b77a;
  --syntax-literal: #c0a0e1;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-md);
  font-weight: 400;
  line-height: 1.6;
  font-variant-ligatures: none;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { color: var(--ink); text-wrap: balance; }
h1 { font-size: var(--t-2xl); font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: var(--t-lg); font-weight: 700; line-height: 1.4; letter-spacing: -0.01em; margin: 0 0 var(--s-2); }
h3 { font-size: var(--t-md); font-weight: 700; line-height: 1.45; margin: var(--s-5) 0 var(--s-2); }
h4 { font-size: var(--t-md); font-weight: 700; margin: 0; }
p { color: var(--muted); margin: 0 0 var(--s-3); max-width: 78ch; overflow-wrap: anywhere; }
b, strong { color: var(--ink); font-weight: 650; }
a { color: var(--accent); text-underline-offset: 3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-6) 0; }
small, .hint { font-size: var(--t-xs); font-weight: 400; color: var(--muted); line-height: 1.55; }
p.hint, .hint { max-width: 78ch; }
code {
  font-family: var(--font);
  font-size: 0.92em;
  font-variant-ligatures: normal;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
  overflow-wrap: anywhere;
}
pre {
  font-family: var(--font);
  font-variant-ligatures: normal;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: var(--s-3) var(--s-4);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.6;
  max-height: 560px;
  overflow: auto;
  margin: var(--s-2) 0 var(--s-3);
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; }
kbd {
  font-family: var(--font);
  font-size: 11px;
  line-height: 1;
  padding: 3px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface);
}
details { margin: var(--s-3) 0; }
summary { cursor: pointer; color: var(--ink); font-weight: 500; }
summary:hover { color: var(--accent); }
::selection { background: var(--accent-soft); color: var(--ink); }
.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Focus ---------- */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* ---------- Buttons ---------- */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-sm);
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  vertical-align: middle;
  white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
button:hover, .button:hover { background: var(--surface-2); border-color: var(--muted); }
button:active { transform: translateY(0.5px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
button:disabled:hover { background: var(--surface); border-color: var(--line-strong); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.primary:disabled:hover { background: var(--accent); border-color: var(--accent); }
button.quiet { border-color: transparent; background: transparent; color: var(--muted); }
button.quiet:hover { background: var(--surface-2); color: var(--ink); border-color: transparent; }
button.danger-button { color: var(--danger); }
button.danger-button:hover { background: var(--danger-soft); border-color: var(--danger); }
button.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
:root[data-theme=dark] button.primary.danger { color: #2a0d13; }
.icon-button { padding: 0; width: 34px; }
.button .icon, button .icon { width: 15px; height: 15px; flex-basis: 15px; }

/* ---------- Form fields ---------- */
form { display: flex; flex-direction: column; gap: var(--s-4); margin-top: var(--s-4); }
form > button { align-self: flex-start; }
form + p, form + .hint, form + #github-token-list, form + p:empty + p { margin-top: var(--s-4); }
label { display: flex; flex-direction: column; gap: 6px; color: var(--ink); font-size: var(--t-sm); font-weight: 500; min-width: 0; }
label small { margin-top: 1px; }
label small.ref-warning { color: var(--warn); }
input, textarea, select {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--field);
  color: var(--ink);
  font-size: var(--t-md);
  font-weight: 400;
  line-height: 1.5;
  box-shadow: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, textarea:hover, select:hover { border-color: var(--muted); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
textarea { resize: vertical; line-height: 1.6; }
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237f969c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  text-overflow: ellipsis;
}
select[multiple] { min-height: 112px; padding-right: 10px; background-image: none; }
input[type=file] { padding: 10px; border-style: dashed; background: var(--surface-2); cursor: pointer; }
input[type=file]::file-selector-button {
  font: inherit;
  font-size: var(--t-xs);
  margin-right: var(--s-3);
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { color: var(--muted); background-color: var(--surface-2); opacity: .7; cursor: not-allowed; }
input[readonly] { background: var(--surface-2); }
.code-input, textarea.code-input { font-size: 12px; tab-size: 4; font-variant-ligatures: normal; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4) var(--s-5); }
.full { grid-column: 1 / -1; }
.check { display: flex; flex-direction: row; align-items: center; gap: 10px; font-weight: 400; font-size: var(--t-md); }
.check input { width: 15px; min-height: 15px; height: 15px; margin: 0; flex-shrink: 0; padding: 0; }
.optional { font-size: var(--t-xs); color: var(--muted); font-weight: 400; margin-left: 4px; }
.optional::before { content: "("; }
.optional::after { content: ")"; }
.form-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin-top: var(--s-1); }
.form-actions small { flex-basis: 100%; }
.save-test-guide {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--surface-2);
}
.save-test-guide b { font-size: var(--t-sm); }
.save-test-guide span { font-size: var(--t-xs); color: var(--muted); }

/* Switches */
.switch-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-6);
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 400;
}
.switch-row > span { min-width: 0; }
.switch-row b { display: block; font-weight: 600; }
.switch-row small { display: block; margin-top: 2px; overflow-wrap: anywhere; max-width: 78ch; }
.switch-row input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 36px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  flex: 0 0 36px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  box-shadow: none;
}
.switch-row input::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s ease, background-color .15s ease;
}
.switch-row input:checked { background: var(--accent); border-color: var(--accent); }
.switch-row input:checked::before { background: var(--accent-ink); transform: translateX(16px); }
.switch-row input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch-row input:disabled { cursor: wait; opacity: .5; }

/* ---------- Pills & badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--t-xs);
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge.status-ok, .badge.tone-ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge.tone-warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.badge.tone-danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.badge.tone-info { color: var(--info); background: var(--info-soft); border-color: transparent; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--t-xs);
  line-height: 1.7;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-ok { color: var(--ok); }
.error { color: var(--danger); white-space: pre-wrap; }
p.error:empty { display: none; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
aside.spine {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--s-4) var(--s-3);
  background: var(--spine);
  color: var(--spine-ink);
  overflow-y: auto;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 6px;
  color: var(--spine-ink-strong);
  text-decoration: none;
  font-size: var(--t-md);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  border-radius: var(--r-ctl);
}
.brand-row { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.brand:hover { background: var(--spine-hover); }
.brand-mark { display: block; width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }
.brand small { display: block; color: var(--spine-muted); font-weight: 400; font-size: var(--t-xs); }
.nav-label { display: block; margin: var(--s-5) 10px 6px; color: var(--spine-muted); font-size: var(--t-xs); font-weight: 500; }
.spine nav { display: flex; flex-direction: column; gap: 2px; }
.spine nav button {
  position: relative;
  width: 100%;
  justify-content: flex-start;
  gap: 10px;
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--r-ctl);
  background: transparent;
  color: var(--spine-ink);
  font-size: var(--t-sm);
  font-weight: 500;
}
.spine nav button .icon { opacity: .8; }
.spine nav button:hover { background: var(--spine-hover); color: var(--spine-ink-strong); }
.spine nav button.active { background: var(--spine-active); color: var(--spine-ink-strong); }
.spine nav button.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--mint);
}
.spine nav button.active .icon { opacity: 1; color: var(--mint); }
.spine nav button:focus-visible { outline-color: var(--mint); }
.sidebar-bottom { margin-top: auto; padding: var(--s-5) 8px 0; border-top: 1px solid var(--spine-line); font-size: var(--t-xs); color: var(--spine-muted); }
.sidebar-bottom .version { display: flex; align-items: center; gap: 8px; margin-bottom: var(--s-3); }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 3px rgb(125 220 184 / 18%); }
.theme {
  width: 100%;
  min-height: 30px;
  font-size: var(--t-xs);
  border-color: var(--spine-line);
  background: transparent;
  color: var(--spine-ink);
}
.theme:hover { background: var(--spine-hover); border-color: var(--spine-muted); color: var(--spine-ink-strong); }
.spine-close { display: none; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: 56px;
  padding: 0 clamp(16px, 3vw, 40px);
  background: var(--canvas);
  border-bottom: 1px solid var(--line);
}
.menu-button { display: none; }
.search-trigger {
  flex: 0 1 380px;
  justify-content: flex-start;
  min-width: 0;
  color: var(--muted);
  background: var(--surface);
  border-color: var(--line);
  font-weight: 400;
}
.search-trigger span { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.search-trigger:hover { color: var(--ink); }
.topbar-actions { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; }
#slack-status.is-connected { color: var(--ok); background: var(--ok-soft); border-color: transparent; }

main { width: 100%; max-width: 1320px; padding: var(--s-6) clamp(16px, 3vw, 40px) var(--s-8); }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-2); }
.intro, .page-lead { color: var(--muted); max-width: 78ch; margin: 0 0 var(--s-6); }
footer {
  margin-top: var(--s-7);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
  font-size: var(--t-xs);
  color: var(--muted);
}
.scrim { display: none; }

/* ---------- Toast (global notice) ---------- */
.toast-region {
  position: fixed;
  right: var(--s-5);
  bottom: var(--s-5);
  z-index: 60;
  width: min(440px, calc(100vw - 32px));
}
#notice {
  margin: 0;
  padding: 12px 44px 12px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-overlay);
  font-size: var(--t-sm);
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  animation: toast-in .18s ease-out;
}
#notice.error { border-left-color: var(--danger); color: var(--ink); background: var(--surface); }
#notice.error::before { content: "Error  "; color: var(--danger); font-weight: 700; }
.toast-dismiss {
  position: absolute;
  top: 7px;
  right: 7px;
  min-height: 28px;
  width: 28px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Inline notices (used inside pages and dialogs) */
.notice {
  padding: 10px 14px;
  margin: 0 0 var(--s-4);
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--ink);
  font-size: var(--t-sm);
}
.notice.error { border-left-color: var(--danger); background: var(--danger-soft); }

/* ---------- Panels & layout ---------- */
.panel {
  min-width: 0;
  margin-bottom: var(--s-5);
  padding: var(--s-5) 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface);
}
.panel > h2:first-child, .panel > .panel-heading:first-child { margin-top: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.panel-heading h2, .panel-heading h3 { margin: 0; }
.panel-heading > div { min-width: 0; }
.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.columns > .panel { margin-bottom: var(--s-5); }
.columns.equal-height { align-items: stretch; }
.columns.equal-height > .panel { margin-bottom: 0; }
.columns.equal-height { margin-bottom: var(--s-5); }
.panel > .button + .hint { margin-top: var(--s-2); }
.narrow { max-width: 860px; }
.section-label { display: block; margin-bottom: 2px; color: var(--muted); font-size: var(--t-xs); font-weight: 500; }
.toolbar { display: flex; align-items: flex-end; gap: var(--s-3); flex-wrap: wrap; margin: 0 0 var(--s-4); }
.toolbar label { min-width: 260px; }
.toolbar > button { min-height: 36px; }
.toolbar .tabs { margin: 0 0 0 auto; }

/* Segmented tabs */
.tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  margin-bottom: var(--s-4);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  flex-wrap: wrap;
}
.tabs button { min-height: 28px; padding: 3px 12px; border-color: transparent; background: transparent; color: var(--muted); }
.tabs button:hover { background: var(--surface); color: var(--ink); border-color: transparent; }
.tabs button.selected { background: var(--surface); color: var(--ink); border-color: var(--line-strong); font-weight: 600; }

/* Rows: dense lists with dividers */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row > div { min-width: 0; }
.row-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-weight: 600; overflow-wrap: anywhere; color: var(--ink); }
.row small { display: block; margin-top: 2px; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; flex-shrink: 0; }
.row-actions button, .row-actions select { min-height: 28px; padding: 3px 10px; font-size: var(--t-xs); }
.row-actions select { width: auto; max-width: 220px; padding-right: 28px; }
.empty {
  padding: var(--s-5);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: var(--t-sm);
  text-align: center;
}

/* Status summary banners (Slack connection, active AI configuration) */
.connection-summary {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-bottom: var(--s-5);
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-panel);
  background: var(--surface);
  overflow-wrap: anywhere;
}
.connection-summary:empty { display: none; }
.connection-summary strong { font-size: var(--t-lg); line-height: 1.4; }
.connection-summary > span:last-child { color: var(--muted); font-size: var(--t-xs); }
.connection-error { border-left-color: var(--danger); }

/* Copyable values */
.copy-field { display: flex; align-items: stretch; gap: 6px; min-width: 0; }
.copy-field > input, .copy-field > textarea, .copy-field > code { flex: 1; min-width: 0; }
.copy-field > code {
  display: flex;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  font-size: var(--t-sm);
}
.copy-field > code:empty::before { content: "—"; color: var(--muted); }
.copy-button { flex-shrink: 0; }
.copy-button.copied { color: var(--ok); border-color: var(--ok); }

/* ---------- Dialogs ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: var(--overlay); }

/* ---------- Command palette ---------- */
.palette {
  width: min(620px, calc(100vw - 32px));
  margin: 12vh auto auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-dialog);
  background: var(--surface);
  box-shadow: var(--shadow-overlay);
  overflow: hidden;
}
.palette[open] { animation: palette-in .14s ease-out; }
@keyframes palette-in { from { opacity: 0; transform: translateY(-6px) scale(.99); } to { opacity: 1; transform: none; } }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 0 var(--s-4); border-bottom: 1px solid var(--line); color: var(--muted); }
.palette-search input { border: 0; min-height: 50px; padding: 0; background: transparent; font-size: var(--t-lg); box-shadow: none; }
.palette-search input:focus { box-shadow: none; }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: min(420px, 60vh); overflow-y: auto; }
.palette-group { padding: 8px 10px 4px; color: var(--muted); font-size: var(--t-xs); }
.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-ctl);
  color: var(--ink);
  cursor: pointer;
}
.palette-item .icon { color: var(--muted); }
.palette-item small { margin-left: auto; padding-left: var(--s-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.palette-item[aria-selected=true] { background: var(--accent-soft); }
.palette-item[aria-selected=true] .icon { color: var(--accent); }
.palette-empty { padding: var(--s-5); color: var(--muted); text-align: center; }
.palette-foot { display: flex; gap: var(--s-4); padding: 8px var(--s-4); border-top: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: var(--t-xs); }
.palette-foot span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Sign-in ---------- */
.auth-shell { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); min-height: 100vh; }
.auth-aside {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--s-7);
  padding: clamp(24px, 5vw, 56px);
  background: var(--spine);
  color: var(--spine-ink);
}
.auth-brand { display: flex; align-items: center; gap: 12px; color: var(--spine-ink-strong); font-size: var(--t-lg); font-weight: 700; }
.auth-brand .brand-mark { width: 40px; height: 40px; }
.auth-pitch h2 { color: var(--spine-ink-strong); font-size: var(--t-2xl); line-height: 1.3; letter-spacing: -0.02em; max-width: 22ch; margin: 0 0 var(--s-5); }
.auth-pitch ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-3); max-width: 46ch; }
.auth-pitch li { display: flex; gap: 10px; color: var(--spine-ink); font-size: var(--t-sm); }
.auth-pitch li .icon { color: var(--mint); margin-top: 2px; }
.auth-foot { color: var(--spine-muted); font-size: var(--t-xs); }
.auth-main { display: grid; place-items: center; padding: var(--s-7) var(--s-5); }
.auth-box { width: min(400px, 100%); }
.auth-box h1 { margin-bottom: var(--s-2); }
.auth-box p { font-size: var(--t-sm); }
.auth-box form button[type=submit] { align-self: stretch; min-height: 40px; }

/* ---------- Overview ---------- */
.overview-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--s-5); align-items: start; }
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface);
  overflow: hidden;
}
.metric { padding: 14px var(--s-5); border-left: 1px solid var(--line); min-width: 0; }
.metric:first-child { border-left: 0; }
.metric small { display: block; font-size: var(--t-xs); color: var(--muted); }
.metric strong { display: block; margin-top: 2px; font-size: 22px; font-weight: 650; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.setup-progress { font-size: var(--t-xs); color: var(--muted); font-weight: 400; }
.setup-list { list-style: none; margin: 0; padding: 0; }
.setup-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: var(--s-3);
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.setup-item:last-child { border-bottom: 0; }
.setup-item b { display: block; font-weight: 600; }
.setup-item small { display: block; }
.setup-state {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.setup-item.is-done .setup-state { border: 0; background: var(--ok-soft); color: var(--ok); }
.setup-item.is-done b { color: var(--muted); font-weight: 500; }
.setup-item button { min-height: 28px; padding: 3px 10px; font-size: var(--t-xs); }
.activity-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: var(--s-3);
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-sm);
}
.activity-row:last-child { border-bottom: 0; }
.activity-row time { color: var(--muted); font-size: var(--t-xs); white-space: nowrap; padding-top: 1px; }
.activity-row b { font-weight: 600; }
.activity-row small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.compact .activity-row { grid-template-columns: 92px minmax(0, 1fr); }

/* ---------- Projects ---------- */
.section-index {
  position: sticky;
  top: 56px;
  z-index: 10;
  display: flex;
  gap: 4px;
  margin: 0 0 var(--s-5);
  padding: 8px 0;
  background: var(--canvas);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.section-index button {
  min-height: 30px;
  padding: 3px 10px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: var(--t-xs);
}
.section-index button:hover { background: var(--surface); color: var(--ink); border-color: var(--line); }
.section-index button.current { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.section-index .dot { width: 8px; height: 8px; border-radius: 2px; background: var(--section-line); }
.project-section { scroll-margin-top: 120px; }
.project-section > .section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--s-2);
  color: var(--section-line);
  font-weight: 600;
}
.project-section > .section-label .icon { width: 14px; height: 14px; flex-basis: 14px; }
.project-section h2 { font-size: var(--t-lg); margin-bottom: var(--s-2); }
.project-section { border-top: 2px solid var(--section-line); }
.tone-directory { --section-line: var(--tone-directory); }
.tone-code { --section-line: var(--tone-code); }
.tone-tools { --section-line: var(--tone-tools); }
.tone-knowledge { --section-line: var(--tone-knowledge); }
.selection-context {
  display: inline-flex;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--t-sm);
}
#repository-status { margin-top: var(--s-4); }
#repository-status > p:first-child { color: var(--ink); font-weight: 500; }
#repository-webhook { margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--line); display: grid; gap: var(--s-3); }
#repository-webhook h3, #repository-webhook p { margin: 0; }
.tool-group { padding: var(--s-4); border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); display: grid; gap: var(--s-3); }
.tool-group h3, .tool-group p, .tool-group .check { margin: 0; }
.tool-group .panel-heading { margin: 0; }
.always-on { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 16px; padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: 8px; }
.always-on .check { color: var(--muted); font-size: var(--t-sm); }
#project-custom-tools { display: grid; gap: 8px; }
#project-custom-tools .check { align-items: flex-start; }
#project-custom-tools .check input { margin-top: 3px; }

/* ---------- Ask ---------- */
.ask-layout { display: grid; grid-template-columns: minmax(320px, 5fr) minmax(0, 7fr); gap: var(--s-5); align-items: start; }
.ask-composer { position: sticky; top: 80px; }
.ask-composer .form-actions { justify-content: space-between; }
.composer-hint { display: inline-flex; align-items: center; gap: 4px; }
#answer > .panel:only-child { margin-bottom: 0; }
.answer-placeholder { display: grid; place-items: center; gap: var(--s-2); min-height: 320px; padding: var(--s-7); border: 1px dashed var(--line-strong); border-radius: var(--r-panel); color: var(--muted); text-align: center; }
.answer-placeholder .icon { width: 22px; height: 22px; color: var(--line-strong); }
.answer-placeholder p { margin: 0 auto; max-width: 46ch; }
.answer-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s-3); }
.answer-panel > h2 { font-size: var(--t-xl); line-height: 1.4; margin-bottom: var(--s-3); }
.answer-body { color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.answer-steps { margin: var(--s-3) 0; padding-left: 0; list-style: none; counter-reset: answer-step; }
.answer-steps > li { counter-increment: answer-step; position: relative; padding: 0 0 var(--s-2) 34px; }
.answer-steps > li::before {
  content: counter(answer-step);
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--t-xs);
  font-weight: 700;
}
.answer-sources-title { display: flex; align-items: center; gap: 8px; }
.answer-source { margin: 0; border-top: 1px solid var(--line); padding: 10px 0; }
.answer-source:last-of-type { border-bottom: 1px solid var(--line); }
.answer-source summary { color: var(--accent); font-size: var(--t-sm); overflow-wrap: anywhere; }
.answer-source a { display: inline-block; margin-top: 4px; font-size: var(--t-sm); }
.answer-feedback { padding-top: var(--s-4); margin-top: var(--s-4); border-top: 1px solid var(--line); }
.answer-panel form { padding-top: var(--s-4); margin-top: var(--s-4); border-top: 1px solid var(--line); }

/* ---------- Knowledge ---------- */
.knowledge-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.knowledge-layout.has-detail { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
#knowledge-list { padding: 4px 22px; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); }
#knowledge-list > .empty { margin: var(--s-4) 0; }
#knowledge-list .row.is-selected { box-shadow: inset 3px 0 var(--accent); margin-left: -22px; padding-left: 19px; margin-right: -22px; padding-right: 22px; background: var(--surface-2); }
#knowledge-detail { position: sticky; top: 80px; max-height: calc(100vh - 100px); display: flex; flex-direction: column; }
#knowledge-detail pre { flex: 1; max-height: none; margin-bottom: 0; }
.j-key { color: var(--syntax-key); }
.j-str { color: var(--syntax-string); }
.j-num { color: var(--syntax-number); }
.j-lit { color: var(--syntax-literal); font-weight: 600; }

/* ---------- Configuration editors (AI, tools, environment) ---------- */
.configuration-layout { display: grid; grid-template-columns: minmax(280px, 2fr) minmax(0, 3fr); gap: var(--s-5); align-items: start; }
.configuration-layout > .panel:last-child { position: sticky; top: 80px; }
.configuration-layout .panel-heading { flex-wrap: wrap; }
.profile-card {
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.profile-card:hover { border-color: var(--line-strong); }
.profile-card.is-active { border-color: var(--accent); box-shadow: inset 3px 0 var(--accent); }
.profile-card .panel-heading { gap: 8px; margin: 0 0 4px; }
.profile-card h3 { margin: 0; font-size: var(--t-md); overflow-wrap: anywhere; }
.profile-card p { font-size: var(--t-sm); margin: 0 0 4px; }
.profile-card small { display: block; overflow-wrap: anywhere; }
.profile-card .form-actions { gap: 6px; margin-top: 10px; }
.profile-card button { min-height: 28px; padding: 3px 10px; font-size: var(--t-xs); }
.profile-test { display: block; margin-top: 6px; font-size: var(--t-xs); color: var(--muted); }
.profile-test.status-ok { color: var(--ok); }
.profile-test.error { color: var(--danger); }
.environment-value { max-height: 140px; margin: 6px 0; font-size: 12px; padding: 6px 10px; }
#ai-test-status { margin-top: var(--s-4); }
#ai-test-status:empty { display: none; }
[id$=-editor] .badge, #ai-editor-badge, #custom-tool-state, #environment-state { flex-shrink: 0; }

/* ---------- Coding agents ---------- */
.bundle-actions { margin: var(--s-3) 0; }
#page-agents h3 { margin-top: var(--s-5); }
#new-token { margin-top: var(--s-5); padding: var(--s-4); border: 1px solid var(--warn); border-radius: 8px; background: var(--warn-soft); }
#new-token p { color: var(--ink); font-weight: 600; margin-bottom: var(--s-2); }
#token-value { font-size: 12px; background: var(--field); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .ask-layout { grid-template-columns: minmax(0, 1fr); }
  .ask-composer { position: static; }
  .knowledge-layout.has-detail { grid-template-columns: minmax(0, 1fr); }
  #knowledge-detail { position: static; max-height: none; }
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1050px) {
  .columns, .configuration-layout { grid-template-columns: minmax(0, 1fr); }
  .configuration-layout > .panel:last-child { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  aside.spine {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 84vw);
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 50;
  }
  .shell.nav-open aside.spine { transform: none; box-shadow: var(--shadow-overlay); }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: var(--overlay); }
  .spine-close { display: inline-flex; margin-left: auto; color: var(--spine-ink); border-color: transparent; background: transparent; }
  .spine-close:hover { background: var(--spine-hover); border-color: transparent; color: var(--spine-ink-strong); }
  .menu-button { display: inline-flex; }
  .search-trigger { flex: 1 1 auto; }
  .search-trigger kbd, .topbar-actions .label { display: none; }
  .topbar-actions #slack-status { display: none; }
  .topbar-actions button { padding: 0; width: 34px; }
  main { padding-top: var(--s-5); }
  h1 { font-size: 21px; }
  button, .button { white-space: normal; text-align: left; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: var(--s-4); }
  .row { align-items: flex-start; flex-wrap: wrap; }
  .row-actions { justify-content: flex-start; }
  .toolbar label { min-width: 0; flex: 1; }
  .metric { padding: 12px; }
  .metric strong { font-size: 18px; }
  .section-index { top: 56px; }
  .auth-shell { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { gap: var(--s-5); }
  .auth-pitch ul, .auth-foot { display: none; }
  .auth-pitch h2 { font-size: var(--t-xl); margin: 0; }
  .activity-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  #knowledge-list { padding: 4px var(--s-4); }
  .switch-row { gap: var(--s-4); }
  .toast-region { right: var(--s-4); bottom: var(--s-4); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
