:root {
  color-scheme: light;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --bg-soft: #f2f5ff;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --line: #dbe3ef;
  --line-strong: #c9d5e6;
  --text: #122033;
  --muted: #64748b;
  --muted-strong: #475569;
  --primary: #4257ff;
  --primary-600: #3143d8;
  --primary-50: #eef1ff;
  --accent: #05b6d4;
  --accent-50: #ecfeff;
  --violet: #7c3aed;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --warn: #d97706;
  --warn-50: #fffbeb;
  --ok: #16a34a;
  --ok-50: #f0fdf4;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 14px 35px rgba(30, 41, 59, 0.10);
  --shadow-glow: 0 18px 55px rgba(66, 87, 255, 0.20);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --ambient-primary: rgba(66, 87, 255, 0.16);
  --ambient-accent: rgba(5, 182, 212, 0.16);
  --grid-color: rgba(66, 87, 255, 0.045);
}

[data-theme="open-source"] {
  --primary: #4257ff;
  --primary-600: #3143d8;
  --primary-50: #eef1ff;
  --accent: #05b6d4;
  --accent-50: #ecfeff;
  --violet: #7c3aed;
  --bg: #f6f7fb;
  --panel: rgba(255, 255, 255, 0.92);
}

[data-theme="signal"] {
  --primary: #0f766e;
  --primary-600: #115e59;
  --primary-50: #ecfdf5;
  --accent: #e11d48;
  --accent-50: #fff1f2;
  --violet: #2563eb;
  --bg: #f5f8f7;
  --bg-soft: #eef7f5;
  --line: #d4e2df;
  --line-strong: #b8ceca;
  --text: #102a2b;
  --muted: #5f7473;
  --muted-strong: #405957;
  --ambient-primary: rgba(15, 118, 110, 0.15);
  --ambient-accent: rgba(225, 29, 72, 0.11);
  --grid-color: rgba(15, 118, 110, 0.05);
  --shadow-glow: 0 18px 55px rgba(15, 118, 110, 0.20);
}

[data-theme="contrast"] {
  --primary: #111827;
  --primary-600: #030712;
  --primary-50: #f3f4f6;
  --accent: #ea580c;
  --accent-50: #fff7ed;
  --violet: #0284c7;
  --bg: #f8fafc;
  --bg-soft: #f1f5f9;
  --line: #cbd5e1;
  --line-strong: #94a3b8;
  --text: #0f172a;
  --muted: #475569;
  --muted-strong: #334155;
  --ambient-primary: rgba(15, 23, 42, 0.12);
  --ambient-accent: rgba(234, 88, 12, 0.12);
  --grid-color: rgba(15, 23, 42, 0.055);
  --shadow-glow: 0 18px 55px rgba(234, 88, 12, 0.16);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 10% 0%, var(--ambient-primary), transparent 30%),
    radial-gradient(circle at 90% 12%, var(--ambient-accent), transparent 26%),
    linear-gradient(135deg, #f8fbff 0%, var(--bg) 44%, #f7f2ff 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.75), transparent 70%);
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px 1fr; position: relative; }
.app-shell.studio-shell { grid-template-columns: 1fr; }
.sidebar {
  border-right: 1px solid rgba(219, 227, 239, 0.78);
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(246,247,251,0.88));
  backdrop-filter: blur(18px);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 2;
  display: flex;
  flex-direction: column;
}
.logo {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.06em;
  margin: 4px 0 24px;
}
.logo::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 0 6px rgba(66, 87, 255, 0.12), 0 0 26px rgba(5, 182, 212, 0.42);
}
.logo span { color: var(--primary); }
.sidebar > nav { display: grid; gap: 7px; align-content: start; flex: 1; min-height: 0; }
.nav-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 14px;
  text-align: left;
  background: transparent;
  padding: 11px 12px;
  margin: 0;
  color: var(--muted-strong);
  font-weight: 650;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.nav-item:hover { background: rgba(66, 87, 255, 0.07); color: var(--primary-600); transform: translateX(2px); }
