:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #ffffff;
  --surface-hover: #efefef;
  --ink: #0d0d0d;
  --muted: #676767;
  --ink-soft: #676767; /* alias，chat 相关样式沿用 */
  --faint: #9b9b9b;
  --line: #e5e5e5;
  --line-strong: #d6d6d6;
  --surface-active: #ececec;
  --rail-bg: #ffffff;
  --accent: #0f7f54;
  --accent-soft: #e6f4ee;
  --danger: #b42318;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.1);
  --z-history: 360;
  --z-floating-control: 120;
  --z-dropdown: 230;
  --z-session-modal: 900;
  --z-lightbox: 1000;
  --z-toast: 3000;
  --z-auth: 4000;
  --rail: 58px;
  --composer: 1088px;
  --composer-dock-height: 190px;
  --composer-dock-offset: 210px;
  font-family: "Aptos", "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  color: var(--ink);
  outline: none;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(15, 127, 84, 0.1);
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus:not(:focus-visible) {
  outline: none;
}

.is-hidden {
  display: none !important;
}

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

.rail {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 14px 9px;
  border-right: 1px solid var(--line);
  background: var(--rail-bg);
}

.rail-logo,
.rail-btn,
.rail-account,
.icon-btn,
.mobile-menu {
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ink);
}

.rail-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.rail-logo .logo-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 9px;
  border: 0;
  background: transparent;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
}

.rail-logo .logo-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.rail-actions {
  display: grid;
  gap: 10px;
}

.rail-btn,
.rail-account,
.icon-btn,
.mobile-menu {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  transition: background 0.16s ease, transform 0.16s ease;
}

.rail-btn:hover,
.rail-account:hover,
.icon-btn:hover,
.mobile-menu:hover {
  background: var(--surface-hover);
}

.rail-account {
  margin-top: auto;
}

.rail-account span,
.avatar-small,
.assistant-mark {
  display: grid;
  place-items: center;
  background: var(--surface-hover);
  color: var(--ink);
  font-weight: 850;
}

.rail-account span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.history-panel {
  position: fixed;
  inset: 0 auto 0 var(--rail);
  z-index: var(--z-history);
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
  transform: translateX(calc(-100% - var(--rail)));
  transition: transform 0.22s ease;
  box-shadow: 22px 0 54px rgba(0, 0, 0, 0.12);
}

.history-panel.is-open {
  transform: translateX(0);
}

