:root {
  color-scheme: dark;
  --bg: #0f0f0f;
  --sidebar: #171717;
  --surface: #212121;
  --surface-2: #2a2a2a;
  --surface-3: #303030;
  --text: #f4f4f4;
  --muted: #b4b4b4;
  --muted-2: #7d7d7d;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.2);
  --user: #2f4154;
  --accent: #10a37f;
  --accent-2: #3478ff;
  --warn: #e0aa38;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  cursor: pointer;
}

select,
button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100vh;
  min-width: 980px;
  background: var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 10px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.sidebar-top {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.sidebar-icon,
.tool-button,
.send-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
}

.sidebar-icon:hover,
.tool-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border-radius: 9px;
  background: transparent;
  color: #ececec;
  text-align: left;
}

.new-chat:hover,
.chat-item:hover,
.history-item:hover,
.account-button:hover,
.chat-item.active {
  background: rgba(255, 255, 255, 0.08);
}

.search-wrap {
  display: grid;
  gap: 5px;
  margin: 12px 0 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.search-wrap span {
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.search-wrap input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-wrap input::placeholder {
  color: var(--muted-2);
}

.history {
  display: grid;
  align-content: start;
  gap: 3px;
  min-height: 0;
  overflow: auto;
}

.section-label {
  margin: 14px 8px 5px;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 700;
}

.chat-item,
.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 9px;
  background: transparent;
  color: #e7e7e7;
  text-align: left;
}

.chat-item span,
.history-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item small,
.history-item kbd,
.desktop-pill {
  min-width: 32px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted-2);
  font-size: 11px;
  text-align: center;
}

.sidebar-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}

.account-button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 42px;
  padding: 0 8px;
  border-radius: 9px;
  background: transparent;
  color: #eeeeee;
  text-align: left;
}

.avatar,
.logo-mark {
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #f2f2f2;
  color: #111;
  font-weight: 800;
}

.avatar {
  width: 30px;
  height: 30px;
}

.chat-pane {
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr) auto;
  min-width: 0;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}

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

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(224, 170, 56, 0.12);
}

.live-dot.ready {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(16, 163, 127, 0.15);
}

.model-cluster {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.model-cluster select {
  height: 36px;
  min-width: 160px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  background: var(--surface);
}

.model-cluster span {
  overflow: hidden;
  color: var(--muted-2);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-button {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.share-button:hover {
  border-color: var(--line-strong);
}

.thread-scroll {
  min-height: 0;
  overflow: auto;
  padding: 22px 18px 150px;
}

.conversation-shell {
  width: min(820px, 100%);
  margin: 0 auto;
}

.welcome {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 34px 0 26px;
  text-align: center;
}

.logo-mark {
  width: 42px;
  height: 42px;
  font-size: 18px;
}

.welcome h1 {
  margin: 0;
  color: #f7f7f7;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: 0;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(680px, 100%);
}

.prompt-grid button {
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.prompt-grid button:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.prompt-grid strong {
  font-size: 14px;
}

.prompt-grid span {
  color: var(--muted-2);
  font-size: 13px;
  line-height: 1.35;
}

.provider-card {
  width: min(680px, 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(52, 120, 255, 0.12), transparent 38%),
    rgba(255, 255, 255, 0.045);
  padding: 14px;
  text-align: left;
}

.provider-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.provider-card strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.provider-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.message-list {
  display: grid;
  gap: 22px;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.message.user {
  grid-template-columns: minmax(0, 1fr);
  justify-items: end;
}

.message-meta {
  display: none;
}

.message::before {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #f2f2f2;
  color: #111;
  content: "AI";
  font-size: 11px;
  font-weight: 800;
}

.message.user::before {
  display: none;
}

.message-text {
  min-width: 0;
  color: #ececec;
  font-size: 15px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-text p {
  margin: 0 0 10px;
}

.message-text p:last-child {
  margin-bottom: 0;
}

.message-text h3,
.message-text h4 {
  margin: 14px 0 8px;
  color: #f5f5f5;
  font-size: 15px;
}

.message-text h3:first-child,
.message-text h4:first-child {
  margin-top: 0;
}

.message-text ul {
  margin: 8px 0 12px;
  padding-left: 20px;
}

.message-text li {
  margin: 5px 0;
}

.message.assistant .message-text {
  padding-top: 4px;
}

.message.user .message-text {
  width: min(650px, 88%);
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--surface-2);
  line-height: 1.5;
}

.artifact-chip {
  grid-column: 2;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-height: 32px;
  margin-top: -12px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #dff8f0;
  text-decoration: none;
}

.work-console {
  margin: 30px 0 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}

.console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 62px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.console-header h2,
.console-grid h3 {
  margin: 0;
  font-size: 14px;
}

.console-header p {
  margin: 4px 0 0;
  color: var(--muted-2);
  font-size: 12px;
}

.console-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-2);
  font-size: 12px;
}

.console-status span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.console-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.console-grid > div {
  min-width: 0;
  padding: 12px;
}

.console-grid > div + div {
  border-left: 1px solid var(--line);
}

.output-list,
.activity-list {
  display: grid;
  gap: 5px;
  max-height: 230px;
  overflow: auto;
  margin-top: 10px;
}

.output-item,
.activity-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
}

.output-item {
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
}

.output-icon,
.activity-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(16, 163, 127, 0.14);
  color: #7ee3c4;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
}

.output-title,
.output-subtitle {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-title,
.activity-card h3 {
  color: #f1f1f1;
  font-size: 13px;
  font-weight: 700;
}

.output-subtitle,
.activity-card p {
  margin: 2px 0 0;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.4;
}

.activity-card {
  grid-template-columns: 30px minmax(0, 1fr);
}

.activity-card h3 {
  margin: 0;
}

.activity-card a {
  display: inline-flex;
  margin-top: 5px;
  color: #9be8d4;
  font-size: 12px;
  text-decoration: none;
}

.composer {
  padding: 0 18px 18px;
  background: linear-gradient(180deg, rgba(15, 15, 15, 0), var(--bg) 32%);
}

.composer-shell {
  width: min(820px, 100%);
  margin: 0 auto;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.composer textarea::placeholder {
  color: #8a8a8a;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 6px;
}

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

.composer select {
  max-width: 180px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: 0;
  background: transparent;
  color: var(--muted);
}

.send-btn {
  background: #f4f4f4;
  color: #111;
  font-weight: 900;
}

.send-btn:disabled {
  opacity: 0.48;
  cursor: wait;
}

.composer-note {
  width: min(820px, 100%);
  margin: 8px auto 0;
  color: var(--muted-2);
  font-size: 12px;
  text-align: center;
}

.empty-state {
  padding: 12px;
  color: var(--muted-2);
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-width: 0;
    min-height: 100vh;
    height: auto;
  }

  .sidebar {
    display: none;
  }

  .chat-pane {
    min-height: 100vh;
  }

  .thread-scroll {
    padding: 18px 14px 150px;
  }

  .prompt-grid,
  .console-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0 12px;
  }

  .topbar-actions .share-button:last-child {
    display: none;
  }

  .console-grid > div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .message.user .message-text {
    width: 100%;
  }
}
