/* Design system: Minimalism & Swiss style, AI purple (ui-ux-pro-max "AI/Chatbot Platform"). */
:root {
  --color-bg: #faf7ff;
  --color-side: #f3eefc;
  --color-card: #ffffff;
  --color-fg: #1e1b4b;
  --color-muted: #ece8f9;
  --color-muted-fg: #475569;
  --color-border: #ddd6fe;
  --color-primary: #7c3aed;
  --color-on-primary: #ffffff;
  --color-primary-soft: #ede9fe;
  --color-accent: #0e7490;
  --color-destructive: #dc2626;
  --color-on-destructive: #ffffff;
  --color-ring: #7c3aed;
  --color-user: #ede9fe;
  --color-code: #f4f1fb;
  --color-scrim: rgb(30 27 75 / 0.35);
  --shadow-1: 0 1px 2px rgb(30 27 75 / 0.06);
  --shadow-2: 0 12px 32px rgb(30 27 75 / 0.16);

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-12: 48px;
  --radius-sm: 8px; --radius: 12px; --radius-lg: 16px;
  --text-xs: 12px; --text-sm: 14px; --text-base: 16px; --text-lg: 18px; --text-2xl: 28px;
  --dur-fast: 150ms; --dur: 220ms; --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --z-scrim: 30; --z-sidebar: 40; --z-toast: 100;

  font-family: "Inter Variable", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
/* Dark tokens apply when <html data-theme="dark">, set in the page head from your choice
   (Auto follows the system). */
:root[data-theme="dark"] {
  & {
    --color-bg: #0e0d16;
    --color-side: #131221;
    --color-card: #1a1830;
    --color-fg: #edebfa;
    --color-muted: #221f3a;
    --color-muted-fg: #a6a3c4;
    --color-border: #2c2947;
    --color-primary: #a78bfa;
    --color-on-primary: #1e1b4b;
    --color-primary-soft: #2a2550;
    --color-accent: #22d3ee;
    --color-destructive: #f87171;
    --color-on-destructive: #1e1b4b;
    --color-ring: #a78bfa;
    --color-user: #2a2550;
    --color-code: #221f3a;
    --color-scrim: rgb(0 0 0 / 0.55);
    --shadow-1: none;
    --shadow-2: 0 12px 40px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  height: 100dvh;
  display: flex;
  background: var(--color-bg);
  color: var(--color-fg);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { text-wrap: balance; }

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; left: var(--space-4); top: -60px; z-index: var(--z-toast);
  background: var(--color-primary); color: var(--color-on-primary);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm);
}
.skip-link:focus { top: var(--space-4); }

/* ---------- buttons ---------- */
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
:where(button, a, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  font-weight: 500;
  font-size: var(--text-sm);
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.btn-primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { border-color: var(--color-border); background: var(--color-card); box-shadow: var(--shadow-1); }
.btn-outline:hover { border-color: var(--color-primary); }
.btn-ghost:hover { background: var(--color-muted); }
.btn-ghost.active { background: var(--color-primary-soft); font-weight: 600; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted-fg);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--color-muted); color: var(--color-fg); }
.mobile-only { display: none; }
.open-sidebar { display: inline-grid; } /* ☰: opens the list on phones, hides/shows it on PC */
@media (min-width: 768px) {
  body.side-collapsed #sidebar { display: none; }
}

/* ---------- sidebar ---------- */
#sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--color-side);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-3);
  gap: var(--space-2);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 650;
  font-size: var(--text-lg);
  padding: var(--space-1) var(--space-2) var(--space-2);
  letter-spacing: -0.01em;
}
.brand > span { flex: 1; }
.brand-mark { color: var(--color-primary); width: 22px; height: 22px; }
#newChat { justify-content: center; }
.side-label {
  margin: var(--space-3) var(--space-2) 0;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted-fg);
}
#convList {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.conv {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: background-color var(--dur-fast) var(--ease-out);
}
.conv:hover { background: var(--color-muted); }
.conv.active { background: var(--color-primary-soft); }
.conv-open {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
  border: 0;
  background: transparent;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}
