.lab-run-controls {
  display: flex;
  align-items: stretch;
}

.lab-ai-button {
  display: flex;
  min-width: 124px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 15px;
  border-right: 1px solid var(--lab-border);
  background: #f7f9fd;
  color: #4f5a6e;
}

.lab-ai-button:hover,
.lab-ai-button[aria-expanded="true"] {
  background: var(--lab-blue-soft);
  color: var(--lab-blue);
}

.lab-ai-button.is-busy {
  pointer-events: none;
}

.lab-ai-button-mark {
  position: relative;
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 8px;
  background: var(--lab-blue);
  color: #ffffff;
  font-family: var(--lab-mono);
  font-size: .75rem;
  font-weight: 800;
  box-shadow: 0 7px 18px rgba(36, 87, 255, 0.18);
}

.lab-ai-button.is-busy .lab-ai-button-mark {
  color: transparent;
}

.lab-ai-button.is-busy .lab-ai-button-mark::after {
  position: absolute;
  width: 9px;
  height: 9px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  content: "";
  animation: lab-spinner 0.7s linear infinite;
}

.lab-ai-button > span:last-child {
  display: grid;
  gap: 2px;
  text-align: left;
}

.lab-ai-button strong {
  font-size: .75rem;
}

.lab-ai-button small {
  color: #919aaa;
  font-family: var(--lab-mono);
  font-size: .75rem;
}

.lab-console-head > div:last-child {
  display: flex;
  align-items: center;
  gap: 9px;
}

.lab-console-ai {
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--lab-blue-soft);
  color: var(--lab-blue);
  font-size: .75rem;
  font-weight: 700;
}

.lab-console-ai[hidden] {
  display: none;
}

.lab-ai-panel {
  position: fixed;
  z-index: 80;
  top: 86px;
  right: 0;
  bottom: 34px;
  display: grid;
  grid-template-rows: 60px auto auto minmax(90px, 1fr) auto auto;
  width: min(450px, calc(100vw - 24px));
  min-height: 0;
  transform: translateX(104%);
  visibility: hidden;
  border-left: 1px solid rgba(36, 87, 255, 0.13);
  background: rgba(250, 251, 254, 0.98);
  box-shadow: -28px 0 70px rgba(24, 39, 79, 0.14);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition:
    transform 0.42s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.42s;
}

.lab-ai-panel.is-open {
  transform: translateX(0);
  visibility: visible;
}

.lab-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 0 20px;
  border-bottom: 1px solid var(--lab-border);
  background: #ffffff;
}

.lab-ai-head > div {
  display: grid;
  gap: 4px;
}

.lab-ai-head span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--lab-blue);
  font-family: var(--lab-mono);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.lab-ai-head span i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #43c95c;
  box-shadow: 0 0 0 4px rgba(67, 201, 92, 0.1);
}

.lab-ai-head strong {
  color: #253147;
  font-size: .75rem;
}

.lab-ai-head > button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: #f1f4f9;
  color: #697488;
  font-size: 1rem;
}

.lab-ai-context {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 0 18px;
  border-bottom: 1px solid var(--lab-border);
  background: #f8f9fc;
}

.lab-ai-context span,
.lab-ai-context small {
  color: #8b95a5;
  font-family: var(--lab-mono);
  font-size: .75rem;
}

.lab-ai-context strong {
  overflow: hidden;
  color: #526074;
  font-family: var(--lab-mono);
  font-size: .75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lab-ai-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 12px;
  border-bottom: 1px solid var(--lab-border);
  background: #ffffff;
}

.lab-ai-actions button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 2px 8px;
  min-height: 48px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid rgba(30, 49, 94, 0.08);
  border-radius: 8px;
  background: #f8f9fc;
  text-align: left;
}

.lab-ai-actions button:hover {
  transform: translateY(-1px);
  border-color: rgba(36, 87, 255, 0.2);
  background: var(--lab-blue-soft);
}

.lab-ai-actions button:disabled {
  pointer-events: none;
  opacity: 0.55;
}

.lab-ai-actions button > span {
  grid-row: 1 / 3;
  color: var(--lab-blue);
  font-family: var(--lab-mono);
  font-size: .75rem;
}

.lab-ai-actions button strong {
  align-self: end;
  color: #374257;
  font-size: .75rem;
}

.lab-ai-actions button small {
  align-self: start;
  color: #929baa;
  font-family: var(--lab-mono);
  font-size: .75rem;
}

.lab-ai-feed {
  min-height: 0;
  padding: 17px 18px;
  overflow: auto;
  background:
    radial-gradient(circle at 88% 5%, rgba(36, 87, 255, 0.06), transparent 28%),
    #fbfcfe;
}

