:root {
  color-scheme: light;
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
  font-synthesis: none;
  --ink: #18181b;
  --muted: #8b8f99;
  --faint: #b7bac2;
  --line: #e6e6e9;
  --panel: #ffffff;
  --soft: #f6f6f7;
  --success: #1d8b5b;
  --danger: #c44343;
  --sidebar-width: 292px;
  --content-width: 980px;
  --window-controls-inset: 148px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #f8f8f9;
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid #64676f;
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.drag-region {
  -webkit-app-region: drag;
}

.no-drag,
button,
input,
textarea {
  -webkit-app-region: no-drag;
}

.app-shell {
  display: flex;
  width: 100%;
  height: 100%;
}

/* The rail does not clip itself: each wide block below clips its own content
   while the sidebar animates, which lets the collapsed rail's tooltips extend
   past the 68px edge instead of being cut off. */
.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex: 0 0 var(--sidebar-width);
  flex-direction: column;
  width: var(--sidebar-width);
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  transition: flex-basis 260ms cubic-bezier(0.22, 1, 0.36, 1), width 260ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: flex-basis, width;
}

.sidebar-head {
  position: relative;
  display: flex;
  overflow: hidden;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  flex: 0 0 72px;
  padding: 18px 16px 12px 20px;
}

#collapseSidebar {
  position: absolute;
  top: 18px;
  right: 16px;
  transition: right 260ms cubic-bezier(0.22, 1, 0.36, 1), background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.brand-lockup,
.page-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.brand-lockup {
  padding-right: 48px;
  font-size: 18px;
  font-weight: 720;
}

.brand-lockup,
.sidebar-wide {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 130ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear;
  visibility: visible;
}

.icon-button {
  position: relative;
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.icon-button:hover {
  background: #f1f1f3;
}

.icon-button:active {
  transform: scale(0.96);
}

.icon-button svg,
button svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.9;
}

[data-tooltip]::after {
  position: absolute;
  z-index: 100;
  right: 0;
  bottom: calc(100% + 9px);
  width: max-content;
  max-width: 220px;
  padding: 7px 9px;
  border-radius: 6px;
  background: #202024;
  color: #fff;
  content: attr(data-tooltip);
  font-size: 12px;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 120ms ease, transform 120ms ease;
  white-space: nowrap;
}

[data-tooltip][data-tooltip-align="left"]::after {
  right: auto;
  left: 0;
}