.history-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-history) - 1);
  background: rgba(0, 0, 0, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.history-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.history-head,
.topbar,
.brand-switch,
.top-actions,
.prompt-row,
.settings-row,
.setting-control,
.message-meta,
.image-actions,
.history-foot,
.user-row,
.balance-card,
.new-chat-wide,
.tool-pill,
.style-drawer,
.auth-badges {
  display: flex;
  align-items: center;
}

.history-head {
  justify-content: space-between;
  min-height: 38px;
}

.history-head strong {
  font-size: 15px;
}

.new-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.new-chat-wide {
  flex: 1;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
  font-size: 13px;
}

.new-chat-wide i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.new-chat-wide:hover {
  background: var(--surface-hover);
}

.sidebar-api-docs-btn {
  width: 100%;
  min-height: 34px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 750;
  font-size: 12px;
}

.sidebar-api-docs-btn i {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.sidebar-api-docs-btn:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.history-tools {
  display: grid;
  gap: 8px;
}

.history-search {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
}

.history-search i {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.history-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  box-shadow: none;
  background: transparent;
  font-size: 13px;
}

.history-filters,
.history-pack-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-filter,
.history-mini-btn {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.history-filter.is-active,
.history-mini-btn:hover {
  border-color: rgba(15, 127, 84, 0.28);
  background: var(--accent-soft);
  color: var(--accent);
}

.history-mini-btn i {
  width: 13px;
  height: 13px;
}

.conversation-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.conversation-item {
  width: 100%;
  min-height: 42px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 8px 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  overflow: visible;
}

.conversation-item:hover,
.conversation-item.is-active {
  background: var(--surface-active);
}

.conversation-open {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 3px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.conversation-open span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 760;
}

.conversation-open span i {
  width: 12px;
  height: 12px;
  color: var(--accent);
  flex: 0 0 auto;
}

.conversation-open small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.conversation-actions {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  width: 116px;
  min-width: 116px;
  padding: 2px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transform: translateX(4px) scale(0.96);
  transform-origin: center right;
  transition: opacity 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
  z-index: 2;
}

.conversation-mini,
.conversation-delete {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  opacity: 0.76;
  transition: opacity 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.conversation-mini i,
.conversation-delete i {
  width: 14px;
  height: 14px;
}

.conversation-item:hover .conversation-actions,
.conversation-item.is-active .conversation-actions,
.conversation-item:focus-within .conversation-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.conversation-mini:hover,
.conversation-delete:hover {
  background: var(--surface);
  color: var(--ink);
  opacity: 1;
}

.conversation-delete:hover {
  color: var(--danger);
}

.conversation-mini[data-tooltip],
.conversation-delete[data-tooltip] {
  position: relative;
}

.conversation-mini[data-tooltip]::after,
.conversation-delete[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: calc(100% + 7px);
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 4;
}

.conversation-mini[data-tooltip]:hover::after,
.conversation-delete[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.conversation-empty {
  padding: 16px 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.history-foot {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.balance-card,
.user-row {
  width: 100%;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.balance-card:hover,
.user-row:hover {
  background: var(--surface-active);
}

.balance-card small,
.user-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.balance-card strong,
.user-row strong {
  display: block;
  margin-top: 2px;
}

.avatar-small {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.user-row {
  justify-content: flex-start;
}

.balance-card > span,
.user-row > span:not(.avatar-small) {
  flex: 1 1 auto;
  min-width: 0;
}

.user-row strong,
.user-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr) auto;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
}

.brand-switch {
  min-width: 0;
  gap: 8px;
}

.brand-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 19px;
  font-weight: 760;
}

.top-actions {
  gap: 10px;
  margin-left: auto;
}

.plain-btn,
.outline-btn,
.solid-btn,
.primary-btn {
  min-height: 40px;
  padding: 0 17px;
  border-radius: 999px;
  font-weight: 750;
  white-space: nowrap;
}

.plain-btn {
  background: var(--ink);
  color: #fff;
}

.outline-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.solid-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
}

.plain-btn:hover {
  background: #262626;
}

.outline-btn:hover {
  background: var(--surface-hover);
}

.solid-btn:hover {
  filter: brightness(1.05);
}

.api-docs-top-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.api-docs-top-btn i {
  width: 16px;
  height: 16px;
}

.api-docs-top-btn span {
  white-space: nowrap;
}

.developer-docs-btn {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: calc(18px + env(safe-area-inset-right));
  z-index: calc(var(--z-dropdown) + 90);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(13, 13, 13, 0.11);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 14px;
  font-weight: 820;
  letter-spacing: 0;
  box-shadow: 0 14px 38px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.developer-docs-btn i {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.developer-docs-btn:hover {
  background: #fff;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.16);
  transform: translateY(-1px);
}

.developer-docs-btn:active {
  transform: translateY(0);
}

.app-shell.is-guest .developer-docs-btn {
  display: none;
}

.balance-pill {
  position: fixed;
  right: 18px;
  bottom: calc(var(--composer-dock-offset, var(--composer-dock-height, 210px)) + 18px + env(safe-area-inset-bottom));
  z-index: calc(var(--z-dropdown) + 80);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #0a6542;
  font-weight: 820;
  box-shadow: 0 12px 30px rgba(10, 101, 66, 0.14);
  white-space: nowrap;
}

.balance-pill[hidden] {
  display: none;
}

.mobile-menu {
  display: none;
}

.icon-btn.mobile-account {
  display: none;
}

.app-shell:not(.is-guest) .workspace {
  grid-template-rows: minmax(0, 1fr) auto;
}

.app-shell:not(.is-guest) .workspace > .topbar {
  display: none;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 36px max(22px, calc((100vw - var(--rail) - var(--composer)) / 2)) 28px;
}

.empty-state {
  min-height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding-bottom: 12vh;
  text-align: center;
}

.empty-state h1 {
  margin: 0;
  font-size: clamp(25px, 3vw, 32px);
  font-weight: 520;
  letter-spacing: 0;
}

.empty-state p {
  max-width: 590px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.suggestion-grid {
  width: min(680px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.suggestion-card {
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.suggestion-card:hover {
  background: var(--surface-hover);
}

.message {
  width: min(var(--composer), 100%);
  margin: 0 auto 24px;
}

.message.user {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.message.assistant {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
}

.assistant-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
}

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

.message.user .message-body {
  max-width: min(690px, 100%);
  padding: 11px 15px;
  border-radius: 18px;
  background: var(--surface-soft);
}

.image-user-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.message.user:hover .image-user-actions,
.image-user-actions:focus-within {
  opacity: 1;
}

@media (hover: none) {
  .image-user-actions,
  .chat-user-actions {
    opacity: 1;
  }
}

.message-body p {
  margin: 0;
  color: var(--ink);
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-meta {
  gap: 8px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.message-meta strong {
  color: var(--ink);
  font-size: 13px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), min(var(--image-card-max, 560px), 100%)));
  justify-content: start;
  align-items: start;
  gap: 12px;
  margin-top: 14px;
}

.generation-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 2px 0 8px;
}

.generation-settings span:not(.generation-status-dot) {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.generation-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #9aa3ad;
  box-shadow: 0 0 0 4px rgba(154, 163, 173, 0.13);
}

.generation-status-dot[data-status="running"],
.generation-status-dot[data-status="queued"],
.generation-status-dot[data-status="starting"],
.generation-status-dot[data-status="recovering"],
.generation-status-dot[data-status="reconnecting"] {
  background: #0f7f54;
  box-shadow: 0 0 0 4px rgba(15, 127, 84, 0.13);
}

.generation-status-dot[data-status="failed"] {
  background: #d64545;
  box-shadow: 0 0 0 4px rgba(214, 69, 69, 0.13);
}

.image-card {
  position: relative;
  overflow: hidden;
  width: min(var(--image-card-max, 560px), 100%);
  justify-self: start;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.06);
}

.image-card img,
.image-skeleton {
  display: block;
  width: 100%;
  aspect-ratio: var(--ratio, 1 / 1);
  object-fit: cover;
  background: var(--surface-soft);
}

.image-skeleton {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(15, 127, 84, 0.08), transparent 34%),
    linear-gradient(135deg, rgba(245, 247, 250, 0.95), rgba(255, 255, 255, 0.98));
}

.image-missing {
  display: grid;
  place-items: center;
  gap: 8px;
  width: 100%;
  aspect-ratio: var(--ratio, 1 / 1);
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.image-missing svg {
  width: 32px;
  height: 32px;
  stroke-width: 1.5;
  opacity: 0.6;
}

.image-missing p {
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
}

.image-broken {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 24px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
}

.image-broken svg {
  width: 32px;
  height: 32px;
  stroke-width: 1.5;
  opacity: 0.6;
}

.image-broken p {
  margin: 0;
}

.image-card.is-broken img {
  display: none;
}

.image-card.is-broken .image-broken {
  display: flex;
}

.image-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  animation: shimmer 1.35s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.image-caption {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.image-actions {
  position: absolute;
  right: 8px;
  top: 8px;
  left: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.image-card:hover .image-actions,
.image-card:focus-within .image-actions {
  opacity: 1;
  transform: translateY(0);
}

@media (hover: none) {
  .image-actions {
    opacity: 1;
    transform: translateY(0);
  }
}

.image-actions .icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.composer-dock {
  position: relative;
  z-index: var(--z-floating-control);
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 0 22px 14px;
  background: #fff;
}

.composer-dock.is-dragging-files .composer {
  border-color: rgba(15, 127, 84, 0.42);
  box-shadow: 0 18px 56px rgba(15, 127, 84, 0.18);
}

.style-drawer {
  width: min(var(--composer), 100%);
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  display: none;
}

.style-drawer.is-open {
  display: flex;
}

.style-chip,
.tool-pill {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 740;
}

.style-chip:hover,
.tool-pill:hover {
  background: var(--surface-hover);
}

.style-chip.is-active {
  border-color: rgba(15, 127, 84, 0.22);
  background: var(--accent-soft);
  color: #0a6542;
}

.composer {
  width: min(var(--composer), 100%);
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.09);
  position: relative;
  overflow: visible;
}

.prompt-row {
  gap: 8px;
  padding: 10px 12px;
}

.composer-feature-picker {
  position: relative;
  flex: 0 0 auto;
}

.composer-feature-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: var(--z-dropdown);
  width: min(268px, calc(100vw - 36px));
  display: grid;
  gap: 3px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(18px);
  transform-origin: left bottom;
  animation: featureMenuIn 0.16s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.composer-feature-menu[hidden] {
  display: none !important;
}

.feature-option {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.feature-option:hover,
.feature-option.is-active {
  background: #f4f7f5;
  transform: translateY(-1px);
}

.feature-option.is-active {
  color: #0a6542;
}

@keyframes featureMenuIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.feature-option i,
.feature-option svg {
  width: 17px;
  height: 17px;
}

.feature-option span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.feature-option strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.2;
}

.feature-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px 0;
}

.attachment-row.is-hidden {
  display: none !important;
}

.attachment-chip {
  position: relative;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--surface-soft);
  animation: attachmentChipIn 0.18s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.attachment-chip:hover {
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.attachment-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attachment-chip.is-file {
  width: 190px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 28px 8px 9px;
}

.attachment-chip.is-file .attachment-chip-remove {
  top: 4px;
  right: 4px;
}

.attachment-file-icon,
.chat-file-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.attachment-file-icon svg,
.chat-file-icon svg {
  width: 17px;
  height: 17px;
}

.attachment-file-text,
.chat-file-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.attachment-file-text strong,
.chat-file-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.2;
}

.attachment-file-text small,
.chat-file-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.2;
  color: var(--muted);
}

.attachment-chip-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  transition: transform 0.16s ease;
}

.attachment-chip-remove:hover {
  transform: scale(1.08);
}

.attachment-chip-remove svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.6;
}

@keyframes attachmentChipIn {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.message-attachments img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.prompt-row textarea {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  max-height: 150px;
  resize: none;
  border: 0;
  padding: 9px 4px;
  background: transparent;
  line-height: 1.5;
  box-shadow: none;
}

.prompt-row textarea:focus {
  box-shadow: none;
}

.mic-btn {
  color: var(--muted);
  position: relative;
  transition: color 0.16s ease, background 0.16s ease;
}

.mic-btn.is-recording {
  color: #b42318;
  background: rgba(180, 35, 24, 0.08);
}

.mic-btn.is-recording::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1.5px solid rgba(180, 35, 24, 0.6);
  animation: micPulse 1.4s ease-out infinite;
}

@keyframes micPulse {
  0% { transform: scale(0.85); opacity: 0.85; }
  100% { transform: scale(1.45); opacity: 0; }
}

.spin,
svg.spin,
.spin svg {
  animation: lucideSpin 0.85s linear infinite;
  transform-origin: center;
}

@keyframes lucideSpin {
  to { transform: rotate(360deg); }
}

.send-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.send-btn:hover:not(:disabled) {
  background: #2a2a2a;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.send-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}

.send-btn:disabled {
  box-shadow: none;
  opacity: 0.56;
}

.settings-row {
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 12px;
}

.settings-row[hidden] {
  display: none !important;
}

.settings-row label,
.setting-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.settings-row select {
  min-height: 32px;
  max-width: 190px;
  border-radius: 999px;
  padding: 0 28px 0 10px;
  background: var(--surface-soft);
}

.model-control,
.choice-control,
.image-key-picker {
  position: relative;
  z-index: calc(var(--z-floating-control) + 10);
}

.model-control:focus-within,
.model-control:has(.model-menu.is-open),
.choice-control.is-open,
.image-key-picker:focus-within {
  z-index: calc(var(--z-dropdown) - 20);
}

.image-key-btn {
  min-height: 34px;
  max-width: 238px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.image-key-btn:hover,
.image-key-btn[aria-expanded="true"] {
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.image-key-btn strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.image-key-btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: var(--muted);
}

.image-key-btn[aria-expanded="true"] svg:last-child {
  transform: rotate(180deg);
}

.image-key-menu {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  z-index: var(--z-dropdown);
  min-width: min(320px, calc(100vw - 36px));
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.14);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

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

.native-model-select,
.native-choice-select {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.model-menu-btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 230px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.model-menu-btn.is-fixed {
  border-color: rgba(15, 127, 84, 0.18);
  background: var(--accent-soft);
  cursor: default;
}

.model-menu-btn:hover,
.model-menu-btn.is-open {
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.model-menu-btn.is-fixed:hover {
  border-color: rgba(15, 127, 84, 0.22);
  background: var(--accent-soft);
  box-shadow: none;
}

.model-menu-btn strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.model-menu-btn small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.model-menu-btn svg {
  flex: 0 0 auto;
  transition: transform 0.16s ease;
}

.model-menu-btn.is-fixed svg,
.model-menu-btn.is-fixed small {
  color: #0a6542;
}

.model-menu-btn.is-open svg {
  transform: rotate(180deg);
}

.choice-btn {
  min-height: 34px;
  min-width: 88px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.choice-btn strong {
  font-size: 13px;
  white-space: nowrap;
}

.choice-btn svg {
  color: var(--muted);
  transition: transform 0.16s ease;
}

.choice-btn:hover,
.choice-btn.is-open {
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.choice-btn.is-open svg {
  transform: rotate(180deg);
}

.choice-menu {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  z-index: var(--z-dropdown);
  min-width: max(100%, 148px);
  max-height: 56vh;
  overflow-y: auto;
  display: none;
  transform: translateX(-50%) translateY(4px);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(18px);
}

.choice-menu.is-open {
  display: grid;
  gap: 3px;
  animation: choiceMenuIn 0.14s ease forwards;
}

@keyframes choiceMenuIn {
  to {
    transform: translateX(-50%) translateY(0);
  }
}

.choice-option {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.choice-option:hover,
.choice-option.is-selected {
  background: var(--surface-soft);
}

.choice-option.is-selected {
  color: #0a6542;
}

.choice-option strong {
  font-size: 13px;
  line-height: 1.2;
}

.choice-option small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
}

.model-menu {
  position: absolute;
  left: 40px;
  bottom: calc(100% + 10px);
  z-index: var(--z-dropdown);
  width: min(338px, calc(100vw - 40px));
  display: none;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(18px);
}

.model-menu.is-open {
  display: grid;
  gap: 4px;
}

.model-option {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 11px;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.model-option:hover,
.model-option.is-selected {
  background: var(--surface-soft);
}

.model-option-main,
.model-option-side {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.model-option-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.model-option-main small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.model-option-side {
  justify-items: end;
}

.model-option-side em {
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #0a6542;
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}

.model-option-side small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  white-space: nowrap;
}

.tool-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cost-preview {
  margin-left: auto;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

@media (min-width: 861px) {
  .settings-row {
    display: grid;
    grid-template-columns: minmax(248px, 320px) repeat(3, max-content) max-content max-content;
    align-items: center;
    justify-content: start;
    gap: 8px;
    flex-wrap: nowrap;
  }

  .settings-row .setting-control,
  .settings-row .tool-pill {
    flex: none;
    min-width: 0;
  }

  .settings-row .setting-control {
    gap: 4px;
  }

  .settings-row .cost-preview {
    display: none;
  }

  .image-key-btn {
    width: 136px;
    max-width: 136px;
    gap: 5px;
    padding: 0 8px 0 10px;
  }

  .model-control {
    min-width: 0;
  }

  .model-menu-btn {
    width: 248px;
    max-width: 248px;
    min-width: 0;
    justify-content: space-between;
    gap: 6px;
    padding: 0 9px 0 11px;
  }

  .model-menu-btn small {
    display: none;
  }

  .choice-btn {
    min-width: 78px;
    gap: 5px;
    padding: 0 8px 0 10px;
  }

  .tool-pill {
    min-width: 70px;
    padding: 0 10px;
    white-space: nowrap;
  }
}

.dock-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: var(--z-auth);
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(18px);
}

.auth-card {
  position: relative;
  width: min(430px, 100%);
  display: grid;
  gap: 15px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-back {
  position: absolute;
  left: 12px;
  top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  transition: background 0.16s ease, color 0.16s ease;
}

.auth-back:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.auth-back svg {
  width: 14px;
  height: 14px;
}

.auth-2fa .auth-mark {
  background: var(--accent);
  color: #fff;
}

.auth-2fa .auth-mark svg {
  width: 26px;
  height: 26px;
  color: #fff;
}

#twoFactorCode {
  letter-spacing: 0.32em;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 18px;
  text-align: center;
}

.auth-close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
}

.auth-close:hover {
  background: var(--surface-hover);
}

.auth-turnstile {
  min-height: 65px;
  display: flex;
  align-items: center;
}

.auth-error {
  margin: -4px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(180, 35, 24, 0.22);
  border-radius: 10px;
  background: rgba(255, 244, 242, 0.95);
  color: #b42318;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.5;
}

.auth-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

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

.auth-copy,
.fine-print {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.fine-print {
  font-size: 12px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.field input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--surface);
}

.endpoint-details {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.endpoint-details summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.compact-field {
  margin-top: 12px;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 50px;
  background: var(--ink);
  color: #fff;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: var(--z-toast);
  max-width: min(430px, calc(100vw - 32px));
  padding: 11px 14px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 14px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.prompt-assist-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-toast) - 1);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 18, 22, 0.28);
  backdrop-filter: blur(12px);
}

.prompt-assist-modal[hidden] {
  display: none !important;
}

.prompt-assist-card {
  width: min(720px, calc(100vw - 32px));
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.2);
}

.prompt-assist-head,
.prompt-assist-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.prompt-assist-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
}

.prompt-assist-head p,
.prompt-assist-field span {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.prompt-assist-field textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--surface-soft);
  color: var(--ink);
  font: inherit;
  line-height: 1.65;
}

.prompt-assist-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.15;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .image-skeleton::after {
    animation: none;
  }
}

@media (max-width: 860px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    display: none;
  }

  .history-panel {
    inset: 0 auto 0 0;
    width: min(286px, calc(100vw - 52px));
    transform: translateX(-105%);
  }

  .conversation-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0) scale(1);
  }

  .workspace {
    width: 100vw;
    min-width: 0;
    grid-template-rows: calc(54px + env(safe-area-inset-top)) minmax(0, 1fr) auto;
  }

  .app-shell:not(.is-guest) .workspace {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .app-shell:not(.is-guest) .workspace > .topbar {
    display: flex;
    position: fixed;
    inset: calc(10px + env(safe-area-inset-top)) auto auto 10px;
    width: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    z-index: calc(var(--z-dropdown) + 30);
  }

  .app-shell:not(.is-guest) .workspace > .topbar .brand-name,
  .app-shell:not(.is-guest) .workspace > .topbar .top-actions {
    display: none;
  }

  .app-shell:not(.is-guest) .workspace > .topbar .mobile-menu {
    display: grid;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
  }

  .topbar {
    min-width: 0;
    gap: 8px;
    padding: 0 10px;
  }

  .mobile-menu,
  .icon-btn.mobile-account {
    display: grid;
  }

  .brand-name {
    min-width: 0;
    max-width: 44vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 17px;
    padding: 0 6px;
  }

  .brand-name::before {
    content: "";
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    border-radius: 7px;
    background: url("./assets/luchikey-logo-20260605T110551Z.png?v=20260605T110551Z-luchikey-logo3") center / contain no-repeat;
    box-shadow: 0 5px 14px rgba(15, 23, 42, 0.18);
  }

  .top-actions {
    min-width: 0;
    gap: 7px;
  }

  .top-actions .plain-btn,
  .top-actions .outline-btn {
    min-height: 36px;
    padding: 0 13px;
  }

  #userActions #logoutTopBtn {
    display: none;
  }

  .outline-btn {
    display: none;
  }

  .top-actions .api-docs-top-btn {
    display: inline-flex;
    width: 38px;
    min-width: 38px;
    justify-content: center;
    padding: 0;
  }

  .top-actions .api-docs-top-btn span {
    display: none;
  }

  .messages {
    padding: 18px 12px 14px;
    overflow-x: hidden;
  }

  .empty-state {
    align-content: center;
    gap: 14px;
    padding-bottom: min(4vh, 28px);
  }

  .empty-state p {
    max-width: calc(100vw - 48px);
    font-size: 14px;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .suggestion-grid {
    grid-template-columns: 1fr;
    width: min(680px, calc(100vw - 32px));
    gap: 8px;
  }

  .suggestion-card {
    min-height: 50px;
    padding: 10px 13px;
    font-size: 14px;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .message.assistant {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 9px;
  }

  .image-grid {
    grid-template-columns: minmax(0, min(var(--image-card-max, 560px), 100%));
  }

  .assistant-mark {
    width: 28px;
    height: 28px;
  }

  .composer-dock {
    gap: 6px;
    padding: 0 10px calc(10px + env(safe-area-inset-bottom));
    overflow-x: hidden;
  }

  .style-drawer {
    width: calc(100vw - 20px);
    display: none;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    padding: 0 2px 2px;
    scrollbar-width: none;
  }

  .style-drawer::-webkit-scrollbar {
    display: none;
  }

  .style-drawer.is-open {
    display: flex;
  }

  .style-chip {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 12px;
  }

  .composer {
    width: min(var(--composer), calc(100vw - 20px));
    border-radius: 24px;
  }

  .settings-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 7px;
  }

  .settings-row label,
  .setting-control {
    min-width: 0;
  }

  .settings-row select {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .settings-row .native-choice-select {
    inline-size: 1px;
    width: 1px;
    min-width: 1px;
  }

  .choice-btn {
    flex: 1 1 auto;
    width: 100%;
  }

  .image-key-btn {
    width: 100%;
    max-width: none;
    justify-content: space-between;
  }

  .choice-menu {
    min-width: min(176px, calc(100vw - 36px));
  }

  .tool-pill,
  .cost-preview {
    flex: 1 1 auto;
    justify-content: center;
  }

  .cost-preview {
    display: none;
  }

  .chat-toolbar {
    width: calc(100vw - 20px);
    flex-wrap: nowrap;
    gap: 7px;
    padding: 0 2px 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }

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

  .chat-key-picker,
  .chat-model-picker,
  .chat-mode-picker,
  .chat-reasoning-picker,
  .chat-tool-toggle {
    flex: 0 0 auto;
  }

  .chat-key-btn,
  .chat-model-btn,
  .chat-mode-btn,
  .chat-reasoning-btn,
  .chat-tool-toggle {
    min-height: 34px;
    padding: 6px 11px;
  }

  .chat-key-btn {
    max-width: 176px;
  }

  .chat-message {
    gap: 8px;
    margin-bottom: 14px;
  }

  .chat-message .chat-bubble {
    padding: 10px 12px;
    border-radius: 14px;
  }

  .chat-message.chat-assistant .chat-bubble {
    flex: 1 1 auto;
    max-width: calc(100% - 38px);
  }

  .chat-message.chat-user .chat-bubble {
    max-width: 92%;
  }

  .chat-text,
  .chat-markdown p,
  .chat-markdown li {
    font-size: 14px;
    line-height: 1.65;
  }

  .chat-markdown table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }

  .chat-markdown .code-block {
    max-width: 100%;
  }

  .chat-markdown pre,
  .chat-markdown pre[class*="language-"] {
    font-size: 12px;
    padding: 10px 12px;
  }

  .canvas-panel {
    inset: auto 0 0 0;
    width: 100vw;
    height: min(72dvh, 620px);
    border-left: 0;
    border-top: 1px solid var(--line);
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.14);
  }

  .asset-library-modal,
  .project-memory-modal,
  .task-modal {
    align-items: flex-end;
    padding: 12px;
  }

  .asset-library-card,
  .project-memory-card,
  .task-card {
    max-height: min(86dvh, 720px);
    border-radius: 14px;
  }

  .task-grid {
    grid-template-columns: 1fr;
  }
}

/* Codex 2026-06-04: stable history actions and tighter image composer. */
body[data-session-type="image"] {
  --composer: min(var(--image-column), 980px);
}

.conversation-item {
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 6px;
}

.conversation-actions {
  width: 110px;
  min-width: 110px;
  gap: 3px;
  justify-content: flex-end;
  border-color: rgba(15, 23, 42, 0.06);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: none;
  opacity: 0.68;
  pointer-events: auto;
  transform: none;
}

.conversation-item:hover .conversation-actions,
.conversation-item.is-active .conversation-actions,
.conversation-item:focus-within .conversation-actions {
  opacity: 1;
  transform: none;
}

.conversation-mini,
.conversation-delete {
  width: 25px;
  height: 25px;
  flex-basis: 25px;
}

body[data-session-type="image"] .composer-dock {
  padding: 0 18px calc(10px + env(safe-area-inset-bottom));
  gap: 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 16px);
}

body[data-session-type="image"] .composer {
  width: min(var(--composer), calc(100vw - 36px));
  border-radius: 24px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.08);
}

