/* Shared floating BioAI assistant (FAB + side panel) for BioStudio studios */

/* One source of truth for the FAB diameter. Declared on the button itself it
   was invisible to ops-support-fab.css, which stacks above it and fell back to
   a stale 52px, leaving the two buttons 4px out of step. */
:root {
  --studio-ai-fab-size: 48px;
}

.studio-ai-host {
  position: relative;
}

.studio-ai-fab {
  position: absolute;
  right: 20px;
  /* One diameter higher than the previous 20px + support-slot offset. */
  bottom: calc(20px + var(--studio-ai-fab-size) + var(--ops-support-fab-clearance, 0px));
  width: var(--studio-ai-fab-size);
  height: var(--studio-ai-fab-size);
  border-radius: 50%;
  border: none;
  background: var(--accent, #1a56db);
  color: var(--on-primary, #fff);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent, #1a56db) 32%, transparent);
  z-index: 100;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.studio-ai-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--accent, #1a56db) 40%, transparent);
}

.studio-ai-panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  top: 16px;
  width: 360px;
  max-width: calc(100% - 32px);
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e5e8ef);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  z-index: 101;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--ink, inherit);
}

.studio-ai-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line, #e5e8ef);
  font-weight: 600;
}

.studio-ai-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent, #1a56db), var(--st-ai, var(--accent, #7c3aed)));
  color: #fff;
}

.studio-ai-close {
  margin-left: auto;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
}