[data-tooltip][data-tooltip-pos="bottom"]::after {
  top: calc(100% + 9px);
  bottom: auto;
  transform: translateY(-3px);
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

/* Collapsed-rail buttons sit at left: 15px and are 38px wide, so the tooltip
   starts 25px past them — 10px clear of the 68px rail — and reads beside the
   icon instead of stacking above it where there is no room. */
.sidebar-compact[data-tooltip]::after {
  top: 50%;
  right: auto;
  bottom: auto;
  left: calc(100% + 25px);
  transform: translate(-3px, -50%);
}

.sidebar-compact[data-tooltip]:hover::after,
.sidebar-compact[data-tooltip]:focus-visible::after {
  transform: translate(0, -50%);
}

.new-button {
  display: flex;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 44px;
  margin: 6px 16px 28px;
  border: 0;
  border-radius: 8px;
  background: #1d1d20;
  color: #fff;
  font-weight: 650;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

.new-button:hover {
  background: #303034;
}

.new-button:active {
  transform: translateY(1px);
}

.history-section {
  display: flex;
  overflow: hidden;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  padding: 0 12px;
}

.history-section h2 {
  margin: 0 8px 12px;
  color: #9a9da6;
  font-size: 13px;
  font-weight: 600;
}

.history-list {
  min-height: 0;
  flex: 1;
  overflow: auto;
}

.history-empty {
  display: grid;
  height: 100%;
  min-height: 220px;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: #a4a7af;
  font-size: 13px;
  text-align: center;
}

.history-empty svg {
  width: 28px;
  height: 28px;
  stroke-width: 1.5;
}

.history-row {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  gap: 9px;
  padding: 8px 38px 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.history-row:hover,
.history-row.active {
  background: #f1f1f3;
}

.history-row > svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: #737780;
}

.history-copy {
  min-width: 0;
  flex: 1;
}

.history-copy strong,
.history-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-copy strong {
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 560;
}

.history-copy small {
  color: #a0a3ab;
  font-size: 11px;
}

.history-delete {
  position: absolute;
  right: 5px;
  width: 30px;
  height: 30px;
  opacity: 0;
}

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

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

.sidebar-footer {
  position: relative;
  padding: 14px 14px 18px;
  border-top: 1px solid #eeeeef;
  transition: padding 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.config-button {
  display: flex;
  overflow: hidden;
  width: 100%;
  min-height: 54px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
  text-align: left;
}

.config-button:hover {
  border-color: #d6d6da;
  background: #f4f4f5;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #a7aab2;
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(29, 139, 91, 0.1);
}

.config-copy {
  min-width: 0;
  flex: 1;
}

.config-copy strong,
.config-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.config-copy strong {
  margin-bottom: 3px;
  font-size: 12px;
  font-weight: 650;
}

.config-copy small {
  color: #9498a1;
  font-size: 11px;
}

.config-endpoint {
  max-width: 92px;
  overflow: hidden;
  color: #747881;
  font-size: 11px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-compact {
  position: absolute;
  left: 15px;
  display: inline-grid;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.88);
  transition: opacity 120ms ease, transform 180ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 180ms;
  visibility: hidden;
}

#newConversationCompact {
  top: 78px;
}

#openConfigCompact {
  bottom: 18px;
}

.app-shell.sidebar-collapsed .sidebar {
  width: 68px !important;
  flex: 0 0 68px !important;
}

.app-shell.sidebar-collapsed .brand-lockup,
.app-shell.sidebar-collapsed .sidebar-wide {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px);
  transition: opacity 110ms ease, transform 180ms ease, visibility 0s linear 110ms;
  visibility: hidden;
}

.app-shell.sidebar-collapsed #collapseSidebar {
  right: 15px;
}

.app-shell.sidebar-collapsed .sidebar-compact {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  transition-delay: 120ms, 120ms, 120ms;
  visibility: visible;
}

.app-shell.sidebar-collapsed .sidebar-footer {
  margin-top: auto;
  padding: 12px 8px 18px;
}

.main-area {
  position: relative;
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  background: #fafafa;
}

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  height: 72px;
  flex: 0 0 72px;
  align-items: center;
  gap: 12px;
  padding: 13px var(--window-controls-inset) 9px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
}

.page-title {
  min-width: 0;
  flex: 1;
  font-size: 17px;
}

.page-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-menu {
  display: none;
}