body[data-session-type="image"] .prompt-row {
  padding: 9px 11px;
}

body[data-session-type="image"] .settings-row {
  gap: 7px;
  padding: 0 11px 10px;
}

body[data-session-type="image"] .settings-row label,
body[data-session-type="image"] .setting-control {
  min-height: 30px;
}

body[data-session-type="image"] .model-menu-btn,
body[data-session-type="image"] .choice-btn,
body[data-session-type="image"] .tool-pill,
body[data-session-type="image"] .image-key-btn {
  min-height: 31px;
}

body[data-session-type="image"] .dock-note {
  margin-top: 0;
  font-size: 11.5px;
}

@media (max-width: 860px) {
  body[data-session-type="image"] {
    --composer: calc(100vw - 20px);
    --image-column: calc(100vw - 20px);
  }

  .conversation-item {
    grid-template-columns: minmax(0, 1fr) 104px;
  }

  .conversation-actions {
    width: 104px;
    min-width: 104px;
  }

  body[data-session-type="image"] .composer-dock {
    padding-left: 10px;
    padding-right: 10px;
  }

  body[data-session-type="image"] .composer {
    width: min(var(--composer), calc(100vw - 20px));
  }
}

body[data-session-type="chat"] .chat-mode-btn {
  min-height: 32px;
  padding: 6px 11px;
  border-color: #e3e3e3;
  background: #fff;
  color: #3f3f3f;
  font-size: 13px;
  font-weight: 500;
}

body[data-session-type="chat"] .chat-mode-btn:hover {
  background: #f7f7f7;
  border-color: #d4d4d4;
}

body[data-session-type="chat"] .chat-mode-btn.is-active {
  border-color: #0d0d0d;
  background: #0d0d0d;
  color: #fff;
}

body[data-session-type="chat"] .chat-mode-btn.is-active i {
  color: #fff;
}

@media (max-width: 520px) {
  .top-actions {
    gap: 6px;
  }

  .brand-name {
    max-width: 40vw;
  }

  .api-docs-top-btn {
    width: 38px;
    min-width: 38px;
    justify-content: center;
    padding: 0;
  }

  .api-docs-top-btn span {
    display: none;
  }

  .plain-btn,
  .outline-btn {
    min-height: 36px;
    padding: 0 12px;
  }

  .balance-pill {
    right: 12px;
    bottom: calc(var(--composer-dock-offset, var(--composer-dock-height, 210px)) + 12px + env(safe-area-inset-bottom));
    max-width: min(124px, calc(100vw - 24px));
    min-height: 36px;
    padding: 0 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .empty-state h1 {
    font-size: 24px;
  }

  .composer {
    border-radius: 22px;
  }

  .prompt-row {
    gap: 6px;
    padding: 9px 10px;
  }

  .settings-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 7px;
    padding: 0 10px 10px;
  }

  .settings-row label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .setting-control {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .model-menu-btn {
    width: 100%;
    max-width: none;
    justify-content: space-between;
  }

  .model-menu-btn small {
    display: none;
  }

  .model-menu,
  .image-key-menu {
    left: 0;
    width: min(338px, calc(100vw - 44px));
    transform: none;
  }

  .chat-key-picker,
  .chat-model-picker {
    max-width: 100%;
  }

  .chat-key-btn,
  .chat-model-btn,
  .chat-mode-btn {
    max-width: calc(100vw - 44px);
  }

  .chat-key-menu,
  .chat-model-menu,
  .chat-mode-menu {
    width: min(338px, calc(100vw - 44px));
  }

  .prompt-row {
    align-items: flex-end;
  }

  .tool-pill,
  .cost-preview {
    width: 100%;
  }

  .auth-card {
    padding: 24px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
  }

  .model-menu,
  .image-key-menu,
  .choice-menu,
  .chat-key-menu,
  .chat-model-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--composer-dock-offset, var(--composer-dock-height, 210px)) + 12px + env(safe-area-inset-bottom));
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: min(42dvh, calc(100dvh - var(--composer-dock-offset, var(--composer-dock-height, 210px)) - 96px));
    overflow-y: auto;
    transform: none;
    z-index: calc(var(--z-dropdown) + 60);
  }

  .choice-menu {
    min-width: 0;
  }
}

