:root {
  color-scheme: light;
  --app-safe-top: max(env(safe-area-inset-top), 0px);
  --bg: #ffffff;
  --bar: #ffffff;
  --pane: #f7f8fa;
  --pane-2: #ffffff;
  --line: #e3e6ea;
  --line-strong: #cdd3da;
  --text: #17202a;
  --muted: #66717e;
  --subtle: #8a95a3;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --ok: #16834a;
  --bad: #d92d20;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  width: 100%;
  max-width: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  color: var(--text);
  cursor: pointer;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 64px 1fr;
  min-width: 0;
}

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
}

.brand {
  min-width: 0;
}

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

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.quota-rings {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
}

.quota-ring {
  --quota: 0;
  --quota-color: var(--ok);
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 50%;
  background: conic-gradient(var(--quota-color) calc(var(--quota) * 1%), #e8ecf1 0);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.quota-ring::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--bar);
}

.quota-ring-value,
.quota-ring-label {
  position: relative;
  z-index: 1;
}

.quota-ring-label {
  display: none;
}

.desktop-download {
  height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.desktop-download:hover {
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.3);
  background: var(--accent-soft);
}

.desktop-update {
  min-height: 28px;
  border: 1px solid rgba(37, 99, 235, 0.24);
  border-radius: 7px;
  padding: 0 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
}

.desktop-update.bad {
  border-color: rgba(180, 35, 24, 0.24);
  background: #fff4f3;
  color: #b42318;
}

.brand p {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.appbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

.sync-pill {
  width: 76px;
  flex: 0 0 76px;
  text-align: center;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  contain: layout paint;
}

.sync-pill.online {
  color: var(--ok);
  border-color: rgba(87, 214, 141, 0.35);
}

.sync-pill.bad {
  color: var(--bad);
  border-color: rgba(255, 107, 107, 0.35);
}

.mobile-thread-status {
  display: none;
}

.icon-button, .small-button {
  height: 34px;
  border-radius: 7px;
  background: var(--pane-2);
  border: 1px solid var(--line);
  padding: 0 12px;
  white-space: nowrap;
}

.cluster-button.online {
  color: var(--ok);
  border-color: rgba(22, 131, 74, 0.28);
  background: rgba(22, 131, 74, 0.06);
}

.small-button {
  height: 28px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}

.projects-pane,
.conversation-pane {
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--pane);
}

.conversation-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-right: 0;
  background: var(--bg);
  width: 100%;
  overflow: hidden;
}

.pane-head {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.pane-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.project-list {
  height: calc(100vh - 108px);
  overflow: auto;
  padding: 8px;
}

.project-group {
  min-width: 0;
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
}

.project,
.thread {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  border-radius: 7px;
  background: transparent;
  padding: 10px;
}

.project-rename {
  align-self: center;
  width: 46px;
  padding: 0 8px;
  opacity: 0;
  transition: opacity 120ms ease, background 120ms ease;
}

.project-row:hover .project-rename,
.project-row:focus-within .project-rename {
  opacity: 1;
}

.project-divider {
  height: 1px;
  margin: 8px 4px;
  background: var(--line);
}

.project:hover,
.thread:hover {
  background: #eef1f5;
}

.project.active,
.thread.active {
  background: var(--accent-soft);
  outline: 1px solid #c8dafc;
}

.project-name,
.thread-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 6px;
}

.project-chevron {
  width: 12px;
  flex: 0 0 12px;
  color: var(--subtle);
  text-align: center;
  font-size: 15px;
  line-height: 1;
}

.project-thread-list {
  display: grid;
  gap: 2px;
  margin: 2px 0 6px 18px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.project-thread-list .thread {
  padding: 8px 9px;
}

.empty-list.compact {
  padding: 8px 10px;
  font-size: 12px;
}

.status-badge {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  display: grid;
  place-items: center;
}

.automation-clock {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  display: inline-grid;
  place-items: center;
  color: var(--subtle);
  font-size: 14px;
  line-height: 1;
}

.automation-clock.active {
  color: var(--accent);
}

.title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-meta,
.thread-preview,
.thread-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.thread-preview {
  color: #4f5b68;
}

.empty-list,
.empty-state {
  color: var(--muted);
  padding: 18px;
  line-height: 1.6;
}

.empty-state {
  display: grid;
  place-content: center;
  gap: 8px;
  min-height: 100%;
  text-align: center;
}

.loading-spinner {
  width: 26px;
  height: 26px;
  justify-self: center;
  border: 3px solid #d8dee8;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}

.mini-spinner {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border: 2px solid #cdd6e3;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
  will-change: transform;
}

.unread-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

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

.conversation-header {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bar);
}

.conversation-header h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.conversation-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.meta-pill {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
}

.automation-panel {
  display: grid;
  gap: 7px;
  margin-top: 9px;
  max-width: min(720px, 100%);
}

.automation-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.automation-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.automation-copy strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.automation-copy span,
.automation-copy small {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.run-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(87, 214, 141, 0.12);
}

.load-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.78;
}

