:root {
  color-scheme: dark light;
  --brand: #ed1c24;
  --brand-soft: rgba(237, 28, 36, 0.1);
  --side-width: 312px;
  --content-width: 900px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #202020;
  --surface: #262626;
  --sidebar: #171717;
  --panel: #2d2d2d;
  --panel-strong: #343434;
  --panel-hover: #383838;
  --text: #f6f6f6;
  --muted: #bdbdbd;
  --faint: #909090;
  --line: rgba(255, 255, 255, 0.11);
  --input: #2f2f2f;
  --chip: rgba(255, 255, 255, 0.07);
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.34);
  --logo-plate: transparent;
}

:root[data-theme="light"] {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --sidebar: #f0f0ed;
  --panel: #ffffff;
  --panel-strong: #f2f2ef;
  --panel-hover: #e9e9e5;
  --text: #202020;
  --muted: #666666;
  --faint: #8b8b8b;
  --line: rgba(32, 32, 32, 0.13);
  --input: #ffffff;
  --chip: rgba(34, 31, 28, 0.06);
  --shadow: 0 18px 48px rgba(20, 20, 20, 0.12);
  --logo-plate: transparent;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  display: grid;
  grid-template-columns: var(--side-width) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  background: var(--bg);
}

.app[data-sidebar-collapsed="true"] {
  grid-template-columns: 78px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 12px 14px;
  background: color-mix(in srgb, var(--sidebar), var(--bg) 16%);
  border-right: 1px solid var(--line);
}

.side-brand,
.nav-action,
.nav-search,
.gpt-card,
.company-row,
.topbar,
.composer,
.message,
.theme-switch,
.theme-option,
.starter-row {
  display: flex;
  align-items: center;
}

.side-brand {
  gap: 12px;
  min-height: 54px;
  padding: 0 10px 12px;
}

.side-brand img,
.company-row img,
.gpt-card img,
.hero-logo {
  object-fit: contain;
  background: transparent;
}

.side-brand img {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.side-brand div,
.company-row div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.side-brand strong,
.company-row strong,
.top-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-brand strong {
  font-size: 18px;
  font-weight: 780;
}

.side-brand span,
.company-row span,
.top-title span {
  color: var(--muted);
  font-size: 13px;
}

.side-toggle {
  margin-left: auto;
}

.app[data-sidebar-collapsed="true"] .side-brand {
  justify-content: center;
  padding-inline: 0;
}

.app[data-sidebar-collapsed="true"] .side-brand div,
.app[data-sidebar-collapsed="true"] .section-title,
.app[data-sidebar-collapsed="true"] .gpt-card span,
.app[data-sidebar-collapsed="true"] .conversation-list,
.app[data-sidebar-collapsed="true"] .company-row div,
.app[data-sidebar-collapsed="true"] .nav-action:not(.primary),
.app[data-sidebar-collapsed="true"] .nav-search input {
  display: none;
}

.app[data-sidebar-collapsed="true"] .side-toggle {
  position: absolute;
  top: 66px;
  left: 20px;
  margin: 0;
}

.app[data-sidebar-collapsed="true"] .side-nav {
  margin-top: 46px;
}

.app[data-sidebar-collapsed="true"] .nav-action,
.app[data-sidebar-collapsed="true"] .nav-search,
.app[data-sidebar-collapsed="true"] .gpt-card,
.app[data-sidebar-collapsed="true"] .company-row {
  justify-content: center;
  padding-inline: 0;
}

.side-nav {
  display: grid;
  gap: 8px;
  margin: 14px 0 24px;
}

.nav-action,
.nav-search {
  width: 100%;
  height: 44px;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  text-align: left;
  font-size: 14px;
  font-weight: 620;
}

.nav-action.primary {
  color: #ffffff;
  background: #16130f;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

:root[data-theme="light"] .nav-action.primary {
  background: #241f1a;
}

.nav-action:hover,
.gpt-card:hover,
.conversation-item:hover,
.theme-option:hover {
  background: var(--panel-hover);
}

.nav-action.primary:hover {
  background: #2a221c;
}

.nav-search {
  background: var(--panel);
  border-color: var(--line);
}

.nav-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 14px;
  font-weight: 580;
}

.nav-search input::placeholder {
  color: var(--faint);
}

.section-title {
  margin: 18px 8px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.gpt-card {
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.gpt-card.active {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.gpt-card img {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.conversation-list {
  display: grid;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.conversation-item {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.conversation-item.active {
  background: var(--panel);
}

.conversation-item strong,
.conversation-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item strong {
  font-size: 14px;
  font-weight: 650;
}

.conversation-item span {
  color: var(--muted);
  font-size: 12px;
}

.company-row {
  gap: 10px;
  min-height: 66px;
  margin: auto -12px -14px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  background: var(--sidebar);
}

.company-row img {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.company-row strong {
  font-size: 14px;
}

.main {
  position: relative;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.topbar {
  justify-content: space-between;
  gap: 14px;
  padding: 0 32px;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 30%);
}

.top-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.top-title img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  object-fit: contain;
}

.top-title div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.top-title strong {
  font-size: 20px;
  font-weight: 780;
}

.top-title span {
  font-size: 13px;
}

.menu-button {
  display: none;
}

.icon-button,
.tool-button,
.send-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  background: transparent;
}

.icon-button:hover,
.tool-button:hover {
  background: var(--panel-hover);
}

.theme-switch {
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip);
}

.theme-option {
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 680;
}

.theme-option[aria-pressed="true"] {
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.12);
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 0 24px 24px;
}

.empty {
  width: min(860px, calc(100% - 32px));
  min-height: calc(100dvh - 220px);
  margin: 0 auto;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.hero-logo {
  width: 106px;
  height: 106px;
  margin-bottom: 22px;
}

.empty h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1.15;
  letter-spacing: 0;
  font-weight: 820;
}

.empty p {
  margin: 12px 0 0;
  max-width: 560px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.starter-row {
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 30px;
}

.starter-row button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel);
  box-shadow: none;
}

.starter-row button:hover {
  background: var(--panel-hover);
}

.messages.has-chat {
  padding-top: 28px;
}

.message {
  align-items: flex-start;
  gap: 14px;
  width: min(790px, calc(100% - 32px));
  margin: 0 auto 24px;
}

.message.user {
  justify-content: flex-end;
}

.message.user .avatar,
.message.user .message-name {
  display: none;
}

.message.user .message-body {
  max-width: min(650px, 88%);
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
}

.message.assistant .message-body {
  width: 100%;
  min-width: 0;
}

.avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 0;
  background: transparent;
  background-image: url("/assets/jiuzhou-logo.png");
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
}

.message-name {
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 760;
}

.message-content {
  color: var(--text);
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.message-content p {
  margin: 0 0 12px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul,
.message-content ol {
  margin: 8px 0 12px;
  padding-left: 22px;
}

.message-content pre {
  overflow-x: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-strong), #000000 28%);
  color: var(--text);
}

.message-content code {
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--chip);
}

.capability-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.capability-row span {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel);
  font-size: 12px;
}

.composer-shell {
  width: min(var(--content-width), calc(100% - 64px));
  margin: 0 auto 22px;
}

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

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

.attachment-chip,
.file-list span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  max-width: 100%;
  padding: 4px 8px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel);
  font-size: 12px;
}

