:root {
  color-scheme: light;
  --bg: #ffffff;
  --sidebar: #f7f7f7;
  --sidebar-hover: #ececec;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e7e7e7;
  --field-line: #dedee3;
  --red: #d92d20;
  --shadow: 0 10px 32px rgba(17, 24, 39, 0.12);
  --chat-message-max: 860px;
  --chat-composer-max: 920px;
  --chat-edge-gap: 40px;
  --chat-empty-lead: clamp(300px, 30vh, 430px);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.brand-image {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 6px;
  border: 1px solid var(--line);
  image-rendering: pixelated;
  background: #fff;
}

.brand-copy {
  display: grid;
  min-width: 0;
}

.brand-copy strong,
.brand-copy small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy strong {
  font-size: 14px;
  font-weight: 750;
}

.brand-copy small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.top-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.top-link {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.top-link:hover {
  color: var(--text);
}

.avatar-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  min-height: 36px;
  place-items: center;
  padding: 0;
  border: 1px solid #c8d7f2;
  border-radius: 999px;
  background: #7fa6df;
  box-shadow:
    0 8px 18px rgba(79, 119, 180, 0.14),
    0 1px 0 rgba(255, 255, 255, 0.32) inset;
}

.avatar-button:hover {
  border-color: #b9cbed;
  background: #6f98d4;
}

.avatar-button span {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.avatar-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(17, 24, 39, 0.12);
}

.avatar-menu[hidden] {
  display: none;
}

.avatar-menu-header {
  display: grid;
  gap: 3px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid #f0f2f5;
}

.avatar-menu-name,
.avatar-menu-id {
  max-width: 100%;
  overflow: hidden;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-menu-name {
  font-size: 14px;
  font-weight: 700;
}

.avatar-menu-id {
  color: var(--muted);
  font-size: 12px;
}

.avatar-menu-link,
.avatar-menu-action {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
}

.avatar-menu-link:hover,
.avatar-menu-action:hover {
  background: #f5f9ff;
}

.ow-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: calc(100vh - 68px);
  background: var(--surface);
}

body.sidebar-collapsed .ow-shell {
  grid-template-columns: 54px minmax(0, 1fr);
}

.chat-sidebar {
  position: sticky;
  top: 68px;
  height: calc(100vh - 68px);
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.sidebar-brand {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 8px;
}

.ow-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 10px;
  background: #f7f7f8;
  color: #2f3540;
  font-size: 12px;
  font-weight: 850;
}

.sidebar-brand strong {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-toggle,
.header-icon,
.tiny-action,
.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(47, 53, 64, 0.78);
}

.sidebar-toggle {
  width: 30px;
  height: 30px;
  border-radius: 12px;
  background: #f7f7f8;
  color: rgba(47, 53, 64, 0.62);
}

.sidebar-toggle:hover {
  background: #eeeeef;
  color: rgba(17, 24, 39, 0.82);
}

.sidebar-toggle:hover,
.header-icon:hover,
.tiny-action:hover,
.tool-button:hover {
  background: #f7f7f8;
}

.sidebar-nav {
  display: grid;
  gap: 2px;
  padding: 4px 8px 10px;
}

.nav-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 5px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #24292f;
  text-align: left;
}

.nav-row:hover {
  background: var(--sidebar-hover);
}

.chat-icon,
.chat-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex: 0 0 auto;
}

.chat-nav-icon {
  width: 24px;
  height: 24px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.56);
  color: rgba(47, 53, 64, 0.72);
  transition:
    background 120ms ease,
    color 120ms ease;
}

.nav-row:hover .chat-nav-icon {
  background: #fff;
  color: #111827;
}

.chat-icon svg,
.chat-nav-icon svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-icon svg {
  width: 15px;
  height: 15px;
}

.chat-icon-sidebar,
.chat-icon-new,
.chat-icon-search,
.chat-icon-note,
.chat-icon-workspace {
  color: currentColor;
}

.chat-icon-sidebar::before,
.chat-icon-new::before,
.chat-icon-search::before,
.chat-icon-note::before,
.chat-icon-workspace::before,
.chat-icon-workspace::after {
  content: "";
  display: block;
  box-sizing: border-box;
}

.chat-icon-sidebar::before {
  width: 14px;
  height: 12px;
  border: 1.8px solid currentColor;
  border-radius: 4px;
  box-shadow: inset 5px 0 0 rgba(47, 53, 64, 0.12);
}

.chat-icon-new::before {
  width: 14px;
  height: 14px;
  border: 1.7px solid currentColor;
  border-radius: 5px;
}

.chat-icon-new::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 1.7px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 currentColor;
}

.chat-icon-new {
  background-image:
    linear-gradient(currentColor, currentColor),
    linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-size: 8px 1.7px, 1.7px 8px;
  background-position: center, center;
}