.chat-viewport {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.empty-state {
  display: grid;
  width: min(720px, calc(100% - 48px));
  min-height: 100%;
  margin: 0 auto;
  padding: 44px 0 52px;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.empty-symbol {
  display: grid;
  width: 68px;
  height: 68px;
  margin-bottom: 18px;
  place-items: center;
  border: 1px solid #dedee2;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(24, 24, 27, 0.06);
}

.empty-symbol svg {
  width: 29px;
  height: 29px;
  stroke-width: 1.55;
}

.empty-state h1 {
  margin: 0 0 10px;
  font-size: 25px;
  line-height: 1.3;
}

.empty-state p {
  margin: 0;
  color: #8f939c;
  font-size: 14px;
}

.quick-prompts {
  display: flex;
  max-width: 100%;
  gap: 8px;
  margin-top: 30px;
  overflow-x: auto;
  padding: 2px;
}

.quick-prompts button {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid #e1e1e4;
  border-radius: 999px;
  background: #fff;
  color: #60636a;
  cursor: pointer;
  font-size: 13px;
}

.quick-prompts button:hover {
  border-color: #c8c9cd;
  color: var(--ink);
}

.message-list {
  width: min(var(--content-width), calc(100% - 48px));
  margin: 0 auto;
  padding: 34px 0 46px;
}

.message {
  margin-bottom: 32px;
}

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

.user-message-content {
  display: flex;
  max-width: min(76%, 720px);
  align-items: flex-end;
  flex-direction: column;
}

.user-bubble {
  max-width: 100%;
  padding: 13px 15px;
  border: 1px solid #e5e5e9;
  border-radius: 12px 12px 3px 12px;
  background: #f1f1f3;
  color: var(--ink);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.user-bubble p {
  margin: 0;
}

.user-message-actions {
  display: flex;
  margin-top: 7px;
}

.user-message-actions .message-action-button {
  height: 30px;
  padding: 0 9px;
  background: transparent;
  color: #777a82;
}

.message-reference-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  margin-bottom: 9px;
}

.message-reference-grid img {
  width: 104px;
  height: 76px;
  border: 1px solid #dcdce0;
  border-radius: 7px;
  background: #fff;
  object-fit: contain;
  cursor: zoom-in;
}

.assistant-message {
  width: 100%;
}

.assistant-text {
  margin: 0 0 13px;
  color: #54575e;
  font-size: 14px;
}

.assistant-message.error .assistant-text {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid #efd4d4;
  border-radius: 8px;
  background: #fff7f7;
  color: #a83d3d;
}

.assistant-message.pending .assistant-text {
  display: none;
}

.result-grid {
  display: grid;
  margin-left: 0;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-grid.single {
  grid-template-columns: minmax(0, 720px);
}

.result-figure {
  position: relative;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid #e2e2e5;
  border-radius: 8px;
  background: #fff;
}

.result-figure img {
  display: block;
  width: 100%;
  max-height: 680px;
  background: #f2f2f3;
  object-fit: contain;
  cursor: zoom-in;
}

.result-figure figcaption {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 7px 5px 11px;
  color: #7d8189;
  font-size: 11px;
}

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

.download-button {
  width: 32px;
  height: 32px;
}

.seed-chip {
  flex: 0 1 auto;
  min-width: 0;
  height: 26px;
  margin-left: auto;
  padding: 0 9px;
  overflow: hidden;
  border: 1px solid #e2e2e5;
  border-radius: 999px;
  background: #fafafa;
  color: #5f626a;
  cursor: pointer;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seed-chip:hover {
  border-color: #202024;
  color: #202024;
}

.request-details {
  margin: 12px 0 0;
  border-top: 1px solid #e6e6e8;
}

.request-details summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 0 5px;
  color: #858992;
  cursor: pointer;
  font-size: 12px;
}

.proof-grid {
  display: grid;
  gap: 7px 14px;
  padding: 8px 0 2px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.proof-item {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #8b8f98;
  font-size: 12px;
}

.proof-item strong {
  overflow: hidden;
  color: #3c3e43;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proof-item.wide {
  grid-column: 1 / -1;
}

.proof-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  padding: 6px 9px;
  border: 1px solid #cce5d8;
  border-radius: 999px;
  background: #f2fbf6;
  color: #22744f;
  font-size: 12px;
}

.proof-badge.transport {
  border-color: #dcdde1;
  background: #f7f7f8;
  color: #676a72;
}

.proof-badge.verified {
  border-color: #cce5d8;
  background: #f2fbf6;
  color: #22744f;
}

.proof-badge svg {
  width: 14px;
  height: 14px;
}

.generating-block {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 0;
  margin-bottom: 12px;
}

.generating-block strong,
.generating-block small {
  display: block;
}

.generating-block strong {
  margin-bottom: 4px;
  font-size: 13px;
}

.generating-block small {
  color: #8f939b;
  font-size: 12px;
}

.gen-status-pulse {
  position: relative;
  display: inline-block;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.gen-status-pulse::before,
.gen-status-pulse::after {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at center, #4b8dff 0%, #6aa4ff 60%, transparent 72%);
  content: "";
}

.gen-status-pulse::after {
  animation: status-ping 1400ms cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}

@keyframes status-ping {
  0% { transform: scale(0.55); opacity: 0.75; }
  70% { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}

.generating-grid {
  display: grid;
  margin-left: 0;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.generating-grid.single {
  grid-template-columns: minmax(0, 720px);
}

.gen-tile {
  position: relative;
  min-width: 0;
  aspect-ratio: 1 / 1;
  max-height: 680px;
  overflow: hidden;
  border: 1px solid #e2e6ef;
  border-radius: 8px;
  background: #f7f9fd;
}

.gen-tile-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, #9dbcf5 1px, transparent 1.6px);
  background-size: 15px 15px;
  -webkit-mask-image: radial-gradient(circle at center, #000 12%, rgba(0, 0, 0, 0.35) 55%, transparent 78%);
  mask-image: radial-gradient(circle at center, #000 12%, rgba(0, 0, 0, 0.35) 55%, transparent 78%);
  animation: gen-dots 1900ms ease-in-out infinite;
}

@keyframes gen-dots {
  0%, 100% { opacity: 0.35; transform: scale(0.98); }
  50% { opacity: 0.9; transform: scale(1); }
}

.gen-tile-sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.75) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: gen-sweep 1900ms ease-in-out infinite;
}

@keyframes gen-sweep {
  0% { transform: translateX(-100%); }
  60%, 100% { transform: translateX(100%); }
}

.gen-tile-core {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  color: #4b8dff;
  box-shadow: 0 4px 14px rgba(75, 141, 255, 0.22);
  transform: translate(-50%, -50%);
}

.gen-tile-core .spinner {
  width: 22px;
  height: 22px;
}

.spinner {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  animation: spin 800ms linear infinite;
}

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

.composer-dock {
  position: relative;
  z-index: 12;
  width: min(var(--content-width), calc(100% - 48px));
  flex: 0 0 auto;
  margin: 0 auto;
  padding: 0 0 22px;
}

.reference-strip {
  position: relative;
  display: flex;
  min-height: 88px;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 8px 56px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.reference-list {
  display: flex;
  min-width: 0;
  flex: 1;
  gap: 8px;
  overflow-x: auto;
}

.reference-card {
  position: relative;
  width: 104px;
  height: 70px;
  flex: 0 0 104px;
  overflow: hidden;
  border: 1px solid #dedee1;
  border-radius: 7px;
  background: #f5f5f6;
}

.reference-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}

.reference-card button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: rgba(24, 24, 27, 0.84);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease;
}

.reference-card:hover button,
.reference-card:focus-within button {
  opacity: 1;
}

.reference-card button svg {
  width: 14px;
  height: 14px;
}

.reference-count {
  position: absolute;
  top: 10px;
  right: 12px;
  color: #9a9da6;
  font-size: 12px;
}

.composer {
  min-height: 152px;
  border: 1px solid #dadade;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 26px rgba(24, 24, 27, 0.05);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.composer:focus-within {
  border-color: #babcc2;
  box-shadow: 0 10px 30px rgba(24, 24, 27, 0.08);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 92px;
  max-height: 190px;
  resize: none;
  padding: 18px 20px 8px;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}

.composer textarea::placeholder {
  color: #b9bcc4;
}

.composer-footer {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px 10px;
}

.composer-settings,
.composer-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.composer-settings {
  overflow: hidden;
}

.tool-button {
  border-color: #e5e5e8;
  background: #fff;
}

.tool-button.active {
  border-color: #1d1d20;
  background: #1d1d20;
  color: #fff;
}

.setting-chip {
  display: inline-flex;
  height: 34px;
  min-width: 0;
  align-items: center;
  padding: 0 11px;
  overflow: hidden;
  border: 1px solid #e4e4e7;
  border-radius: 999px;
  background: #fafafa;
  color: #56595f;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-button {
  border-color: #e2e2e5;
  background: #fff;
  box-shadow: 0 3px 9px rgba(24, 24, 27, 0.05);
}

.send-button {
  border-color: #202024;
  background: #202024;
  color: #fff;
}

.send-button:hover:not(:disabled) {
  background: #333337;
}

.send-button:disabled {
  border-color: #d3d4d8;
  background: #d3d4d8;
  color: #fff;
  cursor: not-allowed;
}

.drop-overlay {
  position: absolute;
  z-index: 20;
  inset: 0 0 22px;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 10px;
  border: 2px dashed #777a82;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  color: #404248;
  font-size: 13px;
  pointer-events: none;
}

.drop-overlay svg {
  width: 28px;
  height: 28px;
}

.composer-dock.dragging .drop-overlay {
  display: grid;
}

.settings-popover {
  position: fixed;
  z-index: 30;
  top: 12px;
  left: 12px;
  width: 330px;
  max-height: min(650px, calc(100vh - 24px));
  padding: 18px;
  overflow-y: auto;
  border: 1px solid #dedee2;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(24, 24, 27, 0.16);
}

.settings-popover section + section {
  margin-top: 20px;
}

.settings-popover h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  color: #8d919a;
  font-size: 13px;
  font-weight: 600;
}

.settings-popover h3 svg {
  width: 15px;
  height: 15px;
}

.segmented {
  display: grid;
  gap: 7px;
}

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

.segmented.three {
  grid-template-columns: repeat(3, 1fr);
}

.segmented button,
.ratio-grid button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f6f6f7;
  color: #9a9da6;
  cursor: pointer;
}

.segmented button {
  min-height: 48px;
  padding: 7px;
  font-size: 16px;
}

.segmented button strong,
.segmented button small {
  display: block;
}

.segmented button strong {
  font-size: 15px;
}

.segmented button small {
  margin-top: 2px;
  font-size: 10px;
}

.segmented button:hover,
.ratio-grid button:hover {
  border-color: #d8d8dc;
  color: #64676e;
}

.segmented button.active,
.ratio-grid button.active {
  border-color: #202024;
  background: #202024;
  color: #fff;
  box-shadow: 0 5px 12px rgba(24, 24, 27, 0.15);
}

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

.ratio-grid button {
  display: grid;
  min-width: 0;
  height: 60px;
  place-content: center;
  justify-items: center;
  gap: 5px;
  padding: 5px;
  font-size: 11px;
}

.ratio-grid button svg {
  width: 17px;
  height: 17px;
}

.ratio-grid button[hidden] {
  display: none;
}

.setting-hint {
  margin-left: auto;
  color: #b0b3ba;
  font-size: 11px;
  font-weight: 400;
}

.setting-textarea,
.setting-input {
  width: 100%;
  border: 1px solid #e2e2e5;
  border-radius: 8px;
  background: #f9f9fa;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  outline: none;
}

.setting-textarea {
  display: block;
  min-height: 66px;
  padding: 8px 10px;
  line-height: 1.45;
  resize: vertical;
}

.setting-input {
  height: 36px;
  padding: 0 10px;
  font-variant-numeric: tabular-nums;
}

.setting-textarea:focus,
.setting-input:focus {
  border-color: #202024;
  background: #fff;
}

.setting-link {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: #6b6e76;
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.seed-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.seed-row .icon-button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
}

.setting-note {
  margin: 7px 0 0;
  color: #a2a5ad;
  font-size: 11px;
  line-height: 1.5;
}

.model-hint {
  margin-top: 16px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f6f6f7;
  color: #74777f;
}

.ratio-shape {
  display: block;
  width: 19px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.ratio-shape.square { width: 15px; height: 15px; }
.ratio-shape.portrait { width: 11px; height: 17px; }
.ratio-shape.portrait.mid { width: 13px; height: 17px; }
.ratio-shape.landscape.mid { width: 18px; height: 14px; }
.ratio-shape.ultrawide { width: 23px; height: 10px; }

.modal-backdrop {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 24, 27, 0.42);
  backdrop-filter: blur(5px);
}

.config-modal {
  width: min(510px, 100%);
  max-height: calc(100vh - 48px);
  overflow: visible;
  border: 1px solid #dedee2;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 25px 70px rgba(10, 10, 12, 0.24);
}

.config-modal > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 24px 12px;
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: #979aa3;
  font-size: 11px;
  font-weight: 650;
}

.config-modal h2 {
  margin: 0;
  font-size: 20px;
}

.config-modal form {
  display: grid;
  gap: 16px;
  padding: 12px 24px 24px;
}

.config-modal label > span {
  display: block;
  margin-bottom: 7px;
  color: #56595f;
  font-size: 12px;
  font-weight: 620;
}

.config-modal input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #dcdce0;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.config-modal input:focus {
  border-color: #8f929a;
  box-shadow: 0 0 0 3px rgba(50, 52, 58, 0.08);
}

