:root {
  color-scheme: light;
}

html {
  min-width: 320px;
  height: 100%;
  background: #ffffff;
}

.ai-lab-page {
  --ai-blue: #2457ff;
  --ai-blue-deep: #153bc6;
  --ai-blue-soft: #e9efff;
  --ai-lime: #c9ff42;
  --ai-ink: #121722;
  --ai-muted: #596577;
  --ai-text-soft: #748093;
  --ai-type-body: clamp(.84rem, .81rem + .08vw, .92rem);
  --ai-type-ui: clamp(.66rem, .63rem + .06vw, .72rem);
  --ai-type-meta: clamp(.56rem, .54rem + .04vw, .6rem);
  --ai-line: rgba(30, 49, 94, 0.12);
  --ai-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  width: 100%;
  height: 100dvh;
  min-width: 320px;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  background: #ffffff;
  color: var(--ai-ink);
  font-family: "Golos Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-variant-emoji: text;
  -webkit-font-smoothing: antialiased;
}

.ai-lab-page *,
.ai-lab-page *::before,
.ai-lab-page *::after {
  box-sizing: border-box;
}

:where(.ai-lab-page) button,
:where(.ai-lab-page) textarea {
  color: inherit;
  font: inherit;
}

:where(.ai-lab-page) button {
  border: 0;
  cursor: pointer;
}

.ai-lab-page a {
  color: inherit;
  text-decoration: none;
}

.ai-lab-page ::selection {
  background: var(--ai-lime);
  color: var(--ai-ink);
}

.ai-lab-shell {
  display: grid;
  grid-template-rows: 86px minmax(0, 1fr) 34px;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
}

.ai-topbar {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 240px minmax(220px, 1fr) auto;
  align-items: center;
  min-height: 0;
  border-bottom: 1px solid rgba(36, 87, 255, 0.12);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 38px rgba(24, 39, 79, 0.06);
  backdrop-filter: blur(18px);
}

.ai-brand {
  display: flex;
  align-items: center;
  align-self: stretch;
  padding-left: clamp(24px, 4vw, 68px);
}

.ai-brand img {
  display: block;
  width: 190px;
  height: 56px;
  object-fit: cover;
  object-position: left center;
  mix-blend-mode: multiply;
}

.ai-page-label {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 0 26px;
}

.ai-page-label span {
  color: var(--ai-blue);
  font-family: var(--ai-mono);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ai-page-label small {
  color: #606875;
  font-size: .75rem;
}

.ai-top-actions {
  display: flex;
  align-self: stretch;
  border-left: 1px solid rgba(36, 87, 255, 0.1);
}

.ai-top-actions a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-width: 118px;
  padding: 0 18px;
  border-left: 1px solid var(--ai-line);
  color: #596376;
  font-size: .75rem;
  font-weight: 700;
}

.ai-top-actions a:first-child {
  border-left: 0;
}

.ai-top-actions i {
  color: var(--ai-blue);
  font-style: normal;
  transition: transform 0.25s ease;
}

.ai-top-actions a:hover i {
  transform: translate(3px, -3px);
}

.ai-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--ai-line);
}

.ai-chat {
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: #fbfcfe;
}

.ai-chat-head {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  border-bottom: 1px solid var(--ai-line);
}

.ai-chat-head > div {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 18px;
}

.ai-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #39bd59;
}

.ai-chat-head strong {
  font-size: .75rem;
}

.ai-chat-head small {
  color: #939cab;
  font-family: var(--ai-mono);
  font-size: .75rem;
}

.ai-chat-head button {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 0 18px;
  border-left: 1px solid var(--ai-line);
  background: #fafbfe;
  color: #687285;
  font-size: .75rem;
  font-weight: 700;
}

.ai-chat-head button i {
  color: var(--ai-blue);
  font-size: 0.8rem;
  font-style: normal;
}

.ai-messages {
  min-height: 0;
  padding: 34px clamp(22px, 5vw, 84px) 26px;
  overflow: auto;
  scroll-behavior: smooth;
}

.ai-welcome {
  position: relative;
  display: flex;
  width: min(100%, 760px);
  min-height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  padding: 32px 0;
  overflow: hidden;
  text-align: center;
}

