:root {
  --chat-v6-sidebar: #f5f6f7;
  --chat-v6-sidebar-active: #e3e6e9;
  --chat-v6-sidebar-hover: #eceeef;
  --chat-v6-border: #e7e9eb;
  --chat-v6-text: #2c2f33;
  --chat-v6-muted: #7d8287;
  --chat-v6-muted-2: #a6abb0;
  --chat-v6-user: #f1f2f3;
  --chat-v6-input: #f7f7f7;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--chat-v6-text);
  background: #fff;
}

.chat-workspace {
  width: 100%;
  height: var(--chat-viewport-height, 100dvh);
  overflow: hidden;
  background: #fff;
}

.chat-workspace .chat-sheet {
  position: relative;
  inset: auto;
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 0;
  max-height: none;
  padding: 0;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  border-radius: 0;
  box-shadow: none;
  transform: none;
}

.chat-sidebar {
  position: relative;
  z-index: 30;
  min-width: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat-v6-sidebar);
  border-right: 1px solid #eef0f2;
}

.chat-sidebar-head {
  height: 64px;
  flex: 0 0 auto;
  padding: 0 14px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, .025);
}

.chat-sidebar-brand {
  min-width: 0;
  width: 100%;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.chat-sidebar-logo {
  width: auto;
  max-width: 96px;
  height: 27px;
  display: block;
  object-fit: contain;
  opacity: .92;
  user-select: none;
  -webkit-user-drag: none;
}

.chat-sidebar-divider {
  width: 1px;
  height: 22px;
  flex: 0 0 auto;
  background: #d9dcdf;
}

.chat-sidebar-brand .chat-sidebar-divider {
  padding: 0;
  border: 0;
}

.chat-sidebar-title {
  color: #33373b;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.chat-sidebar-brand .chat-sidebar-title {
  padding: 0;
  border: 0;
}

.chat-sidebar-actions {
  flex: 0 0 auto;
  padding: 12px 14px 9px;
}

.new-chat-button {
  width: 100%;
  height: 40px;
  min-height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #dadddf;
  border-radius: 10px;
  color: #35393d;
  background: #fff;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}

.new-chat-button span:first-child {
  color: #555;
  font-size: 17px;
}

.new-chat-button:hover {
  border-color: #ccd0d4;
  background: #fafafa;
}

.chat-sidebar-list {
  min-height: 0;
  flex: 1 1 auto;
  padding: 8px 12px 20px;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chat-sidebar-list::-webkit-scrollbar { display: none; }

.chat-history-heading {
  margin: 0;
  padding: 8px 8px 7px;
  color: var(--chat-v6-muted-2);
  font-size: 11px;
}

.chat-history-list {
  min-height: 0;
  padding: 0;
  overflow: visible;
}

.chat-history-empty {
  margin: 0;
  padding: 9px 10px;
  color: var(--chat-v6-muted-2);
  font-size: 12px;
}

.chat-history-item {
  width: 100%;
  margin: 0 0 1px;
  padding: 9px 10px 8px;
  display: block;
  border: 0;
  border-radius: 8px;
  color: #4c5156;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}

.chat-history-item:hover { background: var(--chat-v6-sidebar-hover); }
.chat-history-item.active { color: #24272a; background: var(--chat-v6-sidebar-active); font-weight: 600; }

.chat-history-item-time {
  display: block;
  margin-top: 3px;
  color: var(--chat-v6-muted-2);
  font-size: 10px;
  font-weight: 400;
}

.chat-main {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

.chat-topbar {
  position: relative;
  height: 60px;
  min-height: 60px;
  flex: 0 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #f0f1f2;
}

.chat-topbar h3 {
  margin: 0;
  color: #272b2f;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.chat-menu {
  position: absolute;
  left: 10px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: none;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: #666;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.chat-menu:hover { background: #f4f4f4; }
.session-meta { display: none !important; }

.chat-list {
  position: relative;
  width: min(820px, calc(100% - 64px));
  max-width: none;
  min-height: 0;
  flex: 1 1 auto;
  margin: 0 auto;
  padding: 46px 0 190px;
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chat-list::-webkit-scrollbar { display: none; }

.chat-welcome {
  position: static;
  min-height: 58vh;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.chat-welcome h2 {
  margin: 0 0 9px;
  color: #292d31;
  font-size: 25px;
  font-weight: 500;
  letter-spacing: -.02em;
}

.chat-welcome p {
  margin: 0;
  color: var(--chat-v6-muted);
  font-size: 13px;
}

.bubble {
  min-width: 0;
  margin: 0 0 34px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #34383c;
  background: transparent;
  box-shadow: none;
  font-size: 14px;
  line-height: 1.82;
  overflow-wrap: anywhere;
}

.bubble.user {
  width: fit-content;
  max-width: 70%;
  margin-left: auto;
  padding: 10px 14px;
  border-radius: 16px;
  color: #34373a;
  background: var(--chat-v6-user);
  line-height: 1.55;
}

.bubble.ai,
.bubble.answer {
  width: 100%;
  max-width: 100%;
  margin-right: 0;
  padding: 0 0 8px;
  color: #34383c;
  background: transparent;
  border-radius: 0;
  line-height: 1.82;
}

.bubble.answer p { margin: 0 0 13px; }
.bubble.answer strong { color: #2b2e31; font-weight: 600; }
.bubble.answer h1,
.bubble.answer h2,
.bubble.answer h3,
.bubble.answer h4,
.bubble.answer h5,
.bubble.answer h6 {
  margin: 20px 0 10px;
  padding: 15px 0 0;
  border-top: 1px solid #e8eaec;
  color: #2b2e31;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
}

.bubble.answer ul,
.bubble.answer ol { margin: 8px 0 10px 20px; padding: 0; }
.bubble.answer li { margin: 5px 0; }
.bubble.answer code { border: 1px solid #e5e7e9; background: #f0f1f2; }
.bubble.answer a { color: #3979c6; text-decoration: underline; text-underline-offset: 2px; }
.bubble.answer a:hover { color: #245f9f; }

.run-block {
  width: 100%;
  margin: 0 0 16px;
  color: #8a8f94;
  font-size: 12px;
}

.run-line {
  width: max-content;
  max-width: 100%;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 0;
  color: #8a8f94;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.run-line:hover { color: #5e6368; }
.run-chevron { font-size: 13px; transition: transform .16s ease; }
.run-block.open .run-chevron { transform: rotate(90deg); }

.run-details {
  display: none;
  margin: 10px 0 0 4px;
  padding-left: 13px;
  border-left: 1px solid #e0e2e4;
}

.run-block.open .run-details { display: block; }

.run-step {
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #8b9095;
  font-size: 12px;
  line-height: 1.6;
}

.run-step-title {
  flex: 0 0 auto;
  color: #666c72;
  font-weight: 500;
  white-space: nowrap;
}

.run-step-text { min-width: 0; }

.run-thinking-text {
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scroll-behavior: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.run-thinking-text::-webkit-scrollbar { display: none; }

.run-step-state {
  width: 12px;
  min-width: 12px;
  text-align: center;
}

.run-step.running { color: #565b60; }
.run-step.running .run-step-state {
  width: 10px;
  min-width: 10px;
  height: 10px;
  margin: 4px 2px 0 0;
  border: 1.5px solid #b6babd;
  border-top-color: #555;
  border-radius: 50%;
  animation: chat-v6-spin .8s linear infinite;
}

.run-question {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid #dedfe1;
  border-radius: 14px;
  color: #30353a;
  background: #fff;
  box-shadow: 0 8px 24px rgba(20, 24, 28, .06);
}

.run-question[hidden] { display: none; }
.run-question-head { margin-bottom: 13px; }
.run-question-head strong { display: block; font-size: 14px; font-weight: 600; }
.run-question-head span { display: block; margin-top: 3px; color: #8a8f94; font-size: 12px; }
.run-question-item { min-width: 0; margin: 0; padding: 0; border: 0; }
.run-question-item + .run-question-item { margin-top: 16px; padding-top: 16px; border-top: 1px solid #eceef0; }
.run-question-title { margin: 0 0 4px; color: #252a2f; font-size: 13px; font-weight: 600; line-height: 1.55; }
.run-question-detail { margin: 0 0 10px; color: #6f757b; font-size: 12px; line-height: 1.6; white-space: pre-wrap; }
.run-question-options { display: grid; gap: 7px; }
.run-question-option {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid #e4e6e8;
  border-radius: 9px;
  cursor: pointer;
}
.run-question-option.selected { border-color: #94999e; background: #f6f7f7; }
.run-question-option input { width: 15px; height: 15px; margin: 2px 0 0; accent-color: #44494e; }
.run-question-option strong { display: block; color: #34393e; font-size: 12.5px; font-weight: 550; line-height: 1.5; }
.run-question-option small { display: block; margin-top: 2px; color: #888e94; font-size: 11.5px; line-height: 1.45; }
.run-question-custom {
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
  padding: 10px 11px;
  resize: vertical;
  border: 1px solid #e1e3e5;
  border-radius: 9px;
  outline: none;
  color: #30353a;
  background: #fafafa;
  font-size: 12.5px;
  line-height: 1.5;
}
.run-question-custom:focus { border-color: #a8adb2; background: #fff; }
.run-question-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.run-question-actions button { min-height: 34px; padding: 0 14px; border: 1px solid #dedfe1; border-radius: 9px; color: #565c62; background: #fff; font-size: 12.5px; cursor: pointer; }
.run-question-actions button[type="submit"] { border-color: #34383c; color: #fff; background: #34383c; }
.run-question-actions button:disabled { opacity: .5; cursor: wait; }
.run-question-error { margin-top: 9px; color: #b54b4b; font-size: 12px; }

.chat-composer-shell {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 44px 18px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,.97) 43%, #fff 70%);
  pointer-events: none;
}

.chat-composer-wrap {
  position: relative;
  width: min(820px, calc(100% - 64px));
  margin: 0 auto;
  pointer-events: auto;
}

.chat-composer {
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 8px 10px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #e1e3e5;
  border-radius: 21px;
  background: var(--chat-v6-input);
  box-shadow: 0 3px 15px rgba(0,0,0,.045);
  transition: border-color .16s ease, box-shadow .16s ease;
}

.chat-composer:focus-within {
  border-color: #d4d7da;
  box-shadow: 0 5px 18px rgba(0,0,0,.06);
}

#chatInput {
  width: 100%;
  min-height: 42px;
  max-height: 170px;
  padding: 7px 5px 5px;
  resize: none;
  border: 0;
  outline: 0;
  color: #2c2f32;
  background: transparent;
  font-size: 14px;
  line-height: 1.55;
}

#chatInput::placeholder { color: #9da1a5; }

.chat-composer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-composer .attach-btn {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  color: #686d72;
  background: transparent;
  cursor: pointer;
}

.chat-composer .attach-btn:hover,
.chat-composer .attach-btn:focus-visible { color: #353a3e; background: #e8eaec; }
.chat-composer .attach-btn:focus-visible { outline: 2px solid #aeb3b8; outline-offset: 2px; }
.chat-composer .attach-btn img { width: 17px; height: 17px; opacity: .82; }
.chat-composer .attach-btn:disabled { opacity: .42; cursor: wait; }

.chat-composer .capability-button {
  height: 30px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  color: #686d72;
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}

.chat-composer .capability-button:hover,
.chat-composer .capability-button.open { color: #353a3e; background: #e8eaec; }
.capability-down { color: #9ca0a4; font-size: 10px; }

#chatSend {
  width: 31px;
  height: 31px;
  margin-left: auto;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #2b2b2b;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

#chatSend:hover { background: #111; }
#chatSend:disabled { opacity: .25; cursor: not-allowed; }

.chat-ai-disclaimer {
  margin-top: 7px;
  color: #a5a9ad;
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
}

.capability-popover {
  position: absolute;
  z-index: 25;
  left: 0;
  bottom: 72px;
  width: 260px;
  padding: 6px;
  border: 1px solid #e1e3e5;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 14px 42px rgba(0,0,0,.09);
  transform-origin: left bottom;
  animation: chat-v6-pop .14s ease;
}

.capability-popover[hidden] { display: none; }
.capability-title { padding: 7px 9px 5px; color: #a0a4a8; font-size: 10px; }

.capability-row {
  width: 100%;
  padding: 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 9px;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.capability-row:hover { background: #f4f5f6; }
.capability-copy { min-width: 0; flex: 1 1 auto; }
.capability-copy strong { display: block; color: #2f3337; font-size: 13px; font-weight: 500; }
.capability-copy small { display: block; margin-top: 2px; overflow: hidden; color: #9a9ea2; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.capability-switch {
  width: 34px;
  height: 20px;
  padding: 2px;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #d2d5d8;
  transition: background .14s ease;
}

.capability-switch::after {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  transition: transform .14s ease;
}

.capability-row.active .capability-switch { background: #3d4145; }
.capability-row.active .capability-switch::after { transform: translateX(14px); }

.chat-attachment-tray {
  width: 100%;
  padding: 0 1px 7px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chat-attachment-tray::-webkit-scrollbar { display: none; }

.bubble pre,
.bubble table,
.markdown-table-wrap {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.bubble pre::-webkit-scrollbar,
.bubble table::-webkit-scrollbar,
.markdown-table-wrap::-webkit-scrollbar { display: none; }

.chat-attachment-tray[hidden] { display: none; }
.upload-progress { width: 100%; margin: 0 0 8px; }
.upload-progress-bar { background: #676c71; }

.message-attachments { justify-content: flex-end; }
.message-attachment { background: rgba(255,255,255,.58); }

.sidebar-scrim { display: none; }

@keyframes chat-v6-spin { to { transform: rotate(360deg); } }
@keyframes chat-v6-pop {
  from { opacity: 0; transform: translateY(5px) scale(.988); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 800px) {
  .chat-workspace .chat-sheet { grid-template-columns: 1fr; }

  .chat-sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(82vw, 290px);
    display: flex;
    transform: translateX(-102%);
    box-shadow: 18px 0 40px rgba(0,0,0,.12);
    transition: transform .2s ease;
  }

  body.sidebar-open .chat-sidebar { transform: translateX(0); }
  .chat-sidebar-head { height: 62px; padding: 0 13px; }
  .chat-sidebar-logo { max-width: 90px; height: 25px; }
  .chat-sidebar-title { font-size: 13px; }

  .sidebar-scrim {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: block;
    border: 0;
    background: rgba(0,0,0,.22);
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, visibility .18s ease;
  }

  body.sidebar-open .sidebar-scrim { opacity: 1; visibility: visible; }
  .chat-topbar { height: 54px; min-height: 54px; }
  .chat-topbar h3 { font-size: 14px; }
  .chat-menu { display: grid; visibility: visible; }

  .chat-list {
    width: 100%;
    padding: 26px 14px 170px;
  }

  .chat-welcome { min-height: 55vh; padding: 0 10px; }
  .chat-welcome h2 { font-size: 23px; }
  .bubble { font-size: 14px; }
  .bubble.user { max-width: 86%; padding: 9px 12px; }
  .bubble.ai,
  .bubble.answer { line-height: 1.75; }

  .chat-composer-shell {
    padding: 28px 8px calc(8px + env(safe-area-inset-bottom));
  }

  .chat-composer-wrap { width: 100%; }
  .chat-composer { padding-left: 10px; border-radius: 20px; }
  .chat-composer .attach-btn { width: 32px; height: 32px; flex-basis: 32px; }
  #chatInput { font-size: 16px; }
  .capability-popover { left: 0; right: 0; bottom: 66px; width: auto; }
}

@media (max-width: 420px) {
  .chat-topbar h3 { font-size: 13px; }
  .chat-list { padding-right: 12px; padding-left: 12px; }
}
