:root {
  --bg0: #f4ecf8;
  --bg1: #eef1f8;
  --purple: #6b2d8c;
  --purple-2: #7a3aa3;
  --text: #222;
  --muted: #666;
  --card: #fff;
  --line: #ececec;
  --green: #3cb54a;
  --yellow: #e0a106;
  --red: #d13b3b;
  --side: #f9f9f9;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg0) 0%, #f7f5fb 42%, var(--bg1) 100%);
  display: flex;
}
#sidebar {
  width: 260px;
  flex-shrink: 0;
  padding: 12px 10px 10px;
  background: var(--side);
  border-right: 1px solid #ececf0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 650;
  padding: 8px 8px 12px;
}
.logo { width: 22px; height: 28px; object-fit: contain; }
#new-chat {
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 10px;
  cursor: pointer;
  font: inherit;
  width: 100%;
  text-align: left;
}
#new-chat:hover { background: #ececec; }
.pen { margin-right: 6px; }
.sec {
  font-size: 12px;
  color: #8a8a8a;
  padding: 10px 10px 4px;
}
#hist {
  list-style: none;
  margin: 0; padding: 0;
  overflow-y: auto;
  flex: 1;
}
#hist li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}
#hist li:hover, #hist li.on { background: #ececec; }
#hist .t {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
}
#hist .del {
  border: 0; background: transparent;
  color: #aaa; cursor: pointer; font-size: 16px;
  padding: 0 4px; line-height: 1;
}
#hist .del:hover { color: var(--red); }
.flag {
  font-size: 12px;
  color: var(--purple);
  padding: 4px 10px 8px;
}
#gear {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
}
#gear:hover { background: #ececec; }
#app {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 16px 16px;
}
#thread {
  flex: 1;
  overflow-y: auto;
  padding: 24px 8px 16px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}
#hello { text-align: center; margin-top: 18vh; color: var(--muted); }
#hello .hi { font-size: 42px; margin: 0; color: #333; font-weight: 600; }
#hello .sub { margin-top: 8px; }
.row { display: flex; margin: 10px 0; }
.row.user { justify-content: flex-end; }
.row.bot { justify-content: flex-start; }
.user-pill {
  background: var(--purple);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px;
  max-width: 70%;
  white-space: pre-wrap;
  word-break: break-word;
}
.bot-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(80, 40, 100, .08);
  max-width: 78%;
  min-width: 160px;
  overflow: hidden;
}
.think-card {
  max-width: 78%;
  margin: 8px 0 4px;
  border-radius: 10px;
  background: rgba(107,45,140,.06);
  padding: 8px 12px;
}
.think-card summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}
.think-body {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.5;
  color: #555;
}
.chk { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; font-size: 14px; }
.bot-body {
  padding: 12px 14px 10px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}
.bot-body code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: .92em;
  background: #f3eef7;
  padding: .1em .35em;
  border-radius: 4px;
}
.bot-body a { color: var(--purple); }
.bot-foot {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 8px;
  font-size: 13px;
  color: #444;
  font-variant-numeric: tabular-nums;
}
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green); display: inline-block;
}
.dot.y { background: var(--yellow); }
.dot.r { background: var(--red); }
#lock-banner {
  text-align: center;
  background: #fff;
  border: 1px solid #eadff2;
  color: var(--purple);
  border-radius: 10px;
  padding: 10px;
  margin: 0 auto 8px;
  max-width: 768px;
  width: calc(100% - 24px);
}
#composer {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 26px;
  padding: 10px 10px 10px 18px;
  box-shadow: 0 2px 10px rgba(80, 40, 100, .08);
  max-width: 768px;
  width: calc(100% - 24px);
  margin: 0 auto;
  min-height: 52px;
}
#input {
  flex: 1;
  border: 0;
  resize: none;
  font: inherit;
  font-size: 15px;
  line-height: 24px;
  outline: none;
  max-height: 160px;
  background: transparent;
  padding: 0;
  margin: 0;
  display: block;
}
#stop {
  border: 0;
  background: var(--red);
  color: #fff;
  border-radius: 18px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  flex-shrink: 0;
}
#send {
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: var(--purple-2); color: #fff;
  cursor: pointer; font-size: 16px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
#send:disabled { opacity: .4; cursor: default; }
#modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.28);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
}
#modal[hidden] { display: none; }
.sheet {
  background: #fff;
  border-radius: 14px;
  padding: 20px 22px;
  width: min(420px, 92vw);
  box-shadow: 0 8px 32px rgba(0,0,0,.16);
}
.sheet h3 { margin: 0 0 14px; }
.sheet label { display: block; font-size: 12px; color: #888; margin: 10px 0 4px; }
.mono { font-size: 13px; word-break: break-all; }
.sheet select, #sys-prompt {
  width: 100%;
  padding: 8px;
  font: inherit;
  border-radius: 8px;
  border: 1px solid #ddd;
}
#sys-prompt { min-height: 140px; resize: vertical; line-height: 1.45; }
#save-prompt { margin-top: 8px; width: 100%; padding: 8px 10px; border-radius: 10px; border: 0; cursor: pointer; font: inherit; background: #eee; color: #333; }
.hint { margin-top: 10px; font-size: 12px; color: #888; }
.row-btns { display: flex; gap: 8px; margin-top: 16px; }
.row-btns button {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  font: inherit;
  background: var(--purple); color: #fff;
}
.row-btns .ghost { background: #eee; color: #333; }
@media (prefers-color-scheme: dark) {
  :root { --bg0: #1c1c1e; --bg1: #1c1c1e; --text: #eee; --muted: #aaa; --card: #2c2c2e; --line: #3a3a3c; --side: #161618; }
  body { background: #1c1c1e; }
  #new-chat:hover, #hist li:hover, #hist li.on, #gear:hover { background: #2a2a2c; }
  .user-pill { background: #7a3aa3; }
  #hello .hi { color: #eee; }
  #composer, .sheet { background: #2c2c2e; }
  #input { color: #eee; }
  .bot-foot { color: #ccc; }
  .row-btns .ghost { background: #3a3a3c; color: #eee; }
}
