@import url("https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700&family=Source+Serif+4:opsz,wght@8..60,400;8..60,500;8..60,600&display=swap");

:root {
  color-scheme: light;
  --bg: #faf9f7;
  --surface: #faf9f7;
  --surface-lowest: #ffffff;
  --surface-low: #f4f3f1;
  --surface-mid: #efeeec;
  --surface-high: #e9e8e6;
  --surface-highest: #e3e2e0;
  --ink: #1a1c1b;
  --muted: #464741;
  --weak: #777771;
  --line: #c7c7bf;
  --line-soft: rgba(119, 119, 113, 0.24);
  --primary: #020302;
  --secondary: #65558f;
  --secondary-soft: #e9ddff;
  --shadow: 0 18px 48px rgba(26, 28, 27, 0.08);
  --sidebar-width: 280px;
  font-family: "Hanken Grotesk", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body.auth-locked .app-shell {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

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

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ui-icon {
  width: 24px;
  height: 24px;
  display: block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  background: var(--bg);
  overflow: hidden;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 68%, rgba(182, 234, 185, 0.52), transparent 32%),
    rgba(250, 249, 247, 0.86);
  backdrop-filter: blur(14px);
}

.auth-card {
  width: min(430px, 100%);
  padding: 30px;
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(26, 28, 27, 0.16);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.auth-logo img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.auth-logo strong {
  font-size: 22px;
  font-weight: 800;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.2;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.auth-field {
  display: grid;
  gap: 8px;
}

.auth-field span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.auth-field input {
  width: 100%;
  height: 50px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 0 14px;
  color: var(--ink);
  background: white;
  outline: 0;
}

.auth-field input:focus {
  border-color: rgba(26, 28, 27, 0.42);
  box-shadow: 0 0 0 4px rgba(26, 28, 27, 0.06);
}

.auth-submit {
  height: 52px;
  margin-top: 6px;
  border: 0;
  border-radius: 999px;
  color: white;
  background: var(--primary);
  font-weight: 800;
}

.auth-submit:disabled {
  opacity: 0.56;
  cursor: default;
}

.auth-switch {
  width: max-content;
  justify-self: center;
  border: 0;
  padding: 6px 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.auth-switch:hover {
  color: var(--ink);
  text-decoration: underline;
}

.auth-message {
  min-height: 22px;
  color: #8f1d1d !important;
  font-size: 14px;
}

.app-shell.sidebar-hidden {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell.sidebar-hidden .conversation-panel {
  display: none;
}

.app-shell.sidebar-hidden .chat-main {
  grid-column: 1;
}

.conversation-panel {
  min-width: 0;
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px 16px;
  background: var(--surface-low);
  border-right: 1px solid var(--line-soft);
}

.sidebar-brand {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 8px;
}

.brand-group {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: transparent;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(26, 28, 27, 0.12));
}

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

.brand-copy strong {
  color: var(--primary);
  font-family: "Source Serif 4", serif;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.1;
}

.brand-copy span {
  color: var(--weak);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.icon-button,
.round-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 20px;
  line-height: 1;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease;
}

.icon-button:hover,
.round-button:hover {
  color: var(--primary);
  background: var(--surface-high);
}

.collapse-button {
  border: 0;
  background: transparent;
  color: var(--weak);
  box-shadow: none;
}

.collapse-button:hover {
  color: var(--primary);
  background: rgba(227, 226, 224, 0.7);
}

.collapse-button .ui-icon,
.show-sidebar .ui-icon {
  width: 24px;
  height: 24px;
  stroke-width: 1.9;
}

.side-menu {
  display: grid;
  gap: 4px;
}

.side-menu-item {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 18px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-size: 18px;
  font-weight: 700;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    transform 0.08s ease;
}

.side-menu-item .ui-icon {
  width: 28px;
  height: 28px;
  stroke-width: 2.2;
}

.side-menu-item:hover,
.side-menu-item.active {
  color: var(--primary);
  background: rgba(227, 226, 224, 0.78);
}

.side-menu-item:active,
.mode-tabs button:active,
.quick-actions button:active {
  transform: scale(0.98);
}

.search-box {
  height: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-radius: 4px;
  color: var(--weak);
  background: var(--surface-highest);
}

.search-box .ui-icon {
  width: 26px;
  height: 26px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.search-box input::placeholder,
.composer-card textarea::placeholder {
  color: rgba(70, 71, 65, 0.55);
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mode-tabs button {
  min-height: 68px;
  border: 1px solid transparent;
  border-radius: 4px;
  display: grid;
  place-items: center;
  gap: 6px;
  color: var(--weak);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease;
}

.mode-tabs button .ui-icon {
  width: 30px;
  height: 30px;
  stroke-width: 2.15;
}

.mode-tabs button:hover,
.mode-tabs button.active {
  color: var(--primary);
  background: var(--surface-lowest);
  border-color: var(--line-soft);
}

.sidebar-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 0;
  color: var(--weak);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.mini-button {
  border: 0;
  color: var(--weak);
  background: transparent;
  font-size: 12px;
}

.mini-button:hover {
  color: var(--primary);
}

.chat-list {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  align-content: start;
  gap: 4px;
}

.chat-row {
  min-width: 0;
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  transition:
    background 0.16s ease,
    color 0.16s ease;
}

.chat-row:hover,
.chat-row.active {
  color: var(--primary);
  background: rgba(227, 226, 224, 0.7);
}

.chat-card {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: inherit;
  padding: 9px 8px 9px 16px;
  color: inherit;
  background: transparent;
  text-align: left;
}

.chat-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 500;
}

.chat-card span {
  display: none;
}

.chat-card small {
  display: none;
}

.chat-delete-button {
  width: 32px;
  height: 32px;
  margin-right: 5px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--weak);
  background: transparent;
  opacity: 0.56;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    opacity 0.16s ease;
}

.chat-row:hover .chat-delete-button,
.chat-row:focus-within .chat-delete-button {
  opacity: 1;
}

.chat-delete-button:hover {
  color: #93000a;
  background: var(--surface-lowest);
}

.chat-delete-button .ui-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2.15;
}

.sidebar-footer {
  margin-top: auto;
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 0;
  border-radius: 14px;
  color: inherit;
  background: transparent;
  text-align: left;
}

.sidebar-footer:hover {
  background: var(--surface-high);
}

.user-dot {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #201047;
  background: var(--secondary-soft);
  font-size: 13px;
  font-weight: 700;
}

.footer-chevron {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.user-meta {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.user-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.user-meta span {
  color: var(--weak);
  font-size: 12px;
}

.chat-main {
  min-width: 0;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg);
  overflow: hidden;
}

.chat-main.empty-mode {
  grid-template-rows: auto minmax(250px, 34vh) auto;
}

.chat-header {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: rgba(250, 249, 247, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 2;
}

.show-sidebar {
  display: none;
}

.app-shell.sidebar-hidden .show-sidebar {
  display: grid;
}

.assistant-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  opacity: 0;
  pointer-events: none;
}

.avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--primary);
}

.avatar .ui-icon {
  width: 24px;
  height: 24px;
  stroke-width: 2.15;
}

.persona-name,
.persona-subtitle,
p {
  margin-top: 0;
}

.persona-name {
  margin-bottom: 0;
  color: var(--ink);
  font-family: "Source Serif 4", serif;
  font-size: 20px;
  font-weight: 500;
}

.persona-subtitle {
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ghost-button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
}

.ghost-button:hover {
  color: var(--primary);
  background: var(--surface-high);
}

.connection-badge {
  min-width: 58px;
  padding: 5px 10px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface-high);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.connection-badge.ready {
  color: #0f7a37;
  background: #e7f4e8;
}

.connection-badge.warn {
  color: #93000a;
  background: #ffdad6;
}

.messages {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 64px 24px 22px;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

.messages::-webkit-scrollbar,
.chat-list::-webkit-scrollbar {
  width: 10px;
}

.messages::-webkit-scrollbar-track,
.chat-list::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb,
.chat-list::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(119, 119, 113, 0.34);
  background-clip: content-box;
}

.messages::-webkit-scrollbar-thumb:hover,
.chat-list::-webkit-scrollbar-thumb:hover {
  background: rgba(70, 71, 65, 0.45);
  background-clip: content-box;
}

.empty-state {
  width: min(800px, 100%);
  margin: auto auto 42px;
  display: grid;
  justify-items: center;
  color: var(--muted);
  text-align: center;
}

.empty-logo {
  display: none;
}

.star-mark {
  display: none;
}

.empty-state h2 {
  margin: 0;
  color: var(--ink);
  font-family: "Source Serif 4", serif;
  font-size: clamp(32px, 4vw, 40px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.empty-state p,
.quick-prompts {
  display: none;
}

.message {
  width: min(800px, 100%);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 14px;
  align-self: center;
  align-items: start;
}

.message.user {
  grid-template-columns: minmax(0, 1fr) 34px;
}

.message.user .message-avatar {
  grid-column: 2;
  grid-row: 1;
  color: var(--ink);
  background: var(--surface-highest);
}

.message-body {
  min-width: 0;
}

.message.user .message-body {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  display: grid;
  justify-items: end;
  max-width: min(680px, 100%);
}

.message-name {
  margin: 0 4px 4px 0;
  color: var(--weak);
  font-size: 12px;
}

.message.user .bubble {
  max-width: 100%;
  background: var(--surface-high);
}

.message-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--primary);
  background: var(--surface-high);
  font-size: 18px;
  line-height: 1;
}

.message-avatar .ui-icon {
  width: 21px;
  height: 21px;
  stroke-width: 2.15;
}

.bubble {
  min-width: 0;
  border-radius: 8px;
  padding: 8px 0;
  background: transparent;
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user .bubble {
  padding: 11px 14px;
}

.bubble code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--surface-high);
}

.message-attachments,
.pending-attachments {
  display: grid;
  gap: 8px;
}

.message-attachments {
  margin-top: 8px;
}

.pending-attachments {
  width: min(800px, 100%);
  margin: 0 auto 8px;
}

.attachment-card {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(119, 119, 113, 0.24);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
}

.attachment-preview-image,
.attachment-preview-video {
  width: 116px;
  height: 78px;
  border-radius: 10px;
  background: var(--surface-low);
  object-fit: cover;
}

.attachment-preview-video {
  object-fit: contain;
}

.attachment-file-icon {
  width: 58px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-low);
  font-size: 13px;
  font-weight: 700;
}