.conv-open .title {
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv.active .title { font-weight: 600; }
.conv-open .agent { font-size: var(--text-xs); color: var(--color-muted-fg); }
.conv .icon-btn { width: 36px; height: 36px; opacity: 0; }
.conv:hover .icon-btn, .conv:focus-within .icon-btn, .conv.active .icon-btn { opacity: 1; }
.conv .icon-btn:hover { color: var(--color-destructive); }
.empty-list { font-size: var(--text-sm); color: var(--color-muted-fg); padding: var(--space-2) var(--space-3); }
.side-bottom {
  display: flex;
  gap: var(--space-2);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-3);
}
.side-bottom .btn { flex: 1; justify-content: center; }
#scrim { position: fixed; inset: 0; background: var(--color-scrim); z-index: var(--z-scrim); }

/* ---------- header ---------- */
main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 60px;
  padding: var(--space-2) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}
header h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-pick { display: flex; align-items: center; gap: var(--space-2); color: var(--color-muted-fg); font-size: var(--text-sm); }
select {
  font: inherit;
  font-size: var(--text-sm);
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-fg);
  max-width: 240px;
  cursor: pointer;
}

/* ---------- messages ---------- */
#messages { flex: 1; overflow-y: auto; padding: var(--space-8) var(--space-6); outline: none; }
#messages > * { max-width: 760px; margin-inline: auto; }
#welcome { text-align: center; padding-top: 5vh; }
.welcome-mark { width: 40px; height: 40px; color: var(--color-primary); }
#welcome h2 { font-size: var(--text-2xl); font-weight: 650; letter-spacing: -0.02em; margin: var(--space-3) 0 var(--space-2); }
#welcome p { color: var(--color-muted-fg); max-width: 540px; margin: 0 auto var(--space-8); }
.starters { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); text-align: left; }
.starters button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 2px;
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.starters button:hover { border-color: var(--color-primary); }
.starters button:active { transform: scale(0.98); }
.starters b { font-weight: 600; font-size: var(--text-sm); }
.starters .sub { color: var(--color-muted-fg); font-size: var(--text-sm); }
.tile {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.msg { margin-bottom: var(--space-6); }
.msg .who {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-muted-fg);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.msg.assistant .who .icon { width: 16px; height: 16px; color: var(--color-primary); }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble {
  background: var(--color-user);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 85%;
}
.msg.assistant .bubble { overflow-wrap: anywhere; }
.bubble p:first-child { margin-top: 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble pre { background: var(--color-code); padding: var(--space-3); border-radius: var(--radius-sm); overflow-x: auto; }
.bubble code { background: var(--color-code); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.bubble pre code { padding: 0; background: none; }
.bubble pre { position: relative; padding-top: var(--space-8); }
.copy-btn {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-card);
  color: var(--color-muted-fg);
  font-size: var(--text-xs);
}
.copy-btn .icon { width: 13px; height: 13px; }
.copy-btn:hover { color: var(--color-fg); border-color: var(--color-primary); }
.bubble table { border-collapse: collapse; margin: var(--space-3) 0; display: block; overflow-x: auto; font-variant-numeric: tabular-nums; }
.bubble th, .bubble td { border: 1px solid var(--color-border); padding: var(--space-2) var(--space-3); text-align: left; }
.bubble th { background: var(--color-muted); font-weight: 600; }
.bubble a { color: var(--color-primary); text-underline-offset: 2px; }
.bubble blockquote { border-left: 3px solid var(--color-border); margin: 0; padding-left: var(--space-3); color: var(--color-muted-fg); }

/* tool activity */
.tools { margin-bottom: var(--space-3); }
.tools:empty { display: none; }
.tools summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 32px;
  font-size: var(--text-sm);
  color: var(--color-muted-fg);
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-sm);
  padding: 0 var(--space-2) 0 0;
}
.tools summary::-webkit-details-marker { display: none; }
.tools summary .icon { width: 16px; height: 16px; transition: transform var(--dur-fast) var(--ease-out); }
.tools[open] summary .icon { transform: rotate(90deg); }
.tools summary:hover { color: var(--color-fg); }
.tool-list { display: flex; flex-direction: column; gap: var(--space-1); margin-top: var(--space-1); padding-left: var(--space-2); border-left: 2px solid var(--color-border); }
.tool {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-muted-fg);
  padding: 2px var(--space-2);
  min-width: 0;
}
.tool .icon { width: 15px; height: 15px; color: var(--color-primary); }
.tool.sub { padding-left: var(--space-6); }
.tool.sub .icon { color: var(--color-accent); }
.tool span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thinking { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--color-muted-fg); font-size: var(--text-sm); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--color-primary); animation: pulse 1.2s var(--ease-out) infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.meta { font-size: var(--text-xs); color: var(--color-muted-fg); margin-top: var(--space-2); font-variant-numeric: tabular-nums; }
.error {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-destructive);
  color: var(--color-fg);
  font-size: var(--text-sm);
  white-space: pre-wrap;
}
.error .icon { color: var(--color-destructive); margin-top: 2px; }