@media (min-width: 861px) {
  .app-shell.has-canvas {
    --canvas-space: 448px;
  }

  .app-shell.has-canvas .messages {
    padding-right: max(var(--canvas-space), calc((100vw - var(--rail) - var(--chat-column)) / 2));
  }

  .app-shell.has-canvas .composer-dock {
    width: min(720px, calc(100vw - var(--rail) - var(--canvas-space) - 36px));
    justify-self: start;
    margin-left: max(22px, calc((100vw - var(--rail) - var(--canvas-space) - 720px) / 2));
  }

  .app-shell.has-canvas .balance-pill {
    right: calc(var(--canvas-space) + 18px);
  }
}

@media (max-width: 860px) {
  .canvas-panel {
    position: fixed;
    inset: 72px 8px calc(156px + env(safe-area-inset-bottom)) 8px;
    width: auto;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 18px 54px rgba(15, 23, 42, 0.16);
  }
}

@media (max-width: 380px) {
  .topbar {
    padding-left: 8px;
    padding-right: 8px;
  }

  .brand-switch {
    gap: 4px;
  }

  .brand-name {
    max-width: 38vw;
    font-size: 16px;
  }

  .mobile-menu,
  .icon-btn.mobile-account {
    width: 34px;
    height: 34px;
  }

  .top-actions .plain-btn,
  .top-actions .outline-btn {
    min-height: 34px;
    padding: 0 11px;
    font-size: 13px;
  }

  .empty-state {
    gap: 11px;
  }

  .empty-state h1 {
    font-size: 23px;
  }

  .empty-state p {
    font-size: 13px;
    line-height: 1.6;
  }

  .suggestion-card {
    min-height: 46px;
    padding: 9px 12px;
    font-size: 13px;
  }

  .composer-dock {
    padding-left: 8px;
    padding-right: 8px;
  }

  .composer {
    width: calc(100vw - 16px);
    border-radius: 22px;
  }

  .prompt-row {
    padding: 8px 9px;
  }

  .prompt-row textarea {
    min-height: 36px;
    padding: 8px 2px;
    font-size: 14px;
  }

  .settings-row {
    gap: 6px;
    padding: 0 9px 9px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-row label,
  .setting-control {
    gap: 5px;
    font-size: 11px;
  }

  .image-key-btn,
  .model-menu-btn,
  .choice-btn {
    width: 100%;
    min-width: 0;
    min-height: 32px;
    padding-left: 10px;
    padding-right: 8px;
  }

  .cost-preview {
    display: none;
  }

  .image-key-btn strong,
  .model-menu-btn strong,
  .choice-btn strong {
    font-size: 12px;
  }

  .chat-toolbar {
    width: calc(100vw - 16px);
  }

  .chat-key-btn {
    max-width: 152px;
  }
}

/* ==================== Chat session 样式 ==================== */

/* chat session 下隐藏图像专属控件 */
body[data-session-type="chat"] .style-drawer,
body[data-session-type="chat"] #styleBtn,
body[data-session-type="chat"] .choice-control,
body[data-session-type="chat"] .cost-preview,
body[data-session-type="chat"] .model-control,
body[data-session-type="chat"] #modelMenuBtn,
body[data-session-type="chat"] #modelMenu,
body[data-session-type="chat"] #modelSelect,
body[data-session-type="chat"] #settingsRow,
body[data-session-type="chat"] #uploadBtn {
  display: none !important;
}

/* image session 下隐藏 chat 专属 rail 按钮（避免误点新建生图后再点 chat 入口造成困惑也没用，但保留对称：不隐藏） */
/* 注：保留 newChatChatRailBtn 不隐藏，让用户随时能新建 chat */

/* chat 消息布局 */
.chat-message {
  --chat-message-enter-x: -8px;
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  align-items: flex-start;
}

.chat-message.chat-user {
  --chat-message-enter-x: 8px;
  flex-direction: row-reverse;
}

.chat-message.chat-user .assistant-mark {
  display: none;
}

/* chat 消息气泡 */
.chat-message .chat-bubble {
  max-width: min(680px, 78%);
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--surface-soft);
  word-wrap: break-word;
}

.chat-message.chat-user .chat-bubble {
  background: var(--accent, #2563eb);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message.chat-assistant .chat-bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.chat-message.is-new-message {
  animation: chatMessageIn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.chat-message.is-streaming .chat-bubble {
  border-color: rgba(20, 131, 90, 0.22);
  box-shadow: 0 10px 34px rgba(20, 131, 90, 0.08);
}

@keyframes chatMessageIn {
  from {
    opacity: 0;
    transform: translate3d(var(--chat-message-enter-x), 8px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.chat-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 15px;
}

.chat-message.chat-user .chat-text {
  color: #fff;
}

/* 流式光标动画 */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--ink, #111);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: streamingCursorBlink 1.1s steps(1) infinite;
}

@keyframes streamingCursorBlink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

/* chat 消息 meta 行 */
.chat-message.chat-assistant .message-meta {
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-message.is-streaming .message-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-message.is-streaming .message-meta span::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #14835a;
  box-shadow: 0 0 0 0 rgba(20, 131, 90, 0.32);
  animation: streamingDotPulse 1.25s ease-out infinite;
}

@keyframes streamingDotPulse {
  0% {
    opacity: 0.55;
    box-shadow: 0 0 0 0 rgba(20, 131, 90, 0.28);
  }
  70% {
    opacity: 1;
    box-shadow: 0 0 0 6px rgba(20, 131, 90, 0);
  }
  100% {
    opacity: 0.55;
    box-shadow: 0 0 0 0 rgba(20, 131, 90, 0);
  }
}

.chat-message.chat-assistant .message-meta strong {
  color: var(--ink);
  font-weight: 700;
  font-size: 12px;
}

/* ==================== Chat toolbar（模型选择 + 工具开关） ==================== */

.chat-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  width: min(var(--composer), 100%);
  padding: 4px 0 10px;
  flex-wrap: wrap;
}

.chat-toolbar[hidden] {
  display: none;
}

body[data-session-type="chat"] .composer-dock {
  width: min(var(--composer), calc(100% - 44px));
  justify-self: center;
  padding-right: 0;
  padding-left: 0;
  background: transparent;
}

body[data-session-type="chat"] .chat-toolbar,
body[data-session-type="chat"] .composer,
body[data-session-type="chat"] .dock-note {
  width: 100%;
}

.chat-key-picker,
.chat-model-picker,
.chat-mode-picker,
.chat-reasoning-picker {
  position: relative;
}

.image-key-picker,
.chat-key-picker {
  display: none !important;
}

.chat-key-btn,
.chat-model-btn,
.chat-mode-btn,
.chat-reasoning-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.chat-key-btn {
  max-width: 260px;
}

.chat-key-btn span,
.chat-model-btn span,
.chat-mode-btn span,
.chat-reasoning-btn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-key-btn:hover,
.chat-model-btn:hover,
.chat-mode-btn:hover,
.chat-reasoning-btn:hover {
  background: var(--surface-hover);
  border-color: var(--ink-soft);
}

.chat-reasoning-btn.is-active,
.chat-mode-btn.is-active {
  border-color: rgba(15, 127, 84, 0.24);
  background: var(--accent-soft);
  color: #0a6542;
}

.chat-reasoning-btn.is-active i,
.chat-mode-btn.is-active i {
  color: #0a6542;
}

.chat-key-btn i,
.chat-model-btn i,
.chat-mode-btn i,
.chat-reasoning-btn i {
  width: 14px;
  height: 14px;
  color: var(--ink-soft);
  flex: 0 0 auto;
}

.chat-key-btn[aria-expanded="true"] i:last-child,
.chat-model-btn[aria-expanded="true"] i,
.chat-mode-btn[aria-expanded="true"] i:last-child,
.chat-reasoning-btn[aria-expanded="true"] i:last-child {
  transform: rotate(180deg);
  transition: transform 0.15s;
}

.chat-key-menu,
.chat-model-menu,
.chat-mode-menu,
.chat-reasoning-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
  z-index: var(--z-dropdown);
}

.chat-key-menu {
  min-width: 310px;
}

.chat-key-menu[hidden],
.chat-model-menu[hidden],
.chat-mode-menu[hidden],
.chat-reasoning-menu[hidden] {
  display: none;
}

.chat-model-empty {
  padding: 10px 12px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

.chat-model-empty.is-error {
  color: var(--danger);
}

.chat-key-option,
.chat-model-option,
.chat-mode-option,
.chat-reasoning-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}

.chat-key-option:hover,
.chat-model-option:hover,
.chat-mode-option:hover,
.chat-reasoning-option:hover {
  background: var(--surface-hover);
}

.chat-key-option:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.chat-key-option:disabled:hover {
  background: transparent;
}

.chat-key-option.is-active,
.chat-model-option.is-active,
.chat-mode-option.is-active,
.chat-reasoning-option.is-active {
  background: var(--surface-soft);
}

.chat-key-option strong,
.chat-model-option strong,
.chat-mode-option strong,
.chat-reasoning-option strong {
  font-size: 13px;
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-key-option small,
.chat-model-option small,
.chat-mode-option small,
.chat-reasoning-option small {
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.35;
}

.chat-tool-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chat-tool-toggle i {
  width: 14px;
  height: 14px;
}

.chat-tool-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--ink-soft);
}

