:root {
  color-scheme: dark;
  --bg: #050505;
  --sidebar: #090909;
  --line: #222222;
  --soft: #2b2b2b;
  --text: #f3f3f3;
  --muted: #a7a7a7;
  --user: #303030;
  --assistant: #171717;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
textarea,
select {
  font: inherit;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 280px;
  min-height: 100vh;
  padding: 12px 12px 18px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.brand-row,
.top-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
}

.brand-row strong {
  font-size: 18px;
  letter-spacing: 0;
}

.icon-button,
.attach-button,
.send-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.icon-button {
  color: var(--muted);
  background: transparent;
}

.nav-stack,
.sidebar-section {
  display: grid;
  gap: 4px;
}

.nav-item,
.thread-button,
.delete-thread-button {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover,
.thread-row:hover,
.nav-item.active,
.thread-row.active {
  background: var(--soft);
}

.nav-item.secondary {
  color: var(--muted);
}

.search-box {
  display: grid;
  gap: 6px;
  padding: 8px 12px 10px;
  color: var(--muted);
  font-size: 13px;
}

.search-box input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  outline: 0;
  color: var(--text);
  background: #151515;
}

.search-box input:focus {
  border-color: #4a4a4a;
}

.sidebar-section p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.thread-list {
  display: grid;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
}

.thread-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
}

.thread-button {
  padding-right: 6px;
}

.delete-thread-button {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 0;
  color: var(--muted);
  opacity: 0;
}

.thread-row:hover .delete-thread-button,
.thread-row.active .delete-thread-button {
  opacity: 1;
}

.empty-state {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.chat-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 100vh;
  background: var(--bg);
}

.top-actions {
  justify-content: flex-end;
  padding: 14px 22px;
}

.model-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #202020;
  color: #dedede;
  font-size: 14px;
}

.top-actions {
  gap: 10px;
}

.status-pill {
  color: var(--muted);
  background: #111111;
}

.conversation {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(880px, calc(100vw - 340px));
  margin: 0 auto;
  padding: 56px 20px 140px;
  overflow-y: auto;
}

.welcome {
  display: grid;
  place-items: center;
  min-height: 44vh;
}

.welcome h1 {
  margin: 0;
  color: #e7e7e7;
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 650;
  letter-spacing: 0;
  text-align: center;
}

.message {
  display: grid;
  gap: 8px;
}

.message.user {
  justify-items: end;
}

.bubble {
  max-width: min(720px, 100%);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: pre-wrap;
  line-height: 1.55;
}

.user .bubble {
  background: var(--user);
}

.assistant .bubble {
  background: var(--assistant);
}

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

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: min(720px, 100%);
}

.message-attachments span {
  display: inline-flex;
  max-width: 260px;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #1a1a1a;
  color: #dcdcdc;
  font-size: 13px;
}

.composer {
  position: fixed;
  left: calc(280px + (100vw - 280px) / 2);
  bottom: 28px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto auto 40px;
  align-items: center;
  gap: 8px;
  width: min(860px, calc(100vw - 340px));
  min-height: 62px;
  padding: 10px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: #242424;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.attachment-tray {
  display: none;
  grid-column: 1 / -1;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  max-height: 92px;
  overflow-y: auto;
  padding: 2px 4px 0;
}

.attachment-tray.has-files {
  display: grid;
}

.attachment-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #1a1a1a;
  color: #dcdcdc;
  font-size: 13px;
}

.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.attachment-remove:hover {
  color: var(--text);
  background: var(--soft);
}

.attach-button {
  color: var(--text);
  background: transparent;
  font-size: 30px;
}

.send-button {
  color: #090909;
  background: #f0f0f0;
  font-size: 22px;
  font-weight: 700;
}

.send-button:disabled,
.nav-item:disabled,
.delete-thread-button:disabled {
  cursor: default;
  opacity: 0.55;
}

textarea {
  width: 100%;
  max-height: 160px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.4;
}

textarea::placeholder {
  color: var(--muted);
}

.effort-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

select {
  min-width: 84px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  outline: 0;
  color: #dadada;
  background: transparent;
  cursor: pointer;
}

.composer:focus-within {
  border-color: #494949;
}

.loading .bubble::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1s infinite ease-in-out;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 1;
  }
}

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

  .sidebar {
    display: none;
  }

  .conversation,
  .composer {
    width: min(100vw - 24px, 860px);
  }

  .composer {
    left: 50%;
    grid-template-columns: 36px minmax(0, 1fr) auto 36px;
    bottom: 14px;
  }

  .effort-label,
  select {
    display: none;
  }

  .conversation {
    padding: 32px 12px 120px;
  }
}