.attachment-info {
  min-width: 0;
  display: grid;
  gap: 3px;
}

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

.attachment-info strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.attachment-info span {
  color: var(--weak);
  font-size: 12px;
}

.attachment-download,
.attachment-remove {
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface-low);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.attachment-download {
  padding: 0 10px;
}

.attachment-remove {
  width: 30px;
  padding: 0;
}

.bubble.streaming::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 4px;
  vertical-align: -2px;
  border-radius: 999px;
  background: var(--primary);
  animation: blink 0.9s steps(2, start) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.composer {
  position: relative;
  padding: 24px;
  background: linear-gradient(to top, var(--bg) 72%, rgba(250, 249, 247, 0));
}

.chat-main.empty-mode .messages {
  padding: clamp(84px, 13vh, 150px) 24px 0;
}

.chat-main.empty-mode .composer {
  padding-top: 12px;
  padding-bottom: clamp(220px, 31vh, 320px);
  background: linear-gradient(to top, rgba(250, 249, 247, 0.96) 64%, rgba(250, 249, 247, 0));
}

.composer-card {
  width: min(800px, 100%);
  min-height: 56px;
  margin: 0 auto 8px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid rgba(119, 119, 113, 0.38);
  border-radius: 14px;
  background: var(--surface-lowest);
  box-shadow: 0 4px 16px rgba(26, 28, 27, 0.04);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.composer-card:focus-within {
  border-color: rgba(2, 3, 2, 0.48);
  box-shadow: 0 0 0 1px rgba(2, 3, 2, 0.08);
}

.composer-card textarea {
  width: 100%;
  min-height: 36px;
  max-height: 160px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 6px 4px;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
  line-height: 24px;
  align-self: center;
  overflow-y: hidden;
}

.mode-chip {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  align-self: center;
  color: rgba(70, 71, 65, 0.56);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.send-button {
  width: 38px;
  min-width: 38px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  padding: 0;
  color: white;
  background: var(--primary);
  align-self: center;
}

.send-button .ui-icon {
  width: 19px;
  height: 19px;
  stroke-width: 2.7;
}

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

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

.quick-actions {
  width: min(800px, 100%);
  margin: 0 auto;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-actions button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(119, 119, 113, 0.28);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface-lowest);
  font-size: 12px;
  font-weight: 600;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease;
}

.quick-actions button:hover {
  color: var(--primary);
  background: var(--surface-low);
  border-color: rgba(119, 119, 113, 0.4);
}

.quick-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
}

