:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #fafbfc;
  --surface-muted: #f3f4f6;

  --fg: #111827;
  --fg-soft: #374151;
  --muted: #6b7280;

  --line: #e5e7eb;
  --line-strong: #d7dbe1;

  --user: #111827;
  --user-fg: #ffffff;

  --asst: #f7f8fa;
  --asst-fg: #111827;

  --danger: #b42318;
  --danger-soft: #fef3f2;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 4px 12px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 10px 28px rgba(16, 24, 40, 0.10);

  --radius-page: 12px;
  --radius-card: 14px;
  --radius-md: 12px;
  --radius-sm: 10px;

  --h-control: 36px;
  --h-control-lg: 44px;

  --content-max: 1040px;
  --sidebar-w: 288px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.92), rgba(245, 246, 248, 0.96) 36%, rgba(242, 244, 247, 1) 100%),
    var(--bg);
  color: var(--fg);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

img,
video,
canvas,
iframe {
  display: block;
  max-width: 100%;
}

pre,
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.clear-x.hidden,
.attach-menu.hidden,
.attach-preview.hidden,
.model-dropdown.hidden,
.top-model-quick-dropdown.hidden,
.top-role-quick-dropdown.hidden,
.float-nav.hidden,
.float-btn.hidden,
.code-preview.hidden {
  display: none;
}

.btn,
.input,
.select,
.textarea,
textarea {
  border: 1px solid rgba(229, 231, 235, 0.92);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.94);
  color: var(--fg);
  outline: none;
  transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease, color .18s ease, transform .14s ease;
}

.btn,
.iconbtn,
.attach-menu-item,
.attach-chip-btn,
.think-toggle-btn,
.clear-x,
.float-btn,
.session-del-btn,
.session-export-btn,
.code-copy-btn,
.code-toggle-btn,
.code-preview-btn,
.msg-action-btn,
.top-model-pill,
.top-role-pill,
.top-model-quick-item,
.top-role-quick-item {
  -webkit-tap-highlight-color: transparent;
}

.btn {
  height: var(--h-control);
  padding: 0 13px;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border-color: rgba(215, 219, 225, 0.9);
  background: rgba(255, 255, 255, 0.94);
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03), 0 6px 16px rgba(16, 24, 40, 0.04);
  font-weight: 600;
}

.btn:hover {
  background: #ffffff;
  border-color: #cfd5dd;
  box-shadow: 0 3px 10px rgba(16, 24, 40, 0.06);
}

.btn:active {
  transform: scale(0.985);
}

.btn.secondary {
  border-color: rgba(229, 231, 235, 0.98);
  background: rgba(255, 255, 255, 0.9);
  color: var(--fg);
}

.btn.secondary:hover {
  background: #fff;
  border-color: #d2d8e0;
}

.btn.danger {
  border-color: #f3cfca;
  color: var(--danger);
  background: rgba(255, 255, 255, 0.96);
}

.btn.danger:hover {
  background: var(--danger-soft);
  border-color: #e8bbb4;
}

.btn:disabled {
  opacity: .56;
  cursor: not-allowed;
  transform: none;
}

.input,
.select {
  height: var(--h-control);
  width: 100%;
  padding: 0 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.textarea {
  width: 100%;
  min-height: 132px;
  max-height: 280px;
  resize: vertical;
  padding: 10px 12px;
  font: inherit;
  line-height: 1.5;
}

.btn:focus-visible,
.input:focus,
.select:focus,
.textarea:focus,
textarea:focus,
.iconbtn:focus-visible,
.attach-menu-item:focus-visible,
.msg-action-btn:focus-visible,
.clear-x:focus-visible,
.top-model-pill:focus-visible,
.top-role-pill:focus-visible {
  border-color: #b8c0cc;
  box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.06);
}

label {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.app {
  display: flex;
  height: 100%;
  background: transparent;
}

.wrap {
  max-width: var(--content-max);
  margin: 0 auto;
}

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  padding: 14px;
  border-right: 1px solid rgba(229, 231, 235, 0.88);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(251, 251, 252, 0.9);
  backdrop-filter: blur(18px);
}

.side-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.side-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .1px;
  color: var(--fg);
}

.side-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.side-top-actions .btn {
  height: 34px;
  padding: 0 11px;
}

.session-list {
  flex: 1;
  overflow: auto;
  padding-right: 2px;
}

.session-item {
  position: relative;
  margin-bottom: 8px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .14s ease;
}

.session-item-main {
  flex: 1 1 auto;
  min-width: 0;
}

.session-item-text {
  flex: 1 1 auto;
  min-width: 0;
}

