:root {
  --bg: #0e1218;
  --panel: #161c26;
  --line: #2a3444;
  --text: #e8edf5;
  --muted: #8b97ab;
  --accent: #3ee0b0;
  --accent-dim: #1c4a3e;
  --danger: #ef6b6b;
  --user: #243044;
  --bot: #1a222e;
  --think: #2a2438;
  --radius: 14px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100%;
  max-width: 920px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
}

.brand .sub {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #6aa8ff);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.model-field select {
  min-width: 240px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.think-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
}

.think-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  width: 40px;
  height: 22px;
  border-radius: 99px;
  background: #2b3340;
  position: relative;
  border: 1px solid var(--line);
}

.switch::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #c5cdd8;
  top: 2px;
  left: 3px;
  transition: 0.15s ease;
}

.think-toggle input:checked + .switch {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.think-toggle input:checked + .switch::after {
  left: 19px;
  background: var(--accent);
}

.think-toggle.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

.btn.ghost:hover,
.btn.icon:hover {
  border-color: var(--accent);
}

.btn.primary {
  background: var(--accent);
  color: #06241b;
  border-color: transparent;
  font-weight: 650;
}

.btn.danger {
  background: #4a2222;
  border-color: var(--danger);
  color: #ffd6d6;
}

.btn.icon {
  width: 40px;
  font-size: 20px;
  line-height: 1;
}

.caps {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 16px;
  min-height: 36px;
}

.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #22303f;
  color: #b8c5d8;
}

.badge.on {
  background: var(--accent-dim);
  color: var(--accent);
}

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

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 420px;
}

.msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--user);
}

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

.msg .role {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.thinking {
  background: var(--think);
  border: 1px dashed #4a3f63;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 13px;
  color: #d5c7f0;
}

.thinking summary {
  cursor: pointer;
  color: #c4b5fd;
}

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

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

.file-tag {
  font-size: 12px;
  color: var(--muted);
}

.composer {
  border-top: 1px solid var(--line);
  padding: 12px 16px 16px;
  background: var(--panel);
}

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

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px 4px 10px;
  font-size: 12px;
}

.chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
  min-height: 42px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}

.status {
  margin: 6px 0 0;
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

@media (max-width: 640px) {
  .model-field select {
    min-width: 160px;
  }
  .msg {
    max-width: 94%;
  }
}