/* ---------- composer ---------- */
#composer { padding: var(--space-3) var(--space-6) var(--space-4); }
.composer-box {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-card);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur-fast) var(--ease-out);
}
.composer-box:focus-within { border-color: var(--color-primary); }
#input {
  flex: 1;
  font: inherit;
  resize: none;
  max-height: 220px;
  min-height: 40px;
  padding: var(--space-2) var(--space-2);
  border: 0;
  background: transparent;
  color: var(--color-fg);
  outline: none;
}
#input::placeholder { color: var(--color-muted-fg); }
.send-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--color-on-primary);
  transition: filter var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
}
.send-btn:hover { filter: brightness(1.08); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
.send-btn.stop { background: var(--color-destructive); color: var(--color-on-destructive); }
.composer-hint { max-width: 760px; margin: var(--space-2) auto 0; font-size: var(--text-xs); color: var(--color-muted-fg); text-align: center; }

/* ---------- dialogs & toast ---------- */
dialog {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-card);
  color: var(--color-fg);
  width: min(680px, calc(100vw - 32px));
  padding: 0;
  box-shadow: var(--shadow-2);
}
dialog::backdrop { background: var(--color-scrim); }
.dialog-body { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-3); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: var(--text-lg); font-weight: 650; }
.hint { color: var(--color-muted-fg); margin: 0; font-size: var(--text-sm); }
#memoryText {
  width: 100%;
  min-height: 320px;
  font-family: Consolas, ui-monospace, monospace;
  font-size: var(--text-sm);
  line-height: 1.6;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-fg);
  resize: vertical;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }
.phone-steps { margin: 0; padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
.phone-steps code { overflow-wrap: anywhere; }
.login-code { font-size: var(--text-lg); font-weight: 600; letter-spacing: 0.12em; padding: 2px 8px; }
#phoneUrl a { color: var(--color-primary); overflow-wrap: anywhere; }
#teamList { display: flex; flex-direction: column; gap: var(--space-2); max-height: 60vh; overflow-y: auto; padding: 2px; }
.member {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: transparent;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.member:hover { border-color: var(--color-primary); }
.member .src { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-primary); }
.member b { font-size: var(--text-sm); font-weight: 600; }
.member .desc { color: var(--color-muted-fg); font-size: var(--text-sm); }

#toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-8);
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  background: var(--color-fg);
  color: var(--color-bg);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-2);
}