.session-item-title,
.session-item-preview {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-item-title {
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
  color: inherit;
}

.session-item-preview {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

.session-card-active .session-item-preview {
  color: #64748b;
}

.session-item-actions {
  flex: 0 0 auto;
  align-items: center;
  opacity: 0;
  transition: opacity .16s ease;
}

.session-item:hover .session-item-actions,
.session-card-active .session-item-actions,
.session-item:focus-within .session-item-actions {
  opacity: 1;
}

.session-item:hover {
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(229, 231, 235, 0.96);
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.06);
  transform: translateY(-1px);
}

.session-item.active {
  background: rgba(255, 255, 255, 0.96);
  border-color: #d7dde6;
  box-shadow: 0 10px 26px rgba(16, 24, 40, 0.08);
}

.session-title,
.session-preview {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding-right: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-title {
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
  color: var(--fg);
}

.session-preview {
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.session-item>.session-title,
.session-item>.session-preview {
  max-width: 100%;
}

.session-del-btn,
.session-export-btn {
  position: static;
  width: 26px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.04);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 1;
  transition: opacity .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}

.session-del-btn:hover {
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.session-export-btn:hover {
  background: rgba(17, 24, 39, 0.08);
  color: var(--fg);
}

.session-del-btn:active,
.session-export-btn:active {
  transform: scale(0.96);
}

.backdrop {
  display: none;
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(229, 231, 235, 0.72);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
}

.top-left-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.top-left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.iconbtn {
  display: none;
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(229, 231, 235, 0.95);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  white-space: nowrap;
  align-items: center;
  justify-content: center;
  font: inherit;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.04);
}

.iconbtn:hover {
  background: #fff;
  border-color: #cfd5dd;
}

.chat-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg);
}

.chat-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.top-meta-row .chat-sub {
  min-width: 0;
  flex: 1 1 auto;
}

.top-status {
  justify-self: center;
  max-width: 32vw;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  justify-self: end;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar .btn,
.topbar .iconbtn,
.topbar .top-model-pill,
.topbar .top-role-pill {
  height: 34px;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.05);
}

.topbar .btn,
.topbar .iconbtn {
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}

.top-model-pill,
.top-role-pill {
  appearance: none;
  -webkit-appearance: none;
  max-width: min(42vw, 200px);
  padding: 0 12px;
  border: 1px solid rgba(229, 231, 235, 0.96);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(10px);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}

.top-model-pill:hover,
.top-role-pill:hover {
  border-color: #cfd5dd;
  background: #fff;
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.07);
}

.top-model-pill:active,
.top-role-pill:active {
  transform: scale(0.985);
}

.top-model-pill-text,
.top-role-pill-text {
  display: block;
  min-width: 0;
  max-width: 100%;
  font-size: 12px;
  line-height: 1;
  font-weight: 600;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-model-pill-caret,
.top-role-pill-caret {
  width: 0;
  height: 0;
  flex: 0 0 auto;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #6b7280;
}

.chat {
  flex: 1;
  overflow: auto;
  padding: 18px 16px 10px;
  background: transparent;
  contain: layout style paint;
  will-change: scroll-position;
}

.msg {
  display: flex;
  margin: 16px 0;
  contain: layout style paint;
}

.msg.user {
  justify-content: flex-end;
}

.msg-col {
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(78ch, 88%);
  min-width: 0;
}

.msg.user .msg-col {
  align-items: flex-end;
  margin-left: auto;
}

.msg.assistant .msg-col {
  align-items: flex-start;
  margin-right: auto;
}

.msg-col>.bubble {
  width: auto;
  max-width: 100%;
}

.bubble {
  max-width: min(78ch, 88%);
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 18px;
  white-space: pre-wrap;
  word-break: break-word;
  contain: content;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.05);
}

.bubble .md {
  white-space: normal;
}

.user .bubble {
  background: linear-gradient(180deg, #1b2430 0%, #111827 100%);
  color: var(--user-fg);
  border-color: rgba(17, 24, 39, 0.96);
  border-top-right-radius: 8px;
}

.assistant .bubble {
  background: rgba(255, 255, 255, 0.9);
  color: var(--asst-fg);
  border-color: rgba(229, 231, 235, 0.96);
  border-top-left-radius: 8px;
}

.msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
  margin-top: 0;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-2px);
  transition: max-height .18s ease, opacity .16s ease, margin-top .16s ease, transform .16s ease, visibility .16s ease;
}

