:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #fafbff;
  --line: #e6e8f0;
  --line-strong: #d7dced;
  --text: #172033;
  --text-soft: #6d7488;
  --text-faint: #9aa2b5;
  --accent: #5b35d5;
  --accent-soft: #f1ecff;
  --accent-line: #d9cdfd;
  --success: #4fb66a;
  --user-bubble: #f3f0f7;
  --shadow: 0 12px 36px rgba(20, 30, 50, 0.08);
  --radius-panel: 18px;
  --radius-card: 14px;
  --radius-small: 12px;
  --font-sans:
    "Segoe UI Variable", "Aptos", "PingFang SC", "Microsoft YaHei",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

body {
  overflow: hidden;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
  background: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 76px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

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

.agent-avatar,
.hero-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.agent-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex: 0 0 auto;
}

.hero-avatar {
  width: 86px;
  height: 86px;
  border-radius: 22px;
  margin: 0 auto 18px;
}

.agent-avatar img,
.hero-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.agent-meta {
  min-width: 0;
}

.agent-meta h1 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.2;
}

.agent-meta p {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.4;
}

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

.topbar-button,
.drawer-new-chat {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.topbar-button:hover,
.drawer-new-chat:hover,
.history-item:hover,
.send-button:hover,
.composer-action:hover {
  transform: translateY(-1px);
}

.topbar-button-primary,
.drawer-new-chat {
  background: #3f6ee8;
  border-color: #3f6ee8;
  color: #ffffff;
}

.topbar-button-secondary,
.composer-action {
  background: var(--surface);
  color: var(--text);
}

/* 服务地址由 APK 原生层配置，浏览器版不显示此入口。 */
.android-service-button {
  display: none;
}

body.android-app .android-service-button {
  display: inline-flex;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 0;
  height: calc(100vh - 76px);
  transition: grid-template-columns 220ms ease;
}

body.reference-collapsed .workspace {
  grid-template-columns: minmax(0, 1fr) 0;
}

.conversation-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.conversation-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 28px 28px 14px;
}

.welcome-hero {
  display: flex;
  min-height: calc(100vh - 290px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 110px;
  text-align: center;
}

.welcome-hero h2 {
  margin: 0;
  font-size: 34px;
  line-height: 1.2;
}

.hero-description {
  max-width: 560px;
  margin: 20px auto 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.9;
}

.message-stage {
  max-width: 980px;
  margin: 0 auto;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message-row {
  display: flex;
}

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

.message-row.assistant {
  justify-content: flex-start;
}

.message-frame {
  width: min(100%, 980px);
}

.user-bubble {
  display: inline-flex;
  max-width: min(64%, 480px);
  padding: 13px 18px;
  border-radius: 18px;
  background: var(--user-bubble);
  color: var(--text);
  line-height: 1.8;
}

.assistant-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.assistant-heading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
}

.assistant-heading::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(135deg, #886cff 0%, #5b35d5 100%);
  box-shadow: 0 0 0 5px rgba(91, 53, 213, 0.11);
}

.process-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-left: 8px;
}

.process-item {
  position: relative;
  padding-left: 28px;
}

.process-item::before {
  content: "";
  position: absolute;
  top: 24px;
  bottom: -20px;
  left: 7px;
  width: 2px;
  background: #e8ebf4;
}

.process-item:last-child::before {
  display: none;
}

.process-dot {
  position: absolute;
  top: 2px;
  left: 0;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #d9dfef;
  color: transparent;
}

.process-item.done .process-dot,
.process-item.running .process-dot {
  background: var(--success);
}

.process-item.done .process-dot::before,
.process-item.running .process-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #ffffff;
}

.process-item.pending .process-dot {
  background: #dbe0ed;
}

.process-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.process-detail {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.process-resource-box {
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface-soft);
}

.process-resource-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.process-resource-head strong {
  font-size: 14px;
}

.process-resource-count {
  color: var(--text-soft);
  font-size: 12px;
}

.process-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.process-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.process-source-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.process-source-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.process-source-item::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(180deg, #f6f7fb 0%, #e8ebf4 100%);
  border: 1px solid #d8dceb;
}

.answer-panel {
  padding-left: 28px;
}

.answer-card {
  padding: 0 0 4px;
}