.nav-item.active {
  background: linear-gradient(135deg, var(--primary-50), var(--accent-50));
  color: var(--primary-600);
  border-color: rgba(66, 87, 255, 0.18);
  box-shadow: inset 3px 0 0 var(--primary), var(--shadow-sm);
}
.subnav { display: none; gap: 6px; margin: -3px 0 4px 12px; padding-left: 10px; border-left: 1px solid rgba(66, 87, 255, 0.18); }
.subnav.open { display: grid; }
.subnav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  justify-content: flex-start;
  padding: 8px 10px;
  box-shadow: none;
}
.subnav-item:hover, .subnav-item.active { color: var(--primary-600); background: rgba(66, 87, 255, 0.07); transform: none; box-shadow: none; }
.sidebar-account { position: relative; padding: 13px 0 2px; border-top: 1px solid var(--line); }
.sidebar-user-card { width: 100%; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px; border: 1px solid rgba(219, 227, 239, 0.95); border-radius: 14px; background: rgba(255,255,255,.82); color: var(--text); text-align: left; box-shadow: var(--shadow-sm); }
.sidebar-user-card:hover, .sidebar-user-card[aria-expanded="true"] { border-color: rgba(66,87,255,.28); background: #fff; transform: none; box-shadow: var(--shadow-md); }
.sidebar-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; font-size: 13px; font-weight: 800; box-shadow: 0 6px 16px rgba(66, 87, 255, 0.22); }
.sidebar-user-copy { display: grid; min-width: 0; }
.sidebar-user-copy strong, .sidebar-user-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-copy strong { font-size: 13px; }
.sidebar-user-copy small, .sidebar-workspace-name { color: var(--muted); font-size: 11px; }
.sidebar-account-chevron { color: var(--muted); font-size: 13px; transition: transform 150ms ease; }
.sidebar-user-card[aria-expanded="true"] .sidebar-account-chevron { transform: rotate(180deg); }
.sidebar-user-popover { position: absolute; left: 0; right: 0; bottom: calc(100% + 10px); z-index: 20; display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.98); box-shadow: 0 18px 44px rgba(15,23,42,.18); backdrop-filter: blur(16px); }
.sidebar-user-popover[hidden] { display: none; }
.sidebar-popover-identity { display: grid; min-width: 0; }
.sidebar-popover-identity strong, .sidebar-popover-identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-popover-identity small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.sidebar-popover-workspace { display: grid; gap: 6px; }
.sidebar-popover-workspace > span { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.sidebar-workspace-select { width: 100%; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.8); color: var(--text); font-size: 12px; }
.sidebar-user-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding-top: 3px; border-top: 1px solid var(--line); }
.sidebar-user-actions button { min-height: 34px; padding: 7px 9px; border: 0; background: transparent; box-shadow: none; color: var(--muted-strong); font-size: 12px; }
.sidebar-user-actions button:hover { color: var(--primary-600); background: var(--primary-50); transform: none; }

.member-manage-page { display: grid; gap: 18px; }
.member-list-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.member-list-title { display: flex; align-items: baseline; gap: 12px; }
.member-list-title h3 { margin: 0; }
.member-list-title span { color: var(--muted); font-size: 13px; }
.member-page-actions, .member-row-actions, .member-modal-actions { display: flex; align-items: center; gap: 8px; }
.member-page-actions { flex: 0 0 auto; }
.member-add-fields { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(170px, .55fr); align-items: end; gap: 14px; }
.member-add-fields label { display: grid; gap: 7px; }
.member-table { display: grid; overflow-x: auto; }
.member-row { display: grid; grid-template-columns: minmax(180px, 1.1fr) minmax(200px, 1fr) 150px minmax(170px, .7fr); align-items: center; gap: 16px; min-width: 850px; padding: 13px 4px; border-bottom: 1px solid var(--line); }
.member-row:last-child { border-bottom: 0; }
.member-row[hidden] { display: none; }
.member-row-head { color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.member-identity { display: grid; }
.member-identity small { color: var(--muted); margin-top: 3px; }
.member-row select { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text); }
.member-row button { justify-self: start; }
.member-role-label { display: inline-flex; align-items: center; min-height: 30px; color: var(--text); font-weight: 650; }
.member-row-actions { flex-wrap: wrap; }
.member-row-actions .compact { min-height: 34px; padding: 7px 11px; }
.member-search-empty { margin: 18px 4px 4px; }
.modal-backdrop { background: rgba(244, 248, 255, .16); -webkit-backdrop-filter: blur(14px) saturate(125%); backdrop-filter: blur(14px) saturate(125%); }
.member-modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; }
.member-modal { width: min(620px, 100%); padding: 22px; box-shadow: 0 24px 70px rgba(17, 24, 39, .24); }
.member-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.member-modal-head h3 { margin: 0 0 6px; }
.member-modal-head p { margin: 0; color: var(--muted); line-height: 1.55; }
.member-modal-close { flex: 0 0 auto; width: 34px; height: 34px; padding: 0; border: 0; background: transparent; box-shadow: none; color: var(--muted-strong); font-size: 24px; line-height: 1; }
.member-modal-error { margin-bottom: 16px; }
.member-modal-actions { justify-content: flex-end; margin-top: 20px; }