.chat-tool-toggle.is-active {
  background: var(--accent, #2563eb);
  color: #fff;
  border-color: transparent;
}

.chat-tool-toggle.is-active i {
  color: #fff;
}

.chat-tool-toggle[data-count]:not([data-count=""])::after {
  content: attr(data-count);
  min-width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 850;
}

/* chat user message 附图 */
.chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.chat-attachments img {
  width: 128px;
  height: 128px;
  object-fit: cover;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
}

.chat-file-attachment {
  width: min(260px, 100%);
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.chat-file-text strong,
.chat-file-text small {
  color: #fff;
}

.chat-file-text small {
  opacity: 0.82;
}

/* 只有图、无文本时不需要下边距 */
.chat-bubble .chat-attachments:last-child {
  margin-bottom: 0;
}

/* ==================== chat assistant markdown 渲染 ==================== */

.chat-markdown > *:first-child { margin-top: 0; }
.chat-markdown > *:last-child { margin-bottom: 0; }

.chat-markdown p {
  margin: 0 0 12px;
  line-height: 1.7;
}

.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3,
.chat-markdown h4 {
  margin: 16px 0 8px;
  font-weight: 800;
  line-height: 1.35;
}
.chat-markdown h1 { font-size: 20px; }
.chat-markdown h2 { font-size: 18px; }
.chat-markdown h3 { font-size: 16px; }
.chat-markdown h4 { font-size: 15px; }

.chat-markdown ul,
.chat-markdown ol {
  margin: 8px 0 12px;
  padding-left: 22px;
}
.chat-markdown ul li,
.chat-markdown ol li {
  margin: 4px 0;
  line-height: 1.7;
}
.chat-markdown li > p { margin: 0; }

.chat-markdown strong {
  font-weight: 800;
}

.chat-markdown em {
  font-style: italic;
}

.chat-markdown a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-markdown a:hover {
  text-decoration-thickness: 2px;
}

/* 行内代码 */
.chat-markdown code {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.06);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
  word-break: break-word;
}

/* 代码块容器（包 pre 用） */
.chat-markdown .code-block {
  margin: 10px 0;
  border-radius: 10px;
  overflow: hidden;
  background: #0d0d0d;
  border: 1px solid #1f1f1f;
}

.chat-markdown .code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #161616;
  color: #a0a0a0;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.chat-markdown .code-block-lang {
  font-weight: 700;
  text-transform: lowercase;
  letter-spacing: 0.5px;
}

.chat-markdown .code-block-copy {
  padding: 3px 10px;
  border: 1px solid #2c2c2c;
  border-radius: 5px;
  background: transparent;
  color: #d6d6d6;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.chat-markdown .code-block-copy:hover {
  background: #1f1f1f;
  border-color: #444;
  color: #fff;
}
.chat-markdown .code-block-copy.is-copied {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 代码块本体 pre（覆盖 Prism tomorrow 默认样式） */
.chat-markdown pre,
.chat-markdown pre[class*="language-"] {
  margin: 0;
  padding: 12px 14px;
  background: #0d0d0d;
  color: #f5f5f5;
  border-radius: 0;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
  text-shadow: none;
}
.chat-markdown .code-block pre,
.chat-markdown .code-block pre[class*="language-"] {
  border-radius: 0;
}
.chat-markdown pre code,
.chat-markdown pre[class*="language-"] code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  text-shadow: none;
}

.chat-markdown blockquote {
  margin: 10px 0;
  padding: 4px 0 4px 12px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
}

.chat-markdown table {
  margin: 10px 0;
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
.chat-markdown th,
.chat-markdown td {
  padding: 6px 10px;
  border: 1px solid var(--line);
  text-align: left;
}
.chat-markdown th {
  background: var(--surface-soft);
  font-weight: 800;
}

.chat-markdown hr {
  margin: 16px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

/* ==================== chat 操作按钮（复制 / 停止） ==================== */

.chat-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: auto; /* 推到右侧 */
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}

.chat-action-btn:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.chat-action-btn i {
  width: 14px;
  height: 14px;
}

.chat-user-actions .chat-action-btn,
.image-user-actions .chat-action-btn {
  margin-left: 0;
  background: var(--surface);
  border: 1px solid var(--line);
}

/* user 消息侧的编辑按钮，hover 显示 */
.chat-user-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  opacity: 0;
  transition: opacity 0.15s;
  align-self: center;
}
.chat-message.chat-user:hover .chat-user-actions,
.chat-user-actions:focus-within {
  opacity: 1;
}

/* send 按钮切换为「停止」态（chat 流式中） */
.send-btn.is-stop {
  background: #a33a24;
  box-shadow: 0 8px 24px rgba(163, 58, 36, 0.2);
}
.send-btn.is-stop:hover {
  background: #8f2a15;
  box-shadow: 0 10px 28px rgba(143, 42, 21, 0.26);
}
.send-btn.is-stop i {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

@media (prefers-reduced-motion: reduce) {
  .composer-feature-menu,
  .attachment-chip,
  .chat-message.is-new-message,
  .streaming-cursor,
  .chat-message.is-streaming .message-meta span::before {
    animation: none !important;
  }

  .feature-option:hover,
  .attachment-chip:hover,
  .send-btn:hover:not(:disabled),
  .send-btn:active:not(:disabled) {
    transform: none !important;
  }
}

/* 滚到底部浮动按钮 */
.scroll-bottom-btn {
  position: fixed;
  bottom: 130px;
  right: 24px;
  z-index: 30;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}
.scroll-bottom-btn:hover {
  transform: translateY(-2px);
  background: var(--surface-hover);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}
.scroll-bottom-btn[hidden] {
  display: none;
}
.scroll-bottom-btn i {
  width: 16px;
  height: 16px;
}

@media (max-width: 720px) {
  .scroll-bottom-btn {
    bottom: 110px;
    right: 14px;
  }
}

/* 图片 lightbox */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-lightbox);
  background: rgba(0, 0, 0, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  cursor: zoom-out;
  animation: lightbox-fade 0.15s ease-out;
}

@keyframes lightbox-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.image-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.image-lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}
.image-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* 附图 hover 提示可点 */
.chat-attachments img,
.chat-user .chat-attachments img {
  cursor: zoom-in;
  transition: transform 0.15s;
}
.chat-attachments img:hover {
  transform: scale(1.02);
}

.chat-source-cards {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.chat-source-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 2px 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  text-decoration: none;
}

.chat-source-card span {
  grid-row: span 2;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
}

.chat-source-card strong,
.chat-source-card small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.chat-source-card small {
  color: var(--muted);
  font-size: 11px;
}

.canvas-panel {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: calc(var(--z-history) - 20);
  width: min(430px, calc(100vw - var(--rail)));
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: -24px 0 64px rgba(0, 0, 0, 0.12);
}

.canvas-panel[hidden] {
  display: none;
}

.canvas-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.canvas-head p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.canvas-head input {
  width: 100%;
  border: 0;
  padding: 0;
  box-shadow: none;
  font-size: 20px;
  font-weight: 850;
  background: transparent;
}

.canvas-controls,
.canvas-action-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.canvas-controls select,
.settings-input {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--surface);
}

.canvas-controls button,
.canvas-action-row button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.canvas-controls button:hover,
.canvas-action-row button:hover {
  background: var(--surface-hover);
}

.canvas-editor {
  width: 100%;
  min-height: 0;
  padding: 14px;
  border-radius: 10px;
  resize: none;
  line-height: 1.65;
  font-size: 14px;
  background: #fbfbfb;
}

.canvas-versions {
  max-height: 132px;
  display: grid;
  gap: 6px;
  overflow-y: auto;
}

.canvas-version,
.canvas-version-empty {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.canvas-version {
  display: grid;
  gap: 2px;
}

.canvas-version small,
.canvas-version-empty {
  color: var(--muted);
  font-size: 12px;
}

.asset-library-modal,
.project-memory-modal,
.task-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-session-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.42);
}

.asset-library-modal[hidden],
.project-memory-modal[hidden],
.task-modal[hidden] {
  display: none;
}

.asset-library-card,
.project-memory-card,
.task-card {
  width: min(680px, 100%);
  max-height: min(760px, calc(100dvh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.2);
}

.asset-library-body,
.project-memory-body,
.task-body {
  padding: 18px 22px;
  overflow-y: auto;
  display: grid;
  gap: 16px;
}

.library-actions,
.pm-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.asset-library-list,
.memory-list,
.task-list {
  display: grid;
  gap: 8px;
}

.asset-row,
.task-row,
.memory-item {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

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

.asset-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-soft);
  overflow: hidden;
}

.asset-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-info,
.task-row span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.asset-info strong,
.asset-info small,
.task-row strong,
.task-row small,
.memory-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asset-info strong,
.task-row strong {
  white-space: nowrap;
  font-size: 13px;
}

.asset-info small,
.task-row small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.asset-use,
.asset-remove,
.task-row button,
.memory-item button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.asset-remove,
.task-row button,
.memory-item button {
  width: 32px;
  padding: 0;
}

.asset-empty,
.memory-empty,
.task-empty {
  padding: 18px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.pm-section {
  display: grid;
  gap: 12px;
}

.settings-check {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
}

.settings-check input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.settings-check strong {
  display: block;
  font-size: 13px;
}

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

/* ==================== 会话设置模态框 ==================== */

.session-settings {
  position: fixed;
  inset: 0;
  z-index: var(--z-session-modal);
  background: rgba(0, 0, 0, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: lightbox-fade 0.15s ease-out;
}
.session-settings[hidden] {
  display: none;
}

.session-settings-card {
  width: min(540px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.session-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.session-settings-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}

.session-settings-body {
  padding: 18px 22px;
  overflow-y: auto;
  display: grid;
  gap: 20px;
}

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

.settings-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-value {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
}

.settings-hint {
  font-size: 12px;
  color: var(--muted);
}

.settings-segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
  gap: 7px;
}

.settings-segment {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.settings-segment:hover {
  border-color: rgba(14, 127, 84, 0.35);
  background: var(--surface-soft);
}

.settings-segment.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(14, 127, 84, 0.14);
}

.settings-textarea {
  width: 100%;
  min-height: 100px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.settings-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* range slider */
input[type="range"]#sessionTemperature {
  width: 100%;
  accent-color: var(--accent);
}

.session-settings-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.btn-primary,
.btn-secondary {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
.btn-primary:hover {
  background: #0a6542;
}
.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-secondary:hover {
  background: var(--surface-hover);
}

/* 防止 modal 打开时背景滚动 */
body.modal-open {
  overflow: hidden;
}

@media (max-width: 860px) {
  .chat-toolbar {
    width: calc(100vw - 20px);
    flex-wrap: nowrap;
    gap: 7px;
    padding: 0 2px 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }

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

  .chat-key-picker,
  .chat-model-picker,
  .chat-mode-picker,
  .chat-tool-toggle {
    flex: 0 0 auto;
  }

  .chat-key-btn,
  .chat-model-btn,
  .chat-mode-btn,
  .chat-tool-toggle {
    min-height: 34px;
    padding: 6px 11px;
  }

  .chat-key-btn {
    max-width: 176px;
  }

  .chat-message {
    gap: 8px;
    margin-bottom: 14px;
  }

  .chat-message .chat-bubble {
    padding: 10px 12px;
    border-radius: 14px;
  }

  .chat-message.chat-assistant .chat-bubble {
    flex: 1 1 auto;
    max-width: calc(100% - 38px);
  }

  .chat-message.chat-user .chat-bubble {
    max-width: 92%;
  }

  .chat-text,
  .chat-markdown p,
  .chat-markdown li {
    font-size: 14px;
    line-height: 1.65;
  }

  .chat-markdown table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }

  .chat-markdown .code-block {
    max-width: 100%;
  }

  .chat-markdown pre,
  .chat-markdown pre[class*="language-"] {
    padding: 10px 12px;
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .chat-toolbar {
    width: calc(100vw - 16px);
  }

  .chat-key-btn {
    max-width: 152px;
  }
}

@media (max-width: 520px) {
  #chatToolWebSearch span,
  #chatCanvasBtn span,
  #chatFilesBtn span,
  #chatProjectBtn span,
  #chatTasksBtn span,
  #chatVoiceToggle span,
  #chatSettingsBtn span,
  #chatExportBtn span {
    display: none;
  }

  .chat-tool-toggle {
    width: 38px;
    min-width: 38px;
    justify-content: center;
    padding: 0;
  }

  .chat-key-btn {
    max-width: 120px;
  }

  .chat-model-btn {
    max-width: 86px;
  }

  .chat-mode-btn {
    max-width: 104px;
  }

  .chat-reasoning-btn {
    max-width: 116px;
  }
}

@media (max-width: 380px) {
  .chat-key-btn {
    max-width: 112px;
  }
}

@media (max-width: 520px) {
  .model-menu,
  .image-key-menu,
  .choice-menu,
  .composer-feature-menu,
  .chat-key-menu,
  .chat-model-menu,
  .chat-mode-menu,
  .chat-reasoning-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--composer-dock-offset, var(--composer-dock-height, 210px)) + 10px + env(safe-area-inset-bottom));
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: min(50dvh, calc(100dvh - var(--composer-dock-offset, var(--composer-dock-height, 210px)) - 34px - env(safe-area-inset-bottom)));
    overflow-y: auto;
    transform: none;
    box-sizing: border-box;
    overscroll-behavior: contain;
    z-index: calc(var(--z-dropdown) + 60);
  }

  .choice-menu.is-open,
  .composer-feature-menu {
    transform: none;
    animation: none;
  }

  .choice-menu {
    min-width: 0;
  }

  .choice-menu.is-open {
    display: grid;
    gap: 4px;
  }

  .choice-option {
    min-height: 44px;
    align-content: center;
  }

  .choice-option small {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .composer-feature-menu {
    width: auto;
    transform-origin: center bottom;
  }
}

