:root {
  color-scheme: light;
  --bg: #f7f1e8;
  --panel: #fffaf2;
  --panel-strong: #ffffff;
  --text: #26231f;
  --muted: #6e675e;
  --line: #ded5c8;
  --accent: #bd6d51;
  --accent-dark: #8f4e39;
  --danger: #a33a31;
  --shadow: 0 18px 48px rgba(84, 63, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  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,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

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

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

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.new-chat,
.ghost-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
}

.new-chat {
  text-align: left;
  padding: 0 14px;
  font-weight: 650;
}

.search input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 250, 242, 0.72);
  color: var(--text);
}

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

.conversation-item {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  text-align: left;
  min-height: 42px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item.active {
  background: rgba(255, 250, 242, 0.82);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 26px;
  border-bottom: 1px solid rgba(222, 213, 200, 0.7);
  background: rgba(247, 241, 232, 0.82);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.ghost-button {
  padding: 0 14px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 34px min(8vw, 96px);
  overflow: auto;
}

.welcome {
  max-width: 720px;
  margin: auto;
  text-align: center;
}

.welcome h2 {
  margin: 0 0 10px;
  font-size: clamp(28px, 5vw, 46px);
  font-weight: 720;
  letter-spacing: 0;
}

.welcome p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 760px);
  gap: 13px;
  align-items: start;
}

.message.user {
  grid-template-columns: minmax(0, 760px) 38px;
  justify-content: end;
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 750;
}

.user .avatar {
  background: var(--text);
  color: #fff;
  grid-column: 2;
}

.bubble {
  min-width: 0;
  border-radius: 8px;
  padding: 15px 17px;
  line-height: 1.68;
  background: rgba(255, 250, 242, 0.72);
  border: 1px solid rgba(222, 213, 200, 0.82);
  box-shadow: 0 8px 28px rgba(84, 63, 39, 0.06);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.user .bubble {
  grid-column: 1;
  grid-row: 1;
  background: var(--panel-strong);
}

.bubble p {
  margin: 0 0 12px;
}

.bubble p:last-child,
.bubble pre:last-child {
  margin-bottom: 0;
}

.bubble pre {
  overflow: auto;
  border-radius: 8px;
  padding: 14px;
  background: #24201c;
  color: #fff8ee;
  white-space: pre;
}

.bubble code {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.92em;
}

.thinking {
  color: var(--muted);
}

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

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

.composer {
  padding: 16px min(8vw, 96px) 22px;
  background: linear-gradient(180deg, rgba(247, 241, 232, 0), var(--bg) 24%);
}

.limit-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
  margin: 0 auto 7px;
  max-width: 900px;
}

.composer-box {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  max-width: 900px;
  margin: 0 auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

textarea {
  width: 100%;
  max-height: 220px;
  min-height: 44px;
  border: 0;
  resize: none;
  outline: none;
  padding: 10px 8px;
  color: var(--text);
  background: transparent;
  line-height: 1.5;
}

.send-button,
.stop-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.send-button:disabled {
  background: #cbbfb0;
  cursor: not-allowed;
}

.stop-button {
  width: auto;
  padding: 0 16px;
  background: var(--danger);
}

.notice {
  max-width: 900px;
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 12px;
}

.hidden {
  display: none;
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: min(86vw, 320px);
    transform: translateX(-102%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .icon-button {
    display: grid;
    place-items: center;
  }

  .topbar {
    padding: 12px 14px;
  }

  .messages {
    padding: 24px 14px;
  }

  .message,
  .message.user {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .message.user {
    grid-template-columns: minmax(0, 1fr) 32px;
  }

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

  .composer {
    padding: 13px 12px 16px;
  }

  .limit-row {
    flex-direction: column;
    gap: 4px;
  }
}