.main { display: grid; grid-template-rows: auto 1fr; min-width: 0; }
.studio-shell .main { height: 100vh; min-height: 100vh; overflow: hidden; }
.topbar {
  border-bottom: 1px solid rgba(219, 227, 239, 0.82);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(18px);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 1;
}
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -0.035em; }
.topbar-title { min-width: 0; flex: 1 1 auto; }
.topbar-back {
  flex: 0 0 auto;
  min-width: 92px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
}
.topbar p, .muted { margin: 4px 0 0; color: var(--muted); }
.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  min-width: 190px;
  flex: 0 0 auto;
}
.language-switcher > span { min-width: 64px; white-space: nowrap; text-align: right; }
.language-switcher select { min-width: 112px; }
main { padding: 24px; overflow: auto; min-width: 0; }
.studio-shell main {
  padding: 0;
  overflow: hidden;
  min-height: 0;
}
.create-shell .main { height: 100vh; min-height: 100vh; overflow: hidden; }
.create-shell main { padding: 0; overflow-x: hidden; overflow-y: auto; min-height: 0; }
.page { animation: fade-slide 220ms ease both; }
.studio-page {
  height: 100%;
  min-height: 0;
  animation: none;
}
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
h2 { margin: 0 0 8px; font-size: clamp(26px, 3vw, 38px); letter-spacing: -0.055em; }
h3 { margin: 0 0 12px; letter-spacing: -0.025em; }
h4, h5 { margin: 10px 0 8px; }

