.chat-surface {
  display: flex;
  height: clamp(440px, calc(100dvh - 246px), 780px);
  min-height: 0;
  flex-direction: column;
}

.chat-surface > .surface-toolbar,
.chat-surface > .prompt-suggestions,
.chat-surface > .composer {
  flex: 0 0 auto;
}

.chat-messages {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 24px;
  padding: 26px clamp(18px, 4vw, 56px) 18px;
  overflow-y: auto;
}

.chat-empty {
  display: grid;
  width: min(100%, 720px);
  min-height: 320px;
  margin: auto;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
}

.chat-empty-mark {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--panel-2);
  color: var(--mode-accent);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.1em;
}

.chat-empty strong {
  color: var(--text);
  font-size: 17px;
  font-weight: 500;
}

.chat-empty small {
  max-width: 340px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.7;
}

.message-row {
  display: flex;
  width: min(100%, 820px);
  max-width: 820px;
  align-items: flex-start;
  gap: 11px;
  margin: 0 auto;
  animation: message-in 220ms ease-out both;
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.message-row.user .message-avatar {
  order: 2;
  background: var(--mode-accent-soft);
  border-color: color-mix(in oklch, var(--mode-accent) 34%, transparent);
  color: var(--mode-accent);
}

.message-avatar {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 9px;
}

.message-body {
  min-width: 0;
  max-width: min(84%, 700px);
}

.message-row.user .message-body {
  max-width: min(76%, 620px);
}

.message-content {
  padding: 3px 0;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-row.user .message-content {
  padding: 10px 14px;
  border: 1px solid color-mix(in oklch, var(--mode-accent) 26%, transparent);
  border-radius: 12px;
  background: var(--mode-accent-soft);
  color: var(--text);
}

.message-content.is-streaming::after {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.2em;
  background: var(--mode-accent);
  content: '';
  animation: caret 1s steps(2) infinite;
}

@keyframes caret {
  50% {
    opacity: 0;
  }
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.message-meta .status-light {
  width: 6px;
  height: 6px;
}

.message-tools,
.message-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.message-tools button,
.small-action {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--muted);
  font-size: 10.5px;
  transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease;
}

.message-tools button:hover,
.small-action:hover {
  border-color: oklch(0.77 0.095 190 / 0.42);
  background: var(--cyan-soft);
  color: var(--text);
}

.message-tools svg,
.small-action svg {
  width: 12px;
  height: 12px;
}

.message-edit-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel-2);
}

.message-edit-box textarea {
  min-height: 90px;
  background: var(--inset);
}

.message-edit-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 10.5px;
}

.message-edit-actions {
  justify-content: flex-end;
}