/* ChatGPT-like chat surface */
body[data-session-type="chat"] {
  --composer: 768px;
  --chat-column: 768px;
}

body[data-session-type="chat"] .workspace,
body[data-session-type="chat"] .messages {
  background: #fff;
}

body[data-session-type="chat"] .messages {
  padding: 42px max(20px, calc((100vw - var(--rail) - var(--chat-column)) / 2)) 30px;
  scroll-padding-bottom: 28px;
}

body[data-session-type="chat"] .message.chat-message {
  width: min(var(--chat-column), 100%);
  margin: 0 auto 30px;
}

body[data-session-type="chat"] .chat-empty-state {
  min-height: 100%;
  align-content: center;
  gap: 28px;
  padding-bottom: 18vh;
}

body[data-session-type="chat"] .chat-empty-state h1 {
  color: #2f2f2f;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
}

body[data-session-type="chat"] .chat-empty-state .suggestion-grid {
  width: min(640px, 100%);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 0;
}

body[data-session-type="chat"] .chat-empty-state .suggestion-card {
  min-height: 54px;
  padding: 12px 14px;
  border: 1px solid #ececec;
  border-radius: 14px;
  background: #fff;
  color: #4f4f4f;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: none;
  transition: background 0.14s ease, border-color 0.14s ease;
}

body[data-session-type="chat"] .chat-empty-state .suggestion-card:hover {
  background: #f7f7f7;
  border-color: #dedede;
}

body[data-session-type="chat"] .chat-message {
  gap: 0;
  align-items: flex-start;
}

body[data-session-type="chat"] .chat-message.chat-user {
  justify-content: flex-start;
}

body[data-session-type="chat"] .chat-message.chat-user .chat-bubble {
  max-width: min(70%, 560px);
  padding: 10px 16px;
  border: 0;
  border-radius: 18px;
  background: #f4f4f4;
  color: #0d0d0d;
  box-shadow: none;
}

body[data-session-type="chat"] .chat-message.chat-user .chat-text {
  color: #0d0d0d;
  font-size: 16px;
  line-height: 1.55;
}

body[data-session-type="chat"] .chat-message.chat-assistant {
  display: block;
}

body[data-session-type="chat"] .chat-message.chat-assistant .assistant-mark {
  display: none;
}

body[data-session-type="chat"] .chat-message.chat-assistant .chat-bubble,
body[data-session-type="chat"] .chat-message.is-streaming .chat-bubble {
  width: 100%;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body[data-session-type="chat"] .chat-message.chat-assistant .chat-text {
  color: #0d0d0d;
  font-size: 16px;
  line-height: 1.72;
  white-space: normal;
}

body[data-session-type="chat"] .chat-message.chat-assistant .message-meta {
  display: none !important;
}

body[data-session-type="chat"] .chat-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  color: #8f8f8f;
  font-size: 12px;
}

body[data-session-type="chat"] .chat-status.is-pending::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #14835a;
  box-shadow: 0 0 0 0 rgba(20, 131, 90, 0.32);
  animation: streamingDotPulse 1.25s ease-out infinite;
  flex: 0 0 auto;
}

body[data-session-type="chat"] .chat-message-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  margin-top: 10px;
  opacity: 0;
  transition: opacity 0.14s ease;
}

body[data-session-type="chat"] .chat-message.chat-assistant:hover .chat-message-actions,
body[data-session-type="chat"] .chat-message.chat-assistant:focus-within .chat-message-actions {
  opacity: 1;
}

body[data-session-type="chat"] .chat-message-actions .chat-action-btn,
body[data-session-type="chat"] .chat-user-actions .chat-action-btn {
  width: 30px;
  height: 30px;
  margin-left: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #707070;
}

body[data-session-type="chat"] .chat-message-actions .chat-action-btn:hover,
body[data-session-type="chat"] .chat-user-actions .chat-action-btn:hover {
  background: #f2f2f2;
  color: #0d0d0d;
}

body[data-session-type="chat"] .chat-user-actions {
  margin: 0 8px 0 0;
}

body[data-session-type="chat"] .chat-attachments img {
  width: 132px;
  height: 132px;
  border: 1px solid #dedede;
  border-radius: 14px;
  background: #fff;
}

body[data-session-type="chat"] .chat-file-attachment {
  background: #f4f4f4;
  border: 1px solid #e5e5e5;
}

body[data-session-type="chat"] .chat-file-text strong,
body[data-session-type="chat"] .chat-file-text small {
  color: #0d0d0d;
}

body[data-session-type="chat"] .chat-file-text small {
  color: #676767;
}

body[data-session-type="chat"] .chat-markdown > *:first-child {
  margin-top: 0;
}

body[data-session-type="chat"] .chat-markdown > *:last-child {
  margin-bottom: 0;
}

body[data-session-type="chat"] .chat-markdown p {
  margin: 0 0 1em;
  color: #0d0d0d;
  font-size: 16px;
  line-height: 1.72;
}

body[data-session-type="chat"] .chat-markdown h1,
body[data-session-type="chat"] .chat-markdown h2,
body[data-session-type="chat"] .chat-markdown h3,
body[data-session-type="chat"] .chat-markdown h4 {
  margin: 1.35em 0 0.55em;
  color: #0d0d0d;
  font-weight: 650;
  line-height: 1.3;
}

body[data-session-type="chat"] .chat-markdown h1 {
  font-size: 22px;
}

body[data-session-type="chat"] .chat-markdown h2 {
  font-size: 20px;
}

body[data-session-type="chat"] .chat-markdown h3 {
  font-size: 18px;
}

body[data-session-type="chat"] .chat-markdown h4 {
  font-size: 16px;
}

body[data-session-type="chat"] .chat-markdown ul,
body[data-session-type="chat"] .chat-markdown ol {
  margin: 0.55em 0 1em;
  padding-left: 1.45em;
}

body[data-session-type="chat"] .chat-markdown li {
  margin: 0.28em 0;
  padding-left: 0.15em;
  line-height: 1.72;
}

body[data-session-type="chat"] .chat-markdown li > p {
  margin: 0.25em 0;
}

body[data-session-type="chat"] .chat-markdown blockquote {
  margin: 1em 0;
  padding: 0.15em 0 0.15em 1em;
  border-left: 3px solid #d9d9d9;
  color: #4f4f4f;
}

body[data-session-type="chat"] .chat-markdown code {
  padding: 2px 5px;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  background: #f5f5f5;
  color: #202020;
  font-size: 0.9em;
}

body[data-session-type="chat"] .chat-markdown .code-block {
  margin: 14px 0;
  border: 0;
  border-radius: 8px;
  background: #171717;
}

body[data-session-type="chat"] .chat-markdown .code-block-head {
  padding: 8px 14px;
  background: #2f2f2f;
  color: #d4d4d4;
  font-size: 12px;
}

body[data-session-type="chat"] .chat-markdown .code-block-copy {
  border-color: transparent;
  border-radius: 6px;
  color: #d4d4d4;
}

body[data-session-type="chat"] .chat-markdown .code-block-copy:hover {
  background: #3a3a3a;
  border-color: transparent;
}

body[data-session-type="chat"] .chat-markdown pre,
body[data-session-type="chat"] .chat-markdown pre[class*="language-"] {
  padding: 14px;
  background: #171717;
  color: #f4f4f4;
  font-size: 13px;
  line-height: 1.58;
}

body[data-session-type="chat"] .chat-markdown pre code,
body[data-session-type="chat"] .chat-markdown pre[class*="language-"] code {
  border: 0;
  background: transparent;
  color: inherit;
}

body[data-session-type="chat"] .chat-markdown table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 14px;
}

body[data-session-type="chat"] .chat-markdown th,
body[data-session-type="chat"] .chat-markdown td {
  padding: 8px 10px;
  border: 1px solid #dedede;
}

body[data-session-type="chat"] .chat-markdown th {
  background: #f7f7f7;
  font-weight: 650;
}

body[data-session-type="chat"] .chat-markdown hr {
  margin: 1.4em 0;
  border-top: 1px solid #e5e5e5;
}