button, input, select, textarea { font: inherit; }
button {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  color: #1e293b;
  border-radius: 12px;
  padding: 9px 13px;
  cursor: pointer;
  font-weight: 650;
  box-shadow: var(--shadow-sm);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease, background 150ms ease;
}
button:hover { transform: translateY(-1px); border-color: rgba(66, 87, 255, 0.32); box-shadow: 0 8px 20px rgba(15, 23, 42, 0.09); }
button.primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}
button.primary:hover { box-shadow: 0 22px 55px rgba(66, 87, 255, 0.24); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.card {
  background: var(--panel);
  border: 1px solid rgba(219, 227, 239, 0.92);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card:hover { border-color: rgba(66, 87, 255, 0.18); }
.project-agent-workspace {
  position: relative;
  min-height: 100%;
  overflow: visible;
  border: 0;
  background-color: #f7faff;
  background-image: radial-gradient(circle, rgba(148, 163, 184, 0.24) 1px, transparent 1px);
  background-size: 24px 24px;
}
.project-agent-conversation {
  width: min(780px, calc(100% - 48px));
  min-height: calc(100vh - 112px);
  margin: 0 auto;
  padding: 20px 8px 156px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: visible;
}
.project-agent-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.project-agent-toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.project-agent-toolbar .canvas-tool-icon { width: 18px; height: 18px; }
.project-agent-conversation .ai-chat-list { flex: 1; overflow: visible; }
.project-agent-conversation .ai-chat-bubble p { white-space: pre-wrap; }
.project-agent-conversation > button { align-self: flex-start; }
.project-agent-controls {
  position: sticky;
  bottom: 16px;
  z-index: 60;
  width: min(780px, calc(100% - 64px));
  margin: -140px auto 16px;
  display: grid;
  gap: 8px;
}
.ai-composer.project-agent-composer {
  position: static;
  left: auto;
  bottom: auto;
  width: 100%;
  margin: 0;
  transform: none;
  grid-template-columns: minmax(0, 1fr) auto;
}
.ai-composer.project-agent-composer textarea,
.ai-composer.project-agent-composer.is-expanded textarea {
  grid-column: 1;
  grid-row: 1;
}
.ai-composer.project-agent-composer .ai-send,
.ai-composer.project-agent-composer.is-expanded .ai-send {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  justify-self: end;
}
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
  align-items: stretch;
  gap: 14px;
  margin-top: 14px;
}
.project {
  position: relative;
  isolation: isolate;
  overflow: visible;
  min-width: 0;
  min-height: 316px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 14px 13px 18px;
  border-color: rgba(203, 213, 225, 0.92);
  background:
    linear-gradient(90deg, rgba(66, 87, 255, 0.055), transparent 40%),
    linear-gradient(180deg, #ffffff 0%, rgba(250, 252, 255, 0.97) 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.88), 0 14px 34px rgba(15, 23, 42, 0.08);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}
.project:hover {
  transform: translateY(-2px);
  border-color: rgba(66, 87, 255, 0.30);
  background:
    linear-gradient(90deg, rgba(66, 87, 255, 0.075), transparent 42%),
    linear-gradient(180deg, #ffffff 0%, rgba(248, 251, 255, 0.98) 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.92), 0 20px 42px rgba(15, 23, 42, 0.12);
}
.project::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  background: linear-gradient(180deg, var(--primary) 0%, var(--accent) 58%, var(--violet) 100%);
  pointer-events: none;
}
.project h3 {
  min-width: 0;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.2;
  font-size: 16px;
  letter-spacing: -0.018em;
}
.project-meta {
  min-height: 34px;
  margin: 0;
  color: var(--muted-strong);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.3;
}
.kv-row { display: flex; justify-content: space-between; color: #334155; margin: 9px 0; gap: 8px; flex-wrap: wrap; }
.project-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  padding: 8px 9px;
  border: 1px solid rgba(219, 227, 239, 0.95);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.92), rgba(241, 245, 249, 0.78));
  color: var(--muted-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}
.project-stats span {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 760;
}
.project-stats span:first-child { padding-left: 0; }
.project-stats span + span { border-left: 1px solid rgba(203, 213, 225, 0.78); }
.project-stats strong {
  color: var(--text);
  font-size: 15px;
}
.project-details {
  display: grid;
  gap: 2px;
  padding: 5px 0;
  border-top: 1px solid rgba(219, 227, 239, 0.78);
  border-bottom: 1px solid rgba(219, 227, 239, 0.78);
}
.project-details .kv-row {
  margin: 0;
  align-items: center;
  flex-wrap: nowrap;
  min-height: 24px;
  font-size: 13px;
}
.project-details strong {
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.form label, .tab-body label { display: grid; gap: 6px; color: #334155; font-size: 13px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(66, 87, 255, 0.12); background: #fff; }
textarea { min-height: 82px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 12px; flex-wrap: wrap; }
.project .actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
  gap: 6px;
  justify-content: stretch;
  align-items: stretch;
}
.project .actions button {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 11px;
  border-radius: 10px;
  white-space: nowrap;
  text-align: center;
}
.project .actions button:not(.primary) {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(203, 213, 225, 0.94);
}
.project .actions button:not(.primary):hover {
  background: var(--primary-50);
  border-color: rgba(66, 87, 255, 0.28);
}
.project .actions button:nth-child(3) {
  grid-column: 1 / -1;
}
.project-search { display: grid; gap: 6px; min-width: min(420px, 100%); color: #334155; font-size: 13px; font-weight: 650; }
.project-search input { min-width: 280px; }
.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.panel { overflow: auto; max-height: calc(100vh - 186px); }
.workflow-board { margin-top: 16px; display: grid; gap: 14px; min-width: 0; }
.studio-page .workflow-board {
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  background: transparent;
}
.workflow-board-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  border-bottom: 1px solid rgba(219, 227, 239, 0.78);
  padding-bottom: 12px;
}
.workflow-board-head h3 { margin-bottom: 4px; }
.workflow-alerts { display: flex; flex-wrap: wrap; gap: 8px; }
.workflow-alerts span { border-radius: 999px; padding: 4px 10px; background: rgba(255,255,255,0.78); border: 1px solid var(--line); font-size: 12px; }
.workflow-detail > .panel,
.ai-conversation-drawer > .panel {
  max-height: 100%;
  height: 100%;
  overflow: auto;
  border-radius: 16px;
  background: rgba(248, 251, 255, 0.94);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(14px);
  font-size: 13px;
  line-height: 1.42;
}
.workflow-canvas > .workflow-detail {
  position: absolute;
  right: 12px;
  top: 12px;
  bottom: 110px;
  width: min(360px, calc(100vw - 32px));
  z-index: 45;
  pointer-events: auto;
  animation: drawer-slide-in 180ms ease both;
}
.workflow-canvas > .workflow-detail > .panel {
  border-left: 1px solid rgba(66, 87, 255, 0.20);
}
.workflow-history-panel {
  width: min(680px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 112px));
  pointer-events: auto;
  overflow: auto;
  animation: history-modal-in 160ms ease both;
}
.workflow-history-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  justify-items: center;
  align-items: start;
  padding: 72px 16px 24px;
  pointer-events: auto;
}
.workflow-history-panel .toolbar {
  align-items: flex-start;
}
.workflow-history-panel .toolbar > .row {
  justify-content: flex-end;
}
.ai-conversation-drawer {
  position: absolute;
  left: 12px;
  top: 12px;
  bottom: 110px;
  z-index: 47;
  width: min(360px, calc(100vw - 32px));
  pointer-events: auto;
  animation: drawer-slide-left 180ms ease both;
}
.ai-conversation-drawer > .panel {
  border-right: 1px solid rgba(66, 87, 255, 0.20);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
}
.ai-conversation-drawer .toolbar {
  align-items: start;
  flex: 0 0 auto;
}
.ai-conversation-drawer .row {
  gap: 7px;
}
.ai-conversation-drawer .row button {
  font-size: 12px;
  padding: 7px 9px;
}
.ai-chat-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}
.ai-chat-empty {
  border: 1px dashed rgba(148, 163, 184, 0.7);
  border-radius: 14px;
  padding: 18px;
  color: var(--muted);
  background: rgba(255,255,255,0.62);
}
.ai-chat-message {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 92%;
}
.ai-chat-message.user {
  align-self: flex-end;
  align-items: flex-end;
}
.ai-chat-message.agent {
  align-self: flex-start;
  align-items: flex-start;
}
.ai-chat-meta {
  color: var(--muted);
  font-size: 11px;
}
.ai-chat-bubble {
  border: 1px solid rgba(201, 213, 230, 0.85);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.82);
  box-shadow: var(--shadow-sm);
}
.ai-chat-message.user .ai-chat-bubble {
  background: linear-gradient(135deg, rgba(66, 87, 255, 0.10), rgba(6, 182, 212, 0.10));
  border-color: rgba(66, 87, 255, 0.24);
}
.ai-chat-bubble p {
  margin: 0;
}
.ai-agent-summary {
  display: grid;
  gap: 5px;
}
.edit-session-status {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(66, 87, 255, 0.18);
  border-radius: 14px;
  padding: 10px;
  background: rgba(239, 246, 255, 0.70);
}
.edit-session-status > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.edit-session-status > div strong {
  color: var(--text);
}
.edit-session-status .compact {
  justify-self: start;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}