/* ---------- team page ---------- */
:root {
  --font-display: "Instrument Serif", Georgia, serif;
  --g-orchestrator: #7c3aed; --g-lead: #b45309; --g-design: #be185d; --g-build: #1d4ed8;
  --g-quality-gate: #0f766e; --g-ship: #15803d; --g-research: #c2410c; --g-helper: #4d7c0f;
}
:root[data-theme="dark"] {
  & {
    --g-orchestrator: #a78bfa; --g-lead: #fbbf24; --g-design: #f472b6; --g-build: #60a5fa;
    --g-quality-gate: #2dd4bf; --g-ship: #4ade80; --g-research: #fb923c; --g-helper: #a3e635;
  }
}
#teamView header h1 { flex: 0 1 auto; }
.tabs { margin-left: auto; display: flex; gap: 2px; padding: 3px; border-radius: var(--radius); background: var(--color-muted); }
.tabs button {
  border: 0;
  background: transparent;
  min-height: 34px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-muted-fg);
}
.tabs button[aria-selected="true"] { background: var(--color-card); color: var(--color-fg); box-shadow: var(--shadow-1); }
.team-scroll { flex: 1; overflow-y: auto; padding: var(--space-8) var(--space-6) var(--space-12); }
.team-scroll > * { max-width: 1120px; margin-inline: auto; }
.team-hero { text-align: center; margin-bottom: var(--space-8); }
.eyebrow {
  margin: 0 0 var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted-fg);
}
.display {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(36px, 6vw, 64px);
  line-height: 1.04;
  letter-spacing: -0.01em;
  margin: 0;
}
.display em { color: var(--color-primary); }
.stats { margin: var(--space-5) 0 0; color: var(--color-muted-fg); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.stats b { color: var(--color-fg); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-bottom: var(--space-6); }
.filters button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 0 var(--space-3);
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  font-size: var(--text-sm);
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.filters button::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--g, var(--color-muted-fg)); }
.filters button[data-group=""]::before { display: none; }
.filters button[aria-pressed="true"] { border-color: var(--color-fg); background: var(--color-fg); color: var(--color-bg); }
.filters button:hover { border-color: var(--color-primary); }

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}
.cards li { perspective: 1200px; }
.card {
  position: relative;
  aspect-ratio: 3 / 4;
  transform-style: preserve-3d;
  transition: transform 520ms var(--ease-out);
}
.card.flipped { transform: rotateY(180deg); }
.face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  box-shadow: 0 10px 30px rgb(15 13 30 / 0.22);
  /* iPhone Safari still draws some text of the hidden side (mirrored) and lets it catch taps,
     so the hidden side is also switched off halfway through the turn. */
  transition: visibility 0s linear 260ms;
}
.face.back { transform: rotateY(180deg); }
.card.flipped .front, .card:not(.flipped) .back { visibility: hidden; }
.front {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  text-align: left;
  color: #fff;
  background: #1a1726;
}
.front img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 400ms var(--ease-out); }
.tile-art { position: absolute; inset: 0; overflow: hidden; transition: transform 400ms var(--ease-out); }
.front .tile-art img, .avatar .tile-art img {
  position: absolute;
  inset: auto;
  height: auto;
  max-width: none;
  object-fit: fill;
  transform: none;
}
.front:hover > img, .front:hover .tile-art { transform: scale(1.04); }
.avatar { position: relative; }
.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 80% at 30% 20%, color-mix(in srgb, var(--g) 70%, transparent) 0%, transparent 60%),
    radial-gradient(90% 70% at 80% 90%, color-mix(in srgb, var(--g) 55%, #000) 0%, transparent 70%),
    linear-gradient(160deg, color-mix(in srgb, var(--g) 45%, #1a1726), #120f1c);
}
.placeholder span { font-family: var(--font-display); font-size: 120px; line-height: 1; color: rgb(255 255 255 / 0.85); text-shadow: 0 6px 30px rgb(0 0 0 / 0.35); }
.front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgb(0 0 0 / 0.45) 0%, transparent 26%, transparent 52%, rgb(10 8 20 / 0.88) 100%);
}
.card-top, .card-bottom { position: absolute; left: var(--space-3); right: var(--space-3); z-index: 1; }
.card-top { top: var(--space-3); display: flex; justify-content: space-between; align-items: center; font-size: 11px; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.card-top > span:first-child { white-space: nowrap; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.45);
  backdrop-filter: blur(4px);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--g); }
.card-bottom { bottom: var(--space-3); }
.card-bottom .nm { display: block; font-family: var(--font-display); font-size: 34px; line-height: 1; }
.card-bottom .rl { display: block; margin-top: var(--space-1); font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.85; }