.answer-card-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}

.answer-generation-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.answer-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  box-sizing: border-box;
  border: 2px solid rgba(37, 99, 235, 0.2);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: answer-spinner-rotate 900ms linear infinite;
}

@keyframes answer-spinner-rotate {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .answer-spinner { animation: none; }
}

.draft-block {
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  overflow: hidden;
}

.draft-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  color: var(--text-soft);
  user-select: none;
}

.draft-summary::-webkit-details-marker {
  display: none;
}

.draft-summary-title {
  font-size: 13px;
  font-weight: 700;
}

.draft-summary-hint {
  font-size: 12px;
  color: var(--text-faint);
}

.draft-block[open] .draft-summary {
  border-bottom: 1px solid var(--line);
}

.draft-content {
  padding: 12px 14px 14px;
}

.message-rich-content > :first-child {
  margin-top: 0;
}

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

.message-rich-content p {
  margin: 0 0 14px;
  line-height: 1.9;
}

.message-rich-content strong {
  font-weight: 700;
}

.message-rich-content ul {
  margin: 0 0 14px;
  padding-left: 20px;
}

.message-rich-content li {
  margin: 6px 0;
  line-height: 1.85;
}

.message-rich-content code {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 0.92em;
}

.message-link {
  color: #3557da;
  text-decoration: none;
}

.message-link:hover,
.reference-source-link:hover {
  text-decoration: underline;
}

.message-image-wrapper {
  display: block;
  margin: 12px 0;
}

.message-image {
  display: block;
  max-width: min(100%, 620px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.message-table-wrap {
  margin: 16px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.message-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

.message-table th,
.message-table td {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  line-height: 1.75;
}

.message-table th:last-child,
.message-table td:last-child {
  border-right: 0;
}

.message-table tr:last-child td {
  border-bottom: 0;
}

.message-table th {
  background: var(--surface-soft);
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
  color: var(--text-soft);
  font-size: 12px;
}

.message-action {
  color: inherit;
}

.message-action-button {
  color: var(--accent);
  cursor: pointer;
}

.composer-dock {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding: 16px 28px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.98) 38%, #ffffff 100%);
}

.composer-card {
  max-width: 980px;
  margin: 0 auto;
  padding: 10px 12px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.message-input {
  width: 100%;
  min-height: 84px;
  max-height: 220px;
  padding: 8px 6px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  resize: none;
  outline: none;
}

.message-input::placeholder {
  color: var(--text-faint);
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
}

.composer-tip {
  margin: 0;
  color: var(--text-faint);
  font-size: 12px;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-action {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.voice-button,
.voice-playback-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--text-soft);
  background: #ffffff;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.voice-button-indicator {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
}

.voice-button.recording {
  color: #b42318;
  border-color: #fda29b;
  background: #fff1f0;
}

.voice-button.recording .voice-button-indicator {
  background: #ef4444;
  animation: voice-recording-pulse 1s ease-in-out infinite;
}

.voice-playback-button.active {
  color: #1d4ed8;
  border-color: #93c5fd;
  background: #eff6ff;
}

@keyframes voice-recording-pulse {
  50% {
    box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.16);
  }
}

.send-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4a7cf5 0%, #2563eb 100%);
  cursor: pointer;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.send-button:disabled,
.topbar-button:disabled,
.drawer-new-chat:disabled,
.composer-action:disabled {
  opacity: 0.58;
  cursor: default;
  transform: none;
}

.send-button-arrow {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid #ffffff;
}

.insight-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: #ffffff;
  overflow: hidden;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    border-color 180ms ease;
}

body.reference-collapsed .insight-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateX(18px);
  border-left-color: transparent;
}

.insight-panel-header {
  position: sticky;
  top: 0;
  z-index: 15;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.insight-tabs {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 56px;
}

.insight-tab {
  position: relative;
  padding: 0;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.insight-tab.active {
  color: var(--accent);
}

.insight-tab.active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -17px;
  left: 0;
  height: 2px;
  background: var(--accent);
}

.insight-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 16px 14px 18px;
}

.insight-section {
  display: block;
}

.insight-summary {
  margin: 0 0 12px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.7;
}

.reference-list,
.related-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reference-card,
.related-card,
.empty-reference {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(20, 30, 50, 0.05);
}