.project.running,
.thread.running {
  box-shadow: inset 2px 0 0 rgba(87, 214, 141, 0.55);
}

.project.running .project-meta,
.thread.running .thread-meta {
  color: var(--ok);
}

.running-text {
  color: var(--ok);
}

.conversation-status {
  display: grid;
  gap: 5px;
  justify-items: end;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.messages {
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow: auto;
  padding: 18px 18px 28px;
}

.message {
  max-width: 920px;
  min-width: 0;
  width: 100%;
  margin: 0 auto 14px;
  display: grid;
  gap: 6px;
}

.message-role {
  color: var(--subtle);
  font-size: 12px;
}

.message-body {
  width: fit-content;
  max-width: min(760px, 100%);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--pane);
  line-height: 1.55;
}

.message-body p,
.message-body ul,
.message-body ol,
.message-body blockquote,
.message-body pre,
.message-body h1,
.message-body h2,
.message-body h3 {
  margin: 0 0 10px;
}

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

.message-body ul,
.message-body ol {
  padding-left: 20px;
}

.message-body li + li {
  margin-top: 4px;
}

.message-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  background: #f0f2f5;
  border: 1px solid #e0e4e9;
  border-radius: 5px;
  padding: 1px 5px;
}

.message-body pre {
  max-width: min(720px, calc(100vw - 56px));
  min-width: 0;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f6f8fa;
}

.message-body pre code {
  display: block;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  white-space: pre;
}

.message-body .markdown-table-wrap,
.document-preview-markdown .markdown-table-wrap {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.message-body table,
.document-preview-markdown table {
  width: max-content;
  min-width: min(100%, 420px);
  border-collapse: collapse;
  font-size: 0.94em;
}

.message-body th,
.message-body td,
.document-preview-markdown th,
.document-preview-markdown td {
  padding: 7px 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}

.message-body th:last-child,
.message-body td:last-child,
.document-preview-markdown th:last-child,
.document-preview-markdown td:last-child {
  border-right: 0;
}

.message-body tr:last-child td,
.document-preview-markdown tr:last-child td {
  border-bottom: 0;
}

.message-body th,
.document-preview-markdown th {
  background: #f4f6f9;
  font-weight: 650;
  color: var(--text);
}

.message-body td,
.document-preview-markdown td {
  color: var(--text);
}

.message-body .katex-display,
.document-preview-markdown .katex-display {
  max-width: 100%;
  margin: 10px 0 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0 6px;
}

.message-body .katex,
.document-preview-markdown .katex {
  font-size: 1.02em;
}

.math-fallback {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.markdown-mermaid {
  max-width: min(100%, 820px);
  margin: 10px 0 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.markdown-mermaid svg {
  display: block;
  max-width: none;
  min-width: min(100%, 360px);
  height: auto;
  margin: 0 auto;
}

.mermaid-loading,
.mermaid-error {
  color: var(--muted);
  font-size: 13px;
}

.mermaid-error {
  color: #b42318;
}

.mermaid-source {
  margin-top: 8px;
}

.message-body blockquote {
  padding-left: 10px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
}

.message-body h1,
.message-body h2,
.message-body h3 {
  font-size: 1em;
  line-height: 1.35;
}

.message-body a {
  color: var(--accent);
  text-decoration: none;
}

.message-body a:hover {
  text-decoration: underline;
}

.message-body .markdown-link-wrap {
  display: inline-flex;
  align-items: baseline;
  max-width: 100%;
  min-width: 0;
  gap: 4px;
  vertical-align: baseline;
}

.message-body .link-copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 0;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  text-decoration: none;
}

.message-body .link-copy-button:active {
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--accent-soft);
}

.message-body .markdown-file-link {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-width: 0;
  margin: 0 2px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--accent);
  vertical-align: baseline;
}

.message-body button.markdown-file-link {
  font: inherit;
  cursor: pointer;
}

.message-body button.markdown-file-link:hover {
  border-color: #b7c8de;
  background: #f8fbff;
}

.message-body .markdown-file-link:not(.image-link)::before {
  content: "文件";
  margin-right: 6px;
  color: var(--subtle);
  font-size: 11px;
}