body[data-session-type="chat"] .composer-dock {
  width: min(var(--composer), calc(100% - 40px));
  gap: 8px;
  padding: 0 0 16px;
  background: linear-gradient(to top, #fff 86%, rgba(255, 255, 255, 0));
}

body[data-session-type="chat"] .chat-toolbar {
  width: 100%;
  gap: 7px;
  padding: 0 2px 7px;
}

body[data-session-type="chat"] .chat-key-btn,
body[data-session-type="chat"] .chat-model-btn,
body[data-session-type="chat"] .chat-reasoning-btn,
body[data-session-type="chat"] .chat-tool-toggle {
  min-height: 32px;
  padding: 6px 11px;
  border-color: #e3e3e3;
  background: #fff;
  color: #3f3f3f;
  font-size: 13px;
  font-weight: 500;
}

body[data-session-type="chat"] .chat-key-btn:hover,
body[data-session-type="chat"] .chat-model-btn:hover,
body[data-session-type="chat"] .chat-reasoning-btn:hover,
body[data-session-type="chat"] .chat-tool-toggle:hover {
  background: #f7f7f7;
  border-color: #d4d4d4;
}

body[data-session-type="chat"] .chat-tool-toggle.is-active,
body[data-session-type="chat"] .chat-reasoning-btn.is-active {
  border-color: #0d0d0d;
  background: #0d0d0d;
  color: #fff;
}

body[data-session-type="chat"] .chat-tool-toggle.is-active i,
body[data-session-type="chat"] .chat-reasoning-btn.is-active i {
  color: #fff;
}

body[data-session-type="chat"] .composer {
  width: 100%;
  border: 1px solid #d9d9d9;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
}

body[data-session-type="chat"] .prompt-row {
  align-items: flex-end;
  gap: 8px;
  min-height: 58px;
  padding: 10px;
}

body[data-session-type="chat"] .prompt-row textarea {
  min-height: 38px;
  padding: 8px 2px;
  color: #0d0d0d;
  font-size: 16px;
  line-height: 1.45;
}

body[data-session-type="chat"] .icon-btn,
body[data-session-type="chat"] .send-btn {
  flex: 0 0 auto;
}

body[data-session-type="chat"] .send-btn {
  background: #0d0d0d;
  box-shadow: none;
}

body[data-session-type="chat"] .send-btn:hover:not(:disabled) {
  background: #2f2f2f;
  box-shadow: none;
}

body[data-session-type="chat"] .send-btn:disabled {
  background: #d7d7d7;
  color: #fff;
}

body[data-session-type="chat"] .dock-note {
  color: #8f8f8f;
  font-size: 12px;
}

body[data-session-type="chat"] .scroll-bottom-btn {
  right: max(24px, calc((100vw - var(--rail) - var(--chat-column)) / 2 - 58px));
  bottom: 126px;
  border-color: #e5e5e5;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.12);
}

@media (hover: none) {
  body[data-session-type="chat"] .chat-message-actions {
    opacity: 1;
  }
}

@media (max-width: 860px) {
  body[data-session-type="chat"] {
    --composer: calc(100vw - 20px);
    --chat-column: calc(100vw - 24px);
  }

  body[data-session-type="chat"] .messages {
    padding: 22px 12px 18px;
  }

  body[data-session-type="chat"] .message.chat-message {
    margin-bottom: 24px;
  }

  body[data-session-type="chat"] .chat-empty-state {
    gap: 22px;
    padding-bottom: 10vh;
  }

  body[data-session-type="chat"] .chat-empty-state h1 {
    font-size: 28px;
  }

  body[data-session-type="chat"] .chat-message.chat-user .chat-bubble {
    max-width: 84%;
  }

  body[data-session-type="chat"] .chat-message.chat-user .chat-text,
  body[data-session-type="chat"] .chat-message.chat-assistant .chat-text,
  body[data-session-type="chat"] .chat-markdown p,
  body[data-session-type="chat"] .chat-markdown li {
    font-size: 15px;
    line-height: 1.68;
  }

  body[data-session-type="chat"] .composer-dock {
    width: calc(100vw - 20px);
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  body[data-session-type="chat"] .chat-toolbar {
    width: 100%;
    padding-bottom: 6px;
  }

  body[data-session-type="chat"] .scroll-bottom-btn {
    right: 14px;
    bottom: 112px;
  }
}

@media (max-width: 520px) {
  body[data-session-type="chat"] .chat-empty-state .suggestion-grid {
    grid-template-columns: 1fr;
  }

  body[data-session-type="chat"] .chat-empty-state h1 {
    font-size: 26px;
  }

  body[data-session-type="chat"] .chat-empty-state .suggestion-card {
    min-height: 48px;
  }

  body[data-session-type="chat"] .chat-key-btn,
  body[data-session-type="chat"] .chat-model-btn,
  body[data-session-type="chat"] .chat-reasoning-btn {
    max-width: 132px;
  }

  body[data-session-type="chat"] .chat-message.chat-user .chat-bubble {
    max-width: 88%;
  }

  body[data-session-type="chat"] .prompt-row textarea {
    font-size: 15px;
  }
}

@media (max-width: 520px) {
  .developer-docs-btn {
    top: calc(10px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 12px;
  }

  .developer-docs-btn span {
    display: none;
  }

  .api-docs-top-btn {
    width: 38px;
    min-width: 38px;
    justify-content: center;
    padding: 0;
  }

  .api-docs-top-btn span {
    display: none;
  }

  .settings-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) and (orientation: portrait) {
  .top-actions .api-docs-top-btn {
    display: none;
  }

  .settings-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .top-actions .api-docs-top-btn {
    display: none;
  }
}

@media (min-width: 861px) {
  .app-shell.has-canvas {
    --canvas-space: 448px;
  }

  .app-shell.has-canvas .messages {
    padding-right: max(var(--canvas-space), calc((100vw - var(--rail) - var(--chat-column)) / 2));
  }

  .app-shell.has-canvas .composer-dock {
    width: min(720px, calc(100vw - var(--rail) - var(--canvas-space) - 36px));
    justify-self: start;
    margin-left: max(22px, calc((100vw - var(--rail) - var(--canvas-space) - 720px) / 2));
  }

  .app-shell.has-canvas .balance-pill {
    right: calc(var(--canvas-space) + 18px);
  }
}

@media (max-width: 860px) {
  .canvas-panel {
    position: fixed;
    inset: auto 0 0 0;
    width: 100vw;
    height: min(72dvh, 620px);
    border-left: 0;
    border-top: 1px solid var(--line);
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.14);
  }
}

@media (max-width: 860px) {
  .app-shell.has-canvas .canvas-panel {
    inset: 72px 8px calc(156px + env(safe-area-inset-bottom)) 8px;
    width: auto;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 18px 54px rgba(15, 23, 42, 0.16);
  }
}

/* ChatGPT-style conversation shell */
:root {
  --history-width: 292px;
  --chat-column: 760px;
  --image-column: 1088px;
}

@media (min-width: 861px) {
  .app-shell.history-pinned {
    grid-template-columns: var(--rail) var(--history-width) minmax(0, 1fr);
  }

  .app-shell.history-pinned > .rail {
    grid-column: 1;
    display: flex;
    width: var(--rail);
    min-width: var(--rail);
    position: relative;
    z-index: 3;
  }

  .app-shell.history-pinned .history-panel {
    position: relative;
    inset: auto;
    grid-column: 2;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    transform: translateX(0) !important;
    transition: none;
    box-shadow: none;
    border-right: 1px solid #e8e8e8;
    background: #f9f9f9;
    z-index: 2;
  }

  .app-shell.history-pinned #sidebar.history-panel {
    transform: translateX(0) !important;
  }

  .app-shell.history-pinned .history-backdrop {
    display: none;
  }

  .app-shell.history-pinned .workspace {
    grid-column: 3;
    width: auto;
    min-width: 0;
  }

  body[data-session-type="chat"] .app-shell.history-pinned .messages {
    padding-left: max(20px, calc((100vw - var(--rail) - var(--history-width) - var(--chat-column)) / 2));
    padding-right: max(20px, calc((100vw - var(--rail) - var(--history-width) - var(--chat-column)) / 2));
  }

  body[data-session-type="chat"] .app-shell.history-pinned .scroll-bottom-btn {
    right: max(24px, calc((100vw - var(--rail) - var(--history-width) - var(--chat-column)) / 2 - 58px));
  }

  .app-shell.history-pinned.has-canvas .messages {
    padding-right: max(var(--canvas-space), calc((100vw - var(--rail) - var(--history-width) - var(--composer)) / 2));
  }

  .app-shell.history-pinned.has-canvas .composer-dock {
    width: min(720px, calc(100vw - var(--rail) - var(--history-width) - var(--canvas-space) - 36px));
    margin-left: max(22px, calc((100vw - var(--rail) - var(--history-width) - var(--canvas-space) - 720px) / 2));
  }
}

body[data-session-type="chat"] {
  --composer: var(--chat-column);
}

body[data-session-type="image"] {
  --composer: var(--image-column);
}

.history-panel {
  gap: 10px;
}

.history-head {
  padding: 2px 2px 0;
}

.history-head strong {
  font-size: 14px;
  font-weight: 760;
}

.new-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.new-chat-wide,
.sidebar-api-docs-btn,
.history-search,
.history-filter,
.history-mini-btn,
.balance-card,
.user-row {
  border-radius: 8px;
}

.conversation-item {
  min-height: 38px;
  grid-template-columns: minmax(0, 1fr) 116px;
  padding: 8px;
  border-radius: 8px;
}

.conversation-open span {
  font-size: 13px;
  font-weight: 650;
}

.conversation-open small {
  font-size: 11px;
}

.messages {
  scroll-behavior: smooth;
  padding-top: 44px;
  padding-bottom: 28px;
}

.message {
  margin-bottom: 28px;
}

.message.assistant {
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 14px;
}

.assistant-mark {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

.message.user .message-body {
  background: #f4f4f4;
  border-radius: 18px;
  padding: 10px 14px;
}

body[data-session-type="chat"] .messages {
  padding-top: 54px;
}

body[data-session-type="chat"] .chat-message {
  width: min(var(--chat-column), 100%);
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 28px;
}

body[data-session-type="chat"] .chat-message .chat-bubble {
  max-width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body[data-session-type="chat"] .chat-message.chat-user {
  align-items: flex-start;
}

body[data-session-type="chat"] .chat-message.chat-user .chat-bubble {
  max-width: min(620px, 78%);
  padding: 10px 14px;
  border-radius: 18px;
  background: #f4f4f4;
  color: #0d0d0d;
}

body[data-session-type="chat"] .chat-message.chat-user .chat-text {
  color: #0d0d0d;
}

body[data-session-type="chat"] .chat-message.chat-assistant .assistant-mark {
  background: #0d0d0d;
  color: #fff;
}

body[data-session-type="chat"] .chat-message.chat-assistant .chat-text,
body[data-session-type="chat"] .chat-markdown p,
body[data-session-type="chat"] .chat-markdown li {
  color: #0d0d0d;
  font-size: 15.5px;
  line-height: 1.72;
}

body[data-session-type="chat"] .chat-message-actions {
  justify-content: flex-start;
  margin-top: 10px;
  opacity: 0;
}

body[data-session-type="chat"] .chat-message:hover .chat-message-actions,
body[data-session-type="chat"] .chat-message-actions:focus-within {
  opacity: 1;
}

.image-assistant-message .message-body > p {
  max-width: min(760px, 100%);
  margin-bottom: 10px;
}

.image-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 2px;
}

.image-result-action {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 720;
}

.image-result-action:hover {
  background: var(--surface-hover);
}

.image-result-action svg,
.image-result-action i {
  width: 14px;
  height: 14px;
}

.image-grid {
  gap: 14px;
}

.image-card {
  border-radius: 8px;
  box-shadow: none;
}

.image-card img,
.image-skeleton,
.image-missing {
  border-radius: 8px 8px 0 0;
}

.image-actions {
  position: static;
  display: flex;
  justify-content: flex-start;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
  opacity: 1;
  transform: none;
}

.image-actions .icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.image-actions .icon-btn:hover {
  background: var(--surface-hover);
}

.image-caption {
  border-top: 1px solid var(--line);
  background: #fbfbfb;
}

.composer-dock {
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 18px);
}

.composer {
  border-radius: 26px;
  border-color: #d9d9d9;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
}

.prompt-row textarea {
  font-size: 16px;
  line-height: 1.45;
}

.chat-toolbar {
  gap: 8px;
}

.chat-tool-toggle,
.chat-model-btn,
.chat-mode-btn,
.chat-reasoning-btn,
.model-menu-btn,
.choice-btn {
  border-radius: 999px;
}

@media (max-width: 860px) {
  .app-shell.history-pinned {
    grid-template-columns: 1fr;
  }

  .app-shell.history-pinned .history-panel {
    position: fixed;
  }

  body[data-session-type="image"] {
    --composer: calc(100vw - 20px);
    --image-column: calc(100vw - 20px);
  }

  body[data-session-type="image"] .messages {
    padding: calc(58px + env(safe-area-inset-top)) 10px 12px;
  }

  body[data-session-type="image"] .message {
    width: min(var(--image-column), 100%);
  }

  body[data-session-type="image"] .image-assistant-message {
    display: block;
  }

  body[data-session-type="image"] .image-assistant-message .assistant-mark {
    display: none;
  }

  body[data-session-type="image"] .image-assistant-message .message-body {
    width: 100%;
  }

  body[data-session-type="image"] .image-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  body[data-session-type="image"] .image-card {
    width: 100%;
    justify-self: stretch;
  }

  body[data-session-type="image"] .image-actions {
    justify-content: space-between;
  }

  .new-row {
    grid-template-columns: 1fr;
  }

  body[data-session-type="chat"] .chat-message.chat-user .chat-bubble {
    max-width: 88%;
  }

  .image-result-actions {
    margin-top: 8px;
    gap: 6px;
  }

  .image-result-action {
    min-height: 30px;
    padding: 0 10px;
  }

  .toast {
    top: calc(62px + env(safe-area-inset-top));
    bottom: auto;
    max-width: min(360px, calc(100vw - 28px));
    transform: translate(-50%, -10px);
  }

  .toast.is-visible {
    transform: translate(-50%, 0);
  }
}

/* Final UI overrides for 2026-06-04 route/image fixes. Keep after all mode blocks. */
body[data-session-type="image"] {
  --composer: min(var(--image-column), 980px);
}

.conversation-item {
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 6px;
}

.conversation-actions {
  width: 110px;
  min-width: 110px;
  gap: 3px;
  justify-content: flex-end;
  border-color: rgba(15, 23, 42, 0.06);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: none;
  opacity: 0.68;
  pointer-events: auto;
  transform: none;
}

.conversation-item:hover .conversation-actions,
.conversation-item.is-active .conversation-actions,
.conversation-item:focus-within .conversation-actions {
  opacity: 1;
  transform: none;
}

.conversation-mini,
.conversation-delete {
  width: 25px;
  height: 25px;
  flex-basis: 25px;
}

body[data-session-type="image"] .composer-dock {
  padding: 0 18px calc(10px + env(safe-area-inset-bottom));
  gap: 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 16px);
}

