:root {
  color-scheme: light;
  --bg: #f0f1fd;
  --bg-2: #e8e9fc;
  --panel: #ffffff;
  --panel-2: #f8f8ff;
  --line: #d1d4fa;
  --text: #21244f;
  --muted: #6a6e9e;
  --purple: #2c2d65;
  --purple-soft: #7f81b0;
  --gold: #fed100;
  --gold-2: #fed100;
  --ok: #12805c;
  --bad: #d64b5f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--gold);
  color: var(--purple);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgb(44 45 101 / 10%);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.side {
  border-right: 1px solid var(--line);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  background: var(--bg-2);
}

.brand {
  display: grid;
  gap: 18px;
}

.brand img {
  width: min(220px, 100%);
  height: auto;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--purple);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 44px;
  line-height: 1;
}

h2 {
  font-size: 24px;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
}

.dot.ok {
  background: var(--ok);
}

.dot.bad {
  background: var(--bad);
}

.scope {
  color: var(--muted);
  line-height: 1.55;
}

.scope p:first-child {
  color: var(--text);
  font-weight: 700;
}

.side-actions {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.side-actions a,
.side-actions button {
  display: block;
  text-align: center;
  padding: 11px 12px;
  border-radius: 6px;
  text-decoration: none;
}

.side-actions a {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 70%);
}

.side-actions button {
  background: #ffffff;
  color: var(--muted);
  box-shadow: none;
}

.main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel {
  width: min(680px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.hint,
.message,
.save-message {
  color: var(--muted);
  line-height: 1.5;
}

label {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
  font-weight: 700;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input {
  min-height: 44px;
  padding: 10px 12px;
}

.row button {
  min-height: 44px;
  padding: 0 18px;
}

.chat {
  width: min(1100px, 100%);
  height: calc(100vh - 48px);
  min-height: 620px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.pill {
  color: var(--muted);
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 13px;
}

.messages {
  overflow: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bubble {
  width: min(760px, 92%);
  border-radius: 8px;
  padding: 14px 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble.user {
  align-self: flex-end;
  background: var(--purple);
  color: #ffffff;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.composer textarea {
  min-height: 48px;
  max-height: 150px;
  resize: none;
  padding: 13px 14px;
}

.composer button {
  min-width: 86px;
  min-height: 48px;
}

.save-message {
  margin: 0;
  min-height: 20px;
  padding: 0 18px 14px;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.thinking {
  color: var(--muted);
  font-style: italic;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.think-dots {
  display: inline-flex;
  gap: 4px;
}
.think-dots i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--purple-soft);
  display: inline-block;
  animation: engenai-thinkbounce 1.2s ease-in-out infinite;
}
.think-dots i:nth-child(2) { animation-delay: 0.18s; }
.think-dots i:nth-child(3) { animation-delay: 0.36s; }

@keyframes engenai-thinkbounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

.think-stream {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.think-stream .think-head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--purple-soft);
  font-style: italic;
  font-size: 13px;
}
.think-stream .think-body {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  font-style: italic;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
  opacity: 0.92;
}
.bubble.assistant.reply {
  font-style: normal;
}

/* A subtle pulse on the assistant bubble while the worker is still thinking. */
.bubble.assistant:has(.think-dots) {
  animation: engenai-bubblepulse 1.8s ease-in-out infinite;
}
@keyframes engenai-bubblepulse {
  0%, 100% { border-color: var(--line); }
  50% { border-color: var(--purple-soft); }
}

.error {
  color: var(--bad);
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.activity-log {
  width: min(760px, 92%);
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px dashed var(--line);
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  max-height: 160px;
  overflow: auto;
}

.activity-line {
  line-height: 1.45;
}

.activity-line.thinking {
  color: var(--purple-soft);
}

.activity-line.tool {
  color: var(--text);
}

.activity-line.subagent {
  color: var(--purple);
}

.activity-line.tasks {
  color: var(--ok);
}

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

  .side {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 18px;
    gap: 14px;
  }

  .brand {
    grid-template-columns: 140px 1fr;
    align-items: center;
  }

  h1 {
    font-size: 34px;
  }

  .scope,
  .side-actions {
    display: none;
  }

  .main {
    min-height: auto;
    padding: 12px;
  }

  .chat {
    height: calc(100vh - 162px);
    min-height: 480px;
  }

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

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