:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101113;
  color: #eceff3;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #101113;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto auto;
  height: 100vh;
}

.topbar,
.controls,
.composer,
.image-preview {
  border-bottom: 1px solid #26292f;
  padding: 12px 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1 {
  margin: 0;
  font-size: 1.05rem;
}

p {
  margin: 4px 0 0;
  color: #9aa4b2;
  font-size: 0.82rem;
}

.status {
  border: 1px solid #3a3f48;
  border-radius: 999px;
  padding: 4px 10px;
  color: #aab4c2;
  white-space: nowrap;
}

.status[data-kind="ready"] {
  border-color: #249f69;
  color: #47d18c;
}

.status[data-kind="error"] {
  border-color: #bd3c4a;
  color: #ff7585;
}

.controls {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(120px, 180px) minmax(180px, 1fr) auto auto;
  gap: 8px;
}

input,
select,
textarea {
  min-width: 0;
  border: 1px solid #333842;
  border-radius: 7px;
  background: #181b20;
  color: #eef2f7;
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: none;
  min-height: 42px;
  max-height: 140px;
}

button {
  border: 1px solid #3a3f48;
  border-radius: 7px;
  background: #20242b;
  color: #eef2f7;
  padding: 9px 12px;
  cursor: pointer;
}

button:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.progress {
  padding: 8px 16px;
  color: #98a2b3;
  font-size: 0.8rem;
}

.progress div {
  height: 4px;
  background: #252933;
  border-radius: 999px;
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: #58a6ff;
}

.chat {
  overflow: auto;
  padding: 18px 16px;
}

.task-panel {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  border-bottom: 1px solid #26292f;
  padding: 12px 16px;
}

.task-panel[hidden] {
  display: none;
}

.task-panel label {
  display: grid;
  gap: 6px;
  color: #aab4c2;
  font-size: 0.82rem;
}

.task-panel textarea {
  width: 100%;
}

.empty-state {
  margin: 0;
  color: #98a2b3;
}

.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 860px;
  margin: 0 0 14px;
  line-height: 1.55;
}

.message.user {
  align-items: flex-end;
  margin-left: auto;
}

.message-body {
  display: inline-block;
  max-width: 100%;
  border: 1px solid #282d35;
  border-radius: 8px;
  background: #171a1f;
  padding: 10px 12px;
}

.message.thinking .message-body::after {
  content: "";
  display: inline-block;
  width: 1.4em;
  animation: thinking-dots 1.2s steps(4, end) infinite;
}

.message.user .message-body {
  border-color: #245fb8;
  background: #174a99;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  color: #7d8794;
  font-size: 0.72rem;
}

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

.message-meta button {
  border-radius: 999px;
  padding: 2px 8px;
  color: #aab4c2;
  font-size: 0.72rem;
}

.message-meta [data-metrics] {
  color: #98a2b3;
}

.message img,
.image-preview img {
  display: block;
  max-width: min(320px, 80vw);
  max-height: 220px;
  border-radius: 7px;
  margin-bottom: 8px;
}

pre {
  overflow-x: auto;
}

code,
pre {
  background: #0d1117;
  border-radius: 5px;
  padding: 2px 5px;
}

.image-preview {
  border-top: 1px solid #26292f;
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: end;
  border-top: 1px solid #26292f;
  border-bottom: 0;
}

.muted {
  color: #8b949e;
}

@keyframes thinking-dots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75%,
  100% {
    content: "...";
  }
}

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

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

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

  .composer [data-stop] {
    grid-column: 1 / -1;
  }
}