.msg:hover .msg-actions,
.msg:focus-within .msg-actions {
  margin-top: 2px;
  max-height: 80px;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.msg.user .msg-actions {
  justify-content: flex-end;
}

.msg.assistant .msg-actions {
  justify-content: flex-start;
}

.msg-action-btn {
  appearance: none;
  -webkit-appearance: none;
  min-width: 30px;
  min-height: 30px;
  height: 30px;
  margin: 0;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.48);
  backdrop-filter: blur(8px);
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .16s ease, background .16s ease, border-color .16s ease, transform .16s ease;
}

.msg-action-btn:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(17, 24, 39, 0.05);
}

.msg-action-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  background: transparent;
  border-color: transparent;
}

.msg-action-btn.danger:hover {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.08);
  border-color: rgba(180, 35, 24, 0.10);
}

.composer {
  border-top: 1px solid rgba(229, 231, 235, 0.76);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(18px);
}

.composer-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.attachcol {
  order: 1;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.attach-menu-wrap {
  position: relative;
}

.composer .attachcol .btn,
#btnAttachMenu {
  height: var(--h-control-lg);
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

#composerInput {
  order: 2;
  flex: 1 1 320px;
  min-width: 0;
  width: auto;
  height: var(--h-control-lg);
  min-height: var(--h-control-lg);
  max-height: 180px;
  resize: vertical;
  padding: 11px 13px;
  border: 1px solid rgba(229, 231, 235, 0.98);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--fg);
  outline: none;
  font: inherit;
  line-height: 1.5;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 8px 18px rgba(16, 24, 40, 0.04);
}

#composerInput::placeholder {
  color: #9aa3af;
}

.sendcol {
  order: 3;
  flex: 0 0 98px;
  min-width: 98px;
  display: flex;
  align-items: stretch;
}

#btnSend {
  height: var(--h-control-lg);
  min-width: 88px;
  width: 100%;
  justify-content: center;
  border-color: #111827;
  background: linear-gradient(180deg, #1b2430 0%, #111827 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.16);
}

#btnSend:hover {
  background: linear-gradient(180deg, #273344 0%, #1a2434 100%);
  border-color: #1f2937;
}

#btnSend.danger {
  background: rgba(255, 255, 255, 0.96);
  color: var(--danger);
  border-color: #f0c9c4;
}

#btnSend.danger:hover {
  background: var(--danger-soft);
  border-color: #e5b4ad;
}

.attach-preview {
  order: 4;
  flex: 0 0 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 2px;
  padding: 2px 1px;
  max-height: 132px;
  overflow: auto;
  overscroll-behavior: contain;
}

.attach-menu {
  position: absolute;
  left: 0;
  bottom: calc(var(--h-control-lg) + 10px);
  min-width: 176px;
  padding: 8px;
  border: 1px solid rgba(229, 231, 235, 0.96);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 36px rgba(16, 24, 40, 0.12);
  backdrop-filter: blur(18px);
  z-index: 2500;
}

.attach-menu-item {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  text-align: left;
}

.attach-menu-item:hover {
  background: rgba(17, 24, 39, .04);
  border-color: rgba(17, 24, 39, .05);
}

.attach-menu-item:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid rgba(229, 231, 235, 0.96);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.05);
}

.attach-chip img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.attach-chip-name {
  max-width: 52vw;
  font-size: 12px;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-chip-meta {
  font-size: 12px;
  color: var(--muted);
}

.attach-chip-btn {
  height: 26px;
  padding: 0 9px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.attach-chip-btn:hover {
  color: var(--fg);
  background: var(--surface-soft);
}

.modal,
.preview-modal,
.shot-modal,
.cam-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(10px);
}

.modal {
  z-index: 200;
}

.shot-modal,
.cam-modal {
  z-index: 2600;
}

.preview-modal {
  z-index: 3000;
}

.modal.open,
.preview-modal.open,
.shot-modal.open,
.cam-modal.open {
  display: flex;
}

.panel,
.preview-panel,
.shot-panel,
.cam-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(229, 231, 235, 0.92);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.18);
  overflow: visible;
  backdrop-filter: blur(18px);
}

.panel {
  position: relative;
  z-index: 201;
  width: min(920px, 100%);
  overflow: visible;
}

.preview-panel {
  width: min(1200px, 96vw);
  height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
}

.preview-panel.fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

.shot-panel,
.cam-panel {
  width: min(980px, 96vw);
  height: min(80vh, 720px);
  display: flex;
  flex-direction: column;
}

.panel-head,
.preview-head,
.shot-head,
.cam-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(229, 231, 235, 0.78);
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(12px);
}

.panel-head {
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

.panel-head .h,
.preview-title,
.shot-title,
.cam-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
}