.studio-ai-disclaimer {
  font-size: 10px;
  padding: 6px 12px;
  background: var(--warning-soft, #fef3c7);
  color: var(--warning, #9ca3af);
}

.studio-ai-enc {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 11px;
}

.studio-ai-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 0 4px;
  max-height: 80px;
  overflow-y: auto;
}

.studio-ai-quickbtn {
  padding: 5px 10px;
  border: 1px solid var(--line, #e5e8ef);
  border-radius: 999px;
  background: var(--surface-2, var(--app-bar, #f9fafb));
  color: var(--ink, inherit);
  font-size: 11.5px;
  cursor: pointer;
}
.studio-ai-quickbtn:hover {
  border-color: color-mix(in srgb, var(--accent, #1a56db) 40%, var(--line, #e5e8ef));
  background: color-mix(in srgb, var(--accent, #1a56db) 8%, var(--surface, #fff));
}

.studio-ai-log {
  flex: 1;
  overflow-y: auto;
  padding: 4px 2px 8px;
  min-height: 120px;
}

.studio-ai-msg {
  margin-bottom: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  word-wrap: break-word;
}

.studio-ai-msg.user {
  background: color-mix(in srgb, var(--accent, #1a56db) 12%, var(--surface, #fff));
  color: var(--ink, inherit);
  margin-left: 28px;
}
.studio-ai-msg.ai {
  background: var(--surface-2, var(--app-bar, #f4f6f9));
  color: var(--ink, inherit);
  margin-right: 28px;
}

.studio-ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 12px;
  border-top: 1px solid var(--line, #e5e8ef);
}

.studio-ai-actions button {
  font-size: 10px;
  padding: 4px 8px;
  border: 1px solid var(--line, #e5e8ef);
  border-radius: 6px;
  background: var(--surface, #fff);
  color: var(--ink, inherit);
  cursor: pointer;
}

.studio-ai-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.studio-ai-input {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--line, #e5e8ef);
}

.studio-ai-prompt {
  flex: 1;
  resize: none;
  border: 1px solid var(--line, #e5e8ef);
  border-radius: 6px;
  padding: 6px;
  font: inherit;
  font-size: 13px;
}
.studio-ai-prompt::placeholder {
  color: var(--muted, #94a3b8);
}
.studio-ai-iconbtn:focus-visible,
.studio-ai-send:focus-visible,
.bs-aiwin-btn:focus-visible,
.studio-ai-tab:focus-visible,
.studio-ai-tabadd:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent, #1a56db) 45%, transparent);
  outline-offset: 1px;
}

.studio-ai-send {
  padding: 6px 12px;
  background: var(--accent, #1a56db);
  color: var(--on-primary, #fff);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
}

.studio-ai-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Agent action card ------------------------------------------------------
   Shown only in agent mode: the assistant proposes, the scientist approves.
   Nothing here runs until Apply is pressed. */

.studio-ai-actcard {
  margin: 8px 0 10px;
  border: 1px solid var(--line, #d7dce6);
  border-radius: 12px;
  background: var(--surface, #fff);
  overflow: hidden;
  font-size: 12.5px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.studio-ai-actcard-h {
  padding: 8px 12px;
  background: var(--surface-2, #f4f6f9);
  border-bottom: 1px solid var(--line, #d7dce6);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted, #5b6573);
}

.studio-ai-actlist {
  margin: 0;
  padding: 8px 11px 8px 11px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.studio-ai-actlist li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  line-height: 1.4;
  color: #1f2733;
}

/* Risk is the first thing to read: a database lookup and an overwrite of the
   user's sequence should not look alike. */
.studio-ai-risk {
  flex: none;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.studio-ai-risk.read { background: #e2eefc; color: #1a56db; }
.studio-ai-risk.network { background: #ddf3ef; color: #0a6b52; }
.studio-ai-risk.mutation { background: #fdeacd; color: #8a5200; }

.studio-ai-acterror {
  flex-basis: 100%;
  color: #a02b2b;
  font-size: 11.5px;
}

.studio-ai-actbtns {
  display: flex;
  gap: 8px;
  padding: 0 11px 10px;
}

.studio-ai-apply,
.studio-ai-cancel {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  border: 1px solid transparent;
}
.studio-ai-apply { background: var(--accent, #1a56db); color: var(--on-primary, #fff); }
.studio-ai-apply:hover { filter: brightness(0.92); }
.studio-ai-cancel { background: var(--surface, #fff); border-color: var(--line, #d7dce6); color: var(--muted, #6c7686); }
.studio-ai-cancel:hover { background: var(--surface-2, #eef2f9); color: var(--ink, #1f2733); }

.studio-ai-actstatus {
  padding: 7px 11px;
  border-top: 1px solid #d7dce6;
  font-size: 11.5px;
  font-weight: 600;
}
.studio-ai-actstatus.applied { background: #e7f7f1; color: #0a6b52; }
.studio-ai-actstatus.cancelled { background: #f1f3f7; color: #6c7686; }
.studio-ai-actstatus.failed { background: #fdecec; color: #a02b2b; }
.studio-ai-actstatus.partial { background: #fdeacd; color: #8a5200; }
.studio-ai-actstatus.asked { background: #eef2ff; color: #3730a3; }

/* Unified floating window chrome (every app). */
.bs-aiwin {
  position: absolute;
  z-index: 120;
  display: flex;
  flex-direction: column;
  background: var(--surface, var(--pr-surface, #fff));
  border: 1px solid var(--line, var(--pr-line, #d0d7de));
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.03);
  overflow: hidden;
  min-width: 320px;
  min-height: 360px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  color: var(--ink, var(--pr-ink, #1f2733));
}
.bs-aiwin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  cursor: move;
  user-select: none;
  background: var(--accent, #1a56db);
  color: var(--on-primary, #fff);
}
.bs-aiwin-title { font-weight: 650; font-size: 13px; letter-spacing: 0.01em; }
.bs-aiwin-headbtns { display: flex; gap: 4px; }
.bs-aiwin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}
.bs-aiwin-btn:hover { background: rgba(255, 255, 255, 0.28); }
.bs-aiwin-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Body is hosted inside the window — do not treat it as a second floating card. */
.studio-ai.studio-ai-panel {
  position: relative;
  inset: auto;
  width: auto;
  max-width: none;
  height: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: var(--surface, #fff);
  z-index: auto;
}
.bs-aiwin-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 0 50%, #98a2b3 50% 60%, transparent 60% 70%, #98a2b3 70% 80%, transparent 80%);
  touch-action: none;
}

.studio-ai {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 8px;
  height: 100%;
  min-height: 0;
  font-size: 13px;
  overflow: hidden;
  background: var(--surface, #fff);
}
.studio-ai .studio-ai-head {
  border-bottom: none;
  padding: 0;
}
.studio-ai-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent, #7c3aed);
  display: inline-block;
}
.studio-ai-headbtns { margin-left: auto; display: flex; gap: 6px; }
.studio-ai-headbtn {
  background: var(--surface-2, #f3f4f6);
  color: inherit;
  border: 1px solid var(--line, #e5e8ef);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 7px;
}
.studio-ai-headbtn:hover { border-color: var(--accent, #7c3aed); }

.studio-ai-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  border-bottom: 1px solid var(--line, #e5e8ef);
  padding-bottom: 8px;
  overflow-x: auto;
}
.studio-ai-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 160px;
  background: var(--surface-2, #f4f6f9);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-size: 11.5px;
  color: var(--muted, #5b6573);
  padding: 4px 10px;
}
.studio-ai-tab.active {
  background: color-mix(in srgb, var(--accent, #1a56db) 12%, var(--surface, #fff));
  color: var(--ink, #1f2733);
  font-weight: 650;
}
.studio-ai-tablabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-ai-tabx { color: var(--muted, #9ca3af); font-size: 11px; line-height: 1; }
.studio-ai-tabx:hover { color: var(--ink, #1f2733); }
.studio-ai-tabadd {
  background: transparent;
  border: 1px dashed var(--line, #e5e8ef);
  color: var(--muted, #6c7686);
  border-radius: 999px;
  cursor: pointer;
  padding: 4px 9px;
  font-size: 13px;
  line-height: 1;
}
.studio-ai-tabadd:hover {
  border-color: var(--accent, #1a56db);
  color: var(--accent, #1a56db);
}

.studio-ai-ctxchip {
  font-size: 11.5px;
  color: var(--muted, #5b6573);
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0 2px 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.studio-ai-ctxkicker {
  margin-right: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted, #6b7280);
}
.studio-ai-ctxchip strong {
  color: var(--ink, #1f2733);
  font-weight: 650;
}
.studio-ai-ctxrow {
  display: flex;
  align-items: center;
  gap: 6px;
}
.studio-ai-mapline {
  font-size: 10.5px;
  color: var(--muted, #6b7280);
  line-height: 1.35;
  padding: 0 2px;
}

.studio-ai-do {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}
.studio-ai-do-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #6b7280);
  margin-right: 4px;
}
.studio-ai-dobtn {
  padding: 3px 8px;
  border: 1px solid var(--line, #d7dce6);
  border-radius: 999px;
  background: var(--surface, #fff);
  color: var(--ink, #1f2733);
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
}
.studio-ai-dobtn:hover {
  background: color-mix(in srgb, var(--accent, #1a56db) 10%, var(--surface, #fff));
}

.studio-ai .studio-ai-log { min-height: 80px; flex: 1 1 auto; }
.studio-ai .studio-ai-input {
  align-items: flex-end;
  border-top: 1px solid var(--line, #e5e8ef);
}
.studio-ai-composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
  padding: 8px 0 2px;
  border-top: 1px solid var(--line, #e5e8ef);
  background: var(--surface, #fff);
}
.studio-ai-composer-box {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line, #e5e8ef);
  border-radius: 14px;
  background: var(--surface, #fff);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.studio-ai-composer-box:focus-within {
  border-color: color-mix(in srgb, var(--accent, #1a56db) 55%, var(--line, #e5e8ef));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #1a56db) 16%, transparent);
}
.studio-ai-composer-box .studio-ai-prompt,
.studio-ai.compact .studio-ai-composer-box .studio-ai-prompt {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  min-height: 44px;
  max-height: 160px;
  resize: none;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.45;
  padding: 10px 12px 4px;
  border-radius: 0;
  field-sizing: content;
}
.studio-ai-composer-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 6px;
  min-height: 36px;
}
.studio-ai-voice-slot {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
}
.studio-ai-composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.studio-ai-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted, #6c7686);
  cursor: pointer;
}
.studio-ai-iconbtn svg {
  width: 16px;
  height: 16px;
  display: block;
}
.studio-ai-iconbtn:hover {
  background: var(--surface-2, #f3f4f6);
  color: var(--ink, #1f2733);
}
.studio-ai-lock.on {
  color: #0f766e;
  background: color-mix(in srgb, #0f766e 12%, transparent);
}
.studio-ai-morebtn.open {
  color: var(--accent, #1a56db);
  background: color-mix(in srgb, var(--accent, #1a56db) 12%, transparent);
}
.studio-ai-composer-tools .studio-ai-send,
.studio-ai-composer-row .studio-ai-send {
  margin-left: 2px;
  min-width: 64px;
  min-height: 32px;
  height: 32px;
  font-size: 13px;
  font-weight: 650;
  padding: 0 14px;
  border-radius: 8px;
}
.studio-ai-composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.studio-ai.compact .studio-ai-composer { flex: 0 0 auto; }
.studio-ai.compact .studio-ai-log { min-height: 48px; }
.studio-ai.compact .studio-ai-tabs { flex-wrap: nowrap; overflow-x: auto; }
.studio-ai.compact .studio-ai-ctxchip {
  background: transparent;
  border: none;
  color: var(--muted, #5b6573);
  padding: 0 2px 2px;
  font-size: 11.5px;
}
.studio-ai.compact .studio-ai-quick {
  max-height: 56px;
  overflow-y: auto;
  padding: 0;
}
.studio-ai.compact .studio-ai-hint {
  font-size: 11px;
  color: var(--muted, #6b7280);
}
.studio-ai-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink, inherit);
}
.studio-ai-field .bs-voice-openai-voice {
  max-width: 140px;
}
.studio-ai-more {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line, #e5e8ef);
  border-radius: 12px;
  background: var(--surface-2, #f8fafc);
}
.studio-ai-askbtns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 11px 10px;
}
.studio-ai-askbtn {
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  padding: 6px 10px;
  cursor: pointer;
}
.studio-ai-askbtn:hover { background: #e0e7ff; }
.studio-ai-verb {
  font-size: 11px;
  padding: 5px 4px;
  border: 1px solid var(--line, #e5e8ef);
  border-radius: 6px;
  background: var(--surface, #fff);
  color: var(--ink, inherit);
  max-width: 92px;
}
.studio-ai-hint {
  font-size: 11px;
  color: var(--muted, #9ca3af);
  padding: 0 4px 4px;
  line-height: 1.4;
}

.studio-ai-conv { font-size: 11px; }
.studio-ai-convhead {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
  color: #4b5563;
  padding: 4px 0;
}
.studio-ai-convempty { color: #9ca3af; font-size: 11px; padding: 4px 0 8px; }
.studio-ai-convbody { max-height: 180px; overflow: auto; border: 1px solid var(--line, #e5e8ef); border-radius: 8px; padding: 6px; }
.studio-ai-turn { margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid #f3f4f6; }
.studio-ai-trmeta { display: flex; gap: 8px; align-items: center; font-size: 10px; color: #6b7280; margin-bottom: 4px; }
.studio-ai-encbadge {
  background: #dcfce7;
  color: #166534;
  border-radius: 8px;
  padding: 1px 6px;
  font-weight: 700;
}
.studio-ai-encbadge.off { background: #fef3c7; color: #92400e; }
.studio-ai-trrole { font-size: 10px; font-weight: 700; color: #6b7280; margin: 6px 0 2px; }
.studio-ai-trrole.enc { color: #b45309; }
.studio-ai-trmsg {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11px;
  background: #f9fafb;
  border-radius: 6px;
  padding: 6px;
  max-height: 90px;
  overflow: auto;
}
.studio-ai-trmsg.ai { background: #eef2ff; }
.studio-ai-enc-tok {
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 3px;
  padding: 0 3px;
  font-weight: 700;
}
.studio-ai-mapbtn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: #4b5563;
  padding: 4px 0;
}
.studio-ai-maptbl { width: 100%; border-collapse: collapse; font-size: 11px; }
.studio-ai-maptbl th, .studio-ai-maptbl td { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line, #e5e8ef); }

@media (max-width: 640px) {
  .bs-aiwin { max-width: calc(100% - 16px); }
}
