/* Project Hub design system.
   Tokens first, then base, layout, components, pages. No build step. */

:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --surface-3: #e9e9e5;
  --text: #1b1b1f;
  --text-muted: #5f5f68;
  --border: #e2e2dd;
  --border-strong: #c9c9c2;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #ffffff;
  --success: #15803d;
  --success-soft: #e9f7ee;
  --warning: #a15c07;
  --warning-soft: #fff6e5;
  --danger: #c4231c;
  --danger-soft: #fdeeed;
  --focus: #4f46e5;
  --claude: #c2410c;
  --claude-soft: #fdeee6;
  --codex: #0f766e;
  --codex-soft: #e3f5f2;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .05);
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .06);
  --shadow-lg: 0 10px 40px rgb(0 0 0 / .18);

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

  --nav-w: 232px;
  --side-w: 288px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --surface: #18181c;
    --surface-2: #1f1f24;
    --surface-3: #2a2a31;
    --text: #ececf1;
    --text-muted: #a2a2ad;
    --border: #2b2b32;
    --border-strong: #3d3d46;
    --accent: #8b8cf8;
    --accent-hover: #a5a6fb;
    --accent-soft: #24244a;
    --accent-text: #0e0e2a;
    --success: #4ade80;
    --success-soft: #12301f;
    --warning: #fbbf24;
    --warning-soft: #33270b;
    --danger: #f87171;
    --danger-soft: #3a1717;
    --focus: #a5a6fb;
    --claude: #fb923c;
    --claude-soft: #3a2113;
    --codex: #2dd4bf;
    --codex-soft: #0f2f2c;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 4px 16px rgb(0 0 0 / .35);
    --shadow-lg: 0 10px 40px rgb(0 0 0 / .6);
  }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font-sans); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
code, pre, kbd { font-family: var(--font-mono); font-size: .875em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: .05em .35em; }
img { max-width: 100%; }
ul, ol { margin: 0; padding: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.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; }
.skip-link { position: absolute; left: var(--space-3); top: -48px; z-index: 100; background: var(--surface); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); box-shadow: var(--shadow); transition: top .15s; }
.skip-link:focus { top: var(--space-3); }
.muted { color: var(--text-muted); }
.icon { width: 18px; height: 18px; flex: none; }
.link { font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ------------------------------------------------------------------ app shell */
.app { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100dvh; }
.topbar { display: none; }
.nav {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-4) var(--space-3); background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 650; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand:hover { color: var(--text); }
.brand__mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-text); }
.brand__mark .icon { width: 16px; height: 16px; }
.nav__brand { padding: var(--space-1) var(--space-2); }
.nav__list { list-style: none; display: grid; gap: 2px; }
.nav__heading { margin: var(--space-4) var(--space-2) var(--space-1); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.nav__link {
  display: flex; align-items: center; gap: var(--space-3); padding: 8px var(--space-3); border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-weight: 500; min-height: 40px;
}
.nav__link:hover { background: var(--surface-2); color: var(--text); }
.nav__link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav__footer { margin-top: auto; display: flex; align-items: center; gap: var(--space-1); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.nav__user { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-2); padding: 6px var(--space-2); border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.nav__user:hover, .nav__user[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.nav__user-text { display: grid; min-width: 0; line-height: 1.3; }
.nav__user-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__user-role { font-size: 12px; color: var(--text-muted); }
.nav-scrim { display: none; }
.main { min-width: 0; outline: none; }
.page { padding: var(--space-6) var(--space-6) var(--space-7); max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); align-content: start; }
.page.narrow, .narrow { max-width: 720px; }
.narrow { margin: 0 auto; display: grid; gap: var(--space-5); width: 100%; }
.page__header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page__title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.page__lead { color: var(--text-muted); margin-top: var(--space-1); max-width: 65ch; }
.back-link { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--text-muted); text-decoration: none; font-weight: 500; font-size: 14px; }
.back-link:hover { color: var(--text); }
.grid-2 { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.grid-2--wide { grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.toolbar { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ------------------------------------------------------------------ buttons */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 40px; padding: 0 var(--space-4); border-radius: var(--radius-sm); border: 1px solid var(--btn-border);
  background: var(--btn-bg); color: var(--btn-fg); font-weight: 550; font-size: 14px; text-decoration: none;
  cursor: pointer; white-space: nowrap; transition: background .15s var(--ease), border-color .15s, color .15s, transform .05s;
}
.btn:hover { color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn--primary { --btn-bg: var(--accent); --btn-fg: var(--accent-text); --btn-border: transparent; }
.btn--primary:hover { --btn-bg: var(--accent-hover); }
.btn--secondary:hover { --btn-bg: var(--surface-2); }
.btn--ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--text-muted); }
.btn--ghost:hover { --btn-bg: var(--surface-2); --btn-fg: var(--text); }
.btn--danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-border: transparent; }
.btn--danger:hover { filter: brightness(.95); }
.btn--danger-ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--danger); }
.btn--danger-ghost:hover { --btn-bg: var(--danger-soft); }
.btn--sm { min-height: 32px; padding: 0 var(--space-3); font-size: 13px; }
.btn--lg { min-height: 46px; font-size: 15px; }
.btn--icon { padding: 0; width: 40px; }
.btn--sm.btn--icon { width: 32px; }
.btn--block { width: 100%; }
.btn.is-loading { pointer-events: none; opacity: .8; }

