:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --background: #f7f7f8;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --popover: #ffffff;
  --popover-foreground: #09090b;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --accent: #f4f4f5;
  --accent-foreground: #18181b;
  --success: #16a34a;
  --info: #2563eb;
  --warning: #d97706;
  --destructive: #b91c1c;
  --destructive-foreground: #fef2f2;
  --border: #e4e4e7;
  --input: #d4d4d8;
  --ring: #18181b;
  --radius: 0.5rem;
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--ring) 22%, transparent);
  --avatar-size: 2rem;
  --density-1: 0.35rem;
  --density-2: 0.55rem;
  --density-3: 0.75rem;
  --density-4: 1rem;
  --shadow-sm: 0 1px 2px rgba(9, 9, 11, 0.04);
  --shadow-md: 0 10px 30px rgba(9, 9, 11, 0.08);
  background: var(--background);
  color: var(--foreground);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #09090b;
  --foreground: #fafafa;
  --card: #09090b;
  --card-foreground: #fafafa;
  --popover: #09090b;
  --popover-foreground: #fafafa;
  --primary: #fafafa;
  --primary-foreground: #18181b;
  --secondary: #27272a;
  --secondary-foreground: #fafafa;
  --muted: #18181b;
  --muted-foreground: #a1a1aa;
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --success: #22c55e;
  --info: #60a5fa;
  --warning: #f59e0b;
  --border: #27272a;
  --input: #3f3f46;
  --ring: #fafafa;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--background);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 2.25rem;
  border: 1px solid var(--primary);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.45rem 0.8rem;
  background: var(--primary);
  color: var(--primary-foreground);
  cursor: pointer;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: var(--shadow-sm);
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

button:hover {
  background: color-mix(in srgb, var(--primary) 90%, transparent);
}

:root[data-theme="dark"] button:hover {
  background: color-mix(in srgb, var(--primary) 88%, transparent);
}

.button-outline,
button[role="tab"],
.secondary-link {
  border-color: var(--border);
  background: var(--card);
  color: var(--foreground);
}

.button-outline:hover,
button[role="tab"]:hover,
.secondary-link:hover {
  background: var(--accent);
}

.button-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--foreground);
  box-shadow: none;
}

.button-ghost:hover {
  background: var(--accent);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.55rem 0.7rem;
  background: var(--card);
  color: var(--foreground);
  line-height: 1.35;
  box-shadow: none;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted-foreground);
  font-size: 0.9rem;
  font-weight: 500;
}

.app {
  min-height: 100vh;
}

grantt-app-shell,
grantt-chat-thread,
grantt-chat-message,
grantt-agent-avatar,
grantt-agent-presence,
grantt-login-panel,
grantt-setup-preview,
grantt-setup-error,
grantt-setup-panel,
grantt-mfa-panel,
grantt-error-panel,
grantt-governance-summary,
grantt-governance-workspace,
grantt-governance-route-panel,
grantt-invite-panel,
grantt-identity-panel,
grantt-org-tree,
grantt-saml-panel {
  display: block;
  min-width: 0;
}

.auth-panel {
  width: min(31rem, calc(100vw - 2rem));
  margin: 8vh auto;
  display: grid;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.auth-panel form {
  display: grid;
  gap: 0.85rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.16rem 0.5rem;
  background: var(--secondary);
  color: var(--secondary-foreground);
  overflow-wrap: anywhere;
  text-transform: none;
}

.tooltip-trigger {
  position: relative;
}

.tooltip {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.45rem);
  z-index: 20;
  width: max-content;
  max-width: min(16rem, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.45rem 0.55rem;
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-md);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.2rem);
  transition: opacity 120ms ease, transform 120ms ease;
}

.tooltip-trigger:hover .tooltip,
.tooltip-trigger:focus-visible .tooltip {
  opacity: 1;
  transform: translateY(0);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.65rem, 5vw, 2.25rem);
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
  line-height: 1.25;
}

.muted,
.presence {
  color: var(--muted-foreground);
}

.presence {
  margin: 0.15rem 0 0.85rem calc(var(--avatar-size) + 0.7rem);
  font-size: 0.78rem;
  line-height: 1.35;
}

.error {
  border: 1px solid #fecaca;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.75rem;
  background: #fff1f2;
  color: var(--destructive);
}