.message-image-preview {
  position: relative;
  display: grid;
  width: min(100%, 320px);
  aspect-ratio: 16 / 10;
  min-width: 0;
  max-height: 220px;
  place-items: center;
  margin: 0 0 10px;
  padding: 0;
  overflow: hidden;
  border: 1px solid color-mix(in oklch, var(--line-strong) 82%, var(--mode-accent));
  border-radius: 8px;
  background: var(--inset);
  color: var(--muted);
  cursor: zoom-in;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.message-image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.message-image-preview:hover {
  border-color: color-mix(in oklch, var(--mode-accent) 58%, var(--line-strong));
  background: color-mix(in oklch, var(--inset) 92%, var(--mode-accent));
}

.message-image-preview:focus-visible {
  outline: 2px solid var(--mode-accent);
  outline-offset: 2px;
}

.message-image-preview.is-error {
  cursor: default;
}

.message-image-error {
  display: grid;
  min-height: 96px;
  place-items: center;
  gap: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.message-image-error[hidden] {
  display: none;
}

.message-image-error svg {
  width: 22px;
  height: 22px;
}

.thinking-block {
  margin-bottom: 8px;
  border: 1px solid oklch(0.77 0.095 190 / 0.26);
  border-radius: 10px;
  background: var(--cyan-soft);
  overflow: hidden;
}

.thinking-block summary {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  color: var(--cyan);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9.5px;
  list-style: none;
}

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

.thinking-block summary svg {
  width: 13px;
  height: 13px;
}

.thinking-state {
  margin-left: auto;
  color: var(--muted);
}

.thinking-content {
  padding: 0 11px 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.prompt-suggestions {
  display: flex;
  width: min(calc(100% - 32px), 820px);
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 auto;
  padding: 14px 0 4px;
}

.suggestion-chip {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--panel);
  color: var(--text-dim);
  font-size: 11px;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.suggestion-chip:hover {
  border-color: color-mix(in oklch, var(--mode-accent) 46%, transparent);
  background: var(--mode-accent-soft);
  color: var(--text);
  transform: translateY(-1px);
}

.suggestion-chip svg {
  width: 12px;
  height: 12px;
  color: var(--mode-accent);
}

.composer {
  width: min(calc(100% - 32px), 820px);
  margin: 0 auto 16px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-1);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer:focus-within {
  border-color: color-mix(in oklch, var(--mode-accent) 55%, transparent);
  box-shadow: var(--shadow-1), 0 0 0 4px var(--mode-accent-soft);
}

.composer > textarea {
  min-height: 76px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.composer > textarea:focus {
  background: transparent;
  box-shadow: none;
}

.composer-footer {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px 7px 12px;
  border-top: 1px solid var(--line);
}

.composer-tools {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.composer-hint {
  overflow: hidden;
  color: var(--cyan);
  font-size: 8.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thinking-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  transition: color 160ms ease;
}

.thinking-hint:hover {
  color: var(--text-dim);
}

.thinking-hint svg {
  width: 11px;
  height: 11px;
}

.thinking-hint.is-on {
  color: var(--mode-accent);
}

.thinking-hint.is-on:hover {
  color: color-mix(in oklch, var(--mode-accent) 78%, white);
}

body #inspector-open-toggle {
  position: fixed;
  top: 96px;
  right: 14px;
  z-index: 45;
  box-shadow: var(--shadow-2), 0 0 0 1px var(--line-strong);
  backdrop-filter: blur(12px);
}

@media (min-width: 1161px) {
  .app-shell.sidebar-collapsed #sidebar-collapse-toggle {
    position: fixed;
    top: 96px;
    left: 14px;
    z-index: 60;
    box-shadow: var(--shadow-2), 0 0 0 1px var(--line-strong);
    backdrop-filter: blur(12px);
  }

  .workspace-switcher #sidebar-collapse-toggle {
    margin-left: 4px;
  }

  .app-shell:not(.sidebar-collapsed) .workspace-switcher #sidebar-collapse-toggle::after {
    right: calc(100% + 9px);
    left: auto;
  }
}

body .app-shell.chat-fullscreen {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell.chat-fullscreen .sidebar,
.app-shell.chat-fullscreen .topbar {
  display: none;
}

@media (min-width: 1161px) {
  body .app-shell.chat-fullscreen .content-grid:not(.inspector-collapsed) .inspector {
    position: fixed;
    top: 64px;
    right: 16px;
    bottom: 16px;
    z-index: 60;
    width: min(360px, calc(100vw - 32px));
    height: auto;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-left: 1px solid var(--line-strong);
    border-radius: 16px;
    box-shadow: 0 24px 64px oklch(0 0 0 / 0.45);
    opacity: 1;
    transform: none;
  }

  .app-shell.chat-fullscreen .content-grid.inspector-collapsed .inspector {
    display: none;
  }
}

@media (max-width: 1160px) {
  body .app-shell.chat-fullscreen #mobile-inspector-toggle {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 55;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: 0 10px 26px oklch(0 0 0 / 0.35);
    backdrop-filter: blur(12px);
  }
}

.app-shell.chat-fullscreen .content-grid {
  grid-template-columns: minmax(0, 1fr);
  min-height: 100dvh;
  padding-bottom: 0;
}

.app-shell.chat-fullscreen .studio-column {
  padding: 8px 10px;
}

.app-shell.chat-fullscreen #mode-chat .mode-heading {
  display: none;
}