.attachment-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip button {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
}

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.file-list strong {
  flex-basis: 100%;
  font-size: 13px;
}

.composer {
  gap: 12px;
  width: 100%;
  min-height: 72px;
  margin: 0;
  padding: 12px 12px 12px 18px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--input);
  box-shadow: var(--shadow);
}

.composer textarea {
  width: 100%;
  max-height: 180px;
  min-height: 28px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 16px;
  line-height: 1.55;
}

.composer textarea::placeholder {
  color: var(--faint);
}

.tool-button {
  flex: 0 0 auto;
  color: var(--muted);
}

.tool-button.active {
  color: #ffffff;
  background: var(--brand);
}

.send-button {
  flex: 0 0 auto;
  color: #ffffff;
  background: var(--brand);
  border-radius: 999px;
}

.send-button:hover {
  filter: brightness(1.05);
}

.send-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.typing::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1.1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: currentColor;
  animation: blink 1s steps(2, start) infinite;
}

.scrim {
  display: none;
}

.icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.theme-option .icon {
  width: 16px;
  height: 16px;
}

.icon-edit { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 19h14v2H5a2 2 0 0 1-2-2V5h2zm3-2H6v-2L17.3 3.7a1 1 0 0 1 1.4 0l1.6 1.6a1 1 0 0 1 0 1.4zM18 6.4 17.6 6 8 15.6v.4h.4z'/%3E%3C/svg%3E"); }
.icon-search { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.5 4a6.5 6.5 0 0 1 5.16 10.45l4.45 4.44-1.42 1.42-4.44-4.45A6.5 6.5 0 1 1 10.5 4m0 2a4.5 4.5 0 1 0 0 9 4.5 4.5 0 0 0 0-9'/%3E%3C/svg%3E"); }
.icon-menu { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 6h16v2H4zm0 5h16v2H4zm0 5h16v2H4z'/%3E%3C/svg%3E"); }
.icon-plus { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 5h2v6h6v2h-6v6h-2v-6H5v-2h6z'/%3E%3C/svg%3E"); }
.icon-send { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 11.2 20.5 3a.9.9 0 0 1 1.2 1.1L16 21a.9.9 0 0 1-1.7.1l-3-6.3-6.5-2.1a.9.9 0 0 1-.1-1.7zM7.7 12l4.6 1.5 2.2 4.5 3.6-10.6z'/%3E%3C/svg%3E"); }
.icon-x { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m6.4 5 5.6 5.6L17.6 5 19 6.4 13.4 12l5.6 5.6-1.4 1.4-5.6-5.6L6.4 19 5 17.6l5.6-5.6L5 6.4z'/%3E%3C/svg%3E"); }
.icon-sidebar { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 5a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm5 0H6v14h3zm2 0v14h7V5z'/%3E%3C/svg%3E"); }
.icon-sun { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 2h2v3h-2zm0 17h2v3h-2zM2 11h3v2H2zm17 0h3v2h-3zM4.2 5.6l1.4-1.4 2.1 2.1-1.4 1.4zm12.1 12.1 1.4-1.4 2.1 2.1-1.4 1.4zM18.4 4.2l1.4 1.4-2.1 2.1-1.4-1.4zM6.3 16.3l1.4 1.4-2.1 2.1-1.4-1.4zM12 7a5 5 0 1 1 0 10 5 5 0 0 1 0-10'/%3E%3C/svg%3E"); }
.icon-moon { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14.1 2.3a8.7 8.7 0 1 0 7.6 7.6 7.1 7.1 0 1 1-7.6-7.6z'/%3E%3C/svg%3E"); }
.icon-mic { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 3a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3m6 8a6 6 0 0 1-5 5.92V20h4v2H7v-2h4v-3.08A6 6 0 0 1 6 11h2a4 4 0 0 0 8 0z'/%3E%3C/svg%3E"); }
.icon-phone { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6.6 10.8a15.1 15.1 0 0 0 6.6 6.6l2.2-2.2a1 1 0 0 1 1-.25c1.1.36 2.3.55 3.6.55a1 1 0 0 1 1 1V20a1 1 0 0 1-1 1A17 17 0 0 1 3 4a1 1 0 0 1 1-1h3.5a1 1 0 0 1 1 1c0 1.3.19 2.5.55 3.6a1 1 0 0 1-.25 1z'/%3E%3C/svg%3E"); }
.icon-video { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 6h10a2 2 0 0 1 2 2v1.2l4-2.4A1 1 0 0 1 21.5 7v10a1 1 0 0 1-1.5.86l-4-2.4V16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2m0 2v8h10V8zm12 3.5v1l3.5 2.1V9.4z'/%3E%3C/svg%3E"); }
@keyframes blink {
  50% { opacity: 0; }
}

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

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

  .app[data-sidebar-open="true"] .sidebar {
    transform: translateX(0);
  }

  .scrim {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    background: rgba(0, 0, 0, 0.48);
  }

  .app[data-sidebar-open="true"] .scrim {
    display: block;
  }

  .menu-button {
    display: grid;
  }

  .side-toggle {
    display: grid;
  }

  .app[data-sidebar-collapsed="true"] {
    grid-template-columns: 1fr;
  }

  .app[data-sidebar-collapsed="true"] .side-brand div,
  .app[data-sidebar-collapsed="true"] .section-title,
  .app[data-sidebar-collapsed="true"] .gpt-card span,
  .app[data-sidebar-collapsed="true"] .conversation-list,
  .app[data-sidebar-collapsed="true"] .company-row div,
  .app[data-sidebar-collapsed="true"] .nav-action:not(.primary),
  .app[data-sidebar-collapsed="true"] .nav-search input {
    display: initial;
  }

  .app[data-sidebar-collapsed="true"] .side-toggle {
    position: static;
    margin-left: auto;
  }

  .main {
    grid-template-rows: 58px minmax(0, 1fr) auto;
  }

  .topbar {
    padding: 0 10px;
  }

  .top-title {
    min-width: 0;
    gap: 8px;
    text-align: left;
  }

  .top-title img {
    width: 34px;
    height: 34px;
  }

  .top-title strong {
    max-width: 48vw;
    font-size: 16px;
  }

  .top-title span {
    max-width: 48vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }

  .theme-switch {
    gap: 2px;
    padding: 2px;
  }

  .theme-option {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
  }

  .theme-option span:last-child {
    display: none;
  }

  .messages {
    padding: 0 12px 14px;
  }

  .empty {
    width: min(100%, 390px);
    min-height: calc(100dvh - 194px);
    padding: 0 16px;
  }

  .hero-logo {
    width: 92px;
    height: 92px;
    margin-bottom: 18px;
  }

  .empty h1 {
    font-size: 28px;
  }

  .empty p {
    font-size: 16px;
  }

  .starter-row {
    gap: 8px;
    margin-top: 22px;
  }

  .starter-row button {
    width: 100%;
    min-height: 42px;
  }

  .message {
    width: 100%;
    gap: 10px;
    margin-bottom: 20px;
  }

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

  .composer-shell {
    width: calc(100% - 20px);
    margin-bottom: calc(10px + var(--safe-bottom));
  }

  .composer {
    width: 100%;
    min-height: 62px;
    margin-bottom: 0;
    padding: 10px;
    border-radius: 24px;
  }

  .composer textarea {
    font-size: 16px;
  }

  .composer .tool-button {
    width: 34px;
    height: 34px;
  }
}