.status-row {
  display: grid;
  gap: 0.2rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.75rem;
  background: var(--muted);
  color: var(--foreground);
}

.status-row.success {
  border-color: #86efac;
  background: #f0fdf4;
  color: #14532d;
}

:root[data-theme="dark"] .status-row.success {
  border-color: #166534;
  background: #052e16;
  color: #dcfce7;
}

.qr-frame {
  width: fit-content;
  max-width: 100%;
  overflow: visible;
}

grantt-mfa-panel .auth-panel {
  width: fit-content;
  min-width: min(31rem, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
}

.qr {
  display: block;
  max-width: none;
  box-sizing: content-box;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0;
  background: var(--card);
  image-rendering: pixelated;
}

.secret {
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.65rem;
  background: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  background: var(--background);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem;
  background: var(--card);
  color: var(--foreground);
}

.sidebar-brand-block {
  margin: 0 0.5rem 1rem;
}

.sidebar-brand-block .brand {
  margin: 0 0 0.35rem;
}

.sidebar-tagline {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.3;
}

.sidebar-nav {
  align-content: start;
  display: grid;
  gap: 0.9rem;
}

.sidebar-footer {
  position: relative;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.sidebar-user-trigger {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.sidebar-user-trigger:hover {
  background: var(--accent);
}

.sidebar-user-avatar {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--primary);
  font-size: 0.65rem;
  font-weight: 650;
}

.sidebar-user-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.sidebar-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-email {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-email:empty {
  display: none;
}

.sidebar-user-chevron {
  flex-shrink: 0;
  width: 0.45rem;
  height: 0.45rem;
  margin-top: 2px;
  border-right: 2px solid var(--muted-foreground);
  border-bottom: 2px solid var(--muted-foreground);
  transform: rotate(45deg) translateY(-1px);
  opacity: 0.85;
}

.sidebar-user-menu {
  position: absolute;
  bottom: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  z-index: 11;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar-user-menu .button-outline {
  width: 100%;
  justify-content: start;
  margin: 0;
  text-align: left;
}

.sidebar-user-menu-sep {
  margin: 0.15rem 0;
  border: none;
  border-top: 1px solid var(--border);
}

.nav-toggle {
  display: none;
}

.nav-icon {
  position: relative;
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.nav-icon::before,
.nav-icon::after {
  position: absolute;
  left: 0.08rem;
  width: 0.84rem;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.nav-icon[data-state="menu"]::before {
  top: 0.28rem;
  box-shadow: 0 0.24rem 0 currentColor, 0 0.48rem 0 currentColor;
}

.nav-icon[data-state="menu"]::after {
  display: none;
}

.nav-icon[data-state="close"]::before,
.nav-icon[data-state="close"]::after {
  top: 0.48rem;
}

.nav-icon[data-state="close"]::before {
  transform: rotate(45deg);
}

.nav-icon[data-state="close"]::after {
  transform: rotate(-45deg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0.5rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 650;
}

.brand-mark {
  display: grid;
  width: 1.75rem;
  height: 1.75rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--foreground);
  color: var(--background);
  font-size: 0.8rem;
}

.sidebar-group,
.sidebar-group-content {
  display: grid;
  gap: 0.25rem;
}

.sidebar-group-label {
  margin: 0 0.2rem 0.25rem;
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 650;
}

nav a {
  display: grid;
  grid-template-columns: 1.35rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  border-radius: calc(var(--radius) - 2px);
  min-height: 2.25rem;
  padding: 0.48rem 0.55rem;
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

nav a:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

nav a[aria-current="page"] {
  background: var(--accent);
  color: var(--foreground);
}

.nav-item-icon {
  display: grid;
  width: 1.35rem;
  height: 1.35rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: color-mix(in srgb, var(--muted) 60%, transparent);
  font-size: 0.72rem;
  font-weight: 700;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  min-height: 4rem;
  padding: 0.75rem 1.25rem;
  background: color-mix(in srgb, var(--background) 92%, transparent);
  backdrop-filter: blur(10px);
}

:root[data-theme="dark"] .topbar {
  background: color-mix(in srgb, var(--background) 92%, transparent);
}

.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 650;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: end;
}

.online-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid color-mix(in srgb, var(--success) 34%, var(--border));
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  background: color-mix(in srgb, var(--success) 10%, transparent);
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 700;
}

.online-badge::before {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.account-menu {
  position: absolute;
  top: 4.4rem;
  right: 1.25rem;
  z-index: 10;
  min-width: 14rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-md);
}

.account-menu p {
  margin-bottom: 0.5rem;
  overflow-wrap: anywhere;
}

.account-menu button {
  width: 100%;
  justify-content: start;
  margin-top: 0.35rem;
  border-color: var(--border);
  background: var(--card);
  color: var(--foreground);
  text-align: left;
}

.content-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 25rem);
  gap: 1.25rem;
  padding: 1.25rem;
}

.route-grid {
  grid-template-columns: minmax(0, 1fr);
  overflow: auto;
}

.content-grid:has(.side-panel:empty) {
  grid-template-columns: 1fr;
}

.side-panel:empty {
  display: none;
}

.chat-surface,
.side-panel,
.panel {
  min-width: 0;
}

.chat-surface {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: calc(100vh - 6.75rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.chat-header {
  align-items: center;
}

.chat-title-lockup,
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.chat-header-mark,
.welcome-mark {
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border));
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
  font-weight: 800;
}

.chat-header-mark {
  width: 2rem;
  height: 2rem;
  border-radius: calc(var(--radius) - 1px);
}

.message-count {
  color: var(--muted-foreground);
  font-size: 0.78rem;
  white-space: nowrap;
}

.icon-button {
  width: 2.25rem;
  min-width: 2.25rem;
  padding: 0;
}

.surface-header,
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.surface-header {
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1rem;
}

.new-chat-action {
  flex: 0 0 auto;
}

.surface-header h2,
.panel-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.2;
}

.surface-header p,
.panel-header p {
  margin: 0.2rem 0 0;
  color: var(--muted-foreground);
  font-size: 0.82rem;
}

.panel form,
.action-list {
  display: grid;
  gap: 0.75rem;
}

.action-list button {
  justify-content: start;
  border-color: var(--border);
  background: var(--secondary);
  color: var(--secondary-foreground);
  text-align: left;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.metric-grid div {
  min-width: 0;
  display: grid;
  gap: 0.2rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.7rem;
  background: var(--background);
}

.metric-grid span,
.message,
.panel,
.identity-row {
  overflow-wrap: anywhere;
}

.identity-summary-strip,
.identity-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.75rem 0;
}

.identity-summary-strip div,
.identity-status-grid div {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.65rem;
  background: var(--background);
}

.identity-summary-strip strong,
.identity-status-grid dt {
  display: block;
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 700;
}

.identity-summary-strip span,
.identity-status-grid dd {
  display: block;
  margin: 0.15rem 0 0;
  overflow-wrap: anywhere;
  color: var(--foreground);
  font-weight: 650;
}

.identity-status-grid {
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
}

.identity-status-grid dd {
  margin-left: 0;
}

.messages {
  overflow: auto;
  padding: var(--density-4);
  background: var(--card);
}

.welcome {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 100%;
  max-width: 54rem;
  margin: 0 auto;
  padding: 2rem 1rem;
  gap: 1.6rem;
  text-align: center;
  color: var(--muted-foreground);
}

.welcome-hero {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
}

.welcome-mark {
  width: 4rem;
  height: 4rem;
  border-radius: 1rem;
  font-size: 1.45rem;
}

.welcome h2 {
  margin: 0;
  color: var(--foreground);
  font-size: 1.65rem;
}

.welcome p {
  max-width: 34rem;
  margin: 0;
  line-height: 1.5;
}

.capability-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.capability-card {
  min-height: 8.75rem;
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 0.45rem;
  border-color: color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: var(--radius);
  padding: 0.95rem;
  background: color-mix(in srgb, var(--card) 72%, var(--muted));
  color: var(--foreground);
  text-align: left;
  box-shadow: none;
}

.capability-card:hover {
  border-color: var(--border);
  background: var(--card);
}

.capability-card strong {
  font-size: 0.9rem;
}

.capability-card span:last-child {
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 450;
  line-height: 1.45;
}

.capability-icon {
  display: grid;
  width: 1.55rem;
  height: 1.55rem;
  place-items: center;
  margin-bottom: 0.25rem;
  border-radius: 0.45rem;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
}

.capability-icon[data-tone="success"] {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
}

.capability-icon[data-tone="info"] {
  background: color-mix(in srgb, var(--info) 12%, transparent);
  color: var(--info);
}

.capability-icon[data-tone="warning"] {
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--warning);
}

.capability-icon[data-tone="danger"] {
  background: color-mix(in srgb, var(--destructive) 12%, transparent);
  color: var(--destructive);
}

.welcome-footnote {
  color: color-mix(in srgb, var(--muted-foreground) 70%, transparent);
  font-size: 0.78rem;
}

.message {
  display: grid;
  grid-template-columns: var(--avatar-size) minmax(0, min(44rem, 100%));
  gap: 0.7rem;
  align-items: start;
  max-width: min(48rem, 100%);
  margin-bottom: 1rem;
}

.is-user {
  grid-template-columns: minmax(0, min(38rem, 100%)) var(--avatar-size);
  margin-left: auto;
}

.is-user grantt-agent-avatar {
  grid-column: 2;
}

.is-user .avatar {
  background: var(--primary);
  color: var(--primary-foreground);
}

.is-user .message-card {
  grid-column: 1;
  grid-row: 1;
  background: var(--primary);
  color: var(--primary-foreground);
}

.is-user .message-header,
.is-user .message-role {
  color: color-mix(in srgb, var(--primary-foreground) 72%, transparent);
}

.avatar {
  display: grid;
  width: var(--avatar-size);
  height: var(--avatar-size);
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--foreground);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--shadow-sm);
}