.edit-session-status ol {
  margin: 0;
  padding-left: 18px;
}
.edit-session-status li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0;
  font-size: 12px;
}
.agent-trace {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}
.agent-trace div {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.agent-trace em {
  font-style: normal;
  color: var(--accent);
}
.ai-clarification-list {
  margin: 4px 0 0;
  padding-left: 18px;
  color: #334155;
}
.ai-clarification-list li + li {
  margin-top: 4px;
}
.candidate-node-list {
  list-style: none;
  padding-left: 0;
}
.candidate-node-list button {
  width: 100%;
  justify-content: flex-start;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}
.ai-composer {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 60;
  width: min(780px, calc(100vw - 460px));
  min-height: 64px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid rgba(201, 213, 230, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
  transform: translateX(-50%);
  pointer-events: auto;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.ai-composer.is-expanded:focus-within {
  border-color: var(--primary);
  background: #fff;
  box-shadow: var(--shadow-md), 0 0 0 4px rgba(66, 87, 255, 0.12);
}
.ai-composer textarea {
  min-height: 44px;
  max-height: 94px;
  resize: none;
  overflow-y: hidden;
  line-height: 1.42;
}
.ai-composer.is-expanded textarea {
  grid-column: 1 / -1;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.ai-composer.is-expanded textarea:focus {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.ai-composer.is-expanded .ai-drawer-open {
  grid-column: 1;
  grid-row: 2;
}
.ai-composer.is-expanded .ai-send {
  grid-column: 3;
  grid-row: 2;
  justify-self: end;
}
.ai-send,
.ai-drawer-open {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}
.ai-send.ai-configure {
  width: auto;
  min-width: 104px;
  padding: 0 14px;
  font-size: 12px;
  white-space: nowrap;
}
.ai-drawer-open {
  align-self: end;
}
.diff-review {
  display: grid;
  gap: 10px;
}
.diff-pending {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(66, 87, 255, 0.22);
  border-radius: 12px;
  background: rgba(239, 246, 255, 0.88);
  color: #1e3a8a;
  font-size: 13px;
}
.diff-pending-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(66, 87, 255, 0.35);
  animation: pending-pulse 1.2s ease-in-out infinite;
}
@keyframes pending-pulse {
  0%, 100% { transform: scale(0.82); box-shadow: 0 0 0 0 rgba(66, 87, 255, 0.32); }
  50% { transform: scale(1); box-shadow: 0 0 0 8px rgba(66, 87, 255, 0); }
}
.diff-summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid rgba(201, 213, 230, 0.9);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.82);
  color: #334155;
  font-size: 13px;
}
.diff-review ul {
  padding-left: 0;
  list-style: none;
}
.diff-review li {
  padding: 9px 0;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}
.diff-review .check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.diff-review input[type="checkbox"] {
  width: auto;
  margin-top: 3px;
}
.workflow-canvas {
  min-height: 680px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(219, 227, 239, 0.84);
  border-radius: 14px;
  background:
    radial-gradient(circle at 24px 24px, rgba(66, 87, 255, 0.12) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(135deg, rgba(66, 87, 255, 0.08), rgba(5, 182, 212, 0.04)),
    rgba(255, 255, 255, 0.74);
  cursor: default;
  user-select: none;
}
.workflow-empty-state {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 55;
  width: min(520px, calc(100% - 48px));
  padding: 24px;
  border: 1px solid rgba(201, 213, 230, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-md);
  text-align: center;
  transform: translate(-50%, -50%);
}
.workflow-empty-state h3 { margin: 0 0 8px; }
.workflow-empty-state p { margin: 0 0 18px; color: var(--muted); }
.studio-page .workflow-canvas {
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
}
.workflow-canvas-tools {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid rgba(201, 213, 230, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
}
.workflow-filter-control {
  position: relative;
  display: inline-grid;
  place-items: center;
}
.workflow-zoom-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.9);
  box-shadow: none;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}
.canvas-tool-button {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
}
.canvas-tool-button:hover,
.canvas-tool-button:focus-visible,
.canvas-tool-button.active,
.icon-button:hover,
.icon-button:focus-visible,
.icon-button.active {
  border-color: rgba(66, 87, 255, 0.55);
  background: rgba(66, 87, 255, 0.11);
  color: #2538d8;
}
.canvas-tool-icon,
.icon-button svg {
  width: 18px;
  height: 18px;
}
.canvas-tool-icon svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.canvas-tool-tip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  padding: 5px 8px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  transform: translateY(-3px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.canvas-tool-button:hover .canvas-tool-tip,
.canvas-tool-button:focus-visible .canvas-tool-tip {
  opacity: 1;
  transform: translateY(0);
}
.workflow-filter-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 56;
  display: grid;
  gap: 10px;
  width: min(320px, calc(100vw - 56px));
  margin-top: 0;
  padding: 12px;
  border: 1px solid rgba(201, 213, 230, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(14px);
}
.workflow-filter-popover[hidden] { display: none; }
.workflow-filter-popover label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}
.job-list {
  display: grid;
  gap: 10px;
  padding: 0;
  list-style: none;
}
.job-list li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(248, 251, 255, 0.82);
}
.topbar h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.topbar-title-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}
.topbar-title-badge.warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}
.project-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
}
.project-card-head h3 { margin-right: auto; }
.project-rename-editor {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}
.project-rename-editor label {
  display: grid;
  gap: 5px;
  color: #334155;
  font-size: 12px;
  font-weight: 750;
}
.project-rename-editor input {
  min-height: 36px;
  padding: 8px 10px;
}
.project-rename-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.project-rename-error {
  min-width: 0;
  color: var(--danger);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-rename-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.project-rename-actions button {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 10px;
  font-size: 12px;
}
.project-menu-control {
  position: relative;
  flex: 0 0 auto;
}
.icon-button.project-menu-trigger {
  width: 28px;
  height: 28px;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(203, 213, 225, 0.95);
  color: var(--muted-strong);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.07);
}
.icon-button.project-menu-trigger:hover,
.icon-button.project-menu-trigger.active {
  background: var(--primary-50);
  border-color: rgba(66, 87, 255, 0.34);
  color: var(--primary);
}
.project-menu-trigger svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.project-menu {
  position: absolute;
  top: 34px;
  right: 0;
  z-index: 40;
  display: grid;
  gap: 2px;
  min-width: 218px;
  padding: 6px;
  border: 1px solid rgba(203, 213, 225, 0.96);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(16px);
}
.project-menu[hidden] { display: none; }
.project-menu button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 36px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  box-shadow: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  line-height: 1.15;
  text-align: left;
  white-space: nowrap;
}
.project-menu button:hover,
.project-menu button:focus-visible {
  background: var(--primary-50);
  color: var(--primary);
  transform: none;
  box-shadow: none;
}
.project-menu button.danger-text {
  color: #b91c1c;
}
.project-menu button.danger-text:hover,
.project-menu button.danger-text:focus-visible {
  background: var(--danger-50);
  color: var(--danger);
}
.danger-text { color: var(--danger); }
.workflow-canvas.panning { cursor: grabbing; }
.workflow-canvas-content {
  width: max-content;
  min-width: 100%;
  transform-origin: 0 0;
  will-change: transform;
}
.canvas {
  display: grid;
  grid-template-columns: repeat(7, 214px);
  gap: 12px;
  align-items: start;
  min-height: 640px;
  padding: 12px;
}
.lane {
  position: relative;
  border: 1px solid rgba(201, 213, 230, 0.92);
  border-radius: var(--radius-md);
  padding: 10px;
  background: linear-gradient(180deg, rgba(248,251,255,0.98), rgba(255,255,255,0.82));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.82);
  overflow: visible;
}
.lane.diff-added {
  border-style: dashed;
  border-color: rgba(34, 197, 94, 0.86);
  background: linear-gradient(180deg, rgba(240,253,244,0.98), rgba(255,255,255,0.86));
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.12), inset 0 1px 0 rgba(255,255,255,0.82);
}
.lane h4 { margin: 0 0 9px; font-size: 15px; }
.lane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  line-height: 1;
  flex: 0 0 auto;
}
.phase-menu {
  position: absolute;
  top: 42px;
  right: 8px;
  z-index: 40;
  width: min(260px, calc(100% - 16px));
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(201, 213, 230, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-sm);
}
.phase-menu[hidden] { display: none; }
.phase-menu label { display: grid; gap: 6px; color: #334155; font-size: 12px; font-weight: 700; }
.phase-menu .row { gap: 7px; }
.node-card {
  width: 100%;
  text-align: left;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  border: 1px solid #d8e0ef;
  margin-bottom: 9px;
  border-radius: 14px;
  position: relative;
  overflow: hidden;
}
.node-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
  opacity: 0.85;
}
.node-card:hover { transform: translateY(-2px); }
.node-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(66, 87, 255, 0.16), 0 16px 32px rgba(66, 87, 255, 0.16); }
.node-card.upstream {
  border-color: rgba(5, 182, 212, 0.72);
  background: linear-gradient(180deg, #f0fdff, #ffffff);
  box-shadow: 0 0 0 2px rgba(5, 182, 212, 0.14), 0 12px 24px rgba(5, 182, 212, 0.12);
}
.node-card.downstream {
  border-color: rgba(124, 58, 237, 0.62);
  background: linear-gradient(180deg, #faf5ff, #ffffff);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.12), 0 12px 24px rgba(124, 58, 237, 0.1);
}
.node-card.upstream::before { background: linear-gradient(180deg, #05b6d4, #22c55e); }
.node-card.downstream::before { background: linear-gradient(180deg, #7c3aed, #4257ff); }
.node-card.unrelated {
  opacity: 0.38;
  filter: saturate(0.72);
}
.node-card.diff-updated {
  border-color: rgba(14, 165, 233, 0.82);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.16), 0 12px 24px rgba(14, 165, 233, 0.12);
}
.node-card.diff-added {
  border-style: dashed;
  border-color: rgba(34, 197, 94, 0.86);
  background: linear-gradient(180deg, #f0fdf4, #ffffff);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.14), 0 12px 24px rgba(34, 197, 94, 0.1);
}
.node-card.diff-deleted {
  border-style: dashed;
  border-color: rgba(239, 68, 68, 0.82);
  background: linear-gradient(180deg, #fff1f2, #ffffff);
  opacity: 0.58;
}
.node-card.diff-updated::before { background: linear-gradient(180deg, #0ea5e9, #4257ff); }
.node-card.diff-added::before { background: linear-gradient(180deg, #22c55e, #05b6d4); }
.node-card.diff-deleted::before { background: linear-gradient(180deg, #ef4444, #f97316); }
.preview-node {
  pointer-events: none;
}
.node-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 7px; }
.mode-pill { display: inline-block; border: 1px solid rgba(66, 87, 255, 0.22); border-radius: 999px; padding: 3px 9px; font-size: 12px; margin-bottom: 7px; background: var(--primary-50); color: var(--primary-600); font-weight: 750; }
.meta { color: var(--muted); font-size: 12px; line-height: 1.45; }
.badge { border-radius: 999px; padding: 3px 9px; font-size: 11px; border: 1px solid var(--line); background: rgba(255,255,255,0.82); font-weight: 750; white-space: nowrap; }
.risk-low { color: var(--ok); border-color: #bbf7d0; background: var(--ok-50); }
.risk-medium { color: var(--warn); border-color: #fde68a; background: var(--warn-50); }
.risk-high { color: var(--danger); border-color: #fecaca; background: var(--danger-50); }
.outdated { color: #b45309; background: #fff7ed; border-color: #fed7aa; }
.reviewed { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.draft { color: #475569; background: #f8fafc; border-color: #e2e8f0; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tab.active { background: linear-gradient(135deg, var(--primary-50), var(--accent-50)); color: var(--primary-600); border-color: rgba(66, 87, 255, 0.24); }
.tab-body pre, pre {
  white-space: pre-wrap;
  background: linear-gradient(135deg, #0f172a, #172554);
  color: #bdeeff;
  padding: 13px;
  border-radius: 14px;
  max-height: 440px;
  overflow: auto;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.inline-error { color: var(--danger); }
.inline-warning { color: var(--warn); }
.inline-suggestion { color: var(--ok); }
.inline-error.card, .inline-error.panel { color: #991b1b; background: var(--danger-50); border-color: #fecaca; }
.inline-warning.card, .inline-warning.panel { color: #92400e; background: var(--warn-50); border-color: #fde68a; }
.toast-stack {
  position: fixed;
  left: 50%;
  top: 76px;
  transform: translateX(-50%);
  display: grid;
  gap: 10px;
  z-index: 80;
  width: min(360px, calc(100vw - 36px));
}
.toast {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: 11px 13px;
  color: var(--text);
  font-weight: 700;
}
.toast.success { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.toast.error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.drawer { margin-top: 16px; }
.check { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 7px; }
.check input { width: auto; }
.field-save-status {
  min-height: 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}
.field-save-status.saving { color: #2563eb; }
.field-save-status.saved { color: #15803d; }
.field-save-status.failed { color: #b91c1c; }
.muted-node { opacity: 0.42; }
.edge-hints { margin: 9px 0 0; padding-left: 18px; color: #64748b; font-size: 12px; }
.asset-detail textarea, .panel textarea { width: 100%; }
ul { padding-left: 20px; }
li { margin: 6px 0; }

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.agent-access-page {
  display: grid;
  gap: 16px;
}
.agent-access-page .wide {
  grid-column: 1 / -1;
}
.agent-access-summary {
  display: grid;
  align-content: start;
  gap: 10px;
}
.agent-access-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.agent-handoff-grid {
  align-items: start;
}
.agent-task-summary {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(219, 227, 239, 0.92);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.82);
}
.agent-task-summary p {
  margin: 0;
  color: var(--muted-strong);
  line-height: 1.45;
}
.agent-payload-card {
  min-width: 0;
}
.agent-payload-card pre {
  max-height: min(58vh, 620px);
  font-size: 12px;
  line-height: 1.45;
}
.agent-runs-panel {
  display: grid;
  gap: 8px;
}
.agent-run-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.agent-run-list li {
  display: grid;
  grid-template-columns: 1fr 1.3fr auto auto;
  gap: 10px;
  align-items: center;
  margin: 0;
  padding: 9px 10px;
  border: 1px solid rgba(219, 227, 239, 0.92);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted-strong);
  font-size: 12px;
}
.agent-run-list strong {
  color: var(--text);
}
.theme-option {
  position: relative;
  min-height: 144px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.theme-option:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: var(--shadow-md); }
.theme-option.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50), var(--shadow-md); }
.theme-option input { position: absolute; top: 12px; right: 12px; width: 18px; height: 18px; accent-color: var(--primary); }
.theme-option-swatches { display: flex; gap: 10px; }
.theme-option-swatches span { width: 38px; height: 38px; border: 3px solid #fff; border-radius: 999px; box-shadow: 0 5px 14px rgba(15, 23, 42, 0.16); }
[data-theme-option="open-source"] .theme-option-swatches span:nth-child(1) { background: #4257ff; }
[data-theme-option="open-source"] .theme-option-swatches span:nth-child(2) { background: #05b6d4; }
[data-theme-option="open-source"] .theme-option-swatches span:nth-child(3) { background: #7c3aed; }
[data-theme-option="signal"] .theme-option-swatches span:nth-child(1) { background: #0f766e; }
[data-theme-option="signal"] .theme-option-swatches span:nth-child(2) { background: #e11d48; }
[data-theme-option="signal"] .theme-option-swatches span:nth-child(3) { background: #2563eb; }
[data-theme-option="contrast"] .theme-option-swatches span:nth-child(1) { background: #111827; }
[data-theme-option="contrast"] .theme-option-swatches span:nth-child(2) { background: #ea580c; }
[data-theme-option="contrast"] .theme-option-swatches span:nth-child(3) { background: #0284c7; }

@keyframes fade-slide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes drawer-slide-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes drawer-slide-left {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes history-modal-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1280px) {
  .app-shell { grid-template-columns: 86px 1fr; }
  .sidebar { padding: 18px 10px; }
  .logo { font-size: 0; margin-left: 9px; }
  .logo::before { margin-right: 0; width: 28px; height: 28px; }
  .nav-item { font-size: 0; min-height: 42px; }
  .nav-item::first-letter { font-size: 14px; }
  .sidebar-user-card { grid-template-columns: 1fr; justify-items: center; padding: 8px 4px; }
  .sidebar-user-card .sidebar-user-copy, .sidebar-user-card .sidebar-account-chevron { display: none; }
  .sidebar-user-popover { left: 0; right: auto; width: 240px; }
  .split-2, .grid-2 { grid-template-columns: 1fr; }
  .project-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); }
  .workflow-board-head { align-items: flex-start; flex-direction: column; }
  .ai-composer { width: min(720px, calc(100vw - 120px)); }
  .ai-conversation-drawer { width: min(360px, calc(100vw - 32px)); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; }
  .sidebar > nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-account { margin-top: 14px; }
  .sidebar-user-card { grid-template-columns: 38px minmax(0, 1fr) auto; justify-items: stretch; }
  .sidebar-user-card .sidebar-user-copy, .sidebar-user-card .sidebar-account-chevron { display: grid; }
  .sidebar-user-popover { left: 0; right: 0; width: auto; }
  .member-list-head { align-items: flex-start; flex-direction: column; }
  .member-page-actions { width: 100%; justify-content: flex-end; }
  .member-add-fields { grid-template-columns: 1fr; }
  .nav-item { font-size: 13px; }
  .topbar, .toolbar, .page-head { align-items: flex-start; flex-direction: column; }
  .project-search,
  .project-search input { width: 100%; min-width: 0; }
  .project-grid { grid-template-columns: minmax(0, 1fr); }
  .project { min-height: 316px; }
  .project .actions { grid-template-columns: 1fr; }
  .project .actions button:nth-child(3) { grid-column: auto; }
  .canvas { grid-template-columns: 1fr; min-height: 420px; }
  .theme-grid { grid-template-columns: 1fr; }
  main { padding: 16px; }
  .studio-shell main { padding: 0; }
  .ai-composer {
    left: 12px;
    right: 12px;
    width: auto;
    grid-template-columns: auto minmax(0, 1fr) auto;
    transform: none;
  }
  .ai-composer.is-expanded .ai-send {
    grid-column: 3;
  }
  .ai-composer.project-agent-composer {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .ai-composer.project-agent-composer.is-expanded .ai-send {
    grid-column: 2;
  }
  .ai-conversation-drawer {
    right: 12px;
    width: auto;
  }
}
