:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #14171b;
  --surface-2: #1d2228;
  --surface-3: #0f1216;
  --line: #2b333d;
  --text: #edf2f7;
  --muted: #94a3b3;
  --accent: #3ddc97;
  --accent-2: #62a9ff;
  --danger: #ff6b6b;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --surface-3: #f8fafc;
  --line: #d7dee8;
  --text: #111827;
  --muted: #607084;
  --accent: #18b981;
  --accent-2: #2563eb;
  --shadow: 0 18px 42px rgba(23, 35, 52, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--app-height, 100dvh);
  height: var(--app-height, 100dvh);
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 13px;
  background: var(--accent);
  color: #07120e;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

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

@media (hover: hover) and (pointer: fine) {
  button:hover {
    filter: brightness(1.04);
  }
}

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 18%, transparent);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 16px;
  min-height: 0;
  padding: 20px 16px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-kicker {
  color: var(--accent);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.05;
}

.brand-title {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
}

.brand-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-theme {
  width: 38px;
  height: 38px;
  color: var(--text);
  border-color: var(--line);
  background: var(--surface-2);
}

.new-chat,
.settings-button,
.wide {
  width: 100%;
}

.sidebar-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
}

.sidebar-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.conversation-list {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  overflow: auto;
}

.conversation-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  gap: 6px;
  align-items: center;
  width: 100%;
  padding: 7px 8px 7px 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.conversation-item:hover,
.conversation-item.active {
  background: var(--surface-2);
  border-color: var(--line);
}

.conversation-item.archived {
  opacity: .72;
}

.conversation-main {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.conversation-main:hover,
.conversation-main:focus:not(:focus-visible) {
  filter: none;
  background: transparent;
  box-shadow: none;
}

.conversation-main strong,
.conversation-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-main strong {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.conversation-main strong em {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
}

.conversation-main span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.conversation-edit {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  opacity: 0;
}

.conversation-item:hover .conversation-edit,
.conversation-item.active .conversation-edit,
.conversation-edit:focus-visible {
  opacity: 1;
}

.conversation-edit:hover {
  border-color: var(--line);
  background: var(--surface-3);
  color: var(--text);
}

.sidebar-bottom {
  display: grid;
  gap: 8px;
}

.sidebar-limits {
  min-height: 0;
}

.server-mini {
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
}

.server-mini header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.server-mini header strong {
  font-size: 13px;
}

.server-mini header span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
}

.server-mini.warn header span {
  color: #f6b44b;
}

.server-mini section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.server-mini section div {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 6px 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface) 62%, var(--surface-3));
}

.server-mini section span,
.server-active,
.server-error {
  color: var(--muted);
  font-size: 10px;
}

.server-mini section strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.server-active {
  display: grid;
  gap: 2px;
}

.server-active span,
.server-error {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.limit-mini {
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
}

.limit-mini.compact {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
}

.limit-mini > span {
  color: var(--muted);
  font-size: 12px;
}

.limit-mini section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.limit-mini section div {
  display: grid;
  gap: 1px;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.limit-mini span,
.limit-mini small {
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.limit-mini strong {
  font-size: 13px;
}

.limit-mini.compact .tiny-button {
  width: auto;
  align-self: stretch;
  padding: 0 8px;
  font-size: 10px;
}

.chat-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 84%, var(--surface));
}

.chat-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-kicker {
  color: var(--muted);
  font-size: 12px;
}

.chat-title-wrap h1 {
  overflow: hidden;
  max-width: 42vw;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 22px;
}

.run-controls {
  display: grid;
  grid-template-columns: minmax(110px, 145px) minmax(120px, 165px) minmax(120px, 160px) minmax(150px, 230px) minmax(120px, 160px) minmax(110px, 150px);
  gap: 8px;
  min-width: 0;
}

.mobile-header-actions {
  margin-left: auto;
  align-items: center;
  gap: 8px;
}

.theme-button,
.controls-toggle,
.menu-button,
.close-button {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface-2);
}

.menu-button,
.controls-toggle,
.theme-button {
  width: 52px;
  height: 52px;
  font-size: 25px;
}

.close-button {
  width: 54px;
  height: 54px;
  font-size: 34px;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 26px clamp(18px, 4vw, 58px);
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 55vh;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  color: var(--text);
  font-size: clamp(28px, 4vw, 48px);
}

.empty-state p {
  max-width: 560px;
  margin: 0;
}

.message {
  max-width: min(920px, 100%);
  margin: 0 auto 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.message.user {
  margin-right: clamp(0px, 3vw, 80px);
  background: color-mix(in srgb, var(--accent-2) 11%, var(--surface));
}

.message.assistant {
  margin-left: clamp(0px, 3vw, 80px);
}

.message header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

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

.message-content {
  overflow-wrap: anywhere;
}

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

.message-attachments span,
.attachment-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
}

.message-attachments span {
  padding: 5px 7px;
  color: var(--muted);
  font-size: 12px;
}

.running-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 999px;
  background: var(--accent);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.composer {
  display: grid;
  gap: 8px;
  padding: 14px clamp(18px, 4vw, 58px) calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 90%, var(--surface));
}