.ai-welcome-index {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(36, 87, 255, 0.045);
  font-size: clamp(9rem, 18vw, 17rem);
  font-weight: 800;
  letter-spacing: -0.12em;
  line-height: 0.8;
  pointer-events: none;
}

.ai-welcome > span {
  position: relative;
  color: var(--ai-blue);
  font-family: var(--ai-mono);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.ai-welcome h1 {
  position: relative;
  max-width: 550px;
  margin: 18px 0 0;
  font-size: clamp(2.5rem, 5vw, 5.4rem);
  letter-spacing: -0.075em;
  line-height: 0.9;
}

.ai-welcome p {
  position: relative;
  max-width: 510px;
  margin: 24px 0 0;
  color: var(--ai-muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.ai-welcome-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
  margin-top: 28px;
}

.ai-welcome-actions button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--ai-line);
  border-radius: 6px;
  background: #ffffff;
  color: #687285;
  text-align: left;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.ai-welcome-actions button span {
  color: var(--ai-blue);
  font-family: var(--ai-mono);
  font-size: .75rem;
  font-weight: 800;
}

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

.ai-welcome-actions button i {
  color: #a0a7b3;
  font-size: .75rem;
  font-style: normal;
}

.ai-welcome-actions button:hover {
  transform: translateY(-2px);
  border-color: rgba(36, 87, 255, 0.28);
  color: var(--ai-blue);
}

.ai-welcome.is-compact {
  min-height: 0;
}

.ai-welcome.is-compact h1 {
  font-size: clamp(2.2rem, 4vw, 4rem);
}

.ai-message {
  display: grid;
  gap: 10px;
  width: min(100%, 860px);
  margin: 0 auto 32px;
}

.ai-message > header {
  display: grid;
  grid-template-columns: 30px auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 0;
}

.ai-message.is-assistant > header::before {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  background: var(--ai-blue);
  color: #ffffff;
  content: "AI";
  font-family: var(--ai-mono);
  font-size: .75rem;
  font-weight: 800;
}

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

.ai-message > header span {
  justify-self: end;
  color: #99a2b1;
  font-family: var(--ai-mono);
  font-size: .75rem;
}

.ai-message > div {
  padding: 0;
  border: 0;
  background: transparent;
  color: #344055;
  font-size: 0.82rem;
  line-height: 1.72;
}

.ai-message.is-assistant > div {
  width: calc(100% - 40px);
  margin-left: 40px;
}

.ai-message.is-user > header {
  display: none;
}

.ai-message.is-user > div {
  width: fit-content;
  max-width: min(78%, 680px);
  margin-left: auto;
  padding: 13px 17px;
  border: 1px solid rgba(30, 49, 94, 0.08);
  border-radius: 18px 18px 5px 18px;
  background: #eef2f8;
  color: #2d384c;
}

.ai-message > div > p {
  margin: 0;
  white-space: pre-wrap;
}

.ai-message.is-assistant > div > h2,
.ai-message.is-assistant > div > h3 {
  margin: 22px 0 8px;
  color: #243149;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.ai-message.is-assistant > div > h2:first-child,
.ai-message.is-assistant > div > h3:first-child {
  margin-top: 0;
}

.ai-message.is-assistant > div > h2 {
  font-size: 1.02rem;
}

.ai-message.is-assistant > div > h3 {
  font-size: 0.9rem;
}

.ai-message.is-assistant > div > ul,
.ai-message.is-assistant > div > ol {
  display: grid;
  gap: 7px;
  margin: 14px 0 0;
  padding-left: 21px;
}

.ai-message.is-assistant > div > ul {
  list-style: disc;
}

.ai-message.is-assistant > div > ol {
  list-style: decimal;
}

.ai-message.is-assistant > div strong {
  color: #273349;
  font-weight: 700;
}

.ai-message.is-assistant > div p code,
.ai-message.is-assistant > div li code {
  padding: 2px 5px;
  border: 1px solid rgba(30, 49, 94, 0.09);
  border-radius: 5px;
  background: #f1f4f8;
  color: #1749dd;
  font-family: var(--ai-mono);
  font-size: .75rem;
}

.ai-message > div > p + p,
.ai-message > div > p + .ai-code,
.ai-message > div > .ai-code + p,
.ai-message > div > .ai-code + .ai-code {
  margin-top: 14px;
}

.ai-message.is-writing > div > p:last-child::after {
  display: inline-block;
  width: 2px;
  height: 0.9em;
  margin-left: 4px;
  transform: translateY(0.12em);
  background: var(--ai-blue);
  content: "";
  animation: ai-writing-cursor 0.75s steps(1, end) infinite;
}

@keyframes ai-writing-cursor {
  50% {
    opacity: 0;
  }
}

.ai-message.is-thinking {
  margin-bottom: 24px;
}

.ai-message.is-thinking > div {
  padding: 4px 0 0;
}

.ai-thinking {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 54px;
}

.ai-thinking-symbol {
  display: flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid rgba(36, 87, 255, 0.14);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 9px 24px rgba(36, 87, 255, 0.08);
}

.ai-thinking-symbol i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ai-blue);
  animation: ai-thinking-dot 1.15s ease-in-out infinite;
}