.message-body .markdown-file-link.image-link {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.codex-directives {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.codex-directive {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  padding: 8px 9px;
  border: 1px solid #dfe6ee;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
}

.codex-directive-icon {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.codex-directive-copy {
  min-width: 0;
}

.codex-directive-copy strong {
  display: block;
  font-size: 13px;
}

.codex-directive-copy small {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.codex-directive a {
  white-space: nowrap;
  font-size: 12px;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  min-width: 0;
  gap: 8px;
  margin-top: 10px;
}

.message-image {
  width: 132px;
  margin: 0;
  display: grid;
  gap: 5px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.message-image a {
  display: block;
}

.message-image-button {
  display: block;
  width: 118px;
  height: 92px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--pane-2);
  overflow: hidden;
}

.message-image img {
  width: 118px;
  height: 92px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--pane-2);
}

.message-image figcaption,
.message-file {
  min-width: 0;
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
}

.message-image figcaption {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-file {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px 8px;
  max-width: min(360px, 100%);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.message-file-icon {
  grid-row: 1 / 3;
  align-self: start;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  line-height: 1;
  padding: 5px 6px;
}

.message-file-name,
.message-file-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-file-name {
  color: var(--text);
  font-size: 12px;
}

.message-file-meta {
  color: var(--subtle);
  font-size: 11px;
}

.message-file-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.message-file-actions .small-button {
  height: 26px;
  display: inline-grid;
  place-items: center;
  padding: 0 9px;
  color: var(--muted);
  text-decoration: none;
  background: var(--pane);
}

.message-file-actions .small-button:hover {
  color: var(--accent);
}

.message-file small {
  grid-column: 1 / -1;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--subtle);
  font-size: 11px;
  line-height: 1.35;
}

.codex-turn {
  max-width: 920px;
  min-width: 0;
  width: 100%;
  margin: 0 auto 14px;
  display: grid;
  gap: 8px;
}

.codex-turn-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.codex-turn-title {
  color: var(--subtle);
  font-size: 12px;
}

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

.process-details {
  width: min(760px, 100%);
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
  overflow: hidden;
}

.process-details summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 13px;
}

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

.process-details summary::before {
  content: "›";
  display: inline-block;
  margin-right: 7px;
  color: var(--subtle);
  transition: transform 120ms ease;
}

.process-details[open] summary::before {
  transform: rotate(90deg);
}

.process-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.process-item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) minmax(0, auto);
  gap: 8px;
  padding: 9px 12px;
  align-items: start;
}

.process-item + .process-item {
  border-top: 1px solid #edf1f6;
}

.process-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.process-item.thinking .process-dot {
  background: var(--ok);
}

.process-item.running .process-dot {
  animation: pulse 900ms ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.45;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.process-title {
  font-size: 13px;
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
}

.process-detail {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.process-detail p {
  margin: 0 0 6px;
}

.process-status {
  color: var(--subtle);
  font-size: 12px;
  min-width: 0;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.final-answer {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.message.user {
  justify-items: end;
}

.message.user .message-role {
  padding-right: 4px;
}

.message.user .message-body {
  background: #eaf1ff;
  border-color: #c8dafc;
}

.message.assistant .message-body {
  background: #ffffff;
}

.message.event .message-body {
  color: var(--muted);
  background: transparent;
}

.message-meta {
  color: var(--subtle);
  font-size: 12px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 10px;
  padding: 12px 18px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bar);
  min-width: 0;
  width: 100%;
}

.composer-tools,
.composer-input {
  min-width: 0;
  max-width: 100%;
  display: grid;
  gap: 8px;
}

.paste-catcher {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.composer-tools {
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 220px) minmax(0, 128px) max-content;
  align-items: center;
  justify-content: start;
}

.composer-tools select {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  height: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  min-width: 0;
}

.cluster-modal {
  position: fixed;
  inset: 0;
  z-index: 86;
  display: none;
}

.cluster-modal.open {
  display: block;
}

.cluster-modal.open .cluster-dialog {
  animation: previewSlideIn 180ms ease-out both;
}

.cluster-modal.closing .cluster-dialog {
  animation: previewSlideOut 170ms ease-in both;
}

.cluster-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.22);
}

.cluster-dialog {
  position: absolute;
  top: max(16px, var(--app-safe-top));
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(680px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  overscroll-behavior-x: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.22);
}

.cluster-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.cluster-head h2 {
  margin: 0;
  font-size: 18px;
}

.cluster-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.cluster-body {
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  background: #f7f9fc;
  overscroll-behavior: contain;
}

.cluster-body *,
.cluster-head * {
  box-sizing: border-box;
  max-width: 100%;
}

.cluster-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  min-width: 0;
}

.cluster-stat,
.cluster-node,
.cluster-gpu,
.cluster-pod,
.cluster-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.cluster-stat {
  padding: 11px;
  text-align: center;
}

.cluster-stat strong {
  display: block;
  font-size: 19px;
}

.cluster-stat span,
.cluster-node span,
.cluster-pod span,
.cluster-gpu span,
.gpu-meta,
.gpu-chart-stack span {
  color: var(--muted);
  font-size: 12px;
}

.cluster-section {
  margin-top: 16px;
}

.cluster-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.cluster-section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  min-width: 0;
}