.composer-box {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 10px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.composer-box.dragging {
  border-color: var(--accent-2);
}

.composer-box textarea {
  min-height: 42px;
  max-height: 180px;
  resize: none;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.icon-button,
.send-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 8px;
}

.icon-button {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.desktop-only {
  display: grid;
}

.mic-button {
  position: relative;
  background: var(--surface-2);
  border-color: var(--line);
}

.template-toggle {
  position: relative;
  background: var(--surface-2);
  border-color: var(--line);
}

.template-toggle::before,
.template-toggle::after {
  content: "";
  width: 17px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 6px 0 currentColor;
}

.template-toggle::after {
  position: absolute;
  width: 9px;
  transform: translate(4px, -6px);
  box-shadow: 0 12px 0 currentColor;
  opacity: 0.72;
}

.mic-button::before {
  content: "";
  width: 12px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 9px;
}

.mic-button::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 10px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  border-right: 2px solid currentColor;
  border-radius: 0 0 10px 10px;
  transform: translateY(8px);
}

.mic-button.listening {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

@media (hover: hover) and (pointer: fine) {
  .icon-button:hover {
    background: var(--surface-2);
    border-color: var(--line);
    color: var(--text);
  }
}

.send-button {
  font-size: 20px;
}

.composer-hint {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
}

.attachment-chip {
  display: grid;
  grid-template-columns: 34px auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px;
  max-width: 100%;
}

.attachment-chip img,
.attachment-chip > span {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
}

.attachment-chip > span {
  display: grid;
  place-items: center;
  color: var(--accent-2);
  font-size: 10px;
  font-weight: 900;
}

.attachment-chip strong {
  overflow: hidden;
  max-width: 220px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.attachment-chip small {
  color: var(--muted);
  font-size: 11px;
}

.attachment-chip button {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.42);
}

.settings-panel {
  position: fixed;
  z-index: 50;
  top: 0;
  right: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  width: min(520px, 100vw);
  height: 100vh;
  height: 100dvh;
  padding: 18px;
  overflow: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.settings-head,
.setting-row,
.ssh-item,
.skill-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 6px;
}

.settings-tabs button,
.ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.settings-tabs button {
  min-width: 0;
  min-height: 42px;
  justify-content: center;
  overflow: hidden;
  padding-inline: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-tabs button.active {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
  border-color: var(--accent);
}

.settings-view {
  display: grid;
  gap: 14px;
  align-content: start;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.task-card header,
.task-card footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.task-card header div,
.task-card footer {
  min-width: 0;
}

.task-card header span,
.task-card footer > span,
.task-card p {
  color: var(--muted);
  font-size: 12px;
}

.task-card strong,
.task-card p {
  overflow-wrap: anywhere;
}

.task-card p {
  margin: 0;
  line-height: 1.45;
}

.task-card mark {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-3));
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
}

.task-card.failed mark {
  background: color-mix(in srgb, #ef4444 18%, var(--surface-3));
  color: #ff8b8b;
}

.task-card.cancelled mark {
  background: var(--surface-3);
  color: var(--muted);
}

.task-card.queued mark {
  background: color-mix(in srgb, #f6b44b 18%, var(--surface-3));
  color: #f6b44b;
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.task-detail {
  max-height: 240px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  white-space: pre-wrap;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.project-manager,
.project-manager-section,
.project-list {
  display: grid;
  gap: 10px;
}

.project-manager-section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.project-manager-section > header,
.project-card,
.project-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.project-manager-section > header span,
.project-card span {
  color: var(--muted);
  font-size: 12px;
}

.project-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.project-card.current {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line));
}

.project-card.archived {
  opacity: 0.88;
}

.project-card > div:first-child {
  min-width: 0;
}

.project-card strong,
.project-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-actions {
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.settings-form {
  display: grid;
  gap: 12px;
}

.project-ssh-profile {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.project-git-profile {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.project-info-form {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.project-knowledge-form {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.project-info-form textarea,
.project-knowledge-form textarea {
  min-height: 86px;
}

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

.memory-file {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.memory-file strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-file span {
  color: var(--muted);
  font-size: 12px;
}

.memory-file.ready {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
}

.memory-file.ready span {
  color: var(--accent);
}

.memory-file.missing {
  border-color: color-mix(in srgb, #f6b44b 38%, var(--line));
}

.project-ssh-profile input:disabled,
.project-ssh-profile select:disabled,
.project-ssh-profile textarea:disabled,
.project-git-profile input:disabled,
.project-git-profile select:disabled,
.project-git-profile textarea:disabled,
.project-info-form input:disabled,
.project-info-form select:disabled,
.project-info-form textarea:disabled,
.project-knowledge-form input:disabled,
.project-knowledge-form textarea:disabled {
  opacity: 0.65;
}

.verification-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.verification-result {
  display: grid;
  gap: 8px;
}

.verification-score {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.verification-score strong {
  grid-row: span 2;
  font-size: 24px;
}

.verification-score.ok strong {
  color: var(--accent);
}

.verification-score.warn strong {
  color: var(--danger);
}

.verification-score span,
.verification-score a,
.verification-checks span,
.verification-errors span {
  font-size: 12px;
}

.verification-score a {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.verification-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.verification-checks span {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.verification-checks .ok {
  color: var(--accent);
}

.verification-checks .bad,
.verification-errors {
  color: var(--danger);
}

.verification-errors {
  display: grid;
  gap: 4px;
}

.checkbox-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
  min-height: 38px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  min-height: 18px;
}

.git-status {
  display: grid;
  gap: 8px;
}

.git-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.git-status-grid div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.git-status-grid span,
.git-last,
.git-changes span {
  color: var(--muted);
  font-size: 11px;
}

.git-status-grid strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.git-last {
  overflow-wrap: anywhere;
}

.git-changes {
  display: grid;
  gap: 4px;
  max-height: 140px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.git-changes span {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.git-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.git-actions.commit-row {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
}

.git-actions.git-review-row {
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
}

.git-diff-output,
.git-pr-output {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.git-diff-output {
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
}

.git-pr-output {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.git-pr-output strong {
  color: var(--text);
}

.git-pr-output a {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.settings-form label {
  display: grid;
  gap: 6px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.skill-list,
.ssh-list,
.user-list {
  display: grid;
  gap: 8px;
}

.user-card {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 11px 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}

.user-card:hover {
  border-color: color-mix(in srgb, var(--accent) 46%, var(--line));
}

.user-card span,
.user-card em {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card.disabled {
  opacity: 0.58;
}

.user-form {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.user-form select[multiple] {
  min-height: 132px;
  padding: 8px;
}

.capability-grid {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.capability-group {
  display: grid;
  gap: 6px;
}

.capability-group strong {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.capability-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.capability-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
}

.capability-option input {
  flex: 0 0 auto;
}

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

.skill-item,
.ssh-item,
.setting-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
}

.skill-item label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.skill-item input[type="checkbox"] {
  width: auto;
  margin-top: 4px;
}

.skill-item span,
.ssh-item div,
.setting-row div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.skill-item small,
.ssh-item span,
.setting-row span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--accent);
  color: #07120e;
  font-weight: 800;
  padding: 7px 9px;
  font-size: 12px;
  text-decoration: none;
}

.ghost.small-button {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.tiny-button {
  padding: 7px 8px;
  font-size: 11px;
  justify-self: stretch;
}

.danger-button {
  background: #3a2024;
  color: #ffd8dd;
  border: 1px solid #6b2a34;
}

button.danger {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface-2));
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 34%, var(--line));
}

.mobile-only {
  display: none;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 32;
  background: rgba(0, 0, 0, 0.38);
}

.workspace-toggle::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 4px;
  box-shadow: inset 7px 0 0 color-mix(in srgb, currentColor 22%, transparent);
}

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

.desktop-workspace-toggle,
.desktop-theme-toggle {
  flex: 0 0 auto;
  align-self: center;
  width: 44px;
  height: 44px;
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--line);
}

.workspace-overlay {
  position: fixed;
  inset: 0;
  z-index: 42;
  background: rgba(0, 0, 0, 0.32);
}

.template-overlay {
  position: fixed;
  inset: 0;
  z-index: 48;
  background: rgba(0, 0, 0, 0.24);
}

.template-panel {
  position: fixed;
  z-index: 52;
  right: clamp(18px, 4vw, 58px);
  bottom: calc(94px + env(safe-area-inset-bottom));
  width: min(520px, calc(100vw - 36px));
  max-height: min(540px, calc(100dvh - 140px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 98%, var(--bg));
  box-shadow: var(--shadow);
}

.project-wizard-overlay {
  position: fixed;
  inset: 0;
  z-index: 54;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(5px);
}

.project-wizard {
  position: fixed;
  z-index: 56;
  top: 50%;
  left: 50%;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  width: min(780px, calc(100vw - 32px));
  height: min(92dvh, 920px);
  max-height: calc(100dvh - 24px);
  overflow: hidden;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 98%, var(--bg));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.project-wizard form {
  display: grid;
  gap: 12px;
  min-height: 0;
  max-height: 100%;
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

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

.project-wizard-head {
  position: sticky;
  top: -16px;
  z-index: 2;
  margin: -16px -16px 0;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 98%, var(--bg));
}

.project-wizard-head div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.project-wizard-head span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.project-wizard-head strong {
  font-size: 22px;
}

.wizard-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 86%, var(--surface));
}

details.wizard-section {
  display: block;
}

details.wizard-section > *:not(summary) {
  margin-top: 10px;
}

.wizard-section h3,
.wizard-section summary {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
}

.wizard-section summary {
  cursor: pointer;
  list-style-position: inside;
}

.wizard-section label {
  display: grid;
  gap: 6px;
}

.wizard-section label span {
  color: var(--muted);
  font-size: 12px;
}

.wizard-preview {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface-3));
  color: var(--muted);
  overflow-wrap: anywhere;
}

.wizard-preview strong {
  color: var(--text);
}

.project-wizard-actions {
  position: sticky;
  bottom: -16px;
  z-index: 2;
  margin: 0 -16px -16px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 98%, var(--bg));
}

.project-wizard-actions button:first-child {
  min-width: 190px;
}

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

.template-head div {
  display: grid;
  gap: 2px;
}

.template-head span,
.template-card span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.template-head strong {
  font-size: 18px;
}

.template-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.template-card {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  text-align: left;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.template-card strong {
  font-size: 15px;
}

.template-card small {
  color: var(--muted);
  font-size: 12px;
}

@media (hover: hover) and (pointer: fine) {
  .template-card:hover {
    border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
    background: color-mix(in srgb, var(--surface-2) 86%, var(--accent));
  }
}

.workspace-panel {
  position: fixed;
  z-index: 46;
  top: 12px;
  right: 12px;
  bottom: 12px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  width: min(540px, calc(100vw - 24px));
  min-height: 0;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 96%, var(--bg));
  box-shadow: var(--shadow);
}

.workspace-head,
.workspace-editor-head,
.workspace-toolbar,
.terminal-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.workspace-head h2 {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 22px;
}

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

.workspace-tabs button {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.workspace-tabs button.active {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
  border-color: var(--accent);
}

.workspace-view {
  display: grid;
  grid-template-rows: auto auto minmax(132px, 0.85fr) minmax(230px, 1fr);
  gap: 10px;
  min-height: 0;
}

#workspaceTerminal,
.workspace-site-view {
  grid-template-rows: minmax(0, 1fr) auto;
}

.workspace-site-view {
  grid-template-rows: auto minmax(0, 1fr);
}

.workspace-toolbar {
  flex-wrap: wrap;
}

.workspace-toolbar > div {
  min-width: 0;
}

.workspace-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.workspace-path {
  overflow: hidden;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.workspace-file-list {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
}

.workspace-file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  text-align: left;
  border-radius: 8px;
}

.workspace-file-main {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
}

.workspace-file span,
.workspace-file-main span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.workspace-file strong,
.workspace-file-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-file small,
.workspace-file-main small {
  color: var(--muted);
  font-size: 11px;
}

.workspace-file-actions,
.workspace-editor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.workspace-file-actions button {
  min-height: 28px;
  padding: 5px 8px;
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}

.workspace-file-actions button:hover {
  color: var(--text);
  border-color: var(--accent);
}

.workspace-file:hover,
.workspace-file.selected {
  background: var(--surface-2);
  border-color: var(--line);
}

.workspace-editor-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
}

.workspace-editor-head {
  align-items: flex-start;
}

.workspace-editor-head div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.workspace-editor-head strong,
.workspace-editor-head span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-editor-head span,
.workspace-empty {
  color: var(--muted);
  font-size: 12px;
}

.workspace-editor-card textarea {
  min-height: 0;
  resize: none;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.workspace-editor-card .CodeMirror {
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.workspace-editor-card .CodeMirror-gutters {
  border-right-color: var(--line);
}

body[data-theme="light"] .workspace-editor-card .CodeMirror {
  background: #ffffff;
  color: #111827;
}

.workspace-preview {
  min-height: 0;
  overflow: auto;
}

.workspace-preview img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.workspace-preview iframe {
  width: 100%;
  height: 100%;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.workspace-diff {
  max-height: 180px;
  margin: 0;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #05070a;
  color: #dce7f3;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.workspace-site-url {
  display: block;
  max-width: 320px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.workspace-site-view iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.terminal-output {
  min-height: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #05070a;
  color: #dce7f3;
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.terminal-input-row {
  align-items: stretch;
}

.terminal-input-row input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}

.login-shell {
  width: min(440px, 100%);
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 3px;
  margin: 4px 0 18px;
  text-align: center;
}

.login-brand-main {
  color: var(--text);
  font-size: clamp(38px, 11vw, 58px);
  line-height: 0.95;
  font-weight: 950;
}

.login-brand-sub {
  color: var(--accent);
  font-size: clamp(22px, 6vw, 34px);
  line-height: 1;
  font-weight: 850;
}

.login-panel p {
  margin: 8px 0 22px;
  color: var(--muted);
  text-align: center;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 7px;
}

.login-form label span {
  color: var(--muted);
  font-size: 13px;
}

.error {
  color: var(--danger);
  margin: 0 0 14px;
}

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

  .run-controls {
    grid-template-columns: repeat(3, minmax(110px, 1fr));
  }
}

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

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

  .sidebar {
    position: fixed;
    z-index: 35;
    inset: 0 auto 0 0;
    width: min(84vw, 340px);
    height: 100svh;
    max-height: 100dvh;
    padding: max(18px, calc(env(safe-area-inset-top) + 10px)) 14px max(14px, env(safe-area-inset-bottom));
    overflow: hidden;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow);
  }

  .sidebar .brand-title {
    font-size: clamp(28px, 10vw, 42px);
  }

  .sidebar .brand-kicker {
    font-size: clamp(16px, 5vw, 22px);
  }

  .brand-row {
    align-items: flex-start;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: grid;
  }

  .desktop-header-actions,
  .desktop-workspace-toggle,
  .desktop-theme-toggle,
  .desktop-only {
    display: none;
  }

  .chat-header {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 0;
    min-height: 62px;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  }

  .chat-title-wrap {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  .mobile-header-actions {
    display: flex;
    gap: 8px;
  }

  .mobile-header-actions .workspace-toggle {
    display: grid;
  }

  .chat-header.controls-open .mobile-header-actions .workspace-toggle {
    display: none;
  }

  .chat-header:not(.controls-open) .chat-kicker {
    display: none;
  }

  .chat-header.controls-open .chat-kicker {
    display: block;
  }

  .chat-header.controls-open .menu-button {
    visibility: hidden;
  }

  .chat-title-wrap h1 {
    max-width: calc(100vw - 222px);
    font-size: 21px;
    line-height: 1.05;
  }

  .chat-header.controls-open .chat-title-wrap h1 {
    max-width: calc(100vw - 170px);
  }

  .menu-button,
  .controls-toggle,
  .theme-button,
  .workspace-toggle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface) 68%, transparent);
    border-color: color-mix(in srgb, var(--line) 65%, transparent);
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.14s ease;
  }

  .menu-button {
    font-size: 29px;
  }

  .theme-button {
    font-size: 25px;
  }

  .controls-toggle {
    font-size: 0;
    position: relative;
  }

  .controls-toggle::before {
    content: "";
    width: 15px;
    height: 15px;
    border-right: 5px solid currentColor;
    border-bottom: 5px solid currentColor;
    border-radius: 2px;
    transform: translateY(-3px) rotate(45deg);
    transition: transform 0.16s ease;
  }

  .chat-header.controls-open .controls-toggle::before {
    transform: translateY(4px) rotate(225deg);
  }

  .theme-button:active,
  .controls-toggle:active,
  .menu-button:active,
  .workspace-toggle:active,
  .template-toggle:active,
  .close-button:active {
    transform: scale(0.96);
  }

  .theme-button:focus:not(:focus-visible),
  .controls-toggle:focus:not(:focus-visible),
  .menu-button:focus:not(:focus-visible),
  .workspace-toggle:focus:not(:focus-visible),
  .template-toggle:focus:not(:focus-visible),
  .close-button:focus:not(:focus-visible) {
    background: color-mix(in srgb, var(--surface) 68%, transparent);
    border-color: color-mix(in srgb, var(--line) 65%, transparent);
    color: var(--muted);
  }

  .close-button {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: transparent;
    border-color: transparent;
    font-size: 40px;
    color: var(--muted);
  }

  .run-controls {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-top: 12px;
  }

  .chat-header.controls-open .run-controls {
    display: grid;
  }

  .run-controls select {
    min-height: 54px;
    font-size: 16px;
  }

  .workspace-overlay {
    z-index: 42;
    background: rgba(0, 0, 0, 0.46);
  }

  .workspace-panel {
    z-index: 46;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: min(82dvh, calc(var(--app-height, 100dvh) - 18px));
    padding: 14px 12px max(12px, env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 16px 16px 0 0;
  }

  .workspace-head h2 {
    max-width: calc(100vw - 120px);
    font-size: 20px;
  }

  .workspace-view {
    grid-template-rows: auto auto minmax(112px, 0.75fr) minmax(210px, 1fr);
  }

  #workspaceTerminal {
    grid-template-rows: minmax(0, 1fr) auto;
  }

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

  .workspace-file-main {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .workspace-file-main small {
    grid-column: 2;
  }

  .workspace-file-actions,
  .workspace-editor-actions {
    justify-content: flex-start;
  }

  .workspace-file-actions button {
    flex: 1 1 auto;
  }

  .workspace-site-url {
    max-width: calc(100vw - 48px);
  }

  .workspace-editor-card textarea,
  .terminal-output,
  .terminal-input-row input {
    font-size: 13px;
  }

  .messages {
    padding: 16px 12px;
  }

  .message.user,
  .message.assistant {
    margin-left: 0;
    margin-right: 0;
  }

  .composer {
    gap: 6px;
    padding: 8px 10px max(2px, calc(env(safe-area-inset-bottom) - 30px));
    margin-bottom: 0;
  }

  body.keyboard-open .composer {
    position: fixed;
    z-index: 28;
    right: 0;
    bottom: var(--keyboard-inset, 0px);
    left: 0;
    padding-bottom: 8px;
  }

  body.keyboard-open .messages {
    padding-bottom: calc(108px + var(--keyboard-inset, 0px));
  }

  .composer-box {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    padding: 8px;
    border-radius: 12px;
  }

  .composer-box textarea {
    min-height: 40px;
    font-size: 16px;
  }

  .composer-hint {
    display: none;
  }

  .template-panel {
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-height: min(74svh, 620px);
    border-radius: 14px;
    padding: 12px;
  }

  body.keyboard-open .template-panel {
    bottom: calc(var(--keyboard-inset, 0px) + 8px);
  }

  .template-list {
    max-height: min(58svh, 500px);
  }

  .template-card {
    padding: 13px;
  }

  .project-wizard {
    top: 8px;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    height: auto;
    max-height: none;
    transform: none;
    border-radius: 14px;
  }

  .project-wizard form {
    padding: 12px;
  }

  .project-wizard-head {
    top: -12px;
    margin: -12px -12px 0;
    padding: 12px;
  }

  .project-wizard-head strong {
    font-size: 20px;
  }

  .project-wizard-actions {
    bottom: -12px;
    margin: 0 -12px -12px;
    padding: 10px 12px 12px;
  }

  .project-wizard-actions button {
    flex: 1 1 0;
  }

  .form-grid,
  .git-actions,
  .git-actions.commit-row,
  .git-status-grid,
  .memory-file-grid {
    grid-template-columns: 1fr;
  }

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

  .capability-options {
    grid-template-columns: 1fr;
  }

  .project-card,
  .project-manager-section > header {
    align-items: stretch;
    flex-direction: column;
  }

  .project-actions {
    justify-content: stretch;
  }

  .project-actions button {
    flex: 1 1 auto;
  }
}

@media (hover: none) and (pointer: coarse) {
  button:hover {
    filter: none;
  }

  .icon-button:hover {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
  }

  .conversation-edit {
    opacity: 1;
  }

  .menu-button:hover,
  .theme-button:hover,
  .controls-toggle:hover,
  .template-toggle:hover {
    background: color-mix(in srgb, var(--surface) 68%, transparent);
    border-color: color-mix(in srgb, var(--line) 65%, transparent);
    color: var(--muted);
  }
}

/* Gemini-inspired interface refresh */
:root {
  --bg: #08090b;
  --surface: #1f2023;
  --surface-2: #26272b;
  --surface-3: #101114;
  --line: #33373d;
  --text: #f1f3f4;
  --muted: #aeb7c2;
  --accent: #8ab4f8;
  --accent-2: #a8c7fa;
  --brand: #3ddc97;
  --danger: #ff7b8a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --pill: 999px;
}

body[data-theme="light"] {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --surface-3: #f8fafc;
  --line: #dce3ec;
  --text: #111827;
  --muted: #667589;
  --accent: #2563eb;
  --accent-2: #0f9d58;
  --brand: #0f9d58;
  --shadow: 0 22px 70px rgba(31, 41, 55, 0.14);
}

body {
  background:
    radial-gradient(circle at 58% 82%, rgba(24, 54, 142, 0.58), transparent 34%),
    radial-gradient(circle at 46% 44%, rgba(26, 31, 54, 0.34), transparent 44%),
    var(--bg);
}

body[data-theme="light"] {
  background:
    radial-gradient(circle at 58% 82%, rgba(138, 180, 248, 0.26), transparent 36%),
    radial-gradient(circle at 50% 42%, rgba(61, 220, 151, 0.1), transparent 48%),
    var(--bg);
}

.app-shell {
  grid-template-columns: 304px minmax(0, 1fr);
}

.sidebar {
  gap: 12px;
  padding: 18px 12px 14px;
  background: color-mix(in srgb, var(--surface) 95%, #000000);
  border-right: 0;
}

.brand-title {
  color: var(--text);
  font-size: 27px;
  line-height: 0.96;
  font-weight: 950;
}

.brand-kicker {
  color: var(--brand);
  font-size: 17px;
  line-height: 1;
  font-weight: 900;
}

.sidebar-create {
  display: grid;
  gap: 4px;
}

.new-chat {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--surface-3) 68%, transparent);
  color: var(--text);
  text-align: left;
}

.new-chat.secondary {
  background: transparent;
}

.new-chat span {
  color: var(--accent-2);
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
}

.new-chat strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-chat:hover,
.new-chat.secondary:hover,
.conversation-item:hover,
.conversation-item.active {
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
  border-color: transparent;
  filter: none;
}

.sidebar-label {
  padding: 8px 4px 0;
  color: color-mix(in srgb, var(--muted) 86%, var(--text));
  font-size: 12px;
  font-weight: 650;
  text-transform: none;
}

.conversation-list {
  gap: 2px;
  padding-right: 2px;
}

.conversation-item {
  grid-template-columns: minmax(0, 1fr) 28px;
  min-height: 42px;
  padding: 5px 7px 5px 11px;
  border-radius: var(--pill);
}

.conversation-main {
  gap: 2px;
}

.conversation-main strong {
  font-size: 14px;
  font-weight: 650;
}

.conversation-main span {
  color: var(--muted);
  font-size: 12px;
}

.conversation-edit {
  width: 28px;
  height: 28px;
  border-radius: var(--pill);
}

.sidebar-bottom {
  gap: 6px;
}

.server-mini,
.limit-mini {
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-3) 70%, transparent);
}

.server-mini {
  gap: 6px;
  padding: 8px;
}

.server-mini section div,
.limit-mini section div {
  border-radius: 10px;
}

.limit-mini.compact {
  grid-template-columns: minmax(0, 1fr) 74px;
  padding: 6px;
}

.limit-mini.compact .tiny-button {
  border-radius: 10px;
  font-size: 10px;
}

.settings-button {
  min-height: 42px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--text);
}

.chat-area {
  position: relative;
  isolation: isolate;
}

.chat-area::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 54% 80%, rgba(31, 67, 168, 0.42), transparent 32%),
    radial-gradient(circle at 50% 54%, rgba(19, 22, 31, 0.46), transparent 46%);
}

body[data-theme="light"] .chat-area::before {
  background:
    radial-gradient(circle at 54% 80%, rgba(138, 180, 248, 0.22), transparent 34%),
    radial-gradient(circle at 50% 54%, rgba(255, 255, 255, 0.7), transparent 48%);
}

.chat-header {
  position: relative;
  min-height: 68px;
  padding: 12px 18px;
  border-bottom: 0;
  background: transparent;
}

.chat-title-wrap h1 {
  max-width: min(42vw, 620px);
  font-size: 21px;
  font-weight: 700;
}

.chat-kicker {
  font-size: 12px;
}

.control-summary {
  position: relative;
  display: grid;
  gap: 1px;
  width: min(360px, 30vw);
  min-height: 44px;
  padding: 7px 40px 7px 16px;
  border: 0;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text);
  text-align: left;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 42%, transparent);
}

.control-summary::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: 0.72;
  transform: translateY(-62%) rotate(45deg);
}

.control-summary[aria-expanded="true"]::after {
  transform: translateY(-28%) rotate(225deg);
}

.control-summary span,
.control-summary small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-summary span {
  font-size: 14px;
  font-weight: 750;
}

.control-summary small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.chat-header .run-controls {
  position: absolute;
  z-index: 30;
  top: calc(100% - 6px);
  left: 50%;
  right: auto;
  display: none;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  width: min(520px, calc(100vw - 340px));
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 97%, #000000);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.chat-header.controls-open .run-controls {
  display: grid;
}

.run-controls select {
  min-height: 42px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-3) 78%, transparent);
}