.ai-thinking-symbol i:nth-child(2) {
  animation-delay: 0.16s;
}

.ai-thinking-symbol i:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes ai-thinking-dot {
  0%,
  70%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  35% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.ai-thinking-copy {
  display: grid;
  gap: 3px;
}

.ai-thinking-copy strong {
  color: #344055;
  font-size: .75rem;
}

.ai-thinking-copy small,
.ai-thinking-time {
  color: #929cab;
  font-family: var(--ai-mono);
  font-size: .75rem;
}

.ai-thinking-time {
  min-width: 34px;
  text-align: right;
}

.ai-code {
  overflow: hidden;
  border: 1px solid rgba(30, 49, 94, 0.13);
  border-radius: 8px;
  background: #ffffff;
}

.ai-code header {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 13px;
  border-bottom: 1px solid var(--ai-line);
  background: #f7f9fd;
}

.ai-code header span,
.ai-code header button {
  color: #7e889a;
  font-family: var(--ai-mono);
  font-size: .75rem;
}

.ai-code header button {
  padding: 5px 7px;
  border-radius: 4px;
  background: transparent;
}

.ai-code header button:hover {
  background: var(--ai-blue-soft);
  color: var(--ai-blue);
}

.ai-code pre {
  margin: 0;
  padding: 15px 16px;
  overflow: auto;
}

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

.ai-composer {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto auto;
  width: min(900px, calc(100% - 40px));
  min-height: 96px;
  margin: 0 auto 20px;
  border: 1px solid rgba(30, 49, 94, 0.13);
  border-radius: 24px;
  background: #ffffff;
  box-shadow:
    0 18px 55px rgba(31, 50, 99, 0.09),
    0 2px 8px rgba(31, 50, 99, 0.04);
}

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

.ai-composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 150px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 18px 22px 6px;
  overflow-y: auto;
  background: transparent;
  color: #253147;
  font-size: 0.82rem;
  line-height: 1.55;
}

.ai-composer textarea::placeholder {
  color: #a0a8b5;
}

.ai-composer textarea:disabled {
  opacity: 0.65;
}

.ai-composer-actions {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 15px;
  padding: 0 8px 8px 20px;
}

.ai-composer-actions > span,
.ai-composer-actions > small {
  color: #96a0af;
  font-family: var(--ai-mono);
  font-size: .75rem;
}

.ai-composer-actions > small {
  display: none;
}

.ai-composer-actions button {
  position: relative;
  display: flex;
  width: 40px;
  min-width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 0;
  overflow: hidden;
  border-radius: 50%;
  background: var(--ai-blue);
  color: #ffffff;
  font-size: .75rem;
  font-weight: 700;
}

.ai-composer-actions button > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.ai-composer-actions button:hover {
  background: var(--ai-blue-deep);
}

.ai-composer-actions button i {
  color: #ffffff;
  font-size: 1rem;
  font-style: normal;
}

.ai-composer-actions button:disabled {
  opacity: 0.72;
}

.ai-composer-actions button.is-loading {
  pointer-events: none;
}