.app-shell.chat-fullscreen #mode-chat .chat-surface {
  height: calc(100dvh - 16px);
}

.app-shell.chat-fullscreen #mode-chat .chat-messages {
  gap: 26px;
  padding: 20px clamp(24px, 5vw, 72px) 14px;
}

.app-shell.chat-fullscreen #mode-chat .message-row,
.app-shell.chat-fullscreen #mode-chat .prompt-suggestions,
.app-shell.chat-fullscreen #mode-chat .composer {
  width: min(100%, 1280px);
}

.app-shell.chat-fullscreen #mode-chat .message-row {
  max-width: 1280px;
}

.app-shell.chat-fullscreen #mode-chat .message-content {
  font-size: 16px;
  line-height: 1.8;
}

.app-shell.chat-fullscreen #mode-chat .composer > textarea {
  font-size: 16px;
}

.app-shell.chat-fullscreen #mode-chat .composer {
  margin-bottom: 8px;
}

.app-shell.chat-fullscreen #mode-chat .thinking-content {
  font-size: 12px;
  line-height: 1.75;
}

.app-shell.chat-fullscreen #mode-chat .chat-empty strong {
  font-size: 19px;
}

body .app-shell.image-fullscreen,
body .app-shell.video-fullscreen {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell.image-fullscreen .sidebar,
.app-shell.image-fullscreen .topbar,
.app-shell.video-fullscreen .sidebar,
.app-shell.video-fullscreen .topbar {
  display: none;
}

.app-shell.image-fullscreen .content-grid,
.app-shell.video-fullscreen .content-grid {
  grid-template-columns: minmax(0, 1fr);
  min-height: 100dvh;
  padding-bottom: 0;
}

.app-shell.image-fullscreen .studio-column,
.app-shell.video-fullscreen .studio-column {
  padding: 8px 10px;
}

.app-shell.image-fullscreen #mode-image .mode-heading,
.app-shell.video-fullscreen #mode-video .mode-heading {
  display: none;
}

.app-shell.image-fullscreen #mode-image .studio-split,
.app-shell.video-fullscreen #mode-video .studio-split {
  height: calc(100dvh - 16px);
}

@media (min-width: 1161px) {
  body .app-shell.image-fullscreen .content-grid:not(.inspector-collapsed) .inspector,
  body .app-shell.video-fullscreen .content-grid:not(.inspector-collapsed) .inspector {
    position: fixed;
    top: 64px;
    right: 16px;
    bottom: 16px;
    z-index: 60;
    width: min(360px, calc(100vw - 32px));
    height: auto;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-left: 1px solid var(--line-strong);
    border-radius: 16px;
    box-shadow: 0 24px 64px oklch(0 0 0 / 0.45);
    opacity: 1;
    transform: none;
  }

  .app-shell.image-fullscreen .content-grid.inspector-collapsed .inspector,
  .app-shell.video-fullscreen .content-grid.inspector-collapsed .inspector {
    display: none;
  }
}

@media (max-width: 1160px) {
  body .app-shell.image-fullscreen #mobile-inspector-toggle,
  body .app-shell.video-fullscreen #mobile-inspector-toggle {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 55;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: 0 10px 26px oklch(0 0 0 / 0.35);
    backdrop-filter: blur(12px);
  }
}

.primary-action.is-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 16px color-mix(in oklch, var(--danger) 30%, transparent);
}

.primary-action.is-danger:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 20px color-mix(in oklch, var(--danger) 40%, transparent);
}