.panel-actions,
.preview-actions,
.shot-actions,
.cam-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Stitch composer layout overrides */
.composer .composer-wrap {
  align-items: stretch;
}

.composer .composer-wrap > .relative {
  width: 100%;
  min-width: 0;
}

.composer #composerInput {
  width: 100%;
  min-width: 100%;
  min-height: 76px;
  height: auto;
  max-height: 220px;
  padding: 16px 180px 16px 72px;
  resize: none;
}

.composer .composer-wrap > .relative > .absolute.right-3.bottom-3 > div {
  white-space: nowrap;
  flex: 0 0 auto;
}

.panel-body,
.shot-body,
.cam-body {
  padding: 14px;
  background: transparent;
  overflow: auto;
}

.panel-body {
  max-height: 76vh;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
  margin-right: 1px;
  margin-bottom: 1px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  clip-path: inset(0 round 0 0 20px 20px);
}

.help-content {
  width: 100%;
  max-width: 100%;
  margin: 0;
  border-radius: 14px;
  border: 1px solid rgba(229, 231, 235, 0.92);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: none;
}

.help-content .md {
  font-size: 14px;
  line-height: 1.68;
}

.preview-body {
  flex: 1;
  background: #fff;
}

.preview-frame,
.code-preview-frame {
  width: 100%;
  border: 0;
  background: #fff;
}

.preview-frame {
  height: 100%;
}

.code-preview {
  margin-top: 8px;
  min-height: 260px;
  max-height: 80vh;
  resize: vertical;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.code-preview-frame {
  height: 60vh;
  min-height: 260px;
}

.shot-video,
.cam-video {
  width: 100%;
  height: auto;
  max-height: 60vh;
  border-radius: 14px;
  background: #111827;
}

.shot-tip,
.cam-tip {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

#camModal[aria-hidden="true"],
#shotModal[aria-hidden="true"] {
  display: none !important;
}

#camModal[aria-hidden="false"],
#shotModal[aria-hidden="false"] {
  display: flex !important;
}

.section {
  padding: 12px 0 16px;
  border-bottom: 1px solid rgba(229, 231, 235, 0.8);
}

.section:last-child {
  border-bottom: none;
}

.section-title {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
}

.grid,
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.bubble .md> :first-child {
  margin-top: 0;
}

.bubble .md> :last-child {
  margin-bottom: 0;
}

.bubble .md p {
  margin: 8px 0;
}

.bubble .md a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(107, 114, 128, 0.55);
  text-underline-offset: 2px;
}

.bubble .md img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px 0;
  border-radius: 12px;
}

.bubble .md hr {
  margin: 12px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.bubble .md blockquote {
  margin: 10px 0;
  padding: 9px 11px;
  border-left: 3px solid #cfd5dd;
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.03);
}

.bubble .md h1,
.bubble .md h2,
.bubble .md h3 {
  margin: 12px 0 8px;
  line-height: 1.28;
  color: inherit;
}

.bubble .md h1 {
  font-size: 20px;
}

.bubble .md h2 {
  font-size: 17px;
}

.bubble .md h3 {
  font-size: 15px;
}

.bubble .md ul,
.bubble .md ol {
  margin: 8px 0;
  padding-left: 22px;
}

.bubble .md li+li {
  margin-top: 4px;
}

.bubble .md table {
  display: block;
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
  overflow: auto;
}

.bubble .md th,
.bubble .md td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.bubble .md thead th {
  background: rgba(17, 24, 39, 0.03);
  font-weight: 600;
}

.bubble .md code {
  font-size: 12.5px;
}

.bubble .md :not(pre)>code {
  padding: 1px 6px;
  border: 1px solid rgba(17, 24, 39, .08);
  border-radius: 8px;
  background: rgba(17, 24, 39, .04);
}

.bubble .md pre {
  position: relative;
  margin: 10px 0;
  padding: 12px;
  border: 1px solid #e3e7ee;
  border-radius: 14px;
  overflow: auto;
  background: #f6f8fb;
}

.user .bubble .md pre {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.16);
}

.user .bubble .md :not(pre)>code {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.bubble .md pre code {
  padding: 0;
  border: 0;
  background: transparent;
  white-space: pre;
}

.code-block-wrap {
  position: relative;
  display: block;
  width: 100%;
  margin: 10px 0;
}

.code-block-wrap pre {
  margin: 0;
  padding-top: 40px;
  overflow-x: auto;
  overflow-y: hidden;
}

.code-copy-btn,
.code-toggle-btn,
.code-preview-btn {
  position: absolute;
  top: 8px;
  z-index: 20;
  height: 26px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.8);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14);
}