/* ------------------------------------------------------------------ forms */
.field { display: grid; gap: 6px; }
.field__label { font-weight: 600; font-size: 14px; }
.field__optional { font-weight: 400; color: var(--text-muted); font-size: 13px; }
.field__help { font-size: 13px; color: var(--text-muted); display: flex; gap: 6px; align-items: baseline; }
.field__help .icon { width: 14px; height: 14px; align-self: center; }
.field__error { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--danger); font-weight: 500; }
.field__error .icon { width: 15px; height: 15px; }
.input {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s;
}
textarea.input { resize: vertical; line-height: 1.5; }
.input::placeholder { color: var(--text-muted); opacity: .8; }
.input:hover { border-color: var(--text-muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input--mono { font-family: var(--font-mono); font-size: 13px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.check { display: flex; gap: var(--space-2); align-items: center; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }
.form-actions--split { justify-content: space-between; align-items: center; }
.inline-form { display: flex; gap: var(--space-2); }
.inline-form .input { flex: 1; min-width: 0; }
.secret-input { position: relative; display: flex; gap: var(--space-2); align-items: center; }
.secret-input .input { flex: 1; }

.choice-group { border: 0; padding: 0; margin: 0; display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.choice-group legend { margin-bottom: 6px; padding: 0; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice__body { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, background .15s; height: 100%; }
.choice__body > span { display: grid; line-height: 1.3; }
.choice__body small { color: var(--text-muted); font-size: 13px; }
.choice:hover .choice__body { border-color: var(--text-muted); }
.choice input:checked + .choice__body { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input:focus-visible + .choice__body { outline: 2px solid var(--focus); outline-offset: 2px; }

.segmented { border: 0; margin: 0; padding: 3px; display: inline-flex; background: var(--surface-2); border-radius: var(--radius); gap: 2px; }
.segmented__item { position: relative; }
.segmented__item input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented__item > span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 7px; font-size: 14px; font-weight: 550; color: var(--text-muted); min-height: 34px; }
.segmented__item input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented__item input:focus-visible + span { outline: 2px solid var(--focus); }

.disclosure > summary { cursor: pointer; font-weight: 550; font-size: 14px; color: var(--text-muted); padding: var(--space-1) 0; }
.disclosure > summary:hover { color: var(--text); }
.disclosure[open] > summary { margin-bottom: var(--space-3); }

/* ------------------------------------------------------------------ surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); }
.card__title { font-size: 16px; font-weight: 650; display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.card .stack > .card__title, .card.stack > .card__title { margin-bottom: 0; }
.card--danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.card--danger .card__title { color: var(--danger); }
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-muted); vertical-align: middle; }
.alert { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 1px solid; font-size: 14px; }
.alert > .icon { margin-top: 2px; }
.alert--error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--text); }
.alert--error > .icon { color: var(--danger); }
.alert--success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.alert--success > .icon { color: var(--success); }
.alert--warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.alert--warning > .icon { color: var(--warning); }
.alert__pre { margin: var(--space-2) 0 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; max-height: 200px; overflow: auto; }
.copy-row { display: flex; gap: var(--space-2); align-items: center; margin-top: var(--space-2); flex-wrap: wrap; }
.copy-row code { font-size: 15px; padding: 4px 10px; background: var(--surface); }

.empty { display: grid; justify-items: center; text-align: center; gap: var(--space-3); padding: var(--space-7) var(--space-5); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
.empty__icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.empty__icon .icon { width: 26px; height: 26px; }
.empty__title { font-size: 18px; }
.empty__text { color: var(--text-muted); max-width: 46ch; }

.kv { display: grid; gap: var(--space-2); margin: 0; }
.kv > div { display: grid; grid-template-columns: 160px 1fr; gap: var(--space-3); font-size: 14px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; word-break: break-word; }

.list { list-style: none; display: grid; }
.list__row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.list__row:last-child { border-bottom: 0; }
.list__row--off { opacity: .6; }
.list__main { flex: 1; min-width: 0; display: grid; line-height: 1.35; }
.list__main small { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.list--compact .list__row { padding: var(--space-2) 0; }

.people { list-style: none; display: grid; gap: var(--space-2); margin-bottom: var(--space-3); }
.people li { display: flex; align-items: center; gap: var(--space-2); }

.status-line { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: none; display: inline-block; }
.status-dot--running { background: var(--accent); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); animation: pulse 1.6s infinite; }
.status-dot--ok { background: var(--success); }
.status-dot--error { background: var(--danger); }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* avatars: 12 hues, chosen per person on the server */
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; font-weight: 650; color: #fff; background: #6b7280; user-select: none; }
.avatar--xs { width: 20px; height: 20px; font-size: 9px; }
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.avatar--md { width: 34px; height: 34px; font-size: 13px; }
.avatar--lg { width: 52px; height: 52px; font-size: 18px; }
.hue-0 { background: #b42318; } .hue-1 { background: #c2410c; } .hue-2 { background: #a15c07; }
.hue-3 { background: #4d7c0f; } .hue-4 { background: #15803d; } .hue-5 { background: #0f766e; }
.hue-6 { background: #0e7490; } .hue-7 { background: #1d4ed8; } .hue-8 { background: #4f46e5; }
.hue-9 { background: #7c3aed; } .hue-10 { background: #a21caf; } .hue-11 { background: #be185d; }
.avatar-stack { display: flex; align-items: center; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -8px; }
.avatar--more { background: var(--surface-3); color: var(--text-muted); }

.agent-mark { display: inline-grid; place-items: center; flex: none; border-radius: 9px; }
.agent-mark .icon { width: 58%; height: 58%; }
.agent-mark--claude { background: var(--claude-soft); color: var(--claude); }
.agent-mark--codex { background: var(--codex-soft); color: var(--codex); }
.agent-mark.avatar--xs { width: 20px; height: 20px; border-radius: 6px; }
.agent-mark.avatar--sm { width: 28px; height: 28px; border-radius: 8px; }
.agent-mark.avatar--md { width: 34px; height: 34px; }
.agent-mark.avatar--lg { width: 56px; height: 56px; border-radius: 16px; }

/* ------------------------------------------------------------------ toasts & dialogs */
.toasts { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 60; display: grid; gap: var(--space-2); max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 14px; animation: toast-in .25s var(--ease); }
.toast > span { flex: 1; padding-top: 1px; }
.toast--success > .icon { color: #4ade80; }
.toast--error > .icon { color: #f87171; }
.toast__close { background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; padding: 2px; border-radius: 4px; display: grid; }
.toast__close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.dialog { border: 0; padding: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); }
.dialog::backdrop { background: rgb(10 10 15 / .5); }
.dialog[open] { animation: dialog-in .2s var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dialog__body { padding: var(--space-5); }
.dialog__header { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin: calc(var(--space-2) * -1) calc(var(--space-2) * -1) 0 0; }
.dialog__header h2 { font-size: 18px; }
.dialog__footer { display: flex; justify-content: flex-end; gap: var(--space-2); }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 200px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); display: grid; }
.menu__item { width: 100%; text-align: left; background: none; border: 0; padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.menu__item:hover, .menu__item:focus-visible { background: var(--surface-2); }
.menu__item--danger { color: var(--danger); }

/* ------------------------------------------------------------------ auth */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--space-5); outline: none;
  background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.auth__card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: var(--space-6); box-shadow: var(--shadow); display: grid; gap: var(--space-4); }
.auth__brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 650; }
.auth__title { font-size: 24px; letter-spacing: -.02em; }
.auth__lead { color: var(--text-muted); margin-top: calc(var(--space-3) * -1); }
.auth__foot { font-size: 13px; color: var(--text-muted); text-align: center; }

/* ------------------------------------------------------------------ projects list */
.project-grid { list-style: none; display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.project-card { position: relative; display: grid; gap: var(--space-3); align-content: start; padding: var(--space-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s var(--ease); }
.project-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.project-card:focus-within { border-color: var(--accent); }
.project-card__link { display: flex; align-items: center; gap: var(--space-3); color: var(--text); text-decoration: none; font-weight: 650; font-size: 16px; }
.project-card__link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.project-card__link:focus-visible { outline: none; }
.project-card__link:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 2px; }
.project-card__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.project-card__desc { color: var(--text-muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-card__meta { display: flex; gap: var(--space-4); margin: 0; font-size: 13px; color: var(--text-muted); flex-wrap: wrap; }
.project-card__meta dd { margin: 0; display: inline-flex; gap: 6px; align-items: center; }
.project-card__meta .icon { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ project layout */
.project { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100dvh; }
.project__side { position: sticky; top: 0; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4) var(--space-3); border-right: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 55%, var(--bg)); }
.project__head { display: flex; align-items: center; gap: var(--space-2); min-height: 36px; }
.project__back { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm); color: var(--text-muted); }
.project__back:hover { background: var(--surface-2); color: var(--text); }
.project__name { font-size: 16px; font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project__name a { color: var(--text); text-decoration: none; }
.project__main { min-width: 0; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; background: var(--surface-2); border-radius: var(--radius); }
.tabs__item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 7px; font-size: 12px; font-weight: 550; color: var(--text-muted); text-decoration: none; }
.tabs__item:hover { color: var(--text); }
.tabs__item[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.side-heading { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: var(--space-2) var(--space-2) 0; }
.side-empty { font-size: 14px; color: var(--text-muted); padding: 0 var(--space-2); }
.chat-list { list-style: none; display: grid; gap: 2px; }
.chat-list__item { display: flex; gap: var(--space-3); align-items: center; padding: 8px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.chat-list__item:hover { background: var(--surface-2); color: var(--text); }
.chat-list__item[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }
.chat-list__text { display: grid; min-width: 0; line-height: 1.35; }
.chat-list__title { font-weight: 550; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list__meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; }

/* ------------------------------------------------------------------ files */
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; font-size: 14px; margin-top: var(--space-1); }
.crumbs li + li::before { content: "/"; color: var(--text-muted); margin-right: 4px; }
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs [aria-current="page"] { color: var(--text); font-weight: 600; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 10px var(--space-4); border-bottom: 1px solid var(--border); }
.table td { padding: 0 var(--space-4); border-bottom: 1px solid var(--border); height: 44px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.file-link { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text); text-decoration: none; font-weight: 500; min-height: 44px; }
.file-link:hover { color: var(--accent); }
.file-link .icon { color: var(--text-muted); }
.file-link .icon--folder { color: var(--accent); }
.code-view { margin: 0; padding: var(--space-4) 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; font-size: 13px; line-height: 1.6; counter-reset: line; max-height: calc(100dvh - 200px); }
.code-line { counter-increment: line; }
.code-line::before { content: counter(line); display: inline-block; width: 4.5em; padding-right: 1.25em; text-align: right; color: var(--text-muted); opacity: .6; user-select: none; }
.dropzone { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-6) var(--space-4); border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); text-align: center; cursor: pointer; color: var(--text-muted); transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { border-color: var(--accent); }
.dropzone .icon { width: 28px; height: 28px; color: var(--accent); }
.dropzone strong { color: var(--accent); }
.dropzone__input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone__names { font-size: 13px; color: var(--text); }

/* ------------------------------------------------------------------ credentials */
.cred-list { list-style: none; display: grid; gap: var(--space-3); }
.cred { display: flex; gap: var(--space-4); align-items: flex-start; padding: var(--space-4) var(--space-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.cred--off { opacity: .65; }
.cred__icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; flex: none; background: var(--surface-3); color: var(--text-muted); }
.cred__icon--github { background: #24292f; color: #fff; }
.cred__icon--coolify { background: #6b16ed; color: #fff; }
.cred__icon--anthropic { background: var(--claude-soft); color: var(--claude); }
.cred__icon--openai, .cred__icon--codex_chatgpt { background: var(--codex-soft); color: var(--codex); }
.cred__main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.cred__name { font-weight: 650; }
.cred__kind { font-size: 13px; color: var(--text-muted); }
.cred__vars { display: flex; flex-wrap: wrap; gap: 6px; }
.cred__vars code { font-size: 12px; }
.cred__warn { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--warning); }
.cred__warn .icon { width: 15px; height: 15px; }
.cred__actions { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.kind-list { list-style: none; display: grid; gap: var(--space-2); }
.kind { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.kind > span:not(.cred__icon) { flex: 1; display: grid; line-height: 1.35; }
.kind small { color: var(--text-muted); }
.kind:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.kind > .icon { color: var(--text-muted); }

/* ------------------------------------------------------------------ chat */
.is-chat .project__main { height: 100dvh; }
.chat { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); height: 100dvh; }
.chat__header { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); }
.chat__back { display: none; }
@media (max-width: 900px) { .chat__back { display: inline-flex; } }
.chat__heading { display: flex; gap: var(--space-3); align-items: center; min-width: 0; }
.chat__titles { min-width: 0; }
.chat__title { font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__sub { font-size: 13px; color: var(--text-muted); }
.chat__sub [data-connection].is-offline { color: var(--danger); font-weight: 600; }
.chat__tools { display: flex; align-items: center; gap: var(--space-2); }
.chat__scroll { overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.chat__log { max-width: 860px; margin: 0 auto; padding: var(--space-5) var(--space-5) var(--space-6); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
.chat__empty { display: grid; justify-items: center; text-align: center; gap: var(--space-3); padding: var(--space-7) var(--space-4); color: var(--text-muted); }
.chat__empty h2 { color: var(--text); font-size: 20px; }
.chat__empty p { max-width: 52ch; }
.jump { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); box-shadow: var(--shadow); border-radius: 999px; z-index: 5; }

.msg { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-3); align-items: start; animation: msg-in .2s var(--ease); }
@keyframes msg-in { from { opacity: 0; transform: translateY(4px); } }
.msg__content { min-width: 0; display: grid; gap: 6px; }
.msg__head { display: flex; align-items: baseline; gap: var(--space-2); }
.msg__author { font-weight: 650; font-size: 14px; }
.msg__time { font-size: 12px; color: var(--text-muted); }
.msg__text { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg--user .msg__text { background: var(--surface); border: 1px solid var(--border); padding: 10px 14px; border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg); justify-self: start; max-width: 100%; }
.msg--user.is-mine .msg__text { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.msg--system { display: flex; justify-content: center; align-items: center; gap: var(--space-2); font-size: 13px; color: var(--text-muted); grid-template-columns: none; }
.msg--system .icon { width: 15px; height: 15px; }
.msg__parts { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
.msg__note { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.msg__note .icon { width: 13px; height: 13px; }
.working { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 13px; color: var(--text-muted); }
.working__dots { display: inline-flex; gap: 3px; }
.working__dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite ease-in-out; }
.working__dots span:nth-child(2) { animation-delay: .15s; }
.working__dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

.tool { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 13px; }
.tool--error { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.tool__summary { display: flex; align-items: center; gap: var(--space-2); padding: 7px 10px; cursor: pointer; list-style: none; min-height: 36px; border-radius: var(--radius); }
.tool__summary::-webkit-details-marker { display: none; }
.tool__summary:hover { background: var(--surface-2); }
.tool__summary .icon { width: 15px; height: 15px; color: var(--text-muted); }
.tool__state { display: grid; place-items: center; width: 16px; }
.tool__state .icon { color: var(--success); }
.tool--error .tool__state .icon { color: var(--danger); }
.tool__name { font-weight: 600; }
.tool__arg { background: none; border: 0; padding: 0; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.tool__body { border-top: 1px solid var(--border); padding: var(--space-2) var(--space-3) var(--space-3); display: grid; gap: 4px; }
.tool__label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--text-muted); margin-top: 4px; }
.tool__pre { margin: 0; padding: var(--space-2) var(--space-3); background: var(--surface-2); border-radius: var(--radius-sm); white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; font-size: 12px; }
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.composer { padding: var(--space-3) var(--space-5) var(--space-4); max-width: 860px; width: 100%; margin: 0 auto; }
.composer__box { display: flex; align-items: flex-end; gap: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.composer__box:focus-within { border-color: var(--accent); box-shadow: var(--shadow), 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.composer__input { flex: 1; min-height: 40px; max-height: 40vh; padding: 9px 0; border: 0; background: none; color: var(--text); font: inherit; resize: none; outline: none; line-height: 1.5; }
.composer__actions { display: flex; align-items: center; gap: var(--space-2); }
.composer__hint { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 6px; min-height: 18px; }

/* markdown from agents */
.prose { overflow-wrap: anywhere; }
.prose > * + * { margin-top: .7em; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin-top: 1.1em; font-size: 1.05em; }
.prose h1 { font-size: 1.3em; } .prose h2 { font-size: 1.15em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: .25em; }
.prose pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); overflow-x: auto; font-size: 13px; line-height: 1.5; }
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.prose blockquote { margin-left: 0; padding-left: var(--space-4); border-left: 3px solid var(--border-strong); color: var(--text-muted); }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 14px; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.prose th { background: var(--surface-2); }
.prose hr { border: 0; border-top: 1px solid var(--border); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  :root { --side-w: 248px; }
  .grid-2--wide { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .topbar { display: flex; align-items: center; gap: var(--space-2); position: sticky; top: 0; z-index: 30; height: 56px; padding: 0 var(--space-3); background: var(--surface); border-bottom: 1px solid var(--border); }
  .nav { position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(300px, 85vw); transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
  .app.nav-open .nav { transform: none; }
  .app.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgb(10 10 15 / .45); }
  .page { padding: var(--space-5) var(--space-4) var(--space-6); }
  .project { grid-template-columns: minmax(0, 1fr); min-height: calc(100dvh - 56px); }
  .project__side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .is-chat .project__side { display: none; }
  .is-chat .project__main, .chat { height: calc(100dvh - 56px); }
  .chat__header { padding: var(--space-2) var(--space-4); }
  .chat__log { padding: var(--space-4); }
  .composer { padding: var(--space-2) var(--space-3) var(--space-3); }
  .kv > div { grid-template-columns: 1fr; gap: 0; }
  .hide-sm { display: none; }
  .cred { flex-wrap: wrap; padding: var(--space-4); }
  .cred__actions { width: 100%; justify-content: flex-start; }
}
@media (hover: none) {
  .composer__hint { display: none; }
}