.quick-icon .ui-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.thinking-logo {
  width: min(800px, calc(100% - 48px));
  position: absolute;
  left: 50%;
  top: -23px;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  padding-right: 14px;
  pointer-events: none;
}

.thinking-logo img {
  width: 74px;
  height: 48px;
  object-fit: contain;
  animation: turtle-crawl 0.76s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(26, 28, 27, 0.12));
}

@keyframes turtle-crawl {
  0%,
  100% {
    transform: translateX(-2px) translateY(0) rotate(-1deg);
  }
  45% {
    transform: translateX(5px) translateY(-2px) rotate(1deg);
  }
}

.hidden {
  display: none !important;
}

.insight-panel {
  display: none;
}

.memory-list {
  display: grid;
  gap: 8px;
}

.memory-item {
  padding: 10px 12px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface-high);
  font-size: 13px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(18px);
  z-index: 10;
  max-width: min(520px, calc(100vw - 28px));
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  background: var(--primary);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.user-menu {
  position: fixed;
  left: 16px;
  bottom: 72px;
  z-index: 30;
  width: min(374px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 44px rgba(26, 28, 27, 0.16);
}

.menu-profile-row {
  min-height: 66px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px 12px;
}

.menu-profile-row strong,
.menu-profile-row span {
  display: block;
}

.menu-profile-row strong {
  color: var(--ink);
  font-size: 18px;
  font-weight: 500;
}

.menu-profile-row span {
  color: var(--weak);
}

.menu-separator {
  height: 1px;
  margin: 0 12px 8px;
  background: var(--line-soft);
}

.user-menu button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 0;
  border-radius: 12px;
  padding: 0 14px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  font-size: 16px;
}

