:root {
  font-family: "Segoe UI Variable", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
  color: #203436;
  background: #f5f8f7;
  --ink: #203436;
  --muted: #607578;
  --line: #dce5e3;
  --panel: #ffffff;
  --mist: #f5f8f7;
  --teal: #126e6b;
  --teal-dark: #0c5654;
  --teal-soft: #e3f0ed;
  --amber: #a15a27;
  --red: #a64033;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-width: 320px; }
body { overscroll-behavior: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
summary:focus-visible { outline: 2px solid #1a9188; outline-offset: 2px; }
[hidden] { display: none !important; }
.app { min-height: 100dvh; }

.topbar {
  height: 64px;
  padding: 0 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #f4faf8;
  background: #193335;
  border-bottom: 1px solid #335357;
}
.identity, .top-actions { display: flex; align-items: center; min-width: 0; }
.identity { gap: 12px; }
.identity strong { font-size: 15px; font-weight: 650; white-space: nowrap; }
.mark {
  width: 31px;
  height: 31px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid #86b6ac;
  border-radius: 5px;
  background: #2b6764;
  color: #fff;
  font-size: 17px;
  font-weight: 750;
  line-height: 1;
}
.mark.large { width: 48px; height: 48px; font-size: 26px; }
.top-actions { gap: 14px; }
.connection {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid #4b7172;
  border-radius: 5px;
  color: #d9efea;
  background: #234447;
  font-size: 12px;
  white-space: nowrap;
}
.connection.offline { color: #f6d4be; border-color: #7c6256; background: #473b39; }
.dot, .live-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: #57d8b0;
  box-shadow: 0 0 0 3px #57d8b026;
}
.connection.offline .dot { background: #e4a074; box-shadow: none; }
.icon-button {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: #506b6e;
  background: transparent;
  font-size: 21px;
  line-height: 1;
  transition: background-color .16s ease, color .16s ease;
}
.icon-button:hover { color: var(--teal-dark); background: #e7f0ee; }
.topbar .icon-button { color: #c7ded9; }
.topbar .icon-button:hover { color: #fff; background: #315658; }
.logout-button { min-width: 44px; height: 44px; padding: 0 9px; border: 0; border-radius: 6px; color: #c7ded9; background: transparent; font-size: 12px; }
.logout-button:hover { color: #fff; background: #315658; }

.workspace {
  height: calc(100dvh - 64px);
  min-height: 0;
  display: grid;
  grid-template-columns: 294px minmax(0, 1fr);
}
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #eff4f2;
  border-right: 1px solid #d7e2df;
}
.sidebar-heading {
  height: 64px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px 0 22px;
  border-bottom: 1px solid #dce5e3;
  color: #345052;
  font-size: 13px;
  font-weight: 700;
}
.sidebar-actions { display: flex; gap: 3px; align-items: center; }
.thread-list { min-height: 0; flex: 1; overflow: auto; padding: 13px 9px 20px; scrollbar-color: #bfd0ca transparent; }
.project-group { margin-bottom: 7px; }
.project-group.other { margin-top: 15px; padding-top: 10px; border-top: 1px solid #d7e2df; }
.project-row { min-height: 44px; display: flex; align-items: center; gap: 3px; }
.project-toggle {
  height: 44px;
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: #365253;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 660;
  transition: background-color .16s ease;
}
.project-toggle:hover, .project-add:hover { background: #e2ece8; }
.project-toggle[aria-expanded="true"] { color: var(--teal-dark); }
.project-arrow { width: 15px; flex: none; text-align: center; color: #66817f; font-size: 17px; }
.project-label { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-count { min-width: 22px; flex: none; color: #6c8583; font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.project-add {
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #49716c;
  font-size: 19px;
  line-height: 1;
}
.project-threads { padding: 1px 0 8px 16px; }
.project-group.other .project-threads { padding-left: 0; }
.thread {
  width: 100%;
  min-height: 44px;
  display: block;
  position: relative;
  margin: 2px 0;
  padding: 9px 11px 9px 14px;
  border: 0;
  border-radius: 5px;
  color: #43595a;
  background: transparent;
  text-align: left;
  transition: background-color .16s ease, color .16s ease;
}
.thread:hover { background: #e3ece9; }
.thread.active { color: #0d5553; background: #dcece6; font-weight: 620; }
.thread.active::before { content: ""; position: absolute; top: 7px; bottom: 7px; left: 0; width: 3px; border-radius: 2px; background: #159382; }
.thread-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
.thread-name { display: block; min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.thread-path { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; color: #778d8b; font-size: 11px; }
.thread-badge { flex: none; padding: 2px 6px; border-radius: 4px; color: #855c20; background: #f7e8c5; font-size: 10px; font-variant-numeric: tabular-nums; }
.live-dot { width: 7px; height: 7px; background: #27ad8b; box-shadow: 0 0 0 3px #27ad8b22; animation: breathe 2.1s ease-in-out infinite; }
.refresh-button { width: 100%; min-height: 48px; flex: none; padding: 0 22px; border: 0; border-top: 1px solid #d7e2df; color: #557170; background: #eff4f2; text-align: left; font-size: 12px; }
.refresh-button:hover { color: var(--teal-dark); background: #e5eeea; }

.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #fff; }
.chat-heading {
  height: 64px;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 25px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.chat-title { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.chat-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #1b3031; font-size: 15px; font-weight: 680; }
.chat-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #819291; font-size: 11px; }
.stop-button { min-height: 34px; flex: none; padding: 0 11px; border: 1px solid #e4c8bf; border-radius: 5px; color: #a34333; background: #fff7f3; font-size: 12px; font-weight: 650; }
.stop-button:hover { background: #fceae3; }
.messages {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 25px;
  overflow: auto;
  padding: 30px max(24px, calc((100% - 780px) / 2)) 40px;
  scrollbar-color: #c6d6d3 transparent;
}
.empty { margin: auto; max-width: 300px; color: #849797; text-align: center; font-size: 14px; }
.message { max-width: 100%; overflow-wrap: anywhere; white-space: pre-wrap; color: #283c3d; font-size: 14px; line-height: 1.76; }
.message.user { max-width: min(80%, 590px); align-self: flex-end; padding: 11px 15px; border: 1px solid #d5e8e3; border-radius: 7px; color: #214342; background: #e9f4f1; line-height: 1.62; }
.message.assistant { align-self: stretch; }
.message.assistant::before { content: "Codex"; display: block; width: fit-content; margin-bottom: 6px; padding-left: 10px; border-left: 3px solid #19917f; color: #366761; font-size: 11px; font-weight: 750; line-height: 1.35; }
.message.streaming { min-height: 29px; }
.message.pending { opacity: .76; }
.message.pending.failed { opacity: 1; border-color: #e6bfb3; color: #7d362c; background: #fff0ec; }
.message-status { display: block; margin-top: 5px; color: #6c8984; font-size: 11px; }
.message.failed .message-status { color: var(--red); }
.retry-link { margin-top: 6px; padding: 2px 0; border: 0; color: var(--teal-dark); background: transparent; font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }
.typing { color: #839997; font-size: 13px; }
.typing::after { content: "..."; animation: breathe 1.5s ease-in-out infinite; }
.process { align-self: stretch; padding: 0 0 0 13px; border-left: 2px solid #b8cddb; color: #58717f; font-size: 12px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.process[open] { color: #496472; }
.process summary { width: fit-content; cursor: pointer; font-weight: 660; }
.process div { margin-top: 8px; }

.settings-bar {
  min-height: 48px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 8px max(24px, calc((100% - 780px) / 2));
  border-top: 1px solid var(--line);
  background: #f8faf9;
}
.setting { display: inline-flex; align-items: center; gap: 7px; min-width: 0; color: #617978; font-size: 11px; white-space: nowrap; }
.setting select { height: 31px; max-width: 198px; min-width: 0; padding: 0 25px 0 8px; border: 1px solid #d4e2de; border-radius: 5px; color: #315151; background: #fff; font-size: 12px; }
.setting:first-child select { max-width: 175px; }
.attachments { display: flex; gap: 8px; overflow-x: auto; padding: 8px max(24px, calc((100% - 780px) / 2)); background: #fff; }
.attachment { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 5px 8px; border: 1px solid #d3e6e1; border-radius: 5px; color: #315b54; background: #ecf6f2; font-size: 12px; white-space: nowrap; }
.attachment span { overflow: hidden; text-overflow: ellipsis; }
.attachment button { width: 21px; height: 21px; flex: none; padding: 0; border: 0; color: #5d7971; background: transparent; line-height: 1; }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 12px max(24px, calc((100% - 780px) / 2)) max(18px, env(safe-area-inset-bottom)); background: #fff; }
.composer textarea { width: 100%; min-height: 46px; max-height: 160px; resize: none; padding: 11px 13px; border: 1px solid #cbdad5; border-radius: 6px; outline: none; color: var(--ink); background: #fff; line-height: 1.5; transition: border-color .16s ease, box-shadow .16s ease; }
.composer textarea::placeholder { color: #9aa9a6; }
.composer textarea:focus { border-color: #278b7e; box-shadow: 0 0 0 3px #278b7e1b; }
.attach-button, .send-button { width: 46px; height: 46px; flex: none; border-radius: 6px; line-height: 1; }
.attach-button { border: 1px solid #d2e0db; color: #416761; background: #f6faf8; font-size: 23px; }
.attach-button:hover { background: #e7f3ee; border-color: #a9c9be; }
.send-button { border: 0; color: #fff; background: var(--teal); font-size: 23px; transition: background-color .16s ease, transform .16s ease; }
.send-button:hover:not(:disabled) { background: var(--teal-dark); transform: translateY(-1px); }
.send-button:disabled { color: #6d8781; background: #d7e4df; opacity: 1; }

.notice-bar { position: absolute; z-index: 20; top: 64px; right: 20px; width: min(460px, calc(100% - 40px)); padding: 12px 15px; border: 1px solid #ead3ba; border-radius: 5px; color: #794a24; background: #fff8eb; box-shadow: 0 12px 30px #19333517; font-size: 12px; line-height: 1.5; }
.login { min-height: calc(100dvh - 64px); display: grid; place-items: center; padding: 24px; background: #f5f8f7; }
.login-panel { width: min(100%, 350px); }
.login-panel .mark { border-color: #2d7873; }
.login-panel h1 { margin: 20px 0 30px; color: #193335; font-size: 27px; font-weight: 690; }
.login form { display: flex; flex-direction: column; gap: 9px; }
.login label { color: #57716e; font-size: 12px; font-weight: 660; }
.login input { height: 46px; padding: 0 13px; border: 1px solid #cbdad5; border-radius: 5px; outline: none; background: #fff; }
.login input:focus { border-color: #278b7e; box-shadow: 0 0 0 3px #278b7e1b; }
.login button { height: 45px; margin-top: 8px; border: 0; border-radius: 5px; color: #fff; background: var(--teal); font-weight: 650; }
.login button:hover { background: var(--teal-dark); }
.error { min-height: 20px; margin-top: 12px; color: var(--red); font-size: 12px; }
.mobile-only { display: none; }
.scrim { display: none; }
@keyframes breathe { 50% { opacity: .45; } }

@media (max-width: 760px) {
  .topbar { height: 56px; padding: 0 14px; }
  .top-actions { gap: 6px; }
  .identity { gap: 9px; }
  .identity strong { font-size: 14px; }
  .mark { width: 29px; height: 29px; }
  .connection { min-height: 29px; padding: 0 8px; font-size: 11px; }
  .workspace { height: calc(100dvh - 56px); grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: absolute; z-index: 11; top: 56px; bottom: 0; left: 0; width: min(88vw, 340px); box-shadow: 14px 0 30px #19333520; transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .scrim { position: absolute; z-index: 10; inset: 56px 0 0; background: #122a2c66; }
  .scrim:not([hidden]) { display: block; }
  .mobile-only { display: grid; }
  .chat-heading { height: 56px; min-height: 56px; padding: 0 12px; gap: 7px; }
  .chat-title strong { font-size: 14px; }
  .chat-heading .icon-button { width: 44px; }
  .messages { gap: 21px; padding: 21px 17px 28px; }
  .message.user { max-width: 88%; }
  .settings-bar { gap: 6px 10px; padding: 8px 12px; }
  .setting { gap: 4px; }
  .setting select { max-width: 138px; height: 44px; }
  .setting:first-child select { max-width: 124px; }
  .attachments { padding: 7px 12px; }
  .composer { padding: 9px 12px max(11px, env(safe-area-inset-bottom)); gap: 8px; }
  .attach-button, .send-button { width: 44px; height: 44px; }
  .composer textarea { min-height: 44px; }
  .stop-button { min-height: 44px; }
  .notice-bar { top: 60px; right: 10px; width: min(440px, calc(100% - 20px)); }
  .login { min-height: calc(100dvh - 56px); }
}
@media (max-width: 390px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .top-actions { gap: 3px; }
  .identity { gap: 7px; }
  .identity strong { font-size: 13px; }
  .connection { padding: 0 6px; }
  .setting select { max-width: 113px; }
  .setting:first-child select { max-width: 106px; }
  .stop-button { padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* 消息列表的子元素不允许被压缩，否则流式回复会和下面的气泡重叠 */
.messages > * { flex-shrink: 0; }
.live-status { align-self: flex-start; margin-bottom: -14px; color: #6f8987; font-size: 11px; font-variant-numeric: tabular-nums; }
.message.pending.steered { opacity: 1; }