.back {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--g);
}
.back .tag { align-self: flex-start; background: var(--color-muted); color: var(--color-fg); backdrop-filter: none; }
.back h3 { margin: var(--space-1) 0 0; font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1; }
.back .rl { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-muted-fg); }
.back .persona {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  flex-shrink: 0;
}
.chips { display: flex; flex-wrap: wrap; gap: 4px; overflow: hidden; max-height: 46px; flex-shrink: 0; }
.chips span { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--color-primary-soft); color: var(--color-fg); }
.back .actions { margin-top: auto; display: flex; gap: var(--space-2); }
.back .actions .btn { flex: 1; justify-content: center; min-height: 36px; padding: 0 var(--space-2); }
/* Two cards per row on a phone leaves no room for "Chat with Claude" on one line. */
@media (max-width: 480px) { .back .chat .who { display: none; } }
.portrait-hint { text-align: center; color: var(--color-muted-fg); font-size: var(--text-sm); margin-top: var(--space-6); }

/* pipeline flow */
#flow { display: flex; flex-direction: column; gap: var(--space-4); }
.flow-entry { display: flex; align-items: center; justify-content: center; gap: var(--space-3); flex-wrap: wrap; }
.lane {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: color-mix(in srgb, var(--color-card) 60%, transparent);
}
.lane-head { display: flex; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-3); }
.lane-head h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 24px; }
.lane-head p { margin: 0; color: var(--color-muted-fg); font-size: var(--text-sm); }
.steps { display: flex; align-items: stretch; gap: var(--space-2); overflow-x: auto; padding-bottom: var(--space-1); }
.step { display: flex; flex-direction: column; gap: var(--space-2); flex: 1 1 0; min-width: 118px; }
.step-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-muted-fg); }
.arrow { align-self: center; color: var(--color-muted-fg); flex-shrink: 0; padding-top: 18px; }
.arrow .icon { width: 14px; height: 14px; }
.node {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--g, var(--color-border));
  background: var(--color-card);
  text-align: left;
  transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
button.node:hover { border-color: var(--color-primary); }
button.node:active { transform: scale(0.98); }
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 22px;
  color: #fff;
  background: linear-gradient(160deg, color-mix(in srgb, var(--g, #7c3aed) 75%, #1a1726), #1a1726);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.node b { display: block; font-size: var(--text-sm); }
.node small { display: block; font-size: 11px; color: var(--color-muted-fg); }
.node.output { border-style: dashed; border-left-style: solid; color: var(--color-muted-fg); font-size: var(--text-sm); padding: var(--space-3); }
.node.you { border-left-color: var(--color-fg); }

/* agent name in chat */
.who .avatar { width: 22px; height: 22px; border-radius: 6px; font-size: 13px; }

/* ---------- briefings ---------- */
.side-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1); }
.briefings { max-width: 760px; display: flex; flex-direction: column; gap: var(--space-6); }
.panel, .brief {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-card);
  padding: var(--space-5);
  box-shadow: var(--shadow-1);
}
.panel-head { display: flex; align-items: center; gap: var(--space-2); }
.panel-head .icon { color: var(--color-primary); }
.panel h2, .section-head h2 { margin: 0; font-size: var(--text-lg); font-weight: 650; }
.panel .hint { margin: var(--space-2) 0 var(--space-4); }
.panel-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.section-head .hint { margin-top: var(--space-1); max-width: 480px; }
#briefingList { display: flex; flex-direction: column; gap: var(--space-4); }
.brief { display: flex; flex-direction: column; gap: var(--space-4); }
.brief.off { opacity: 0.65; }
.brief-head { display: flex; align-items: center; gap: var(--space-3); }
.brief-head .avatar { width: 44px; height: 44px; border-radius: 12px; font-size: 24px; }
.brief-head input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: var(--text-lg);
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  background: transparent;
  color: var(--color-fg);
}
.brief-head input:hover { border-color: var(--color-border); }
.switch { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-muted-fg); cursor: pointer; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--color-border); position: relative; cursor: pointer; transition: background-color var(--dur-fast) var(--ease-out); margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform var(--dur-fast) var(--ease-out); box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); }
.switch input:checked { background: var(--color-primary); }
.switch input:checked::after { transform: translateX(18px); }
.brief-row { display: grid; grid-template-columns: 1fr auto; gap: var(--space-3); }
.field { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-sm); font-weight: 600; }
.field select, .field input, .field textarea {
  font: inherit;
  font-weight: 400;
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-fg);
  max-width: none;
}
.field textarea { resize: vertical; line-height: 1.5; }
.days { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.days button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: transparent;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-muted-fg);
}
.days button[aria-pressed="true"] { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
.brief-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.brief-foot .hint { margin: 0; }
.brief-foot .actions { display: flex; gap: var(--space-2); }
.btn-danger-ghost { color: var(--color-destructive); }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--color-destructive) 10%, transparent); }