.code-copy-btn {
  right: 8px;
}

.code-toggle-btn {
  right: 60px;
  z-index: 21;
}

.code-preview-btn {
  right: 112px;
  z-index: 21;
}

.code-copy-btn:hover,
.code-toggle-btn:hover,
.code-preview-btn:hover {
  background: rgba(17, 24, 39, 0.92);
}

.code-copy-btn:active,
.code-toggle-btn:active,
.code-preview-btn:active {
  transform: scale(0.97);
}

.code-block-wrap.collapsed pre {
  max-height: 220px;
  overflow: hidden;
}

.code-block-wrap.collapsed::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  pointer-events: none;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  background: linear-gradient(to bottom, rgba(246, 248, 251, 0), rgba(246, 248, 251, 1));
}

.mermaid {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid rgba(17, 24, 39, .08);
  border-radius: 12px;
  background: #fff;
  overflow: auto;
}

pre {
  overflow-x: auto;
  overflow-y: hidden;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 0;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 1000;
  max-width: min(92vw, 420px);
  padding: 11px 15px;
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.94);
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 16px 36px rgba(16, 24, 40, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-8px);
  transition: opacity .2s ease, transform .2s ease;
  backdrop-filter: blur(12px);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  background: rgba(22, 101, 52, 0.95);
}

.toast.error {
  background: rgba(180, 35, 24, 0.95);
}

.toast.info {
  background: rgba(17, 24, 39, 0.94);
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, .24);
  backdrop-filter: blur(8px);
}

.drop-overlay.open {
  display: flex;
}

.drop-box {
  width: min(520px, 92vw);
  padding: 24px 20px;
  border: 1px dashed #a4acb8;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  text-align: center;
  box-shadow: 0 24px 50px rgba(16, 24, 40, 0.14);
  backdrop-filter: blur(18px);
}

.drop-title {
  margin-bottom: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
}

.drop-sub {
  font-size: 13px;
  color: var(--muted);
}

.float-nav {
  position: fixed;
  right: 16px;
  bottom: calc(var(--float-safe-bottom, 16px) + env(safe-area-inset-bottom, 0px));
  z-index: 1600;
  display: flex;
  flex-direction: column;
  gap: 8px;
  touch-action: none;
  user-select: none;
}

.float-nav.dragging {
  cursor: grabbing;
}

.float-nav.dragging .float-btn {
  pointer-events: none;
}

.float-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(229, 231, 235, 0.96);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--fg);
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(16, 24, 40, 0.10);
  backdrop-filter: blur(10px);
}

.float-btn:hover {
  border-color: #cfd5dd;
  background: rgba(255, 255, 255, 0.98);
}

.float-btn-icon {
  font-size: 0;
  line-height: 0;
}

.float-btn-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  opacity: 0.92;
}

.float-btn-icon.prev::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5.5 10L10 5.5 14.5 10' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M10 14.25V5.75' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5.5 10L10 5.5 14.5 10' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M10 14.25V5.75' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain;
}

.float-btn-icon.next::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5.5 10L10 14.5 14.5 10' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M10 5.75v8.5' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5.5 10L10 14.5 14.5 10' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M10 5.75v8.5' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain;
}

.bubble.streaming .stream-live {
  display: block;
  max-width: 100%;
  line-height: 1.5;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  opacity: 0.95;
  scrollbar-width: none;
}

.bubble.streaming .stream-live::-webkit-scrollbar {
  display: none;
}

.model-picker {
  position: relative;
}

.model-dropdown {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 99999;
  width: 100%;
  max-height: min(360px, 48vh);
  overflow: auto;
  border: 1px solid rgba(229, 231, 235, 0.96);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 20px 46px rgba(16, 24, 40, 0.14);
  backdrop-filter: blur(18px);
  padding: 6px;
}

.model-opt {
  padding: 10px 11px;
  color: var(--fg);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 10px;
}

.model-opt:hover {
  background: #f6f7f9;
}

.model-opt.muted {
  color: var(--muted);
  cursor: default;
}

.clear-x {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 44px;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  font-size: 12px;
}

.clear-x:hover {
  color: var(--fg);
  border-color: #cfd5dd;
  background: var(--surface-soft);
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin: 10px 0 6px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.03);
}

.file-label-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user .bubble .file-label {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.user .bubble .file-label-name {
  color: rgba(255, 255, 255, 0.95);
}

.think-wrap {
  margin: 10px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.02);
}

.think-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  background: rgba(17, 24, 39, 0.03);
  color: var(--muted);
  font-size: 12px;
}