.user-menu button:hover {
  background: var(--surface-low);
}

.user-menu button .ui-icon {
  width: 23px;
  height: 23px;
}

.profile-avatar {
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: white;
  background: #9b55bd;
  font-weight: 600;
}

.profile-avatar.small {
  width: 38px;
  height: 38px;
  font-size: 13px;
}

.profile-avatar.large {
  width: 192px;
  height: 192px;
  font-size: 70px;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: start center;
  padding: 36px 16px;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(2px);
}

.modal-card {
  width: min(720px, calc(100vw - 28px));
  border: 1px solid rgba(119, 119, 113, 0.24);
  border-radius: 24px;
  background: white;
  box-shadow: 0 24px 70px rgba(26, 28, 27, 0.22);
}

.search-modal {
  width: min(640px, calc(100vw - 28px));
  padding: 10px;
}

.modal-search-input {
  height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 0 10px 0 16px;
  border-radius: 16px;
  background: var(--surface-low);
}

.modal-search-input input {
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 18px;
}

.modal-caption {
  margin: 14px 10px 8px;
  color: var(--weak);
  font-size: 13px;
  font-weight: 700;
}

.search-results {
  max-height: min(60vh, 460px);
  overflow: auto;
  display: grid;
  gap: 2px;
}

.search-result {
  min-height: 46px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 0;
  border-radius: 12px;
  padding: 0 14px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.search-result:hover {
  background: var(--surface-low);
}

.search-result span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result small {
  color: var(--weak);
}

.project-modal,
.profile-modal,
.settings-modal {
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 24px;
}

.modal-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 500;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.plain-icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
}