body[data-session-type="image"] .composer {
  width: min(var(--composer), calc(100vw - 36px));
  border-radius: 24px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.08);
}

body[data-session-type="image"] .prompt-row {
  padding: 9px 11px;
}

body[data-session-type="image"] .settings-row {
  gap: 7px;
  padding: 0 11px 10px;
}

body[data-session-type="image"] .settings-row label,
body[data-session-type="image"] .setting-control {
  min-height: 30px;
}

body[data-session-type="image"] .model-menu-btn,
body[data-session-type="image"] .choice-btn,
body[data-session-type="image"] .tool-pill,
body[data-session-type="image"] .image-key-btn {
  min-height: 31px;
}

body[data-session-type="image"] .dock-note {
  margin-top: 0;
  font-size: 11.5px;
}

@media (max-width: 860px) {
  body[data-session-type="image"] {
    --composer: calc(100vw - 20px);
    --image-column: calc(100vw - 20px);
  }

  .conversation-item {
    grid-template-columns: minmax(0, 1fr) 104px;
  }

  .conversation-actions {
    width: 104px;
    min-width: 104px;
  }

  body[data-session-type="image"] .composer-dock {
    padding-left: 10px;
    padding-right: 10px;
  }

  body[data-session-type="image"] .composer {
    width: min(var(--composer), calc(100vw - 20px));
  }
}

/* True final composer polish for 2026-06-04 ui3. Keep this at EOF. */
body[data-session-type="image"] {
  --composer: min(940px, calc(100vw - 36px));
}

body[data-session-type="image"] .composer-dock {
  padding: 0 18px calc(8px + env(safe-area-inset-bottom));
  gap: 5px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 14px);
}

body[data-session-type="image"] .composer {
  width: min(var(--composer), calc(100vw - 36px));
  max-width: 940px;
  border-radius: 22px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.075);
}

body[data-session-type="image"] .prompt-row {
  min-height: 56px;
  gap: 7px;
  padding: 8px 10px 7px;
  align-items: center;
}

body[data-session-type="image"] .prompt-row textarea {
  min-height: 35px;
  max-height: 112px;
  padding: 7px 3px;
  line-height: 1.38;
}

body[data-session-type="image"] .prompt-row .icon-btn,
body[data-session-type="image"] .send-btn {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
}

body[data-session-type="image"] .settings-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(220px, 280px) repeat(3, max-content) max-content max-content;
  align-items: center;
  justify-content: start;
  gap: 6px;
  padding: 0 10px 8px;
}

body[data-session-type="image"] .settings-row label,
body[data-session-type="image"] .setting-control {
  min-height: 28px;
  gap: 4px;
  font-size: 11.5px;
}

body[data-session-type="image"] .setting-control > span {
  color: rgba(17, 24, 39, 0.62);
}

body[data-session-type="image"] .model-menu-btn {
  width: 230px;
  max-width: 230px;
}

body[data-session-type="image"] .model-menu-btn,
body[data-session-type="image"] .choice-btn,
body[data-session-type="image"] .tool-pill,
body[data-session-type="image"] .image-key-btn {
  min-height: 29px;
  box-shadow: none;
}

body[data-session-type="image"] .choice-btn {
  min-width: 74px;
  gap: 5px;
  padding: 0 8px 0 10px;
}

body[data-session-type="image"] .tool-pill {
  min-width: 64px;
  gap: 5px;
  padding: 0 10px;
}

body[data-session-type="image"] .tool-pill svg,
body[data-session-type="image"] .choice-btn svg,
body[data-session-type="image"] .model-menu-btn svg {
  width: 14px;
  height: 14px;
}

body[data-session-type="image"] .cost-preview {
  display: none;
}

body[data-session-type="image"] .dock-note {
  max-width: min(760px, calc(100vw - 36px));
  color: rgba(17, 24, 39, 0.48);
  font-size: 11px;
  line-height: 1.25;
}

body[data-session-type="image"] .balance-pill {
  right: max(18px, calc((100vw - var(--composer)) / 2 - 76px));
  bottom: calc(var(--composer-dock-offset, var(--composer-dock-height, 210px)) + 12px + env(safe-area-inset-bottom));
  min-height: 34px;
  padding: 0 13px;
  background: rgba(232, 247, 241, 0.88);
  box-shadow: 0 10px 24px rgba(10, 101, 66, 0.1);
  font-size: 14px;
}

@media (max-width: 1120px) {
  body[data-session-type="image"] .settings-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  body[data-session-type="image"] .model-menu-btn {
    width: min(230px, calc(100vw - 132px));
  }
}

@media (max-width: 640px) {
  body[data-session-type="image"] {
    --composer: calc(100vw - 20px);
  }

  body[data-session-type="image"] .composer-dock {
    padding-left: 10px;
    padding-right: 10px;
  }

  body[data-session-type="image"] .composer {
    width: min(var(--composer), calc(100vw - 20px));
    border-radius: 20px;
  }

  body[data-session-type="image"] .prompt-row {
    min-height: 52px;
    padding: 7px 8px;
  }

  body[data-session-type="image"] .settings-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
    padding: 0 8px 8px;
  }

  body[data-session-type="image"] .model-control {
    grid-column: 1 / -1;
  }

  body[data-session-type="image"] .model-menu-btn {
    width: 100%;
    max-width: none;
  }

  body[data-session-type="image"] .setting-control,
  body[data-session-type="image"] .tool-pill {
    width: 100%;
    justify-content: space-between;
  }

  body[data-session-type="image"] .choice-btn {
    min-width: 86px;
  }

  body[data-session-type="image"] .balance-pill {
    right: 12px;
    bottom: calc(var(--composer-dock-offset, var(--composer-dock-height, 210px)) + 8px + env(safe-area-inset-bottom));
  }
}

/* Final history action polish for 2026-06-05 login/image cache fix. */
.conversation-item {
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 4px;
  overflow: hidden;
}

.conversation-open {
  min-width: 0;
  overflow: hidden;
}

.conversation-open span,
.conversation-open small {
  max-width: 100%;
}

.conversation-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  width: 110px;
  min-width: 110px;
  height: 28px;
  gap: 1px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  opacity: 0;
  pointer-events: auto;
  transform: none;
}

.conversation-item:hover .conversation-actions,
.conversation-item.is-active .conversation-actions,
.conversation-item:focus-within .conversation-actions {
  opacity: 1;
  transform: none;
}

.conversation-mini,
.conversation-delete {
  width: 26px;
  height: 26px;
  min-width: 26px;
  flex: 0 0 26px;
  border-radius: 6px;
  background: transparent;
  color: rgba(15, 23, 42, 0.58);
}

.conversation-mini i,
.conversation-delete i {
  width: 14px;
  height: 14px;
}

.conversation-mini:hover,
.conversation-delete:hover {
  background: rgba(15, 23, 42, 0.08);
  color: var(--ink);
}

@media (max-width: 860px) {
  .conversation-item {
    grid-template-columns: minmax(0, 1fr) 106px;
  }

  .conversation-actions {
    width: 106px;
    min-width: 106px;
  }

  .conversation-mini,
  .conversation-delete {
    width: 25px;
    height: 25px;
    min-width: 25px;
    flex-basis: 25px;
  }
}
