:root {
  color-scheme: dark;
  --bg: #070a10;
  --panel: rgba(12, 17, 26, 0.94);
  --panel-soft: rgba(255, 255, 255, 0.045);
  --border: rgba(255, 255, 255, 0.12);
  --text: #f7fafc;
  --muted: #9aa7b8;
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.12);
  --violet: #8b5cf6;
  --orange: #fb923c;
  --green: #34d399;
  --danger: #fb7185;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: clip;
}

body {
  min-height: 100dvh;
  margin: 0;
  overflow-x: clip;
  background:
    linear-gradient(135deg, rgba(34, 211, 238, 0.08), transparent 34%),
    linear-gradient(225deg, rgba(251, 146, 60, 0.08), transparent 36%),
    linear-gradient(180deg, #070a10 0%, #0a111c 54%, #070a10 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1380px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.brand img {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(34, 211, 238, 0.24),
    0 0 30px rgba(139, 92, 246, 0.28);
}

.brand span {
  display: grid;
  min-width: 0;
}

.brand strong {
  font-size: 0.96rem;
  line-height: 1.2;
}

.brand small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.ghost-link,
.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 650;
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
  white-space: nowrap;
}

.ghost-link {
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.ghost-link:hover {
  border-color: rgba(34, 211, 238, 0.38);
  color: var(--text);
}

.primary-link {
  border-color: rgba(34, 211, 238, 0.36);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(139, 92, 246, 0.18));
  color: #eafdff;
}

.primary-link:hover {
  border-color: rgba(251, 146, 60, 0.52);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 18px;
  padding-top: 18px;
}

.chat-surface,
.tech-panel article {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
}

.chat-surface {
  display: flex;
  min-height: calc(100dvh - 116px);
  overflow: hidden;
  border-radius: 8px;
  flex-direction: column;
}

.chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 760;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-block-start: 0;
}

h1 {
  margin-block-end: 0;
  font-size: clamp(1.28rem, 2.2vw, 2rem);
  line-height: 1.1;
}

.route-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.route-meta span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  padding: 0 9px;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  border: 1px solid rgba(52, 211, 153, 0.24);
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.08);
  padding: 0 10px;
  color: #b7f7d8;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 16px rgba(52, 211, 153, 0.72);
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: #cdd8e6;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.icon-button:hover {
  border-color: rgba(34, 211, 238, 0.38);
  color: white;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.model-picker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 18px 14px;
  scrollbar-width: none;
}

.model-picker::-webkit-scrollbar {
  display: none;
}

.model-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  padding: 0 12px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 720;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.model-button .badge {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 6px;
  color: #b7c2d2;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
}

.model-button[aria-pressed="true"] {
  border-color: rgba(34, 211, 238, 0.52);
  background: var(--cyan-soft);
  color: #d9fbff;
}

.model-button[aria-pressed="true"] .badge {
  background: rgba(34, 211, 238, 0.16);
  color: #7deeff;
}

.messages {
  flex: 1 1 auto;
  min-height: 360px;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.065);
  border-bottom: 1px solid rgba(255, 255, 255, 0.065);
  padding: 18px;
}

.empty-state {
  display: grid;
  min-height: 100%;
  place-items: center;
  align-content: center;
  gap: 18px;
  color: var(--muted);
  text-align: center;
}

.empty-state p {
  margin-bottom: 5px;
  color: var(--text);
  font-weight: 720;
}

.empty-state span {
  color: var(--muted);
  font-size: 0.86rem;
}

.empty-mascot {
  display: grid;
  width: 148px;
  height: 148px;
  place-items: center;
  border: 1px solid rgba(34, 211, 238, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.34);
}

.empty-mascot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.starters {
  display: grid;
  width: min(560px, 100%);
  gap: 8px;
}

.starter-button {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: #c6d0dd;
  cursor: pointer;
  padding: 9px 12px;
  text-align: left;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.starter-button:hover {
  border-color: rgba(34, 211, 238, 0.34);
  background: rgba(34, 211, 238, 0.06);
  color: var(--text);
}

.message-row {
  display: flex;
  margin-bottom: 14px;
}

.message-row.user {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(76ch, 86%);
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.56;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-row.user .message-bubble {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.92), rgba(34, 211, 238, 0.74));
  color: white;
}

.message-row.assistant .message-bubble {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.055);
  color: #edf5ff;
}

.typing {
  color: var(--muted);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px 8px;
}

.composer textarea {
  width: 100%;
  min-height: 44px;
  max-height: 132px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 12px 13px;
  line-height: 1.4;
}

.composer textarea:focus {
  border-color: rgba(34, 211, 238, 0.46);
}

.composer textarea::placeholder {
  color: #6f7c8d;
}

.composer-actions {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.composer-actions button {
  display: grid;
  grid-area: 1 / 1;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(34, 211, 238, 0.4);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.9), rgba(139, 92, 246, 0.88));
  color: white;
  cursor: pointer;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

#stopButton {
  border-color: rgba(251, 113, 133, 0.38);
  background: rgba(251, 113, 133, 0.18);
  color: #ffd4dc;
}

.composer-actions button[hidden] {
  display: none;
}

.composer-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.composer-actions button:not(:disabled):active {
  transform: translateY(1px);
}

.composer-actions button svg {
  width: 18px;
  height: 18px;
}

.fine-print {
  margin: 0;
  padding: 0 18px 14px;
  color: #738195;
  font-size: 0.72rem;
  text-align: center;
}

.fine-print a {
  color: #8cefff;
  text-underline-offset: 3px;
}

.tech-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.tech-panel article {
  border-radius: 8px;
  padding: 16px;
}

.mascot-panel {
  display: grid;
  gap: 14px;
  overflow: hidden;
}

.mascot-panel img {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  border-radius: 8px;
  object-fit: cover;
  background: #03060c;
}

.metric {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid rgba(251, 146, 60, 0.28);
  border-radius: 999px;
  background: rgba(251, 146, 60, 0.09);
  color: #ffd4b5;
  padding: 0 9px;
  font-size: 0.72rem;
  font-weight: 820;
}

.tech-panel h2 {
  margin: 10px 0 6px;
  font-size: 0.98rem;
}

.tech-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.52;
}

.tech-panel p.ca-line {
  margin-top: 8px;
  font-size: 0.72rem;
  word-break: break-all;
}

.ca-line a {
  color: #ffd4b5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-decoration: none;
}

.ca-line a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .actions {
    flex-wrap: wrap;
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .chat-surface {
    min-height: calc(100dvh - 104px);
  }

  .tech-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar {
    display: grid;
  }

  .actions {
    justify-content: flex-start;
  }

  .ghost-link,
  .primary-link {
    min-height: 34px;
    padding-inline: 10px;
    font-size: 0.78rem;
  }

  .chat-head {
    display: grid;
  }

  .header-actions {
    justify-content: space-between;
    width: 100%;
  }

  .status-pill {
    width: max-content;
  }

  .messages {
    min-height: 300px;
    padding: 14px;
  }

  .message-bubble {
    max-width: 92%;
  }

  .composer {
    padding-inline: 12px;
  }

  .empty-mascot {
    width: 118px;
    height: 118px;
  }

  .fine-print {
    padding-inline: 12px;
  }

  .tech-panel {
    grid-template-columns: 1fr;
  }
}
