:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --panel: #ffffff;
  --panel-soft: #f0f0ed;
  --text: #202123;
  --muted: #6b6f76;
  --line: #deded9;
  --accent: #10a37f;
  --accent-dark: #0d8f70;
  --danger: #b42318;
  --shadow: 0 16px 45px rgba(20, 20, 20, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
textarea {
  font: inherit;
}

.app {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 292px;
  height: 100vh;
  padding: 18px;
  background: #202123;
  color: #fff;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: #2f312f;
  color: #fff;
  font-weight: 700;
}

.brand h1,
.brand p,
.chat-header h2,
.chat-header p {
  margin: 0;
}

.brand h1 {
  font-size: 17px;
  line-height: 1.2;
}

.brand p {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
}

.new-chat,
.conversation-item,
.delete-conversation,
.ghost-button,
.composer button {
  border: 0;
  cursor: pointer;
}

.new-chat {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  text-align: left;
  padding: 0 14px;
}

.new-chat:hover,
.conversation-row:hover {
  background: rgba(255, 255, 255, 0.08);
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
}

.conversation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  width: 100%;
  min-height: 40px;
  border-radius: 8px;
  background: transparent;
  overflow: hidden;
}

.conversation-row.active {
  background: rgba(255, 255, 255, 0.12);
}

.conversation-item {
  min-width: 0;
  min-height: 40px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  text-align: left;
  padding: 9px 4px 9px 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-row.active .conversation-item {
  color: #fff;
}

.delete-conversation {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: 4px;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.42);
  font-size: 20px;
  line-height: 1;
}

.delete-conversation:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.chat-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 100vh;
  margin-left: 292px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
}

.chat-header h2 {
  font-size: 18px;
  font-weight: 650;
}

.chat-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.ghost-button {
  min-width: 64px;
  min-height: 36px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
}

.ghost-button:hover {
  background: #e8e8e4;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 34px max(24px, calc((100vw - 980px) / 2)) 24px;
}

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

.empty-state h3 {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
}

.message-row {
  display: flex;
  gap: 14px;
  max-width: 860px;
  width: 100%;
}

.message-row.user {
  margin-left: auto;
  justify-content: flex-end;
}

.avatar {
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #202123;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.message-row.user .avatar {
  order: 2;
  background: var(--accent);
}

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

.message-content {
  white-space: pre-wrap;
}

.thinking-bubble {
  min-width: 156px;
  color: var(--muted);
}

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

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.thinking-dots i {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #9ca3af;
  animation: thinkingPulse 1.2s infinite ease-in-out;
}

.thinking-dots i:nth-child(2) {
  animation-delay: 0.16s;
}

.thinking-dots i:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes thinkingPulse {
  0%,
  80%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.reasoning-box {
  margin-bottom: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8f8f7;
  color: #8a8f98;
  font-size: 13px;
}

.reasoning-box summary {
  cursor: pointer;
  padding: 8px 10px;
  color: #7b8088;
  user-select: none;
}

.reasoning-box pre {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  border-top: 1px solid #e5e7eb;
  padding: 10px;
  white-space: pre-wrap;
  font-family: "Cascadia Code", Consolas, "Liberation Mono", monospace;
  line-height: 1.55;
}

.message-row.user .bubble {
  background: #e7f8f3;
  border-color: #c8eee3;
  box-shadow: none;
}

.bubble img {
  display: block;
  width: min(100%, 760px);
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tool-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.code-result {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  overflow: hidden;
}

.code-result.failed {
  border-color: #f2c9c5;
  background: #fff8f7;
}

.code-result-summary {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.code-block {
  border-top: 1px solid var(--line);
}

.code-block:first-of-type {
  border-top: 0;
}

.code-label {
  padding: 8px 11px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.code-block pre {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  padding: 8px 11px 12px;
  color: #1f2937;
  white-space: pre-wrap;
  font-family: "Cascadia Code", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px max(24px, calc((100vw - 980px) / 2)) 22px;
  border-top: 1px solid var(--line);
  background: rgba(247, 247, 245, 0.86);
  backdrop-filter: blur(10px);
}

.composer textarea {
  width: 100%;
  max-height: 180px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--panel);
  color: var(--text);
  padding: 13px 14px;
  line-height: 1.5;
  box-shadow: var(--shadow);
}

.composer textarea:focus {
  border-color: var(--accent);
}

.composer button {
  min-width: 78px;
  min-height: 48px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
}

.composer button:hover {
  background: var(--accent-dark);
}

.composer button:disabled,
.new-chat:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: auto;
    height: auto;
    min-height: auto;
    padding: 12px;
  }

  .conversation-list {
    flex-direction: row;
    overflow-x: auto;
  }

  .conversation-row {
    flex: 0 0 160px;
  }

  .conversation-item {
    min-width: 0;
  }

  .chat-shell {
    margin-left: 0;
    min-height: calc(100vh - 152px);
  }

  .chat-header,
  .messages,
  .composer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .message-row,
  .message-row.user {
    max-width: 100%;
    margin-left: 0;
  }

  .avatar {
    display: none;
  }
}