.plain-icon-button:hover {
  background: var(--surface-low);
}

.field-label {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 16px;
}

.project-name-field {
  height: 56px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.project-icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-low);
}

.project-name-field input {
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 18px;
}

.project-current {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface-low);
}

.project-current span {
  color: var(--weak);
  font-size: 13px;
  font-weight: 700;
}

.project-current strong {
  min-width: 0;
  color: var(--ink);
  font-size: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-list {
  display: grid;
  gap: 8px;
  max-height: 230px;
  margin-bottom: 18px;
  padding-right: 4px;
  overflow: auto;
}

.project-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.project-list-item {
  min-width: 0;
  min-height: 56px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.project-list-row.active .project-list-item,
.project-list-item:hover {
  background: var(--surface-low);
}

.project-list-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--project-color, var(--primary));
  background: white;
  box-shadow: inset 0 0 0 1px var(--line-soft);
}

.project-list-icon .ui-icon {
  width: 20px;
  height: 20px;
}

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

.project-list-item strong {
  font-size: 15px;
}

.project-list-item small {
  margin-top: 2px;
  color: var(--weak);
  font-size: 12px;
}

.project-delete-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--weak);
  background: transparent;
}

.project-delete-button .ui-icon {
  width: 19px;
  height: 19px;
}

.project-delete-button:hover {
  color: #93000a;
  background: #ffdad6;
}

.project-helper {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-low);
  line-height: 1.5;
}

.project-picker {
  width: min(390px, 100%);
  margin-top: -2px;
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  background: white;
  box-shadow: 0 10px 28px rgba(26, 28, 27, 0.12);
  overflow: hidden;
}

.color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 24px 26px 18px;
}

.color-dot {
  width: 36px;
  height: 36px;
  border: 3px solid transparent;
  border-radius: 999px;
  background: var(--dot);
}

.color-dot.active {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.project-icon-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  padding: 18px 20px 24px;
  border-top: 1px solid var(--line-soft);
}

.project-icon-grid button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
}

.project-icon-grid button.active,
.project-icon-grid button:hover {
  background: var(--surface-low);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.primary-modal-button,
.secondary-modal-button {
  min-height: 48px;
  border-radius: 999px;
  padding: 0 22px;
  font-size: 16px;
}

.primary-modal-button {
  border: 0;
  color: white;
  background: var(--primary);
}

.primary-modal-button:disabled {
  color: white;
  background: #b9b9b4;
  cursor: default;
}

.secondary-modal-button {
  border: 1px solid var(--line-soft);
  color: var(--ink);
  background: white;
}

.profile-editor-avatar {
  width: max-content;
  position: relative;
  margin: 12px auto 34px;
}

.camera-button {
  position: absolute;
  right: 8px;
  bottom: 6px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--muted);
  background: white;
}

.text-field {
  min-height: 86px;
  display: grid;
  gap: 6px;
  padding: 12px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.text-field + .text-field {
  margin-top: 12px;
}

.text-field span {
  color: var(--muted);
  font-size: 14px;
}

.text-field input {
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 20px;
}

.profile-note {
  margin: 18px 0 0;
  color: var(--weak);
  text-align: center;
}

.settings-list {
  display: grid;
  gap: 10px;
}

.settings-list label {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--surface-low);
}