.desktop-header-actions {
  gap: 6px;
}

.theme-button,
.workspace-toggle,
.project-menu-toggle,
.controls-toggle,
.menu-button,
.close-button {
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-color: color-mix(in srgb, var(--line) 62%, transparent);
  color: var(--muted);
}

.desktop-workspace-toggle,
.desktop-theme-toggle,
.desktop-project-menu-toggle {
  width: 44px;
  height: 44px;
}

.project-menu-toggle {
  font-size: 26px;
  line-height: 1;
}

.messages {
  padding: 28px clamp(18px, 5vw, 72px) 20px;
}

.empty-state {
  min-height: 62vh;
}

.empty-state h2 {
  font-size: clamp(34px, 4vw, 56px);
  font-weight: 500;
}

.message {
  max-width: min(900px, 100%);
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  border-color: color-mix(in srgb, var(--line) 62%, transparent);
}

.message.user {
  max-width: min(640px, 78%);
  margin-left: auto;
  margin-right: clamp(12px, 5vw, 92px);
  border-color: transparent;
  border-radius: 28px;
  background: color-mix(in srgb, var(--surface-2) 90%, var(--accent) 6%);
}

.message.assistant {
  margin-left: clamp(12px, 5vw, 92px);
  background: color-mix(in srgb, var(--surface) 64%, transparent);
}