.message-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 1rem;
  border-top-left-radius: 0.25rem;
  padding: 0.75rem 0.9rem;
  background: color-mix(in srgb, var(--muted) 50%, transparent);
  color: var(--foreground);
  box-shadow: none;
}

.is-user .message-card {
  border-top-left-radius: 1rem;
  border-top-right-radius: 0.25rem;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.message-author {
  color: inherit;
  font-weight: 700;
}

.message-role {
  font-size: 0.72rem;
  font-weight: 500;
}

.message-text {
  line-height: 1.45;
}

.message-text > :first-child {
  margin-top: 0;
}

.message-text > :last-child {
  margin-bottom: 0;
}

.message-text p,
.message-text ul,
.message-text ol,
.message-text blockquote,
.message-text pre,
.message-text table {
  margin: 0 0 0.65rem;
}

.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
  margin: 0 0 0.55rem;
  font-size: 0.98rem;
  line-height: 1.3;
  letter-spacing: 0;
}

.message-text ul,
.message-text ol {
  padding-left: 1.25rem;
}

.message-text li + li {
  margin-top: 0.2rem;
}

.message-text blockquote {
  border-left: 3px solid var(--border);
  padding-left: 0.75rem;
  color: var(--muted-foreground);
}

.message-text code {
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: calc(var(--radius) - 4px);
  padding: 0.06rem 0.25rem;
  background: color-mix(in srgb, var(--muted) 65%, transparent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.86em;
}

.message-text pre {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.65rem;
  background: color-mix(in srgb, var(--muted) 72%, transparent);
}

.message-text pre code {
  border: 0;
  padding: 0;
  background: transparent;
  white-space: pre;
}

.message-text a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.message-text table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.message-text th,
.message-text td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.45rem;
  text-align: left;
  vertical-align: top;
}