.empty-list {
  padding: 12px 16px;
  color: var(--weak);
  font-size: 14px;
}

.mobile-tabs {
  display: none;
}

.mobile-chat-top,
.mobile-drawer-scrim {
  display: none;
}

.mic-button {
  display: none;
}

.attachment-sheet {
  width: min(800px, 100%);
  margin: -2px auto 12px;
  border: 1px solid rgba(119, 119, 113, 0.18);
  border-radius: 22px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 18px 44px rgba(26, 28, 27, 0.14);
}

.attachment-handle {
  width: 44px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: rgba(26, 28, 27, 0.18);
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.attachment-grid button {
  min-height: 92px;
  display: grid;
  place-items: center;
  gap: 8px;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--surface-low);
  font-size: 16px;
  font-weight: 700;
}

.attachment-grid button span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
}

.attachment-grid .ui-icon {
  width: 30px;
  height: 30px;
  stroke-width: 2;
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: 260px;
  }

  .conversation-panel {
    padding: 18px 10px;
  }

  .mode-tabs button {
    font-size: 12px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    height: 100dvh;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 58px;
  }

  .conversation-panel,
  .chat-main {
    grid-row: 1;
    grid-column: 1;
    height: 100%;
    min-height: 0;
  }

  .conversation-panel {
    overflow: hidden;
  }

  .chat-main {
    display: none;
  }

  .app-shell.mobile-chat .conversation-panel {
    display: none;
  }

  .app-shell.mobile-chat .chat-main {
    display: grid;
  }

  .app-shell.sidebar-hidden .chat-main {
    display: grid;
  }

  .chat-header {
    min-height: 56px;
    padding: 0 14px;
  }

  .messages {
    padding: 18px 14px;
  }

  .empty-state {
    margin-top: 42px;
  }

  .composer {
    padding: 10px 12px;
  }

  .chat-main.empty-mode .composer {
    padding-bottom: 112px;
  }

  .composer-card {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .thinking-logo {
    width: calc(100% - 24px);
    top: -28px;
    bottom: auto;
    padding-right: 16px;
  }

  .thinking-logo img {
    width: 58px;
    height: 38px;
  }

  .mode-chip,
  .round-button {
    display: none;
  }

  .quick-actions {
    gap: 8px;
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-row: 2;
    grid-column: 1;
    background: var(--bg);
    border-top: 1px solid var(--line-soft);
  }

  .mobile-tabs button {
    border: 0;
    background: transparent;
    color: var(--muted);
  }

  .mobile-tabs button.active {
    color: var(--primary);
    font-weight: 800;
  }

  .modal-layer {
    align-items: start;
    padding: 10px;
  }

  .modal-card {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    overflow: auto;
    border-radius: 18px;
  }

  .project-modal,
  .profile-modal,
  .settings-modal {
    padding: 20px;
  }

  .project-picker {
    width: 100%;
  }

  .project-icon-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .profile-avatar.large {
    width: 144px;
    height: 144px;
    font-size: 52px;
  }

  .user-menu {
    left: 8px;
    right: 8px;
    bottom: 66px;
    width: auto;
  }
}