.chat-icon-search::before {
  width: 11px;
  height: 11px;
  border: 1.8px solid currentColor;
  border-radius: 50%;
  transform: translate(-1px, -1px);
}

.chat-icon-search::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 1.8px;
  border-radius: 999px;
  background: currentColor;
  transform: translate(5px, 5px) rotate(45deg);
}

.chat-icon-note::before {
  width: 13px;
  height: 15px;
  border: 1.7px solid currentColor;
  border-radius: 4px;
  background:
    linear-gradient(currentColor, currentColor) 3px 4px / 7px 1.4px no-repeat,
    linear-gradient(currentColor, currentColor) 3px 8px / 6px 1.4px no-repeat;
}

.chat-icon-workspace::before {
  width: 12px;
  height: 12px;
  border: 1.7px solid currentColor;
  border-radius: 4px;
}

.chat-icon-workspace::after {
  position: absolute;
  width: 6px;
  height: 6px;
  right: 3px;
  bottom: 3px;
  border-right: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
}

.nav-row strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted-nav {
  color: #52525b;
}

.search-wrap {
  padding: 0 8px 10px;
}

.search-wrap input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  outline: none;
  text-overflow: ellipsis;
}

.search-wrap input::placeholder,
.composer textarea::placeholder {
  color: #8b949e;
}

.sidebar-section {
  padding: 0 8px 8px;
}

.section-title,
.chat-section-title {
  color: #787f8b;
  font-size: 11px;
  font-weight: 650;
}

.section-title {
  padding: 6px 0;
}

.with-action,
.chat-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tiny-action {
  width: 24px;
  height: 24px;
  font-size: 16px;
}

.group-item {
  min-height: 30px;
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 8px;
  color: #3f3f46;
  font-size: 13px;
  font-weight: 600;
}

.group-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
}

.group-item:hover,
.group-item.active {
  background: var(--sidebar-hover);
}

.thread-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 8px 12px;
}

.thread-group {
  margin-top: 2px;
}

.thread-group-title {
  padding: 8px 0 5px;
  color: #8a8f98;
  font-size: 11px;
  font-weight: 650;
}

.thread-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 30px;
  margin: 1px 0;
  padding: 5px 6px 5px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 120ms ease;
}

.thread-item:hover,
.thread-item.active {
  background: var(--sidebar-hover);
}

.thread-item .thread-copy {
  display: block;
  min-width: 0;
  overflow: hidden;
}

.thread-item .thread-copy strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
}

.pin-mark {
  display: inline;
  margin-right: 4px;
  color: #111827;
  font-size: 11px;
}

.thread-menu-button {
  visibility: hidden;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #52525b;
  text-align: center;
}

.thread-menu-button:hover {
  background: #fff;
}

.thread-item:hover .thread-menu-button,
.thread-item.active .thread-menu-button {
  visibility: visible;
}

.thread-action-menu {
  position: fixed;
  z-index: 70;
  width: 168px;
  overflow: hidden;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(17, 24, 39, 0.14);
}

.thread-action-menu[hidden] {
  display: none;
}

.thread-action-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
}

.thread-action-menu button:hover {
  background: #f5f5f5;
}

.thread-action-menu .danger {
  color: var(--red);
}

body.sidebar-collapsed .chat-sidebar {
  overflow: hidden;
}

body.sidebar-collapsed .sidebar-brand {
  grid-template-columns: 38px;
  justify-items: center;
  padding: 8px;
}

body.sidebar-collapsed .ow-mark,
body.sidebar-collapsed .sidebar-brand strong,
body.sidebar-collapsed .search-wrap,
body.sidebar-collapsed .sidebar-section,
body.sidebar-collapsed .thread-list,
body.sidebar-collapsed .nav-row strong {
  display: none;
}

body.sidebar-collapsed .sidebar-nav {
  padding: 8px;
}

body.sidebar-collapsed .nav-row {
  grid-template-columns: 38px;
  justify-items: center;
  padding: 5px 0;
}

body.sidebar-collapsed .sidebar-toggle {
  width: 34px;
  height: 30px;
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: calc(100vh - 68px);
  background: #fff;
}

.chat-main.empty-chat {
  display: grid;
  grid-template-rows: auto var(--chat-empty-lead) auto minmax(0, 1fr);
}

.chat-header {
  min-height: 48px;
  padding: 0;
  background: #fff;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: min(520px, 100%);
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  font-weight: 640;
  line-height: 1.25;
  white-space: nowrap;
}

#threadTitle {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-chevron,
.add-model-button {
  color: #6b7280;
}