.config-modal label > small {
  display: block;
  margin-top: 6px;
  color: #9a9da5;
  font-size: 11px;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 48px;
}

.password-field button {
  position: absolute;
  top: 2px;
  right: 2px;
}

.config-feedback {
  min-height: 18px;
  color: #777b84;
  font-size: 12px;
}

.config-feedback.success { color: var(--success); }
.config-feedback.error { color: var(--danger); }

.config-modal footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 3px;
}

/* The login gate is modal by design: no dismiss control, so it sits above
   every other overlay and its single action stretches full width. */
.login-backdrop {
  z-index: 400;
  background: rgba(24, 24, 27, 0.62);
}

.login-backdrop .config-modal {
  width: min(420px, 100%);
}

.config-modal footer.login-footer {
  margin-top: 5px;
}

.config-modal footer.login-footer .primary-button {
  width: 100%;
}

.primary-button,
.secondary-button,
.clear-key-button {
  display: inline-flex;
  height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 620;
}

.primary-button {
  border: 1px solid #202024;
  background: #202024;
  color: #fff;
}

.secondary-button {
  border: 1px solid #dedee2;
  background: #fff;
}

.clear-key-button {
  margin-right: auto;
  border: 1px solid transparent;
  background: transparent;
  color: #a74444;
}