@media (max-width: 760px) {
  body {
    background: #fafff8;
  }

  .app-shell {
    position: relative;
    grid-template-rows: minmax(0, 1fr);
    background:
      radial-gradient(circle at 50% 76%, rgba(176, 231, 181, 0.58), transparent 34%),
      linear-gradient(180deg, #fffdfd 0%, #fffdfd 55%, #daf7df 100%);
  }

  .chat-main,
  .app-shell.mobile-chat .chat-main,
  .app-shell.sidebar-hidden .chat-main {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: transparent;
  }

  .chat-header,
  .mobile-tabs {
    display: none;
  }

  .mobile-chat-top {
    min-height: calc(72px + env(safe-area-inset-top));
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    align-items: center;
    gap: 8px;
    padding: calc(14px + env(safe-area-inset-top)) 14px 8px;
    z-index: 6;
  }

  .mobile-top-button {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    color: #101312;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 10px 26px rgba(38, 55, 42, 0.08);
    backdrop-filter: blur(14px);
  }

  .mobile-top-button .ui-icon {
    width: 24px;
    height: 24px;
    stroke-width: 2.1;
  }

  .compose-new-button .ui-icon {
    stroke-dasharray: 2.4 4;
  }

  .mobile-title-button {
    min-width: 0;
    height: 46px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 7px;
    border: 0;
    border-radius: 999px;
    padding: 0 10px;
    color: #161917;
    background: transparent;
    font-size: 21px;
    font-weight: 600;
    overflow: hidden;
    cursor: default;
  }

  .mobile-title-button img {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    object-fit: contain;
  }

  .mobile-title-button span,
  .mobile-title-button small {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .mobile-title-button small,
  .mobile-title-button .ui-icon {
    display: none;
  }

  .compose-new-button {
    visibility: hidden;
    pointer-events: none;
  }

  .mobile-drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    background: rgba(17, 19, 17, 0.22);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    backdrop-filter: blur(2px);
  }

  .app-shell.mobile-drawer-open .mobile-drawer-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .conversation-panel,
  .app-shell.mobile-chat .conversation-panel {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 45;
    width: min(88vw, 360px);
    height: 100dvh;
    display: flex !important;
    gap: 18px;
    padding: calc(42px + env(safe-area-inset-top)) 18px calc(22px + env(safe-area-inset-bottom));
    border-right: 0;
    border-radius: 0 30px 30px 0;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 22px 0 60px rgba(26, 28, 27, 0.16);
    transform: translateX(-104%);
    transition: transform 0.22s ease;
  }

  .app-shell.mobile-drawer-open .conversation-panel {
    transform: translateX(0);
  }

  .sidebar-brand {
    min-height: 52px;
    padding: 0;
  }

  .brand-logo {
    width: 40px;
    height: 40px;
  }

  .brand-copy strong {
    font-family: "Hanken Grotesk", "Microsoft YaHei", system-ui, sans-serif;
    font-size: 27px;
    font-weight: 700;
  }

  .brand-copy span {
    display: none;
  }

  .collapse-button {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    color: #111;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 12px 26px rgba(26, 28, 27, 0.08);
  }

  .collapse-button .ui-icon {
    display: none;
  }

  .collapse-button::before {
    content: "×";
    font-size: 34px;
    font-weight: 300;
    line-height: 1;
  }

  .side-menu {
    gap: 8px;
  }

  .side-menu-item {
    min-height: 52px;
    gap: 16px;
    border-radius: 999px;
    padding: 0 20px;
    color: #111;
    font-size: 19px;
    font-weight: 700;
  }

  .side-menu-item .ui-icon {
    width: 28px;
    height: 28px;
    stroke-width: 2.05;
  }

  .side-menu-item.active,
  .side-menu-item:hover {
    background: rgba(239, 238, 236, 0.92);
  }

  .mode-tabs {
    display: none;
  }

  .sidebar-title {
    padding-top: 18px;
    font-size: 16px;
  }

  .chat-list {
    flex: 1 1 auto;
    padding-right: 4px;
  }

  .chat-row {
    min-height: 46px;
  }

  .chat-card {
    min-height: 46px;
    padding-left: 18px;
  }

  .chat-card strong {
    font-size: 18px;
  }

  .sidebar-footer {
    min-height: 64px;
    border-radius: 22px;
    padding: 10px;
  }

  .user-dot {
    width: 46px;
    height: 46px;
    border-radius: 999px;
  }

  .user-meta strong {
    font-size: 19px;
  }

  .messages {
    padding: 6px 20px 20px;
  }

  .chat-main.empty-mode .messages {
    padding: 0 20px;
  }

  .empty-state {
    margin: auto auto clamp(52px, 9vh, 92px);
    gap: 14px;
  }

  .empty-logo {
    width: 78px;
    height: 52px;
    display: block;
    object-fit: contain;
    filter: drop-shadow(0 10px 18px rgba(55, 115, 67, 0.16));
  }

  .empty-state h2 {
    font-family: "Hanken Grotesk", "Microsoft YaHei", system-ui, sans-serif;
    font-size: clamp(28px, 7.6vw, 38px);
    font-weight: 700;
    letter-spacing: 0;
  }

  .message {
    width: 100%;
  }

  .message-attachments {
    gap: 7px;
  }

  .pending-attachments {
    width: 100%;
    margin-bottom: 6px;
  }

  .attachment-card {
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
    gap: 8px;
    padding: 7px;
    border-radius: 14px;
  }

  .attachment-preview-image,
  .attachment-preview-video {
    width: 84px;
    height: 58px;
    border-radius: 10px;
  }

  .attachment-file-icon {
    width: 48px;
    height: 42px;
    font-size: 12px;
  }

  .attachment-info strong {
    font-size: 13px;
  }

  .attachment-download {
    padding: 0 8px;
  }

  .composer {
    padding: 0 14px calc(16px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(218, 247, 223, 0.98) 0%, rgba(218, 247, 223, 0.84) 58%, rgba(218, 247, 223, 0));
  }

  .chat-main.empty-mode .composer {
    padding-top: 0;
    padding-bottom: calc(38px + env(safe-area-inset-bottom));
    background: transparent;
  }

  .composer-card {
    width: 100%;
    min-height: 62px;
    grid-template-columns: 42px minmax(0, 1fr) 40px 44px;
    gap: 6px;
    margin-bottom: 0;
    padding: 7px 8px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 18px 44px rgba(53, 92, 60, 0.16);
    backdrop-filter: blur(18px);
  }

  .composer-card:focus-within {
    box-shadow: 0 18px 44px rgba(53, 92, 60, 0.2);
  }

  .composer-card textarea {
    min-height: 38px;
    max-height: 104px;
    padding: 7px 5px;
    color: #222;
    font-size: 18px;
    line-height: 24px;
  }

  .composer-card textarea::placeholder {
    color: rgba(34, 34, 34, 0.42);
  }

  .mode-chip {
    display: none;
  }

  .composer-card .round-button {
    width: 40px;
    height: 40px;
    display: grid;
    border-radius: 999px;
    color: #151716;
    background: transparent;
  }

  .composer-card button:focus-visible {
    outline: 2px solid rgba(56, 178, 96, 0.34);
    outline-offset: 2px;
  }

  .mic-button.is-listening {
    color: #0c5c2f;
    background: rgba(43, 178, 91, 0.16);
  }

  #stopBtn {
    min-height: 36px;
    padding: 0 6px;
    color: #333;
    font-size: 13px;
  }

  #stopBtn:not(.hidden) + .mic-button {
    display: none;
  }

  .send-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    background: #050706;
  }

  .send-button .ui-icon {
    width: 21px;
    height: 21px;
  }

  .quick-actions {
    display: none;
  }

  .thinking-logo {
    width: 100%;
    top: -48px;
    padding-right: 66px;
  }

  .thinking-logo img {
    width: 64px;
    height: 42px;
  }

  .attachment-sheet {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: calc(90px + env(safe-area-inset-bottom));
    z-index: 8;
    width: auto;
    margin: 0;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 26px 60px rgba(53, 92, 60, 0.2);
    backdrop-filter: blur(22px);
  }

  .attachment-grid {
    gap: 12px;
  }

  .attachment-grid button {
    min-height: 90px;
    border-radius: 22px;
    background: rgba(239, 242, 239, 0.78);
    font-size: 16px;
  }

  .modal-layer {
    z-index: 70;
  }

  .user-menu {
    z-index: 80;
    bottom: calc(20px + env(safe-area-inset-bottom));
  }
}