.ai-composer-actions button.is-loading::after {
  position: absolute;
  width: 11px;
  height: 11px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--ai-lime);
  border-radius: 50%;
  content: "";
  animation: ai-spin 0.7s linear infinite;
}

.ai-composer-actions button.is-loading i {
  visibility: hidden;
}

@keyframes ai-spin {
  to {
    transform: rotate(360deg);
  }
}

.ai-statusbar {
  display: flex;
  min-width: 0;
  align-items: center;
  overflow: hidden;
  background: var(--ai-blue);
  color: rgba(255, 255, 255, 0.72);
  font-family: var(--ai-mono);
  font-size: .75rem;
  letter-spacing: 0.04em;
}

.ai-statusbar > span,
.ai-statusbar > a {
  display: flex;
  height: 100%;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border-right: 1px solid rgba(255, 255, 255, 0.13);
  white-space: nowrap;
}

.ai-statusbar > span:first-child {
  padding-left: clamp(24px, 4vw, 68px);
  color: #ffffff;
}

.ai-statusbar > span:first-child i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ai-lime);
}

.ai-statusbar > a {
  margin-left: auto;
  border-right: 0;
  color: #ffffff;
}

@media (max-width: 1180px) {
  .ai-topbar {
    grid-template-columns: 220px minmax(180px, 1fr) auto;
  }
}

@media (max-width: 940px) {
  .ai-top-actions a {
    min-width: 82px;
  }

  .ai-top-actions a span {
    display: none;
  }
}

@media (max-width: 700px) {
  .ai-lab-shell {
    grid-template-rows: 62px minmax(0, 1fr) 34px;
  }

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

  .ai-brand {
    padding: 7px 0 7px 15px;
  }

  .ai-brand img {
    width: 158px;
    height: 48px;
  }

  .ai-page-label {
    display: none;
  }

  .ai-top-actions a {
    min-width: 54px;
    padding: 0 12px;
  }

  .ai-chat {
    grid-template-rows: 48px minmax(0, 1fr) auto;
  }

  .ai-messages {
    padding: 18px 14px;
  }

  .ai-welcome {
    padding: 30px 0;
  }

  .ai-welcome h1 {
    font-size: clamp(2.45rem, 14vw, 4.2rem);
  }

  .ai-message.is-user {
    width: 100%;
  }

  .ai-message.is-assistant > div {
    width: calc(100% - 36px);
    margin-left: 36px;
  }

  .ai-composer {
    width: calc(100% - 20px);
    min-height: 92px;
    margin: 0 10px 10px;
  }

  .ai-composer-actions > small {
    display: none;
  }

  .ai-composer-actions > span {
    margin-right: auto;
  }

  .ai-composer-actions button {
    min-width: 40px;
  }

  .ai-statusbar > span:nth-child(2),
  .ai-statusbar > span:nth-child(3),
  .ai-statusbar > a {
    display: none;
  }

  .ai-statusbar > span:first-child {
    padding-left: 14px;
  }
}

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

/* Chat typography stays compact, but no essential label drops below the UI scale. */
.ai-page-label span,
.ai-chat-head small,
.ai-welcome > span,
.ai-welcome-actions button span,
.ai-message.is-assistant > header::before,
.ai-message > header span,
.ai-thinking-copy small,
.ai-thinking-time,
.ai-code header span,
.ai-code header button,
.ai-composer-actions > span,
.ai-composer-actions > small,
.ai-statusbar {
  font-size: var(--ai-type-meta);
}

.ai-page-label small,
.ai-top-actions a,
.ai-chat-head strong,
.ai-chat-head button,
.ai-welcome-actions button strong,
.ai-message > header strong,
.ai-thinking-copy strong,
.ai-code code {
  font-size: var(--ai-type-ui);
}

.ai-welcome p,
.ai-message > div,
.ai-composer textarea {
  color: var(--ai-muted);
  font-size: var(--ai-type-body);
}

.ai-chat-head small,
.ai-welcome-actions button,
.ai-message > header span,
.ai-thinking-copy small,
.ai-thinking-time,
.ai-code header span,
.ai-code header button,
.ai-composer-actions > span,
.ai-composer-actions > small {
  color: var(--ai-text-soft);
}