.cluster-section-head h3 {
  margin: 0;
}

.cluster-chart-controls {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.cluster-chart-controls span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.cluster-chart-controls button {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
}

.cluster-chart-controls button:active {
  background: #eaf2ff;
  border-color: var(--accent);
}

.cluster-node-list,
.cluster-pod-list,
.cluster-gpu-list,
.cluster-pod-groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.cluster-pod-groups {
  gap: 12px;
}

.cluster-pod-group {
  display: grid;
  min-width: 0;
  max-width: 100%;
  gap: 7px;
}

.cluster-pod-group h4 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef5ff;
  color: var(--ink);
  font-size: 12px;
}

.cluster-pod-group h4 span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cluster-pod-group h4 em {
  display: inline-flex;
  min-width: 24px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
}

.cluster-node,
.cluster-pod {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(48px, max-content);
  align-items: start;
  gap: 10px;
  padding: 10px 11px;
}

.cluster-node > div,
.cluster-pod > div,
.cluster-gpu header > div {
  min-width: 0;
}

.cluster-node strong,
.cluster-node span,
.cluster-gpu strong,
.cluster-gpu span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cluster-pod strong,
.cluster-pod span {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cluster-node em,
.cluster-pod em,
.cluster-gpu em {
  display: block;
  color: var(--ok);
  font-style: normal;
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
  max-width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cluster-node.bad em,
.cluster-gpu.bad em {
  color: var(--bad);
}

.cluster-node.maintenance em,
.cluster-node.cordoned em {
  color: #a16207;
}

.cluster-node.excluded em,
.cluster-gpu.skipped em {
  color: var(--muted);
}

.cluster-node.maintenance,
.cluster-node.cordoned {
  background: #fffbeb;
  border-color: #fde68a;
}

.cluster-node.excluded,
.cluster-gpu.skipped {
  background: #f8fafc;
  border-color: #e5eaf1;
}

.cluster-gpu {
  padding: 11px;
}

.cluster-gpu header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(42px, max-content);
  align-items: start;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}

.gpu-bars {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.gpu-bars label {
  display: grid;
  gap: 4px;
}

.gpu-bars i {
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eaf1;
}

.gpu-bars i::before {
  content: "";
  display: block;
  width: calc(var(--value) * 1%);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.gpu-meta {
  margin-top: 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.gpu-process-empty {
  margin-top: 9px;
  padding: 8px 9px;
  border-radius: 7px;
  background: #f7f9fc;
  color: var(--subtle);
  font-size: 12px;
}

.gpu-processes {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  min-width: 0;
}

.gpu-processes-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.gpu-process {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}

.gpu-process strong,
.gpu-process span,
.gpu-process em,
.gpu-process-more {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.gpu-process strong {
  color: var(--ink);
}

.gpu-process em {
  color: var(--accent);
  font-style: normal;
}

.gpu-process-more {
  color: var(--muted);
}

.gpu-chart-stack {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  margin-top: 10px;
}

.gpu-chart-stack > div {
  min-width: 0;
  max-width: 100%;
}

.gpu-chart-stack span {
  display: block;
  margin-bottom: 4px;
}

.gpu-echart {
  width: 100%;
  max-width: 100%;
  height: 132px;
  overflow: hidden;
  border: 1px solid #e5eaf1;
  border-radius: 7px;
  background: #f8fafc;
}

.cluster-empty {
  padding: 16px;
  color: var(--muted);
}

.preview-modal.open {
  display: block;
}

.preview-modal.open .preview-dialog {
  animation: previewSlideIn 180ms ease-out both;
}

.preview-modal.closing .preview-dialog {
  animation: previewSlideOut 180ms ease-in both;
}

.preview-modal.closing .preview-backdrop {
  opacity: 0;
  transition: opacity 180ms ease;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
}

.preview-dialog {
  position: absolute;
  top: max(16px, var(--app-safe-top));
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(760px, calc(100vw - 32px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.22);
}

.preview-resize {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -5px;
  z-index: 3;
  width: 10px;
  cursor: ew-resize;
  touch-action: none;
}

.preview-resize::after {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 4px;
  width: 2px;
  border-radius: 999px;
  background: transparent;
  transition: background 120ms ease;
}

.preview-resize:hover::after,
body.preview-resizing .preview-resize::after {
  background: var(--accent);
}

body.preview-resizing {
  cursor: ew-resize;
  user-select: none;
}

body.viewport-changing .projects-pane,
body.viewport-changing .preview-dialog,
body.viewport-changing .cluster-dialog,
body.viewport-changing .mobile-backdrop {
  transition: none !important;
}

@media (pointer: coarse) and (min-width: 761px) {
  :root {
    --app-safe-top: max(env(safe-area-inset-top), 24px);
  }

  .preview-dialog {
    top: var(--app-safe-top);
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .preview-resize {
    left: -10px;
    width: 20px;
  }
}

@keyframes previewSlideIn {
  from {
    transform: translateX(24px);
    opacity: 0.72;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes previewSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(calc(100% + 24px));
    opacity: 0.72;
  }
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.preview-head h2 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.preview-head p {
  margin: 4px 0 0;
  max-width: min(72vw, 760px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

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

.preview-zoom-controls[hidden] {
  display: none;
}

.preview-zoom-label {
  min-width: 46px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.preview-actions .small-button {
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}

.preview-body {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--pane);
}

.pdf-preview {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.pdfjs-preview {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 100%;
  min-width: 0;
  background: #f8fafc;
}

.pdfjs-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
}

.pdfjs-counter,
.pdfjs-zoom {
  min-width: 52px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
}

.pdfjs-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
}

.pdfjs-stage {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: auto;
  padding: 14px;
  text-align: center;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}

.pdfjs-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: max-content;
}

.pdfjs-page {
  margin: 0;
  display: grid;
  justify-items: center;
  gap: 6px;
}

.pdfjs-page canvas {
  display: inline-block;
  max-width: none;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.pdfjs-page figcaption {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.document-preview-text {
  margin: 0;
  min-height: 100%;
  padding: 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  background: #fff;
  font: 14px/1.65 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.code-preview {
  min-height: 100%;
  background: #0f1720;
  color: #d8e2ef;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.code-preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 32, 0.96);
  color: #9fb1c6;
  font: 12px/1.4 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.code-preview-lines {
  margin: 0;
  padding: 10px 0 18px;
  overflow: auto;
}

.code-line {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  min-height: 21px;
  padding-right: 14px;
}

.code-line.highlighted {
  background: rgba(75, 142, 255, 0.22);
  box-shadow: inset 3px 0 0 #60a5fa;
}

.code-line-number {
  user-select: none;
  padding-right: 14px;
  color: #708196;
  text-align: right;
}

.code-line code {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.tok-keyword {
  color: #8cc7ff;
}

.tok-string {
  color: #a7e0a1;
}

.tok-number {
  color: #f6c177;
}

.tok-comment {
  color: #7d8da1;
}

.document-preview-markdown {
  min-height: 100%;
  padding: 24px 28px 48px;
  color: var(--text);
  background: #fff;
  font: 15px/1.7 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.document-preview-markdown h1,
.document-preview-markdown h2,
.document-preview-markdown h3 {
  margin: 1.1em 0 0.55em;
  line-height: 1.25;
  font-weight: 700;
}

.document-preview-markdown h1 {
  font-size: 24px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.document-preview-markdown h2 {
  font-size: 20px;
}

.document-preview-markdown h3 {
  font-size: 17px;
}

.document-preview-markdown p,
.document-preview-markdown ul,
.document-preview-markdown ol,
.document-preview-markdown blockquote,
.document-preview-markdown pre {
  margin: 0 0 14px;
}

.document-preview-markdown ul,
.document-preview-markdown ol {
  padding-left: 24px;
}

.document-preview-markdown li {
  margin: 4px 0;
}

.document-preview-markdown blockquote {
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: var(--soft);
  color: var(--muted);
}

.document-preview-markdown code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--soft);
  font: 0.92em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.document-preview-markdown pre {
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.document-preview-markdown pre code {
  padding: 0;
  border: 0;
  background: transparent;
}

.document-preview-markdown a {
  color: var(--accent);
  text-decoration: none;
}

.document-preview-markdown a:hover {
  text-decoration: underline;
}

.image-preview-pane {
  min-height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 18px;
  overflow: auto;
  overscroll-behavior: contain;
  background: #fff;
}

.image-preview-pane img {
  flex: 0 0 auto;
  max-width: 100%;
  max-height: calc(100vh - 130px);
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: pan-x pan-y;
}

.image-preview-pane.can-pan img {
  cursor: grab;
  touch-action: none;
}

.image-preview-pane.panning img {
  cursor: grabbing;
}

.video-preview-pane {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  place-items: center;
  padding: 18px;
  background: #0b0f17;
}

.video-preview-hint {
  justify-self: stretch;
  color: rgba(255, 255, 255, .86);
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
}

.video-preview-pane video {
  width: 100%;
  max-width: 100%;
  max-height: calc(100vh - 130px);
  object-fit: contain;
  border-radius: 8px;
  background: #000;
  border: 1px solid rgba(255, 255, 255, .16);
}

.preview-loading,
.preview-error,
.preview-warning {
  margin: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.preview-error {
  color: var(--bad);
}

.tool-button {
  min-height: 42px;
  border-radius: 8px;
  background: var(--pane-2);
  border: 1px solid var(--line);
  padding: 0 11px;
}

.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  min-height: 0;
}

.attachment-chips.has-attachments {
  padding-bottom: 2px;
}

.attachment-preview {
  position: relative;
  min-width: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--pane-2);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.image-preview {
  width: 82px;
  display: grid;
  gap: 4px;
  padding: 5px;
}

.image-preview img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--pane);
}

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

.file-preview {
  max-width: 260px;
  min-height: 42px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 5px 8px;
  align-items: center;
  padding: 7px 30px 7px 9px;
}

.file-icon {
  grid-row: 1 / 3;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  padding: 4px 6px;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.file-size {
  grid-column: 2;
  color: var(--subtle);
  font-size: 11px;
}

.attachment-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14);
}

select,
textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--pane-2);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 11px;
  min-width: 0;
}

.prompt-editor {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--line);
  background: var(--pane-2);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  outline: none;
}

.prompt-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--subtle);
  pointer-events: none;
}

.prompt-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.prompt-editor img {
  max-width: 120px;
  max-height: 90px;
  object-fit: contain;
}

textarea {
  min-height: 42px;
  max-height: 140px;
  resize: vertical;
}

#send {
  min-height: 42px;
  border-radius: 8px;
  background: #1f2937;
  border: 1px solid #111827;
  color: #ffffff;
  font-weight: 650;
}

#send.interrupt {
  background: #ffffff;
  border-color: #d0d7de;
  color: #b42318;
}

.interrupt-divider {
  max-width: 920px;
  width: 100%;
  margin: 14px auto;
  display: grid;
  grid-template-columns: minmax(24px, 1fr) auto minmax(24px, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--subtle);
  font-size: 12px;
}

.interrupt-divider::before,
.interrupt-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.automation-divider,
.heartbeat-divider {
  max-width: 920px;
  width: 100%;
  margin: 14px auto;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.automation-divider-copy,
.heartbeat-divider-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.automation-divider-copy strong,
.heartbeat-divider-copy strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
}

.automation-divider-copy span,
.heartbeat-divider-copy span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.45;
}

.login {
  width: min(420px, calc(100vw - 32px));
  margin: 18vh auto 0;
  display: grid;
  gap: 12px;
}

.login h1 {
  margin: 0;
  font-size: 22px;
}

.login #error {
  color: var(--bad);
}

@media (max-width: 1180px) {
  :root {
    --app-safe-top: max(env(safe-area-inset-top), 22px);
    --mobile-top: calc(74px + var(--app-safe-top));
    --drawer-total: min(92vw, 420px);
  }

  body {
    overflow: hidden;
  }

  .app-shell {
    width: 100vw;
    overflow: hidden;
    height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .appbar {
    min-height: var(--mobile-top);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    gap: 7px;
    padding: var(--app-safe-top) 12px 8px;
  }

  .brand h1,
  .brand p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-title {
    gap: 7px;
  }

  .desktop-download {
    display: none;
  }

  .quota-rings {
    gap: 4px;
    min-height: 24px;
  }

  .quota-ring {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
    font-size: 9px;
  }

  .quota-ring::after {
    inset: 3px;
  }

  .appbar-actions {
    width: 100%;
    gap: 7px;
    overflow: hidden;
  }

  .mobile-menu-button {
    flex: 0 0 86px;
    width: 86px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-inline: 8px;
  }

  .mobile-thread-status {
    display: inline-flex;
    flex: 0 0 64px;
    width: 64px;
    justify-content: center;
    padding-inline: 6px;
  }

  #runningSummary {
    display: none;
  }

  #commandStatus {
    display: none;
  }

  #sync {
    width: 54px;
    flex-basis: 54px;
  }

  #automation {
    display: none;
  }

  #clusterToggle {
    width: 54px;
    flex: 0 0 54px;
    padding-inline: 7px;
  }

  .workspace {
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    position: relative;
  }

  .projects-pane {
    position: fixed;
    top: var(--mobile-top, 64px);
    bottom: 0;
    z-index: 30;
    left: 0;
    width: var(--drawer-total);
    transform: translateX(calc(-1 * var(--drawer-total) - 16px));
    transition: transform 160ms ease;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  body.menu-open .projects-pane {
    transform: translateX(0);
  }

  .mobile-backdrop {
    display: none;
    position: fixed;
    inset: var(--mobile-top, 64px) 0 0;
    z-index: 20;
    background: rgba(15, 23, 42, 0.24);
  }

  body.menu-open .mobile-backdrop {
    display: block;
  }

  .project-list {
    height: calc(100dvh - var(--mobile-top, 64px) - 44px);
    max-height: none;
  }

  .project-list {
    display: block;
    overflow: auto;
  }

  .project {
    min-width: 0;
  }

  .project-rename {
    opacity: 1;
    width: 42px;
  }

  .conversation-pane {
    min-height: 0;
    max-width: 100vw;
    width: 100vw;
    min-width: 0;
    overflow: hidden;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 68px;
    gap: 8px;
    padding: 9px 10px max(9px, env(safe-area-inset-bottom));
  }

  .composer-tools {
    grid-template-columns: minmax(0, 1fr) minmax(92px, 0.58fr) auto;
  }

  select,
  textarea,
  input,
  .tool-button,
  #send {
    border-radius: 7px;
    padding: 9px 9px;
    font-size: 14px;
  }

  .tool-button,
  #send {
    min-height: 40px;
  }

  .conversation-header {
    min-height: auto;
    padding: 10px 12px;
    gap: 8px;
  }

  .conversation-header h2 {
    font-size: 16px;
  }

  .conversation-header p {
    font-size: 12px;
    max-height: 2.8em;
    overflow: hidden;
  }

  .meta-row {
    gap: 5px;
    margin-top: 6px;
  }

  .meta-pill {
    max-width: 170px;
  }

  .messages {
    padding: 12px 10px 18px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .message {
    margin-bottom: 11px;
  }

  .message-body {
    width: auto;
    max-width: 100%;
    border-radius: 7px;
    padding: 9px 10px;
    font-size: 14px;
  }

  .message-body pre {
    max-width: 100%;
  }
}