.message-content {
  line-height: 1.58;
}

.composer {
  padding: 10px clamp(18px, 4vw, 58px) calc(16px + env(safe-area-inset-bottom));
  border-top: 0;
  background: linear-gradient(to top, color-mix(in srgb, var(--bg) 96%, transparent), color-mix(in srgb, var(--bg) 42%, transparent), transparent);
}

.composer-box {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  max-width: 860px;
  padding: 8px 10px;
  border: 0;
  border-radius: 30px;
  background: color-mix(in srgb, var(--surface) 96%, #000000);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 35%, transparent);
}

.composer-box textarea {
  min-height: 44px;
  padding: 11px 6px;
}

.composer-box .icon-button,
.composer-box .send-button {
  width: 42px;
  height: 42px;
  border-radius: var(--pill);
}

.composer-plus {
  position: relative;
  font-size: 28px;
  font-weight: 400;
  background: transparent;
  border-color: transparent;
  color: var(--text);
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.composer-plus.open {
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
  color: var(--text);
  font-size: 0;
  transform: rotate(90deg);
}

.composer-plus.open::before {
  content: "×";
  font-size: 30px;
  line-height: 1;
}

.mic-button {
  background: transparent;
  border-color: transparent;
}

.send-button {
  background: var(--accent);
  color: #07111f;
  width: 0 !important;
  margin-left: -8px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: scale(0.72);
  transition: width 0.18s ease, margin 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

.send-button.visible {
  width: 42px !important;
  margin-left: 0;
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.composer-hint,
.attachment-strip {
  max-width: 860px;
}

.template-panel,
.workspace-panel,
.settings-panel,
.project-wizard,
.login-panel {
  border-radius: 26px;
}

.composer-tools-overlay {
  position: fixed;
  inset: 0;
  z-index: 47;
  background: transparent;
}

.composer-tools-panel {
  position: fixed;
  z-index: 55;
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: max(18px, calc(50% - 430px));
  display: grid;
  gap: 2px;
  width: min(360px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 98%, #000000);
  box-shadow: var(--shadow);
}

.composer-tools-panel button {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 2px 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px;
  border-radius: 18px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.composer-tools-panel button:hover {
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
  filter: none;
}

.composer-tools-panel button > span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
  color: var(--accent-2);
  font-size: 20px;
}

.composer-tools-panel strong,
.composer-tools-panel small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-tools-panel strong {
  font-size: 15px;
}

.composer-tools-panel small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.project-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 48;
  background: rgba(0, 0, 0, 0.12);
}

.project-menu-panel {
  position: fixed;
  z-index: 54;
  top: 64px;
  right: 16px;
  width: min(340px, calc(100vw - 24px));
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 98%, #000000);
  box-shadow: var(--shadow);
}

.project-menu-list {
  display: grid;
  gap: 2px;
}

.project-menu-list hr {
  width: 100%;
  height: 1px;
  margin: 8px 0;
  border: 0;
  background: var(--line);
}

.project-menu-list button {
  display: grid;
  gap: 2px;
  min-height: 46px;
  padding: 8px 12px;
  border-radius: 16px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.project-menu-list button:hover {
  background: color-mix(in srgb, var(--surface-2) 86%, transparent);
  filter: none;
}

.project-menu-list button:disabled {
  color: color-mix(in srgb, var(--muted) 55%, transparent);
  cursor: not-allowed;
}

.project-menu-list button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

@media (max-width: 1180px) {
  .chat-header .run-controls {
    width: min(500px, calc(100vw - 330px));
  }

  .control-summary {
    width: min(310px, 28vw);
  }
}

@media (max-width: 820px) {
  body {
    background:
      radial-gradient(circle at 50% 78%, rgba(22, 49, 136, 0.58), transparent 38%),
      var(--bg);
  }

  .sidebar {
    width: min(88vw, 380px);
    padding: max(20px, calc(env(safe-area-inset-top) + 16px)) 14px max(14px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, #000000);
  }

  .sidebar .brand-title {
    font-size: clamp(36px, 11vw, 54px);
  }

  .sidebar .brand-kicker {
    font-size: clamp(19px, 5.3vw, 26px);
  }

  .sidebar-create {
    gap: 8px;
  }

  .new-chat {
    min-height: 48px;
    padding: 10px 14px;
  }

  .conversation-list {
    gap: 8px;
  }

  .conversation-item {
    min-height: 56px;
    border-radius: 18px;
  }

  .conversation-main strong {
    font-size: 17px;
  }

  .conversation-main span {
    font-size: 14px;
  }

  .sidebar-server,
  .sidebar-limits {
    display: none;
  }

  .settings-button {
    min-height: 50px;
  }

  .chat-header {
    position: sticky;
    top: 0;
    z-index: 26;
    min-height: 76px;
    padding: max(10px, calc(env(safe-area-inset-top) + 8px)) 14px 10px;
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  }

  .chat-title-wrap {
    grid-template-columns: 54px minmax(0, 1fr) auto;
    gap: 12px;
  }

  .chat-title-wrap h1 {
    max-width: calc(100vw - 250px);
    font-size: 22px;
    font-weight: 750;
  }

  .chat-header.controls-open .chat-title-wrap h1 {
    max-width: calc(100vw - 220px);
  }

  .menu-button,
  .controls-toggle,
  .theme-button,
  .workspace-toggle,
  .project-menu-toggle {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    border-color: color-mix(in srgb, var(--line) 62%, transparent);
  }

  .menu-button {
    font-size: 30px;
  }

  .mobile-header-actions {
    gap: 8px;
  }

  .mobile-header-actions .workspace-toggle,
  .chat-header.controls-open .mobile-header-actions .workspace-toggle {
    display: grid;
  }

  .project-menu-toggle {
    display: grid;
  }

  .chat-header.controls-open .menu-button {
    visibility: visible;
  }

  .chat-header .run-controls {
    top: calc(100% + 8px);
    right: 14px;
    left: 14px;
    width: auto;
    grid-template-columns: 1fr;
    gap: 8px;
    max-height: min(68dvh, 520px);
    overflow: auto;
    padding: 14px;
    border-radius: 26px;
    transform: none;
  }

  .chat-header.controls-open .run-controls {
    display: grid;
  }

  .run-controls select {
    min-height: 50px;
    border-radius: 18px;
    font-size: 16px;
  }

  .messages {
    padding: 18px 14px 12px;
  }

  .message,
  .message.user,
  .message.assistant {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    border-radius: 20px;
  }

  .message {
    padding: 14px 15px;
  }

  .message-content {
    font-size: 16px;
    line-height: 1.55;
  }

  .composer {
    padding: 8px 12px max(4px, calc(env(safe-area-inset-bottom) - 22px));
    background: linear-gradient(to top, color-mix(in srgb, var(--bg) 98%, transparent), color-mix(in srgb, var(--bg) 62%, transparent), transparent);
  }

  body.keyboard-open .composer {
    bottom: var(--keyboard-inset, 0px);
    padding-bottom: 8px;
  }

  .composer-box {
    grid-template-columns: auto minmax(0, 1fr) auto;
    max-width: none;
    min-height: 58px;
    padding: 8px 10px;
    border-radius: 24px;
  }

  .composer-box textarea {
    min-height: 42px;
    padding: 10px 4px;
    font-size: 16px;
  }

  .composer-box .icon-button,
  .composer-box .send-button {
    width: 44px;
    height: 44px;
  }

  .send-button {
    width: 0 !important;
  }

  .send-button.visible {
    width: 44px !important;
  }

  .composer-tools-panel {
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    border-radius: 24px;
  }

  .project-menu-overlay {
    background: rgba(0, 0, 0, 0.28);
  }

  .project-menu-panel {
    top: calc(env(safe-area-inset-top) + 64px);
    right: 12px;
    left: auto;
    width: min(330px, calc(100vw - 24px));
    border-radius: 24px;
  }

  .workspace-panel,
  .settings-panel,
  .template-panel,
  .project-wizard {
    border-radius: 24px 24px 0 0;
  }
}

@media (hover: none) and (pointer: coarse) {
  .project-menu-list button:hover {
    background: transparent;
  }

  .menu-button:hover,
  .theme-button:hover,
  .controls-toggle:hover,
  .workspace-toggle:hover,
  .project-menu-toggle:hover,
  .template-toggle:hover {
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    border-color: color-mix(in srgb, var(--line) 62%, transparent);
    color: var(--muted);
  }
}

.server-reason {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .control-summary.desktop-only {
    display: none !important;
  }

  .controls-toggle {
    display: none !important;
  }

  .chat-header {
    min-height: 72px;
    padding: max(8px, calc(env(safe-area-inset-top) + 6px)) 14px 9px;
  }

  .chat-title-wrap {
    grid-template-columns: 54px minmax(0, 1fr) auto;
  }

  .chat-title-wrap h1 {
    max-width: calc(100vw - 220px);
  }

  .mobile-header-actions {
    grid-auto-flow: column;
    justify-content: end;
  }

  .mobile-header-actions .theme-button,
  .mobile-header-actions .project-menu-toggle {
    display: grid;
  }

  .chat-header .run-controls {
    left: 12px;
    right: 12px;
    top: calc(100% + 6px);
    width: auto;
  }

  .composer-box {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 4px;
  }

  .mic-button {
    display: grid;
  }

  .composer-hint {
    display: none;
  }

  .message-content {
    font-size: 15px;
  }
}

/* Final mobile and dialog polish */
.control-summary-mobile {
  display: none;
  align-items: center;
  justify-items: start;
  width: max-content;
  max-width: min(220px, calc(100vw - 190px));
  margin-top: 6px;
  padding: 7px 34px 7px 13px;
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text);
  position: relative;
  text-align: left;
}

.control-summary-mobile::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: 0.72;
  transform: translateY(-62%) rotate(45deg);
}

.control-summary-mobile[aria-expanded="true"]::after {
  transform: translateY(-28%) rotate(225deg);
}

.control-summary-mobile span,
.control-summary-mobile small {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-summary-mobile span {
  font-size: 13px;
  font-weight: 800;
}

.control-summary-mobile small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.message-attachments {
  display: grid;
  gap: 10px;
}

.message-image {
  display: grid;
  gap: 7px;
  width: min(420px, 100%);
  color: var(--muted);
  text-decoration: none;
}

.message-image img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface-3) 80%, transparent);
}

.conversation-editor-overlay,
.image-generator-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
}

.conversation-editor,
.image-generator {
  position: fixed;
  z-index: 71;
  top: 50%;
  left: 50%;
  width: min(520px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  overflow: auto;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 26px;
  background: color-mix(in srgb, var(--surface) 98%, #000000);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}

.conversation-editor form,
.image-generator form {
  display: grid;
  gap: 14px;
}

.conversation-editor header,
.image-generator header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.conversation-editor header span,
.image-generator header span {
  color: var(--brand);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.conversation-editor header strong,
.image-generator header strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
  line-height: 1.1;
}

.conversation-editor label,
.image-generator label {
  display: grid;
  gap: 7px;
}

.conversation-editor label span,
.image-generator label span {
  color: var(--muted);
  font-size: 12px;
}

.conversation-editor-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.conversation-editor-meta span {
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--line) 66%, transparent);
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--surface-3) 72%, transparent);
}