.reference-card-header,
.related-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.reference-card-id {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.reference-card-title,
.related-card-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
}

.reference-card-text,
.related-card-text {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

.reference-source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.reference-source-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
}

.reference-card-image {
  display: block;
  width: 100%;
  max-height: 240px;
  margin-top: 12px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  cursor: zoom-in;
}

.reference-inline-trigger {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  margin: 0 2px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  font-size: 0.92em;
  line-height: 1.6;
}

.reference-inline-trigger:hover {
  background: #ebe5ff;
}

.related-card-count {
  color: var(--text-faint);
  font-size: 12px;
  white-space: nowrap;
}

.related-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.related-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #f3f5fa;
  color: var(--text-soft);
  font-size: 12px;
}

.knowledge-placeholder {
  display: flex;
  min-height: 260px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 26px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: var(--surface-soft);
  text-align: center;
}

.knowledge-placeholder h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.knowledge-placeholder p {
  max-width: 260px;
  margin: 0;
  color: var(--text-soft);
  line-height: 1.8;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
}

.image-lightbox[hidden] {
  display: none !important;
}

.image-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 20, 34, 0.74);
  backdrop-filter: blur(4px);
}

.image-lightbox-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(100vw - 40px, 1200px);
  height: min(100vh - 40px, 900px);
  margin: 20px auto;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-lightbox-viewport {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.image-lightbox-viewport.dragging {
  cursor: grabbing;
}

.image-lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}

.image-lightbox-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(16, 24, 40, 0.25);
}

.reference-mask {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  pointer-events: none;
  background: rgba(16, 24, 40, 0.22);
}

.reference-mask[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.history-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 60;
  display: flex;
  width: 360px;
  max-width: 100%;
  height: 100vh;
  flex-direction: column;
  padding: 24px 22px;
  background: #ffffff;
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 36px rgba(20, 30, 50, 0.12);
  transform: translateX(100%);
  transition: transform 220ms ease;
}

body.drawer-open .history-drawer {
  transform: translateX(0);
}

.drawer-header,
.drawer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-header h3 {
  margin: 0;
  font-size: 16px;
}

.drawer-header p {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 12px;
}

.drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 24px;
  cursor: pointer;
}

.drawer-toolbar {
  margin: 18px 0;
}

.history-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.history-list {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}