.add-model-button {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.add-model-button:hover {
  background: var(--sidebar-hover);
}

.thread-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.thread-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.header-icon {
  width: 30px;
  height: 30px;
  font-size: 18px;
}

.header-icon:disabled {
  cursor: default;
  opacity: 0.34;
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 18px 16px 22px;
}

.chat-main.empty-chat .messages {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 18px;
}

.empty-state {
  max-width: 620px;
  margin: 20vh auto 0;
  text-align: center;
}

.chat-main.empty-chat .empty-state {
  margin: 0 auto;
}

.empty-state h2 {
  margin-bottom: 8px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.message-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: min(var(--chat-message-max), 100%);
  margin: 0 auto 18px;
}

.message-row.user {
  justify-items: end;
}

.message-stack {
  display: grid;
  gap: 3px;
  max-width: 100%;
}

.message-row.user .message-stack {
  justify-items: end;
  max-width: min(640px, 78%);
}

.message-bubble {
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-row.user .message-bubble {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 12px;
  background: #f7f7f8;
  color: #111827;
  line-height: 1.55;
}

.message-meta {
  color: rgba(107, 114, 128, 0.72);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}

.message-row.user .message-meta {
  padding-right: 3px;
  text-align: right;
}

.composer {
  width: min(var(--chat-composer-max), calc(100% - var(--chat-edge-gap)));
  margin: 0 auto;
  padding: 12px 14px 10px;
  border: 1px solid #e4e4e7;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.1);
}

.chat-main.empty-chat .composer {
  align-self: center;
}

.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.attachment-tray[hidden] {
  display: none;
}

.attachment-card {
  position: relative;
  display: grid;
  grid-template-rows: 64px auto;
  width: 86px;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.attachment-card img,
.attachment-file-icon {
  width: 100%;
  height: 64px;
  border-radius: 6px;
  background: #f3f4f6;
}

.attachment-card img {
  object-fit: cover;
}

.attachment-file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #111827;
  font-size: 11px;
  font-weight: 750;
}

.attachment-card-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 14px;
  line-height: 1;
}

.composer-top {
  display: grid;
}

.composer textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  max-height: 180px;
  resize: none;
  padding: 4px 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.5;
  outline: none;
}

.composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tool-button {
  width: 30px;
  height: 30px;
  background: #f7f7f8;
  color: rgba(47, 53, 64, 0.74);
  font-size: 17px;
}

.tool-button:hover {
  background: #eeeeef;
  color: #111827;
}

.primary-button,
.send-button,
.ghost-button,
.icon-button {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-weight: 650;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

.primary-button,
.send-button {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.primary-button:hover,
.send-button:hover {
  border-color: #000;
  background: #000;
}

.ghost-button,
.icon-button {
  background: #fff;
  color: var(--text);
}

.ghost-button {
  padding: 0 10px;
  font-size: 12px;
}

.icon-button {
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.ghost-button:hover,
.icon-button:hover {
  background: var(--sidebar-hover);
}

.ghost-button.danger {
  color: var(--red);
}

.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 999px;
}

.send-button svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.send-button:disabled,
.primary-button:disabled,
.ghost-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.status-line {
  width: min(var(--chat-composer-max), calc(100% - var(--chat-edge-gap)));
  min-height: 18px;
  margin: 8px auto 12px;
  color: var(--muted);
  font-size: 12px;
}

@media (min-width: 3000px) {
  :root {
    --chat-message-max: 900px;
    --chat-composer-max: 960px;
    --chat-empty-lead: 430px;
  }

  .messages {
    padding-top: 26px;
  }
}

@media (max-width: 900px) {
  .ow-shell,
  body.sidebar-collapsed .ow-shell {
    grid-template-columns: 1fr;
  }

  .chat-sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  body.sidebar-collapsed .chat-sidebar {
    display: none;
  }

  .thread-list {
    max-height: 220px;
  }

  .chat-main {
    height: auto;
    min-height: calc(100vh - 68px);
  }
}

@media (max-width: 680px) {
  :root {
    --chat-edge-gap: 24px;
    --chat-empty-lead: clamp(220px, 28vh, 300px);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
  }

  .top-actions {
    width: 100%;
    overflow-x: auto;
    gap: 12px;
  }

  .chat-header {
    align-items: flex-start;
  }

  .message-row.user .message-bubble {
    max-width: 88%;
  }

  .composer,
  .status-line {
    width: min(100% - var(--chat-edge-gap), var(--chat-composer-max));
  }
}

/* 2026-05-16 real logo asset. Keep this last so the clickable brand slot stays stable. */
.brand {
  flex: 0 0 auto;
  min-width: 42px;
  min-height: 42px;
  justify-content: center;
  border-radius: 8px;
}

.brand-image {
  width: 36px;
  height: 36px;
  display: block;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  image-rendering: auto;
}