.think-title {
  font-weight: 700;
}

.think-toggle-btn {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.think-toggle-btn:hover {
  color: var(--fg);
  background: var(--surface-soft);
}

.think-wrap pre {
  margin: 0;
  padding: 10px 12px;
  border: 0;
  background: transparent;
}

.think-wrap.collapsed pre {
  display: none;
}

.user .bubble .think-wrap {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.user .bubble .think-head {
  background: rgba(0, 0, 0, 0.16);
  color: rgba(255, 255, 255, 0.76);
}

.user .bubble .think-toggle-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.92);
}

.bubble .md img.chat-img {
  width: auto;
  max-width: 220px;
  max-height: 160px;
  height: auto;
  object-fit: cover;
  cursor: zoom-in;
  border: 1px solid var(--line);
}

.bubble .md img.chat-img.expanded {
  max-width: 100%;
  max-height: none;
  object-fit: contain;
  cursor: zoom-out;
}

.top-model-quick-dropdown,
.top-role-quick-dropdown {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 99998;
  width: 240px;
  max-width: min(88vw, 320px);
  max-height: 52vh;
  overflow: auto;
  padding: 8px;
  border: 1px solid rgba(229, 231, 235, 0.96);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 52px rgba(16, 24, 40, 0.14);
  backdrop-filter: blur(18px);
}