.conversation-editor footer,
.image-generator footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 820px) {
  html,
  body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100vw;
    max-width: 100vw;
    overflow: hidden;
  }

  .chat-area,
  .chat-header,
  .messages,
  .composer {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .chat-title-wrap {
    grid-template-columns: 54px minmax(0, 1fr) auto !important;
    width: 100%;
  }

  .chat-title-wrap h1 {
    max-width: calc(100vw - 198px) !important;
  }

  .chat-kicker {
    display: none !important;
  }

  .control-summary-mobile {
    display: inline-grid !important;
  }

  .mobile-header-actions {
    display: flex !important;
    flex-shrink: 0;
    grid-auto-flow: column;
    justify-content: end;
  }

  .message {
    max-width: calc(100vw - 28px) !important;
  }

  .composer-box {
    grid-template-columns: auto minmax(0, 1fr) auto auto !important;
    width: 100%;
    max-width: 100%;
    gap: 4px;
    border-radius: var(--pill);
  }

  .composer-box textarea {
    min-width: 0;
  }

  .conversation-editor,
  .image-generator {
    top: auto;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    max-height: min(76dvh, calc(var(--app-height, 100dvh) - 24px));
    border-radius: 26px 26px 18px 18px;
    transform: none;
  }

  .conversation-editor footer,
  .image-generator footer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .conversation-editor footer button,
  .image-generator footer button {
    width: 100%;
  }
}