.lab-ai-welcome {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.lab-ai-welcome > span {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  background: var(--lab-blue);
  color: #ffffff;
  font-family: var(--lab-mono);
  font-size: .75rem;
  font-weight: 800;
}

.lab-ai-welcome > div {
  padding-top: 2px;
}

.lab-ai-welcome strong {
  color: #344055;
  font-size: .75rem;
}

.lab-ai-welcome p {
  margin: 7px 0 0;
  color: #758093;
  font-size: .75rem;
  line-height: 1.55;
}

.lab-ai-message {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.lab-ai-message header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lab-ai-message header strong {
  color: #566174;
  font-size: .75rem;
}

.lab-ai-message header span {
  color: #9aa3b1;
  font-family: var(--lab-mono);
  font-size: .75rem;
}

.lab-ai-message p {
  margin: 0;
  padding: 11px 12px;
  border: 1px solid rgba(30, 49, 94, 0.08);
  border-radius: 10px;
  background: #ffffff;
  color: #3d485b;
  font-size: .75rem;
  line-height: 1.58;
  white-space: pre-wrap;
}

.lab-ai-message.is-user {
  width: 86%;
  margin-left: auto;
}

.lab-ai-message.is-user p {
  border-color: rgba(36, 87, 255, 0.12);
  background: var(--lab-blue-soft);
}

.lab-ai-message.is-thinking p {
  position: relative;
  padding-left: 34px;
  color: #7e8899;
}

.lab-ai-message.is-thinking p::before {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border: 1px solid rgba(36, 87, 255, 0.25);
  border-top-color: var(--lab-blue);
  border-radius: 50%;
  content: "";
  animation: lab-spinner 0.7s linear infinite;
}

.lab-ai-proposal {
  display: grid;
  max-height: min(310px, 42vh);
  grid-template-rows: 44px minmax(70px, 1fr) 48px;
  min-height: 180px;
  margin: 0 12px 10px;
  overflow: hidden;
  border: 1px solid rgba(36, 87, 255, 0.17);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 14px 35px rgba(31, 50, 99, 0.1);
}

.lab-ai-proposal[hidden] {
  display: none;
}

.lab-ai-proposal > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--lab-border);
  background: #f7f9fd;
}

.lab-ai-proposal > header div {
  display: grid;
  gap: 2px;
}

.lab-ai-proposal > header span {
  color: var(--lab-blue);
  font-family: var(--lab-mono);
  font-size: .75rem;
  font-weight: 700;
}

.lab-ai-proposal > header strong {
  color: #697386;
  font-size: .75rem;
}

.lab-ai-proposal > header button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  color: #818b9b;
}

.lab-ai-proposal pre {
  min-height: 0;
  margin: 0;
  padding: 13px 15px;
  overflow: auto;
  background: #ffffff;
}

.lab-ai-proposal code {
  color: #273246;
  font-family: var(--lab-mono);
  font-size: .75rem;
  line-height: 1.58;
  white-space: pre;
}

.lab-ai-proposal footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 8px;
  border-top: 1px solid var(--lab-border);
  background: #f9fafc;
}

.lab-ai-proposal footer button {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 6px;
  background: #eef1f6;
  color: #647084;
  font-size: .75rem;
  font-weight: 700;
}

.lab-ai-proposal footer [data-ai-apply] {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--lab-blue);
  color: #ffffff;
}

.lab-ai-proposal footer [data-ai-apply] i {
  color: var(--lab-lime);
  font-style: normal;
}

.lab-ai-form {
  display: grid;
  grid-template-rows: minmax(58px, auto) 40px;
  margin: 0 12px 12px;
  border: 1px solid rgba(36, 87, 255, 0.15);
  border-radius: 13px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(31, 50, 99, 0.07);
}

.lab-ai-form > label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.lab-ai-form textarea {
  width: 100%;
  min-height: 58px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 13px 14px 5px;
  background: transparent;
  color: #344055;
  font-size: .75rem;
  line-height: 1.5;
}

.lab-ai-form textarea::placeholder {
  color: #9ba4b2;
}

.lab-ai-form > div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 6px 13px;
}

.lab-ai-form > div > span {
  overflow: hidden;
  color: #929baa;
  font-family: var(--lab-mono);
  font-size: .75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lab-ai-form button {
  display: grid;
  width: 34px;
  min-width: 34px;
  height: 34px;
  margin-left: auto;
  place-items: center;
  border-radius: 50%;
  background: var(--lab-blue);
  color: #ffffff;
}

.lab-ai-form button i {
  font-style: normal;
}

.lab-ai-form button:disabled {
  opacity: 0.55;
}

@media (max-width: 920px) {
  .lab-ai-panel {
    top: 74px;
  }

  .lab-ai-button {
    min-width: 48px;
    padding: 0 10px;
  }

  .lab-ai-button > span:last-child {
    display: none;
  }
}

@media (max-width: 720px) {
  .lab-ai-panel {
    width: 100%;
  }

  .lab-console-ai {
    max-width: 86px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .lab-ai-panel {
    top: 66px;
  }

  .lab-ai-actions {
    padding: 9px;
  }

  .lab-ai-context {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .lab-ai-context small {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lab-ai-panel,
  .lab-ai-panel * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Keep assistant controls aligned with the IDE's readable compact scale. */
.lab-ai-button-mark,
.lab-ai-button small,
.lab-ai-head span,
.lab-ai-context span,
.lab-ai-context small,
.lab-ai-actions button > span,
.lab-ai-actions button small,
.lab-ai-message header span,
.lab-ai-proposal > header span,
.lab-ai-form > div > span {
  font-size: var(--lab-type-meta, .58rem);
}

.lab-ai-button strong,
.lab-console-ai,
.lab-ai-head strong,
.lab-ai-context strong,
.lab-ai-actions button strong,
.lab-ai-welcome strong,
.lab-ai-welcome p,
.lab-ai-message header strong,
.lab-ai-message p,
.lab-ai-proposal > header strong,
.lab-ai-proposal code,
.lab-ai-proposal footer button,
.lab-ai-form textarea {
  font-size: var(--lab-type-ui, .68rem);
}

.lab-ai-button small,
.lab-ai-context span,
.lab-ai-context small,
.lab-ai-actions button small,
.lab-ai-message header span,
.lab-ai-form > div > span {
  color: #748092;
}