/* ---------- search, live status, reports, working now ---------- */
.search-box {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  min-height: 40px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-card);
  color: var(--color-muted-fg);
}
.search-box:focus-within { border-color: var(--color-primary); }
.search-box input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: var(--text-sm); color: var(--color-fg); outline: none; }
.conv-open .snippet { font-size: var(--text-xs); color: var(--color-muted-fg); white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.conv-open mark { background: var(--color-primary-soft); color: inherit; border-radius: 3px; padding: 0 2px; }

.live { margin-bottom: var(--space-2); }
.live span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch; }

.working {
  margin: var(--space-5) auto 0;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  text-align: left;
}
.working a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--g, var(--color-primary));
  border-radius: var(--radius);
  background: var(--color-card);
  color: inherit;
  text-decoration: none;
}
.working a:hover { border-color: var(--color-primary); }
.working .who-line { flex: 1; min-width: 0; font-size: var(--text-sm); }
.working .who-line b { font-weight: 600; }
.working .who-line small { display: block; color: var(--color-muted-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.working .secs { font-size: var(--text-xs); color: var(--color-muted-fg); font-variant-numeric: tabular-nums; }
.card .busy {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.reports { max-width: 820px; }
#reportList { display: flex; flex-direction: column; gap: var(--space-2); }
.report-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
  color: inherit;
  text-decoration: none;
}
.report-item:hover { border-color: var(--color-primary); }
.report-item .icon { color: var(--color-primary); }
.report-item span { flex: 1; min-width: 0; }
.report-item b { display: block; font-weight: 600; }
.report-item small { color: var(--color-muted-fg); font-size: var(--text-xs); }
.back-link { margin-bottom: var(--space-4); text-decoration: none; color: var(--color-fg); }
.report-body {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-card);
  padding: var(--space-6);
}

/* ---------- small screens ---------- */
@media (max-width: 767px) {
  .mobile-only { display: inline-grid; }
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: var(--z-sidebar);
    width: min(300px, 85vw);
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease-out);
  }
  body.side-open #sidebar { transform: none; box-shadow: var(--shadow-2); }
  .conv .icon-btn { opacity: 1; }
  header { padding: var(--space-2) var(--space-4); }
  #messages { padding: var(--space-6) var(--space-4); }
  #composer { padding: var(--space-2) var(--space-4) var(--space-3); }
  .composer-hint { display: none; }
  .agent-pick span { display: none; }
  select { max-width: 150px; }
  #welcome h2 { font-size: 24px; }
  .team-scroll { padding: var(--space-6) var(--space-4) var(--space-12); }
  .cards { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .card-bottom .nm { font-size: 26px; }
  .placeholder span { font-size: 80px; }
  .back { padding: var(--space-3); gap: var(--space-1); }
  .back h3 { font-size: 24px; }
  .back .persona { font-size: 15px; -webkit-line-clamp: 4; }
  .chips { display: none; }
  .tabs button { padding: 0 var(--space-2); }
  .steps { flex-direction: column; }
  .arrow { transform: rotate(90deg); padding-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
}

/* ---------- installed app on phones: notch, home bar, no zoom-on-focus ---------- */
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
header { padding-top: max(var(--space-2), env(safe-area-inset-top)); padding-left: max(var(--space-4), env(safe-area-inset-left)); padding-right: max(var(--space-4), env(safe-area-inset-right)); }
#composer { padding-bottom: max(var(--space-3), env(safe-area-inset-bottom)); }
#sidebar { padding-top: max(var(--space-4), env(safe-area-inset-top)); padding-bottom: max(var(--space-4), env(safe-area-inset-bottom)); }
.team-scroll { padding-bottom: max(var(--space-12), env(safe-area-inset-bottom)); }
@media (max-width: 767px) {
  select, #input, #memoryText { font-size: 16px; }
  .side-bottom .btn { padding: var(--space-2); font-size: 13px; }
}

/* ---------- motion & finish ---------- */
:root { --ease-spring: cubic-bezier(0.34, 1.3, 0.64, 1); }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes float { 50% { transform: translateY(-4px) rotate(8deg); } }

/* Pages ease in when you switch between Chat, Team, Briefings and Reports. */
#chatView, #teamView, #briefingsView, #reportsView { animation: fade-in 240ms var(--ease-out) both; }
#welcome { animation: fade-up 420ms var(--ease-out) both; }
.welcome-mark { animation: float 5s ease-in-out infinite; filter: drop-shadow(0 4px 18px color-mix(in srgb, var(--color-primary) 55%, transparent)); }
#welcome::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: min(560px, 90vw);
  height: 260px;
  translate: -50% -30%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--color-primary) 18%, transparent), transparent);
  pointer-events: none;
  z-index: -1;
}
#welcome { position: relative; isolation: isolate; }
.starters button { animation: fade-up 420ms var(--ease-out) both; }
.starters button:nth-child(2) { animation-delay: 40ms; }
.starters button:nth-child(3) { animation-delay: 80ms; }
.starters button:nth-child(4) { animation-delay: 120ms; }
.starters button:nth-child(5) { animation-delay: 160ms; }
.starters button:nth-child(6) { animation-delay: 200ms; }
.starters button { transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out); }
@media (hover: hover) {
  .starters button:hover { transform: translateY(-2px); box-shadow: 0 10px 24px color-mix(in srgb, var(--color-primary) 16%, transparent); }
}