.top-model-quick-head,
.top-role-quick-head {
  padding: 4px 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.top-model-quick-item,
.top-role-quick-item {
  width: 100%;
  min-height: 46px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  transition: background .16s ease, border-color .16s ease, transform .14s ease;
}

.top-model-quick-item:hover,
.top-role-quick-item:hover {
  background: rgba(17, 24, 39, 0.04);
  border-color: rgba(17, 24, 39, 0.05);
}

.top-model-quick-item.active,
.top-role-quick-item.active {
  background: rgba(17, 24, 39, 0.06);
  border-color: rgba(17, 24, 39, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.top-model-quick-item:active,
.top-role-quick-item:active {
  transform: scale(0.99);
}

.top-model-quick-item-title,
.top-role-quick-item-title {
  width: 100%;
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-model-quick-item-sub,
.top-role-quick-item-sub {
  font-size: 11px;
  color: var(--muted);
}

.top-model-quick-empty,
.top-role-quick-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 1080px) {
  .top-status {
    max-width: 28vw;
  }

  .wrap {
    max-width: 960px;
  }
}

@media (max-width: 860px) {

  .grid,
  .grid2 {
    grid-template-columns: 1fr;
  }

  .iconbtn {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: min(86vw, 320px);
    min-width: 0;
    transform: translateX(-104%);
    transition: transform .22s ease;
    border-right: 1px solid rgba(229, 231, 235, 0.92);
    box-shadow: 0 18px 48px rgba(16, 24, 40, 0.14);
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: rgba(251, 251, 252, 0.96);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    background: rgba(15, 23, 42, .24);
    backdrop-filter: blur(4px);
  }

  .backdrop.open {
    display: block;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0 10px;
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
  }

  .top-left-row {
    align-items: flex-start;
    gap: 8px;
  }

  .top-left {
    flex: 1 1 auto;
    gap: 2px;
  }

  .chat-title {
    font-size: 14px;
    line-height: 1.25;
  }

  .top-meta-row {
    justify-content: flex-start;
    gap: 6px;
    flex-wrap: nowrap;
    margin-top: 0;
    padding-left: 0;
  }

  .top-meta-row .chat-sub {
    flex: 0 1 auto;
    max-width: 30%;
    font-size: 11px;
    line-height: 1.2;
  }

  .top-status {
    display: none;
  }

  .top-actions {
    align-self: start;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .topbar .btn,
  .topbar .iconbtn,
  .topbar .top-model-pill,
  .topbar .top-role-pill {
    height: 32px;
    border-radius: 12px;
  }

  .topbar .btn,
  .topbar .iconbtn {
    padding: 0 10px;
    font-size: 12px;
  }

  .top-model-pill,
  .top-role-pill {
    flex: 0 0 auto;
    min-width: 0;
    width: auto;
    max-width: 108px;
    padding: 0 10px;
    gap: 6px;
  }

  .top-model-pill-text,
  .top-role-pill-text {
    font-size: 11px;
  }

  .top-model-quick-dropdown,
  .top-role-quick-dropdown {
    max-width: calc(100vw - 20px);
    max-height: min(56vh, 420px);
    padding: 6px;
    border-radius: 14px;
  }

  .top-model-quick-head,
  .top-role-quick-head {
    padding: 4px 6px 6px;
    font-size: 11px;
  }

  .top-model-quick-item,
  .top-role-quick-item {
    min-height: 42px;
    padding: 8px 9px;
    border-radius: 12px;
  }

  .top-model-quick-item-title,
  .top-role-quick-item-title {
    font-size: 12px;
  }

  .top-model-quick-item-sub,
  .top-role-quick-item-sub {
    font-size: 10px;
  }

  .chat {
    padding: 8px 8px 6px;
  }

  .wrap {
    max-width: 100%;
  }

  .msg {
    margin: 10px 0;
  }

  .msg-col {
    max-width: 96%;
    gap: 6px;
  }

  .bubble {
    max-width: 100%;
    padding: 10px 11px;
    border-radius: 16px;
    font-size: 14px;
  }

  .msg-actions {
    gap: 3px;
  }

  .msg-action-btn {
    min-width: 27px;
    min-height: 27px;
    height: 27px;
    padding: 0 6px;
    font-size: 11px;
    border-radius: 8px;
  }

  .composer {
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .composer-wrap {
    align-items: center;
    gap: 6px;
  }

  .attach-preview {
    order: 1;
    max-height: 88px;
  }

  .attachcol {
    order: 2;
    width: auto;
  }

  .composer .attachcol .btn,
  #btnAttachMenu {
    height: 38px;
    padding: 0 11px;
    font-size: 13px;
  }

  #composerInput {
    order: 3;
    flex: 1 1 auto;
    height: 38px;
    min-height: 38px;
    max-height: 108px;
    padding: 8px 10px;
    font-size: 14px;
    line-height: 1.45;
    resize: none;
    border-radius: 14px;
  }

  .sendcol {
    order: 4;
    flex: 0 0 88px;
    min-width: 88px;
  }

  #btnSend {
    height: 38px;
    min-width: 0;
    border-radius: 12px;
  }

  .attach-chip {
    gap: 6px;
    padding: 5px 8px;
  }

  .attach-chip-name {
    max-width: 36vw;
  }

  .attach-chip-meta,
  .attach-chip-btn {
    font-size: 11px;
  }

  .attach-chip-btn {
    height: 22px;
    padding: 0 7px;
  }

  .attach-menu {
    left: 0;
    right: auto;
    bottom: calc(38px + 8px);
    min-width: 156px;
  }

  .panel,
  .preview-panel,
  .shot-panel,
  .cam-panel {
    width: 100%;
    max-width: 100%;
    border-radius: 16px;
  }

  .panel-head,
  .preview-head,
  .shot-head,
  .cam-head {
    padding: 10px 12px;
  }

  .panel-body,
  .shot-body,
  .cam-body {
    padding: 10px;
  }

  .preview-actions,
  .shot-actions,
  .cam-actions,
  .panel-actions {
    gap: 6px;
    flex-wrap: wrap;
  }

  .preview-actions .btn,
  .shot-actions .btn,
  .cam-actions .btn,
  .panel-actions .btn {
    height: 34px;
    padding: 0 10px;
  }

  .float-nav {
    right: 12px;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  .session-del-btn,
  .session-export-btn {
    opacity: 1;
    width: 26px;
    height: 26px;
  }

  .session-item-actions {
    opacity: 1;
  }

  #miAttachShot {
    display: none;
  }

  #btnCamera {
    display: inline-flex;
    align-items: center;
  }

  #btnScreenshot {
    display: none;
  }
}

@media (max-width: 640px) {
  .side-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .side-top-actions {
    width: 100%;
  }

  .side-top-actions .btn {
    flex: 1 1 0;
  }

  .topbar {
    padding-left: 10px;
    padding-right: 10px;
    gap: 4px 8px;
  }

  .top-left-row {
    gap: 7px;
    align-items: center;
  }

  .iconbtn {
    height: 32px;
    padding: 0 9px;
    font-size: 13px;
  }

  .chat-title {
    font-size: 13px;
  }

  .top-meta-row {
    gap: 5px;
  }

  .top-meta-row .chat-sub {
    max-width: 24%;
    font-size: 10.5px;
    line-height: 1.15;
  }

  .top-model-pill,
  .top-role-pill {
    max-width: 94px;
    height: 24px;
    padding: 0 7px;
    border-radius: 10px;
  }

  .top-model-pill-text,
  .top-role-pill-text {
    font-size: 10px;
  }

  .top-actions .btn {
    height: 32px;
    padding: 0 9px;
    font-size: 12px;
  }

  .code-copy-btn,
  .code-toggle-btn,
  .code-preview-btn {
    height: 22px;
    padding: 0 7px;
    font-size: 11px;
  }

  .code-toggle-btn {
    right: 52px;
  }

  .code-preview-btn {
    right: 96px;
  }
}