@media (max-width: 760px) {
  :root {
    --app-safe-top: max(env(safe-area-inset-top), 24px);
    --mobile-top: calc(82px + var(--app-safe-top));
    --drawer-total: 94vw;
  }

  .appbar {
    height: auto;
    min-height: var(--mobile-top);
    padding: var(--app-safe-top) 10px 8px;
    min-width: 0;
  }

  .brand {
    min-width: 0;
  }

  .brand-title {
    gap: 6px;
  }

  .quota-ring {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
    font-size: 8px;
  }

  .brand p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .appbar-actions {
    gap: 5px;
    min-width: 0;
    flex-shrink: 1;
  }

  .mobile-menu-button {
    flex-basis: 76px;
    width: 76px;
    padding-inline: 5px;
  }

  .mobile-thread-status {
    flex-basis: 48px;
    width: 48px;
    padding-inline: 4px;
  }

  .sync-pill {
    padding: 5px 5px;
    font-size: 11px;
  }

  #runningSummary {
    display: none;
  }

  #commandStatus {
    display: none;
  }

  #automation {
    display: none;
  }

  #sync {
    width: 48px;
    flex-basis: 48px;
  }

  #refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    min-width: 38px;
    padding-inline: 5px;
    overflow: hidden;
    text-overflow: clip;
  }

  #clusterToggle {
    width: 40px;
    min-width: 40px;
    flex-basis: 40px;
    padding-inline: 5px;
  }

  .cluster-dialog {
    top: var(--app-safe-top);
    right: 0;
    bottom: 0;
    width: 100dvw;
    max-width: 100dvw;
    box-sizing: border-box;
    border-radius: 10px 0 0 10px;
  }

  .cluster-head {
    padding: 12px 12px;
  }

  .cluster-body {
    padding: 8px;
  }

  .cluster-summary {
    gap: 5px;
  }

  .cluster-stat {
    min-width: 0;
    padding: 7px 5px;
  }

  .cluster-stat strong {
    font-size: 15px;
  }

  .cluster-section {
    margin-top: 12px;
  }

  .cluster-node,
  .cluster-pod,
  .cluster-gpu {
    padding: 8px;
  }

  .cluster-node,
  .cluster-pod {
    grid-template-columns: minmax(0, 1fr) minmax(44px, max-content);
    gap: 7px;
  }

  .cluster-node strong,
  .cluster-node span,
  .cluster-pod strong,
  .cluster-pod span,
  .cluster-gpu strong,
  .cluster-gpu span,
  .gpu-meta,
  .gpu-chart-stack span {
    font-size: 11px;
  }

  .cluster-gpu header {
    gap: 7px;
    margin-bottom: 8px;
  }

  .gpu-chart-stack {
    gap: 8px;
    margin-top: 8px;
  }

  .gpu-echart {
    height: 116px;
  }

  .brand h1 {
    font-size: 15px;
  }

  .brand p {
    font-size: 11px;
    margin-top: 3px;
  }

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

  .conversation-status {
    flex: 0 0 auto;
    justify-items: end;
    gap: 2px;
    font-size: 11px;
    max-width: 78px;
    overflow: hidden;
  }

  .conversation-status span {
    max-width: 78px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .conversation-title {
    min-width: 0;
    flex: 1 1 auto;
  }

  .conversation-header h2 {
    max-width: 100%;
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .conversation-header p {
    display: none;
  }

  .conversation-header .meta-row {
    display: none;
  }

  .conversation-header .automation-panel {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    max-width: 100%;
    min-height: 22px;
  }

  .conversation-header .automation-panel::after {
    content: attr(data-extra);
    display: none;
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 10px;
    line-height: 1;
    padding: 2px 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
  }

  .conversation-header .automation-panel[data-extra]:not([data-extra=""])::after {
    display: inline-flex;
  }

  .conversation-header .automation-item {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 6px;
    border-radius: 999px;
    background: #f8fafc;
  }

  .conversation-header .automation-item:not(:first-child) {
    display: none;
  }

  .conversation-header .automation-copy {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .conversation-header .automation-copy strong {
    max-width: min(42vw, 220px);
    font-size: 11px;
    line-height: 1.15;
  }

  .conversation-header .automation-copy span {
    flex: 0 1 auto;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow-wrap: normal;
    font-size: 10px;
    line-height: 1;
  }

  .conversation-header .automation-copy small {
    display: none;
  }

  .messages {
    padding-top: 8px;
  }

  .message,
  .codex-turn,
  .process-details,
  .final-answer,
  .message-body {
    max-width: 100%;
  }

  .message.user .message-body,
  .message.assistant .message-body,
  .message.event .message-body,
  .final-answer .message-body {
    width: auto;
    justify-self: stretch;
  }

  .message-body pre code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .composer {
    grid-template-columns: 1fr 62px;
    max-width: 100vw;
    overflow: hidden;
  }

  .composer-tools {
    grid-template-columns: minmax(0, 1fr) minmax(70px, 0.52fr) 48px;
    grid-column: 1 / -1;
  }

  #attach {
    min-height: 34px;
    white-space: nowrap;
    padding-inline: 6px;
  }

  .composer-input {
    grid-column: 1;
  }

  .attachment-chips {
    gap: 7px;
  }

  .image-preview {
    width: 74px;
    padding: 4px;
  }

  .image-preview img {
    width: 64px;
    height: 64px;
  }

  .file-preview {
    max-width: 100%;
  }

  .preview-dialog {
    top: var(--app-safe-top);
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    border-radius: 0;
    border: 0;
  }

  .preview-resize {
    display: none;
  }

  .preview-head {
    align-items: stretch;
    gap: 8px;
    padding: 9px 10px;
  }

  .preview-head h2 {
    max-width: 58vw;
    font-size: 14px;
  }

  .preview-head p {
    max-width: 58vw;
  }

  .preview-actions {
    gap: 6px;
  }

  .preview-actions .small-button {
    height: 30px;
    padding-inline: 8px;
  }

  .document-preview-text {
    padding: 12px;
    font-size: 13px;
    line-height: 1.6;
  }

  .pdfjs-toolbar {
    justify-content: flex-start;
    gap: 6px;
    padding: 7px 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .pdfjs-toolbar .small-button {
    flex: 0 0 auto;
    height: 30px;
    padding-inline: 9px;
  }

  .pdfjs-stage {
    padding: 10px;
  }

  .pdfjs-pages {
    gap: 12px;
  }

  .code-preview {
    font-size: 12px;
  }

  .code-preview-toolbar {
    padding: 7px 10px;
  }

  .code-line {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .code-line-number {
    padding-right: 10px;
  }

  .pane-head {
    height: 40px;
  }

  .project-list {
    height: calc(100dvh - var(--mobile-top) - 40px);
  }

  .project,
  .thread {
    padding: 11px 10px;
  }

  .thread-title,
  .project-name {
    font-size: 14px;
  }

  .thread-preview,
  .thread-meta,
  .project-meta {
    font-size: 11px;
  }
}

@media (min-width: 1181px) {
  .mobile-menu-button,
  .mobile-backdrop {
    display: none;
  }
}