/* New messages slide in; old ones from history just appear. */
.msg.enter { animation: fade-up 320ms var(--ease-out) both; }

/* Everything you press gives a little squeeze. */
.btn, .icon-btn, .conv-open, .filters button, .tabs button { transition-property: background-color, border-color, color, transform, filter, opacity; transition-duration: var(--dur-fast); transition-timing-function: var(--ease-out); }
.btn:active, .icon-btn:active, .filters button:active, .tabs button:active { transform: scale(0.96); }
.conv-open:active { transform: scale(0.98); }

/* Message box glows softly while you type. */
.composer-box { transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur) var(--ease-out); }
.composer-box:focus-within { box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary) 18%, transparent); }

/* Team cards arrive one after another. */
.cards li { animation: fade-up 460ms var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 12) * 35ms); }
.card { transition-timing-function: var(--ease-spring); transition-duration: 620ms; }
@media (hover: hover) {
  .front { transition: visibility 0s linear 260ms, box-shadow var(--dur) var(--ease-out), translate var(--dur) var(--ease-out); }
  .card:not(.flipped) .front:hover { translate: 0 -3px; box-shadow: 0 18px 40px rgb(15 13 30 / 0.32); }
}

/* Lists, dialogs, the sidebar backdrop and the toast fade in instead of popping. */
.report-item, .briefing, .lane { animation: fade-up 360ms var(--ease-out) both; }
dialog[open] { animation: pop-in 260ms var(--ease-spring) both; }
dialog[open]::backdrop { animation: fade-in 200ms var(--ease-out) both; backdrop-filter: blur(3px); }
#scrim:not([hidden]) { animation: fade-in 200ms var(--ease-out) both; backdrop-filter: blur(2px); }
#toast:not([hidden]) { animation: pop-in 280ms var(--ease-spring) both; }

/* Thin, quiet scrollbars. */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--color-muted-fg) 35%, transparent) transparent; }

/* Light/dark switch fades instead of flashing. */
body, header { transition: background-color 300ms var(--ease-out), color 300ms var(--ease-out); }

@media (prefers-reduced-motion: reduce) {
  .welcome-mark { animation: none; }
  .cards li { animation-delay: 0ms; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .dots i { opacity: 1; }
}