.history-item,
.empty-history,
.loading-placeholder {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.history-item {
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.history-item.active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.history-item-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.history-item-preview,
.history-item-time,
.empty-history {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.history-item-time {
  margin-top: 8px;
}

.empty-history,
.empty-reference,
.loading-placeholder {
  text-align: center;
  color: var(--text-soft);
  line-height: 1.7;
}

.loading-placeholder {
  max-width: 760px;
  margin: 8vh auto 0;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .conversation-pane {
    border-right: 0;
  }

  .insight-panel {
    position: fixed;
    top: 76px;
    right: 0;
    bottom: 0;
    z-index: 50;
    width: min(100%, 410px);
    border-left: 1px solid var(--line);
    box-shadow: -10px 0 36px rgba(20, 30, 50, 0.12);
    transform: translateX(100%);
    transition: transform 220ms ease;
  }

  body.reference-open .insight-panel {
    transform: translateX(0);
  }

  .reference-mask {
    display: block;
  }

  .reference-mask:not([hidden]) {
    pointer-events: auto;
  }

  body.reference-open {
    overflow: hidden;
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 12px 14px;
  }

  .workspace {
    height: auto;
  }

  .conversation-scroll {
    padding: 16px 14px 8px;
  }

  .composer-dock {
    position: sticky;
    bottom: 0;
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .topbar-actions {
    position: fixed;
    top: 104px;
    right: 12px;
    z-index: 48;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: auto;
  }

  .topbar-button {
    position: relative;
    width: 58px;
    min-width: 58px;
    height: 58px;
    min-height: 58px;
    padding: 0;
    border-radius: 999px;
    box-shadow: 0 10px 24px rgba(20, 30, 50, 0.12);
    font-size: 0;
    overflow: hidden;
  }

  .topbar-button::after {
    content: attr(data-mobile-label);
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
  }

  .welcome-hero {
    min-height: calc(100vh - 360px);
    justify-content: flex-start;
    padding: 56px 12px 28px;
  }

  .welcome-hero h2 {
    font-size: 24px;
  }

  .hero-description {
    margin-top: 14px;
    font-size: 16px;
    line-height: 1.7;
  }

  .hero-avatar {
    width: 72px;
    height: 72px;
    margin-bottom: 14px;
  }

  .agent-avatar {
    width: 34px;
    height: 34px;
  }

  .agent-meta h1 {
    font-size: 14px;
  }

  .agent-meta p {
    font-size: 12px;
  }

  .conversation-pane {
    min-height: calc(100vh - 74px);
  }

  .message-stage {
    max-width: 100%;
  }

  .user-bubble {
    max-width: 92%;
    padding: 12px 14px;
    border-radius: 16px;
  }

  .assistant-shell {
    gap: 14px;
  }

  .assistant-heading,
  .process-title,
  .answer-card-title {
    font-size: 14px;
  }

  .process-panel {
    gap: 14px;
    padding-left: 2px;
  }

  .process-item {
    padding-left: 24px;
  }

  .process-detail,
  .message-rich-content p,
  .message-rich-content li {
    font-size: 14px;
    line-height: 1.75;
  }

  .answer-panel {
    padding-left: 24px;
  }

  .composer-card {
    padding: 8px 10px 10px;
    border-radius: 14px;
  }

  .message-input {
    min-height: 56px;
    max-height: 160px;
    padding-top: 6px;
    font-size: 16px;
  }

  .composer-footer {
    align-items: flex-end;
    gap: 10px;
  }

  .composer-tip {
    max-width: 46%;
    font-size: 11px;
    line-height: 1.5;
  }

  .composer-tools {
    flex: 1 1 auto;
    justify-content: flex-end;
  }

  .composer-action {
    min-height: 34px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 14px;
  }

  .send-button {
    width: 36px;
    height: 36px;
  }

  .message-actions {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .insight-panel {
    top: 74px;
    width: 100%;
  }

  .history-drawer {
    width: 100%;
    padding: 18px 14px;
  }

  .image-lightbox-dialog {
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
    margin: 10px auto;
    padding: 14px;
  }

  .image-lightbox-image {
    border-radius: 12px;
  }

  .image-lightbox-close {
    top: 2px;
    right: 2px;
  }
}

@media (max-width: 560px) {
  html,
  body,
  .app-shell {
    min-height: 100dvh;
  }

  body {
    overflow: hidden;
  }

  .topbar {
    height: 58px;
    min-height: 58px;
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 7px 10px;
  }

  .agent-profile {
    gap: 8px;
  }

  .agent-avatar {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  .agent-meta h1 {
    margin: 0;
    font-size: 14px;
  }

  .agent-meta p {
    display: none;
  }

  .topbar-actions {
    position: static;
    flex: 0 0 auto;
    flex-direction: row;
    gap: 4px;
    margin-left: auto;
  }

  .topbar-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    border-radius: 11px;
    box-shadow: none;
  }

  .topbar-button::after {
    font-size: 10px;
  }

  .welcome-hero {
    min-height: calc(100dvh - 298px);
    padding-top: 28px;
  }

  .workspace {
    height: calc(100dvh - 58px);
  }

  .conversation-pane {
    min-height: 0;
  }

  .conversation-scroll {
    padding: 14px 12px 8px;
  }

  .composer-dock {
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .composer-card {
    border-radius: 18px;
  }

  .message-input {
    min-height: 48px;
    padding: 5px 4px 0;
  }

  .composer-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-tip {
    max-width: none;
  }

  .composer-tools {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 7px;
  }

  .composer-action {
    min-height: 42px;
  }

  #focusReferenceButton {
    display: none;
  }

  .voice-button {
    grid-column: 1;
    min-width: 0;
    font-weight: 700;
  }

  .voice-playback-button {
    grid-column: 2;
    padding: 0 9px;
    font-size: 12px;
  }

  .send-button {
    grid-column: 3;
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .process-resource-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .reference-card,
  .related-card,
  .empty-reference,
  .history-item,
  .empty-history {
    padding: 12px;
  }
}

@media (max-width: 370px) {
  .agent-meta h1 {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
  }

  .topbar-button::after {
    font-size: 10px;
  }
}