.clear-key-button:hover {
  background: #fff3f3;
}

.primary-button:disabled,
.secondary-button:disabled,
.clear-key-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.toast-region {
  position: fixed;
  z-index: 300;
  top: 70px;
  right: 22px;
  display: grid;
  width: min(340px, calc(100vw - 44px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid #dedee2;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(24, 24, 27, 0.16);
  color: #4e5158;
  font-size: 12px;
  animation: toast-in 180ms ease both;
}

.toast.error {
  border-color: #efd0d0;
  color: #a43e3e;
}

.toast svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

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

.message-action-button {
  display: inline-flex;
  height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid #dedee2;
  border-radius: 7px;
  background: #fff;
  color: #4d5057;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.message-action-button:hover {
  border-color: #bfc1c7;
  background: #f7f7f8;
  color: #202024;
}

.message-action-button.primary {
  border-color: #202024;
  background: #202024;
  color: #fff;
}

.message-action-button.primary:hover {
  background: #333337;
}

.message-action-button:disabled,
.message-action-button.primary:disabled,
.message-action-button:disabled:hover,
.message-action-button.primary:disabled:hover {
  border-color: #e5e5e8;
  background: #f5f5f6;
  color: #b0b3ba;
  cursor: not-allowed;
}

.message-action-button svg {
  width: 15px;
  height: 15px;
}

.error-details {
  margin: 10px 0 0;
  color: #9598a0;
  font-size: 11px;
}

.error-details summary {
  cursor: pointer;
}

.error-details p {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
}

.model-field > input {
  display: none;
}

.model-select {
  position: relative;
}

.model-select-button {
  display: flex;
  width: 100%;
  height: 44px;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  border: 1px solid #dcdce0;
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.model-select-button:hover,
.model-select.open .model-select-button {
  border-color: #9a9da5;
}

.model-select.open .model-select-button {
  box-shadow: 0 0 0 3px rgba(50, 52, 58, 0.08);
}

.model-option-icon {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #e3e3e6;
  border-radius: 6px;
  background: #f7f7f8;
  color: #555860;
}

.model-option-icon svg {
  width: 14px;
  height: 14px;
}

#modelSelectValue {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  font-size: 14px;
  font-weight: 580;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-select-chevron {
  width: 16px;
  height: 16px;
  color: #8d9098;
  transition: transform 140ms ease;
}

.model-select.open .model-select-chevron {
  transform: rotate(180deg);
}

.model-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 7px);
  right: 0;
  left: 0;
  max-height: 210px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid #dedee2;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(24, 24, 27, 0.17);
}

.model-menu button {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.model-menu button:hover,
.model-menu button[aria-selected="true"] {
  background: #f2f2f4;
}

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

.model-menu-check {
  width: 16px;
  height: 16px;
  color: #1f7a53;
}

.image-lightbox {
  position: fixed;
  z-index: 400;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: rgba(12, 12, 14, 0.94);
  color: #fff;
  backdrop-filter: blur(8px);
}

.lightbox-toolbar {
  display: flex;
  height: 62px;
  flex: 0 0 62px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 var(--window-controls-inset) 0 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.lightbox-toolbar > span {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-tools,
.lightbox-zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lightbox-tools {
  flex: 0 0 auto;
}

.lightbox-zoom-controls {
  gap: 5px;
}

#lightboxZoomLabel {
  width: 46px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.lightbox-tool-divider {
  width: 1px;
  height: 24px;
  margin: 0 2px;
  background: rgba(255, 255, 255, 0.14);
}

.lightbox-button {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.lightbox-button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.lightbox-button:disabled {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.28);
  cursor: not-allowed;
}

.lightbox-stage {
  min-height: 0;
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
}

.lightbox-stage[data-pannable="true"] {
  cursor: grab;
}

.lightbox-stage[data-panning="true"] {
  cursor: grabbing;
}

.lightbox-canvas {
  display: grid;
  width: max-content;
  height: max-content;
  min-width: 100%;
  min-height: 100%;
  padding: 22px;
  place-items: center;
  user-select: none;
}

.lightbox-stage img {
  display: block;
  max-width: none;
  max-height: none;
  object-fit: contain;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.34));
  -webkit-user-drag: none;
}

@media (max-width: 1000px) {
  :root { --content-width: 860px; }
  .message-list,
  .composer-dock { width: calc(100% - 32px); }
  .topbar { padding-left: 18px; }
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(292px, calc(100vw - 56px));
    flex-basis: auto;
    box-shadow: 18px 0 45px rgba(24, 24, 27, 0.14);
    transform: translateX(-105%);
    transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
  }
  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .app-shell.sidebar-collapsed .sidebar {
    width: min(292px, calc(100vw - 56px)) !important;
    max-width: none;
    flex: 0 0 auto !important;
  }
  .app-shell.sidebar-collapsed .brand-lockup,
  .app-shell.sidebar-collapsed .sidebar-wide {
    opacity: 1;
    pointer-events: auto;
    transform: none;
    visibility: visible;
  }
  .app-shell.sidebar-collapsed .sidebar-compact {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.88);
    visibility: hidden;
  }
  .app-shell.sidebar-collapsed .sidebar-footer { padding: 14px 14px 18px; }
  .app-shell.sidebar-collapsed #collapseSidebar { right: 16px; }
  .mobile-menu { display: inline-grid; }
  .topbar { padding-left: 12px; }
  .result-grid { grid-template-columns: 1fr; }
  .generating-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { padding-right: 134px; }
  .page-title strong { font-size: 15px; }
  .message-list,
  .composer-dock { width: calc(100% - 24px); }
  .message-list { padding-top: 24px; }
  .user-message-content { max-width: 92%; }
  .user-bubble { max-width: 100%; }
  .result-grid,
  .request-details,
  .proof-badge,
  .generating-block,
  .generating-grid,
  .message-actions,
  .error-details { margin-left: 0; }
  .proof-grid { grid-template-columns: 1fr; }
  .composer-dock { padding-bottom: 12px; }
  .composer { min-height: 140px; }
  .composer textarea { min-height: 82px; padding: 15px 15px 6px; }
  .setting-chip { max-width: 132px; padding: 0 9px; }
  .settings-popover { width: min(330px, calc(100vw - 24px)); }
  .empty-state { width: calc(100% - 28px); }
  .quick-prompts { justify-content: flex-start; }
}

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