.message-text th {
  background: color-mix(in srgb, var(--muted) 65%, transparent);
  font-weight: 650;
}

.composer {
  display: grid;
  gap: 0.65rem;
  border-top: 1px solid var(--border);
  padding: 0.85rem 1rem;
  background: color-mix(in srgb, var(--background) 84%, transparent);
  backdrop-filter: blur(10px);
}

.prompt-suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding-bottom: 0.25rem;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.prompt-chip {
  min-height: 1.85rem;
  border-color: color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  background: color-mix(in srgb, var(--muted) 35%, transparent);
  color: var(--foreground);
  box-shadow: none;
  font-size: 0.8rem;
  font-weight: 500;
}

.prompt-chip:hover {
  border-color: var(--border);
  background: var(--muted);
}

.composer-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.65rem;
}

.composer textarea {
  min-height: 2.75rem;
  max-height: 12.5rem;
  border-color: color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: 0.85rem;
  padding: 0.75rem 0.9rem;
  background: color-mix(in srgb, var(--muted) 32%, transparent);
  resize: none;
}

.send-button {
  min-width: 4rem;
  min-height: 2.6rem;
  border-radius: 0.8rem;
}

.composer-note {
  margin: -0.1rem 0 0;
  color: color-mix(in srgb, var(--muted-foreground) 74%, transparent);
  font-size: 0.74rem;
  text-align: center;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 1rem;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-sm);
}

