:root {
  --bg: #07090d;
  --bg-2: #0d1117;
  --panel: rgba(16, 20, 28, 0.86);
  --line: rgba(232, 237, 245, 0.08);
  --line-strong: rgba(232, 237, 245, 0.14);
  --text: #e8edf5;
  --muted: #8b95a5;
  --faint: #5c6573;
  --up: #3ecf8e;
  --up-dim: rgba(62, 207, 142, 0.14);
  --down: #ff5d73;
  --down-dim: rgba(255, 93, 115, 0.14);
  --warn: #e8c36a;
  --user: rgba(90, 140, 255, 0.16);
  --user-line: rgba(90, 140, 255, 0.28);
  --radius: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
}

body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
}

.bg {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 420px at 12% -12%, rgba(62, 207, 142, 0.09), transparent 60%),
    radial-gradient(800px 380px at 92% 0%, rgba(90, 140, 255, 0.08), transparent 55%),
    linear-gradient(180deg, #090c11 0%, #07090d 100%);
  z-index: 0;
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 80%);
}

.top,
.stage,
.dock {
  position: relative;
  z-index: 1;
}

.top,
.dock {
  flex-shrink: 0;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 30% 30%, #49d89a, #1e8a58 55%, #0b0e13 100%);
  box-shadow: 0 0 0 1px rgba(62, 207, 142, 0.25), 0 8px 24px rgba(0, 0, 0, 0.35);
  position: relative;
}

.mark::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 2px;
  height: 12px;
  background: #8a6a45;
  border-radius: 1px;
  transform: translateX(-50%);
}

h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand p,
.fineprint {
  color: var(--muted);
  font-size: 12px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 3px rgba(92, 101, 115, 0.15);
}

.live.ok .dot {
  background: var(--up);
  box-shadow: 0 0 0 3px var(--up-dim);
}

.live.busy .dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(232, 195, 106, 0.18);
  animation: pulse 1.2s ease-in-out infinite;
}

.live.down .dot {
  background: var(--down);
  box-shadow: 0 0 0 3px var(--down-dim);
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

.ghost,
.send,
.icon {
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
}

.ghost {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

.ghost:hover,
.icon:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.empty {
  margin: auto;
  max-width: 560px;
  text-align: center;
  padding: 24px 12px 48px;
}

.empty h2 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.empty p {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 22px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.chip {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.chip:hover {
  border-color: rgba(62, 207, 142, 0.45);
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(760px, 100%);
}

.msg.user {
  align-self: flex-end;
}

.msg.assistant {
  align-self: stretch;
}

.bubble {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  line-height: 1.55;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.msg.user .bubble {
  background: var(--user);
  border-color: var(--user-line);
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.thumbs img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.think {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: rgba(8, 10, 14, 0.5);
  overflow: hidden;
}

.think summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 12px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  display: flex;
  align-items: center;
  gap: 8px;
}

.think summary::-webkit-details-marker {
  display: none;
}

.think summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

.think[open] .think-body {
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 13px;
  white-space: pre-wrap;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  line-height: 1.5;
}

.md p + p {
  margin-top: 0.75em;
}

.md h1,
.md h2,
.md h3 {
  margin: 0.9em 0 0.4em;
  letter-spacing: -0.02em;
}

.md h1 {
  font-size: 1.25em;
}
.md h2 {
  font-size: 1.12em;
}
.md h3 {
  font-size: 1.02em;
}

.md ul,
.md ol {
  padding-left: 1.2em;
  margin: 0.5em 0;
}

.md li + li {
  margin-top: 0.2em;
}

.md blockquote {
  border-left: 2px solid var(--up);
  padding-left: 12px;
  color: var(--muted);
  margin: 0.6em 0;
}

.md a {
  color: var(--up);
}

.md code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.1em 0.35em;
  border-radius: 5px;
}

.md pre {
  margin: 0.7em 0;
  padding: 12px 14px;
  overflow: auto;
  background: #0a0d12;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.md pre code {
  background: none;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.5;
}

.cursor::after {
  content: "▍";
  color: var(--up);
  animation: pulse 1s step-end infinite;
}

.meta {
  font-size: 11px;
  color: var(--faint);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.err {
  color: var(--down);
  font-size: 13px;
}

.dock {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

.composer {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 10px 12px 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.composer:focus-within {
  border-color: rgba(62, 207, 142, 0.4);
}

.composer textarea {
  width: 100%;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
  max-height: 180px;
  min-height: 24px;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  accent-color: var(--up);
}

.icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.send {
  background: var(--up);
  color: #062214;
  border: 0;
  border-radius: 11px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
}

.send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.send.stop {
  background: var(--down);
  color: #fff;
}

.previews {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.previews[hidden] {
  display: none;
}

.preview {
  position: relative;
}

.preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.preview button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 0;
  background: #1b212c;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  line-height: 18px;
}

.fineprint {
  text-align: center;
}

.composer.drop {
  outline: 1px dashed var(--up);
}

@media (max-width: 640px) {
  body {
    padding: 12px 12px calc(10px + env(safe-area-inset-bottom));
  }

  h1 {
    font-size: 14px;
  }

  .empty h2 {
    font-size: 22px;
  }

  .ghost {
    padding: 6px 10px;
  }
}