@media (min-width: 861px) {

  #btnCamera,
  #btnScreenshot {
    display: inline-flex;
    align-items: center;
  }
}

@media (hover: none), (pointer: coarse) {
  .msg-actions {
    margin-top: 2px;
    max-height: 80px;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }
}

/* Final stitch composer polish */
.composer #composerInput {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  outline: none !important;
}

@media (max-width: 980px) {
  .composer .composer-wrap > .relative > .absolute.right-3.bottom-3 > div {
    display: none !important;
  }

  .composer #composerInput {
    padding-right: 72px !important;
  }
}

@media (min-width: 861px) {
  .sidebar {
    transition:
      width .22s ease,
      min-width .22s ease,
      padding .22s ease,
      border-color .22s ease,
      opacity .18s ease;
  }

  .sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-right-color: transparent !important;
    overflow: hidden;
  }

  .sidebar.collapsed > * {
    opacity: 0;
    pointer-events: none;
  }
}


/* Mobile adaptation pass (2026-04-10) */
@media (max-width: 860px) {
  html,
  body {
    overflow-x: clip;
  }

  aside.sidebar {
    z-index: 70 !important;
    width: min(82vw, 304px) !important;
    min-width: 0 !important;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    gap: 8px;
  }

  #sidebarBackdrop.backdrop {
    z-index: 60 !important;
  }

  header.topbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: start !important;
    align-content: start;
    gap: 8px !important;
    height: auto !important;
    min-height: 0 !important;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px !important;
  }

  header.topbar .top-left-row {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
  }

  header.topbar .top-left-row > div:last-child {
    min-width: 0;
  }

  header.topbar #chatTitle {
    font-size: 14px;
    line-height: 1.25;
  }

  header.topbar #chatSub {
    font-size: 11px;
    line-height: 1.2;
  }

  header.topbar .top-actions {
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  header.topbar .top-actions::-webkit-scrollbar {
    display: none;
  }

  header.topbar .top-actions > * {
    flex: 0 0 auto;
  }

  header.topbar .top-actions-divider {
    display: none !important;
  }

  header.topbar #topStatus {
    display: inline-flex !important;
    max-width: none;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 999px;
  }

  header.topbar #btnTopRoleQuick,
  header.topbar #btnTopModelQuick {
    max-width: none;
    min-width: 0;
    height: 32px;
    padding: 0 10px;
  }

  header.topbar #btnSettings {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  section.chat {
    padding: 0 !important;
  }

  #chatWrap {
    width: 100%;
    max-width: 100% !important;
    padding: 18px 12px 22px !important;
  }

  #chatWrap > :not([hidden]) ~ :not([hidden]) {
    margin-top: 18px !important;
  }

  .msg {
    margin: 12px 0;
  }

  .msg-col {
    max-width: 100%;
  }

  .bubble {
    max-width: 100%;
    font-size: 14px;
  }

  footer.composer {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  }

  footer.composer .composer-wrap {
    width: 100%;
    max-width: 100% !important;
    gap: 8px !important;
  }

  footer.composer .composer-wrap > .relative {
    width: 100%;
  }

  footer.composer #attachPreview {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  footer.composer #composerInput {
    min-height: 56px !important;
    max-height: 132px !important;
    padding: 14px 58px 14px 50px !important;
    font-size: 15px !important;
    line-height: 1.45 !important;
  }

  footer.composer .absolute.left-3.top-3\.5 {
    left: 10px !important;
    top: 10px !important;
  }

  footer.composer .absolute.right-3.bottom-3 {
    right: 10px !important;
    bottom: 10px !important;
  }

  footer.composer #btnAttachMenu,
  footer.composer #btnSend {
    width: 36px;
    height: 36px;
    padding: 0 !important;
  }
}

@media (max-width: 640px) {
  header.topbar {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  header.topbar .top-actions {
    gap: 6px !important;
  }

  header.topbar #topStatus {
    padding: 0 8px;
  }

  header.topbar #btnTopRoleQuick,
  header.topbar #btnTopModelQuick {
    max-width: 120px;
  }

  #chatWrap {
    padding: 16px 10px 20px !important;
  }

  #chatWrap > :not([hidden]) ~ :not([hidden]) {
    margin-top: 16px !important;
  }

  footer.composer {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  footer.composer #composerInput {
    padding-left: 48px !important;
    padding-right: 56px !important;
    font-size: 14px !important;
  }
}