.send-button,
.primary-action {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--mode-accent);
  color: oklch(0.13 0.02 60);
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: 0 4px 16px color-mix(in oklch, var(--mode-accent) 26%, transparent);
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.send-button:hover,
.primary-action:hover {
  filter: brightness(1.07);
  box-shadow: 0 6px 20px color-mix(in oklch, var(--mode-accent) 36%, transparent);
  transform: translateY(-1px);
}

.send-button svg,
.primary-action svg {
  width: 15px;
  height: 15px;
}

.is-cyan-action {
  background: var(--cyan);
  color: oklch(0.13 0.02 200);
}

.vision-input-panel {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--cyan-soft);
}

.inline-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.inline-label svg {
  width: 13px;
  height: 13px;
}

.chat-upload-zone,
.drop-zone {
  display: grid;
  min-height: 82px;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: oklch(1 0 0 / 0.02);
  color: var(--text-dim);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.chat-upload-zone:hover {
  border-color: var(--cyan);
  background: var(--cyan-soft);
}

.chat-upload-zone.is-dragover {
  border-color: var(--cyan);
  background: var(--cyan-soft);
  box-shadow: inset 0 0 0 1px var(--cyan);
}

.chat-image-source-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(2, minmax(72px, 0.28fr));
  gap: 6px;
}

.chat-source-button {
  display: grid;
  min-height: 82px;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 10px;
  transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease;
}

.chat-source-button:hover,
.chat-source-button:focus-visible {
  border-color: var(--cyan);
  background: var(--cyan-soft);
  color: var(--text);
}

.chat-source-button svg {
  width: 18px;
  height: 18px;
  color: var(--cyan);
}

.drop-zone:hover {
  border-color: var(--mode-accent);
  background: var(--mode-accent-soft);
}

.drop-zone.is-disabled {
  border-color: var(--line);
  background: oklch(1 0 0 / 0.01);
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.55;
}

.drop-zone.is-dragover,
.video-ref-grid.is-dragover .video-ref-empty,
.video-ref-slot.is-dragover .video-ref-empty {
  border-color: var(--mode-accent);
  background: var(--mode-accent-soft);
}

.drop-zone.is-disabled svg {
  color: var(--muted);
}

.chat-upload-zone svg,
.drop-zone svg {
  width: 19px;
  height: 19px;
}

.chat-upload-zone svg {
  color: var(--cyan);
}

.drop-zone svg {
  color: var(--mode-accent);
}

.chat-upload-zone span,
.drop-zone span {
  font-size: 11.5px;
}

.chat-upload-zone small,
.drop-zone small,
.vision-helper {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  line-height: 1.5;
}

.chat-upload-zone input,
.drop-zone input {
  display: none;
}

.chat-image-preview {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}

.chat-image-preview-media {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--inset);
  cursor: zoom-in;
}

.chat-image-preview-media img {
  width: 100%;
  height: 100%;
  flex: 0 0 auto;
  object-fit: contain;
}

.chat-image-preview-media:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 1px;
}

.chat-image-preview-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.chat-image-preview-copy strong {
  overflow: hidden;
  color: var(--text-dim);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-image-preview-copy small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
}

.chat-image-preview .media-ref-remove {
  margin-left: auto;
}

.vision-helper {
  display: block;
  margin-top: 6px;
}

.studio-split {
  display: grid;
  height: clamp(440px, calc(100dvh - 190px), 780px);
  min-height: 0;
  align-items: stretch;
  grid-template-columns: minmax(300px, 0.82fr) minmax(0, 1.18fr);
  gap: 18px;
}

.control-surface,
.output-surface {
  min-width: 0;
  min-height: 0;
}

.control-surface {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.output-surface {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
}

.control-surface > .field-block {
  padding: 20px 20px 0;
}

.field-block {
  display: grid;
  gap: 8px;
}

.field-label,
.range-heading,
.inspector-section-title,
.reference-zone-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field-label {
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 500;
}

.field-required {
  color: var(--mode-accent);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.large-textarea {
  min-height: 160px;
}