.route-panel-host {
  width: min(100%, 78rem);
  margin: 0 auto;
}

.route-panel {
  display: grid;
  gap: 1.25rem;
}

.route-panel-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.route-panel-header h2 {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.35rem;
}

.route-panel-header p:last-child {
  margin: 0;
  color: var(--muted-foreground);
}

.route-section-grid {
  display: grid;
  gap: 1rem;
}

.route-section-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.empty-route-state {
  display: grid;
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: color-mix(in srgb, var(--muted) 45%, transparent);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}

.empty-route-state strong {
  font-weight: 650;
}

.empty-route-state span,
.route-section p {
  color: var(--muted-foreground);
  line-height: 1.45;
}

.route-section h3 {
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.identity-row {
  width: 100%;
  min-height: 0;
  display: grid;
  gap: 0.15rem;
  justify-items: start;
  margin-top: 0.5rem;
  border-color: var(--border);
  background: var(--background);
  color: var(--secondary-foreground);
  text-align: left;
}

.identity-row[hidden],
[hidden] {
  display: none !important;
}

.identity-row:hover {
  background: var(--accent);
}

.identity-graph-flow {
  min-height: 16rem;
  margin: 0.75rem 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--border) 28%, transparent) 1px, transparent 1px),
    linear-gradient(180deg, color-mix(in srgb, var(--border) 28%, transparent) 1px, transparent 1px),
    var(--background);
  background-size: 1.5rem 1.5rem;
}

.org-tree {
  min-width: max-content;
  padding: 0.5rem;
}

.org-tree-list {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.org-tree-node {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 1rem;
}

.org-tree-node > .org-tree-list {
  position: relative;
  padding-top: 1rem;
}

.org-tree-node > .org-tree-list::before {
  position: absolute;
  top: 0;
  left: 50%;
  height: 1rem;
  border-left: 2px solid var(--border);
  content: "";
}

.org-tree-node > .org-tree-list > .org-tree-node::before {
  position: absolute;
  top: -1rem;
  left: 50%;
  height: 1rem;
  border-left: 2px solid var(--border);
  content: "";
}

.org-tree-node > .org-tree-list > .org-tree-node::after {
  position: absolute;
  top: -1rem;
  left: -0.5rem;
  right: -0.5rem;
  border-top: 2px solid var(--border);
  content: "";
}

.org-tree-node > .org-tree-list > .org-tree-node:first-child::after {
  left: 50%;
}

.org-tree-node > .org-tree-list > .org-tree-node:last-child::after {
  right: 50%;
}

.org-tree-node > .org-tree-list > .org-tree-node:only-child::after {
  display: none;
}

.org-tree-card {
  width: 13rem;
  min-height: 5rem;
  margin-top: 0;
  border-color: var(--border);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.org-tree-card[aria-selected="true"] {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.org-tree-card [data-manager-edge] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.selected-identity-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 0;
}

.selected-identity-card div {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.65rem;
  background: var(--background);
}

.selected-identity-card dt {
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 700;
}

.selected-identity-card dd {
  margin: 0.15rem 0 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.45rem 0.85rem;
  text-decoration: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .shell[data-nav-open="true"] .sidebar {
    display: block;
  }

  .nav-toggle {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 0.4rem;
  }

  .topbar,
  .composer {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .topbar-actions button,
  .composer button {
    width: 100%;
  }

  .chat-header,
  .chat-title-lockup,
  .chat-header-actions,
  .composer-input-row {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-title-lockup {
    align-items: center;
  }

  .composer-input-row,
  .capability-grid,
  .route-section-grid,
  .identity-summary-strip,
  .identity-status-grid,
  .selected-identity-card {
    grid-template-columns: 1fr;
  }

  .prompt-chip {
    width: auto;
  }

  .content-grid {
    padding: 0.75rem;
  }

  .chat-surface {
    min-height: 60vh;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}
