:root {
  color-scheme: light;
  --bg-root: #f8f8f9;
  --bg-panel: #ffffff;
  --bg-panel-soft: #f3f4f6;
  --bg-sidebar: #f1f2f4;
  --bg-hover: #e8eaed;
  --text-main: #18181b;
  --text-muted: #61656c;
  --text-soft: #92969d;
  --border: #e2e4e7;
  --border-strong: #cfd2d7;
  --accent: #18181b;
  --accent-hover: #000000;
  --accent-soft: #e8f0ff;
  --focus: #2563eb;
  --success: #16825d;
  --danger: #d0443e;
  --warning: #b66a13;
  --shadow-sm: 0 1px 2px rgba(18, 24, 40, 0.06), 0 1px 4px rgba(18, 24, 40, 0.04);
  --shadow-md: 0 12px 32px rgba(18, 24, 40, 0.10), 0 2px 8px rgba(18, 24, 40, 0.05);
  --shadow-lg: 0 24px 72px rgba(18, 24, 40, 0.16), 0 4px 16px rgba(18, 24, 40, 0.07);
  --shadow: var(--shadow-lg);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 14px;
  --duration: 180ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg-root: #111214;
    --bg-panel: #1a1b1e;
    --bg-panel-soft: #23252a;
    --bg-sidebar: #161719;
    --bg-hover: #292b30;
    --text-main: #f4f4f5;
    --text-muted: #b1b3b8;
    --text-soft: #777b83;
    --border: #2c2e33;
    --border-strong: #40434a;
    --accent: #f4f4f5;
    --accent-hover: #ffffff;
    --accent-soft: rgba(66, 133, 244, 0.18);
    --focus: #76a7ff;
    --success: #4fc59a;
    --danger: #ff7770;
    --warning: #eab05f;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.26);
    --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.34);
    --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.48);
    --shadow: var(--shadow-lg);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--bg-root);
  color: var(--text-main);
  font-family: var(--font);
  letter-spacing: 0;
}

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

button {
  border: 0;
}

.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-root);
}

.sidebar {
  width: 304px;
  min-width: 304px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  transition: width 0.18s ease, min-width 0.18s ease, transform 0.22s ease;
}

.sidebar.collapsed {
  width: 84px;
  min-width: 84px;
}

.sidebar.collapsed .mode-switch,
.sidebar.collapsed .search-wrap,
.sidebar.collapsed .session-list,
.sidebar.collapsed .plain-row-text {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  flex-direction: column;
  justify-content: center;
  padding-inline: 10px;
}

.sidebar.collapsed .primary-action {
  width: 48px;
  flex: 0 0 38px;
  padding: 0;
  font-size: 0;
}

.sidebar.collapsed .primary-action::before {
  content: "+";
  font-size: 22px;
  line-height: 1;
}

.sidebar.collapsed .plain-row {
  justify-content: center;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 12px;
}

.icon-button,
.tool-button,
.accent-button,
.danger-button,
.primary-action,
.mini-button,
.chip,
.mode-button,
.plain-row,
.stop-button,
.send-button {
  min-height: 38px;
  border-radius: var(--radius);
  color: var(--text-main);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.icon-button {
  width: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.icon-button:hover,
.tool-button:hover,
.plain-row:hover,
.mini-button:hover {
  background: var(--bg-hover);
}

.primary-action {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  font-weight: 650;
}

.primary-action:hover {
  border-color: var(--border-strong);
  background: var(--bg-panel-soft);
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 14px 12px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.42);
}

.mode-button {
  min-height: 34px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 650;
}

.mode-button.active {
  color: var(--text-main);
  background: var(--bg-panel);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.search-wrap {
  padding: 0 14px 12px;
}

.search-input,
.field input,
.field textarea,
.field select,
.quick-select,
#promptInput {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  color: var(--text-main);
  background: var(--bg-panel);
}

.search-input {
  height: 38px;
  padding: 0 12px;
}

.search-input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus,
.quick-select:focus,
#promptInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.session-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 10px 12px;
}

.session-group-label {
  padding: 12px 8px 6px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.session-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 8px 8px 10px;
  margin-bottom: 4px;
  border-radius: var(--radius);
  color: var(--text-main);
  background: transparent;
  text-align: left;
  cursor: pointer;
  user-select: none;
}

.session-item:hover,
.session-item.active {
  background: var(--bg-hover);
}

.session-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.session-meta {
  color: var(--text-soft);
  font-size: 11px;
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
}

.session-item:hover .session-actions,
.session-item.active .session-actions {
  opacity: 1;
}

.tiny-action {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
}

.tiny-action:hover {
  color: var(--text-main);
  background: var(--bg-panel);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.plain-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  text-align: left;
}

.avatar {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #ffffff;
  background: linear-gradient(135deg, #23645a, #3b82f6);
  font-size: 12px;
  font-weight: 800;
}

.plain-row-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-root);
}

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px 12px;
}

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

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

.title-block h1 {
  max-width: min(520px, 42vw);
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 760;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-badge {
  max-width: min(360px, 40vw);
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--bg-panel);
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-button,
.accent-button,
.danger-button,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 650;
}

.accent-button {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.accent-button:hover {
  background: var(--accent-hover);
}

.danger-button {
  color: var(--danger);
  border-color: rgba(194, 65, 59, 0.28);
}

.danger-button:hover {
  background: rgba(194, 65, 59, 0.1);
}

.content-panel {
  position: relative;
  flex: 1;
  min-height: 0;
  display: none;
  padding: 0 24px;
  overflow: hidden;
}

.content-panel.active {
  display: block;
}

.messages {
  height: 100%;
  overflow-y: auto;
  padding: 10px 0 180px;
}

.message {
  display: flex;
  margin: 0 auto 14px;
  max-width: 980px;
  animation: appear 0.18s ease-out;
}

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

.bubble {
  max-width: min(760px, 86%);
  padding: 13px 15px;
  border-radius: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.message.user .bubble {
  color: #ffffff;
  background: var(--accent);
  border-bottom-right-radius: 5px;
}

.message.assistant .bubble {
  color: var(--text-main);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}

.message.error .bubble {
  color: var(--danger);
  background: rgba(194, 65, 59, 0.1);
  border-color: rgba(194, 65, 59, 0.25);
}

.message-tools {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.copy-message,
.retry-message {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  background: var(--bg-panel-soft);
  cursor: pointer;
  font-size: 12px;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}

.empty-state.compact {
  position: static;
  min-height: 360px;
}

.empty-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 26px;
  font-weight: 800;
}

.empty-state h2 {
  margin: 16px 0 6px;
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  color: var(--text-muted);
}

.composer {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 10;
  pointer-events: none;
}

.composer-card {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  pointer-events: auto;
}

#promptInput {
  min-height: 54px;
  max-height: 220px;
  resize: none;
  border: 0;
  padding: 10px 12px;
  background: transparent;
  line-height: 1.5;
}

#promptInput:focus {
  box-shadow: none;
}

.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 6px;
}

.quick-controls,
.send-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chip {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 650;
}

.chip.active {
  color: var(--accent);
  border-color: rgba(35, 100, 90, 0.42);
  background: var(--accent-soft);
}

.quick-select {
  width: 220px;
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.send-button,
.stop-button {
  min-width: 72px;
  padding: 0 16px;
  font-weight: 760;
}

.send-button {
  color: #ffffff;
  background: var(--accent);
}

.send-button:hover {
  background: var(--accent-hover);
}

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

.stop-button {
  color: var(--danger);
  border: 1px solid rgba(194, 65, 59, 0.32);
  background: rgba(194, 65, 59, 0.1);
}

.image-workbench {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  padding-bottom: 180px;
}

.image-preview,
.image-history {
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-panel);
  overflow: hidden;
}

.image-preview {
  overflow-y: auto;
  padding: 16px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.image-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-panel-soft);
}

.image-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.image-card-body {
  padding: 10px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.image-history {
  display: flex;
  flex-direction: column;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 750;
}

.mini-button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
}

.history-item {
  width: 100%;
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-main);
  background: var(--bg-panel-soft);
  text-align: left;
  cursor: pointer;
}

.history-item:hover {
  border-color: var(--border-strong);
}

.history-prompt {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  font-size: 13px;
  line-height: 1.45;
}

.history-meta {
  margin-top: 6px;
  color: var(--text-soft);
  font-size: 11px;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.36);
}

.settings-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  color: var(--text-main);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.34);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.settings-header h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--bg-panel-soft);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.ok {
  color: var(--accent);
  background: var(--accent-soft);
}

.status-pill.error {
  color: var(--danger);
  background: rgba(194, 65, 59, 0.1);
}

.settings-body {
  overflow-y: auto;
  padding: 18px 20px 20px;
}

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

.settings-note {
  margin: -4px 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  background: var(--bg-panel-soft);
  font-size: 13px;
  line-height: 1.55;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}

.field span {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  height: 40px;
  padding: 0 11px;
}

.field textarea {
  min-height: 90px;
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.5;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 2px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-main);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  line-height: 1.45;
}

.toast.error {
  color: var(--danger);
  border-color: rgba(194, 65, 59, 0.28);
}

.mobile-only {
  display: none;
}

.is-loading {
  opacity: 0.72;
}

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }

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

  .sidebar.collapsed {
    width: 304px;
    min-width: 304px;
  }

  .workspace {
    width: 100%;
  }

  .topbar {
    padding: max(14px, env(safe-area-inset-top)) 14px 10px;
  }

  .title-block {
    gap: 8px;
  }

  .title-block h1 {
    font-size: 19px;
  }

  .model-badge {
    max-width: 42vw;
  }

  .content-panel {
    padding: 0 12px;
  }

  .composer {
    left: 0;
    right: 0;
    bottom: 0;
  }

  .composer-card {
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
  }

  .composer-row {
    align-items: stretch;
    flex-direction: column;
  }

  .quick-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .quick-select {
    flex: 1;
    min-width: 160px;
  }

  .send-wrap {
    justify-content: flex-end;
  }

  .messages {
    padding-bottom: 210px;
  }

  .image-workbench {
    grid-template-columns: 1fr;
    padding-bottom: 230px;
  }

  .image-history {
    display: none;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .mobile-only {
    display: inline-flex;
  }

  .desktop-only {
    display: none;
  }
}

@media (max-width: 560px) {
  .top-actions {
    gap: 6px;
  }

  .tool-button,
  .accent-button {
    padding: 0 10px;
    font-size: 13px;
  }

  .model-badge {
    display: none;
  }

  #openHistory,
  #testModels {
    display: none;
  }

  .title-line {
    flex: 1;
  }

  .title-block h1 {
    max-width: none;
    font-size: 17px;
    line-height: 1.2;
    white-space: normal;
  }

  .bubble {
    max-width: 94%;
  }
}

.visual-shell {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  padding-bottom: 190px;
}

.visual-main,
.visual-inspector {
  min-height: 0;
}

.visual-main {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), var(--bg-panel));
  overflow: hidden;
}

.visual-tabs {
  display: inline-flex;
  width: fit-content;
  gap: 6px;
  margin: 14px 14px 0;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-panel-soft);
}

.visual-tab,
.segment-button,
.option-button {
  min-height: 32px;
  border-radius: 8px;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.visual-tab {
  padding: 0 14px;
}

.visual-tab.active,
.segment-button.active,
.option-button.active {
  color: var(--text-main);
  background: var(--bg-panel);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.visual-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.visual-head h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.2;
}

.visual-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.visual-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hint-pill,
.soft-count {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--bg-panel-soft);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.visual-canvas {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}

.visual-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.visual-task {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-panel);
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
  animation: appear 0.18s ease-out;
}

.visual-task-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 10px;
}

.task-model {
  max-width: min(560px, 55vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}

.task-meta {
  margin-top: 3px;
  color: var(--text-soft);
  font-size: 11px;
}

.task-type {
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.task-prompt {
  padding: 0 12px 12px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.task-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: 8px;
  padding: 0 12px 12px;
}

.generated-media-item {
  position: relative;
  min-width: 0;
}

.generated-media-item > .generated-media {
  width: 100%;
}

.generated-media {
  position: relative;
  display: block;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel-soft);
  overflow: hidden;
}

.generated-image {
  padding: 0;
  cursor: zoom-in;
}

.generated-image img,
.generated-video video {
  display: block;
  width: 100%;
  min-height: 360px;
  max-height: 68vh;
  object-fit: contain;
  background: #101216;
}

.generated-video video {
  aspect-ratio: 16 / 9;
  min-height: 0;
  background: #000000;
}

.media-open,
.media-continue,
.media-to-video {
  position: absolute;
  bottom: 8px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.62);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.media-open {
  right: 8px;
}

.media-to-video {
  right: 8px;
}

.media-continue {
  left: 8px;
}

.media-open:hover,
.media-continue:hover,
.media-to-video:hover {
  background: rgba(0, 0, 0, 0.82);
}

.task-loading,
.task-error {
  min-height: 210px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  color: var(--text-muted);
  background: var(--bg-panel-soft);
  text-align: center;
}

.task-loading small {
  max-width: 100%;
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.task-error {
  color: var(--danger);
  overflow-wrap: anywhere;
}

.loader-dot {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.task-param-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 12px;
}

.task-param-row span {
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--bg-panel-soft);
  font-size: 11px;
  font-weight: 700;
}

.task-param-row .context-param {
  color: var(--accent);
  border-color: rgba(35, 100, 90, 0.35);
  background: var(--accent-soft);
}

.media-viewer {
  width: min(1440px, calc(100vw - 24px));
  height: min(940px, calc(100vh - 24px));
  padding: 0;
  border: 1px solid #30343b;
  border-radius: 12px;
  color: #f6f7f9;
  background: #111317;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
  overflow: hidden;
}

.media-viewer::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.viewer-toolbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid #30343b;
  background: #191c21;
}

.viewer-toolbar > div:first-child {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.viewer-toolbar strong {
  max-width: min(620px, 48vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.viewer-toolbar span {
  color: #aeb6c2;
  font-size: 12px;
  white-space: nowrap;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.viewer-actions .icon-button,
.viewer-actions .tool-button {
  color: #f6f7f9;
  border-color: #3b414b;
  background: #252a31;
}

.viewer-download {
  min-height: 38px;
  text-decoration: none;
}

.viewer-stage {
  width: 100%;
  height: calc(100% - 58px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  background: #0b0d10;
}

.viewer-stage img,
.viewer-stage video {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center;
  transition: transform 0.16s ease;
}

.task-references {
  padding: 0 12px 12px;
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.task-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 12px;
}

.task-actions span {
  min-width: 0;
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.task-command-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel-soft);
}

.task-command-row .task-delete {
  color: var(--danger);
  border-color: rgba(194, 65, 59, 0.28);
}

.task-command-row .task-delete:hover,
.task-command-row .task-delete.armed {
  background: rgba(194, 65, 59, 0.1);
}

.visual-inspector {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.inspector-panel {
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-panel);
  overflow: hidden;
}

.inspector-panel:last-child {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.model-summary {
  padding: 14px;
}

.model-name {
  font-size: 16px;
  font-weight: 820;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.model-provider {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.capability-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.capability-row span {
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 800;
}

.model-param-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.model-param-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel-soft);
}

.model-param-list span {
  color: var(--text-muted);
  font-size: 12px;
}

.model-param-list strong {
  min-width: 0;
  color: var(--text-main);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visual-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px 8px;
}

.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px 8px;
}

.model-picker-trigger {
  max-width: min(430px, 44vw);
  min-height: 34px;
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-main);
  background: var(--bg-panel-soft);
  cursor: pointer;
}

.model-picker-trigger > span:first-child {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

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

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

.message-attachments span,
.message-web-badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
}

.message-web-badge {
  width: fit-content;
  margin-top: 7px;
}

.model-picker-dialog {
  width: min(900px, calc(100vw - 32px));
  height: min(650px, calc(100vh - 40px));
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  color: var(--text-main);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.model-picker-dialog::backdrop {
  background: rgba(20, 24, 31, 0.36);
  backdrop-filter: blur(3px);
}

.model-picker-header {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px 0 20px;
  border-bottom: 1px solid var(--border);
}

.model-picker-header > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.model-picker-header span {
  color: var(--text-soft);
  font-size: 12px;
}

.model-picker-body {
  height: calc(100% - 58px);
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.model-vendor-panel {
  min-width: 0;
  padding: 14px 12px;
  border-right: 1px solid var(--border);
  background: var(--bg-panel-soft);
  overflow-y: auto;
}

.model-vendor-heading {
  padding: 0 8px 10px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
}

.model-vendor-list {
  display: grid;
  gap: 4px;
}

.model-vendor-button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-weight: 700;
}

.model-vendor-button:hover,
.model-vendor-button.active {
  color: var(--text-main);
  background: var(--bg-hover);
}

.model-vendor-button small {
  color: var(--text-soft);
  font-size: 11px;
}

.model-results-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow: hidden;
}

.model-search-wrap {
  min-height: 44px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel-soft);
}

.model-search-wrap > span {
  color: var(--text-soft);
  font-size: 22px;
}

.model-search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text-main);
  background: transparent;
}

.model-picker-list {
  flex: 1;
  min-height: 0;
  margin-top: 10px;
  overflow-y: auto;
}

.model-result-item {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 13px;
  border-radius: 8px;
  color: var(--text-main);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.model-result-item:hover,
.model-result-item.active {
  background: var(--bg-panel-soft);
}

.model-result-item > span:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.model-result-item strong,
.model-result-item small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-result-item strong {
  font-size: 14px;
}

.model-result-item small {
  color: var(--text-soft);
  font-size: 11px;
}

.model-result-check {
  width: 24px;
  flex: 0 0 24px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.model-picker-empty {
  padding: 36px 16px;
  color: var(--text-soft);
  text-align: center;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel-soft);
}

.mini-segmented {
  flex-shrink: 0;
}

.segment-button {
  padding: 0 10px;
  white-space: nowrap;
}

.tool-chip {
  background: var(--bg-panel-soft);
}

.draft-media-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px 8px;
}

.draft-media {
  max-width: 240px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 6px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-panel-soft);
}

.draft-media img,
.draft-file-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 6px;
  object-fit: cover;
}

.draft-file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 10px;
  font-weight: 800;
}

.draft-media span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.draft-media button {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
}

.draft-media button:hover {
  color: var(--danger);
  background: rgba(194, 65, 59, 0.1);
}

.composer-card {
  position: relative;
}

.output-popover {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  max-height: min(560px, 58vh);
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

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

.setting-row,
.inline-field,
.toggle-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.setting-row > span,
.inline-field > span,
.toggle-row > span {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
}

.option-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.option-button {
  min-width: 64px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--bg-panel-soft);
  white-space: nowrap;
}

.compact-options .option-button {
  min-width: 52px;
}

.inline-field input {
  width: 120px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  background: var(--bg-panel-soft);
}

.toggle-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

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

@media (min-width: 901px) {
  .settings-dialog {
    width: min(980px, calc(100vw - 48px));
  }
}

@media (max-width: 1120px) {
  .visual-shell {
    grid-template-columns: minmax(0, 1fr) 240px;
  }
}

@media (max-width: 900px) {
  .visual-shell {
    grid-template-columns: 1fr;
    padding-bottom: 250px;
  }

  .visual-inspector {
    display: none;
  }

  .visual-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .visual-head-actions {
    width: 100%;
    justify-content: space-between;
  }

  .visual-grid {
    grid-template-columns: 1fr;
  }

  .output-popover {
    left: 10px;
    right: 10px;
    max-height: 52vh;
  }

  .setting-row,
  .inline-field,
  .toggle-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

}

@media (max-width: 560px) {
  .visual-toolbar {
    gap: 6px;
  }

  .segmented {
    width: 100%;
  }

  .segment-button {
    flex: 1;
  }

  .tool-chip {
    flex: 1 1 calc(50% - 6px);
  }

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

  .model-picker-trigger {
    width: 100%;
    max-width: none;
  }

  .model-picker-dialog {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .model-picker-body {
    grid-template-columns: 118px minmax(0, 1fr);
  }

  .model-vendor-panel,
  .model-results-panel {
    padding: 10px 8px;
  }

  .model-vendor-button {
    min-height: 40px;
    padding: 0 8px;
    font-size: 12px;
  }

  .draft-media {
    max-width: 100%;
  }

  .task-media-grid {
    grid-template-columns: 1fr;
  }

  .generated-image img,
  .generated-video video {
    min-height: 240px;
    max-height: 58vh;
  }

  .media-viewer {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .viewer-toolbar {
    height: auto;
    min-height: 58px;
    align-items: flex-start;
    flex-direction: column;
    padding: 10px;
  }

  .viewer-toolbar strong {
    max-width: 72vw;
  }

  .viewer-actions {
    width: 100%;
  }

  .viewer-actions .tool-button,
  .viewer-actions .icon-button {
    flex: 1;
    min-width: 0;
  }

  .viewer-stage {
    height: calc(100% - 112px);
    padding: 10px;
  }
}

/* Premium UI layer: presentation-only overrides. */

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

button,
input,
textarea,
select,
summary,
a {
  -webkit-tap-highlight-color: transparent;
}

button,
summary,
a,
.session-item,
.history-item,
.generated-media,
.model-result-item,
.model-vendor-button {
  transition:
    color var(--duration) var(--ease),
    background-color var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    opacity var(--duration) var(--ease),
    transform var(--duration) var(--ease);
}

button:active:not(:disabled),
summary:active,
.session-item:active,
.history-item:active {
  transform: scale(0.98);
}

:where(button, input, textarea, select, summary, a, .session-item):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

::selection {
  color: #ffffff;
  background: var(--focus);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--border-strong);
  background-clip: padding-box;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

.app-shell,
.workspace {
  background: var(--bg-root);
}

.sidebar {
  width: 268px;
  min-width: 268px;
  border-right-color: color-mix(in srgb, var(--border) 72%, transparent);
  background: var(--bg-sidebar);
  transition:
    width var(--duration) var(--ease),
    min-width var(--duration) var(--ease),
    transform var(--duration) var(--ease);
}

.sidebar.collapsed {
  width: 72px;
  min-width: 72px;
}

.sidebar-header {
  gap: 8px;
  padding: 14px 12px 10px;
}

.sidebar-header .icon-button {
  color: var(--text-muted);
}

.primary-action {
  min-height: 38px;
  border-color: transparent;
  background: var(--bg-panel);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  font-weight: 680;
}

.primary-action:hover {
  border-color: transparent;
  background: var(--bg-panel);
  box-shadow: 0 4px 14px rgba(18, 24, 40, 0.09);
  transform: translateY(-1px);
}

.mode-switch {
  gap: 2px;
  margin: 0 12px 10px;
  padding: 3px;
  border: 0;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-hover) 72%, transparent);
}

.mode-button {
  min-height: 32px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 650;
}

.mode-button.active {
  background: var(--bg-panel);
  box-shadow: var(--shadow-sm);
}

.search-wrap {
  padding: 0 12px 8px;
}

.search-input {
  height: 36px;
  padding-inline: 11px;
  border-color: transparent;
  background: color-mix(in srgb, var(--bg-panel) 66%, transparent);
  font-size: 13px;
}

.search-input:hover,
.search-input:focus {
  border-color: var(--border);
  background: var(--bg-panel);
}

.session-list {
  padding: 2px 8px 12px;
}

.session-group-label {
  padding: 14px 10px 5px;
  font-size: 11px;
  font-weight: 650;
}

.session-item {
  position: relative;
  min-height: 40px;
  gap: 4px;
  margin-bottom: 2px;
  padding: 7px 6px 7px 10px;
  border-radius: var(--radius);
}

.session-item:hover {
  background: color-mix(in srgb, var(--bg-hover) 72%, transparent);
}

.session-item.active {
  background: var(--bg-hover);
  box-shadow: inset 2px 0 0 var(--text-main);
}

.session-item.menu-open {
  z-index: 30;
  margin-bottom: 42px;
}

.session-title {
  font-size: 13px;
  line-height: 1.45;
}

.session-menu {
  position: relative;
  z-index: 2;
}

.session-menu > summary {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  list-style: none;
  opacity: 0;
}

.session-menu > summary::-webkit-details-marker {
  display: none;
}

.session-item:hover .session-menu > summary,
.session-item.active .session-menu > summary,
.session-menu[open] > summary,
.session-menu > summary:focus-visible {
  opacity: 1;
}

.session-menu > summary:hover,
.session-menu[open] > summary {
  color: var(--text-main);
  background: var(--bg-panel);
  box-shadow: var(--shadow-sm);
}

.session-menu .session-actions {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  z-index: 20;
  width: max-content;
  display: flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  box-shadow: var(--shadow-md);
  opacity: 1;
}

.session-menu:not([open]) .session-actions {
  display: none;
}

.tiny-action {
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.tiny-action:hover {
  background: var(--bg-hover);
}

.sidebar-footer {
  padding: 8px;
  border-top-color: color-mix(in srgb, var(--border) 72%, transparent);
}

.plain-row {
  min-height: 44px;
  border-radius: var(--radius);
}

.avatar {
  border-radius: var(--radius);
  background: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.topbar {
  min-height: 68px;
  padding: 14px 22px 10px;
}

.title-block h1 {
  font-size: 19px;
  font-weight: 720;
  letter-spacing: 0;
}

.model-badge,
.hint-pill,
.soft-count,
.status-pill {
  border: 0;
  background: var(--bg-panel-soft);
  font-weight: 620;
}

.top-actions {
  gap: 6px;
}

.tool-button,
.accent-button,
.danger-button,
.mini-button {
  border-radius: var(--radius);
  font-weight: 650;
}

.tool-button,
.mini-button {
  border-color: transparent;
  background: transparent;
}

.tool-button:hover,
.mini-button:hover {
  border-color: transparent;
  background: var(--bg-hover);
}

.accent-button,
.send-button {
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.accent-button:hover,
.send-button:hover {
  box-shadow: 0 5px 16px rgba(18, 24, 40, 0.16);
  transform: translateY(-1px);
}

.content-panel {
  padding: 0 22px;
}

.messages {
  padding: 18px 0 184px;
}

.message {
  max-width: 900px;
  margin-bottom: 20px;
}

.bubble {
  padding: 12px 15px;
  border-radius: var(--radius-lg);
  box-shadow: none;
  line-height: 1.62;
}

.message.user .bubble {
  border-bottom-right-radius: var(--radius-sm);
}

.message.assistant .bubble {
  padding-inline: 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.copy-message,
.retry-message {
  border-color: transparent;
  background: transparent;
}

.copy-message:hover,
.retry-message:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.empty-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  background: var(--bg-panel-soft);
  font-size: 21px;
}

.empty-state h2 {
  margin-top: 14px;
  font-size: 17px;
}

.empty-state p {
  font-size: 13px;
}

.composer {
  left: 22px;
  right: 22px;
  bottom: max(18px, env(safe-area-inset-bottom));
}

.composer-card {
  max-width: 980px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--border-strong) 74%, transparent);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px) saturate(130%);
}

.composer-card:focus-within {
  border-color: color-mix(in srgb, var(--focus) 52%, var(--border));
  box-shadow: var(--shadow-md), 0 0 0 3px color-mix(in srgb, var(--focus) 12%, transparent);
}

#promptInput {
  min-height: 56px;
  padding: 9px 10px;
  font-size: 15px;
  line-height: 1.55;
}

#promptInput::placeholder {
  color: var(--text-soft);
}

.composer-row {
  gap: 10px;
  padding-top: 4px;
}

.visual-toolbar,
.chat-toolbar,
.draft-media-tray {
  gap: 6px;
  padding: 0 0 7px;
}

.chip,
.model-picker-trigger,
.segmented {
  border-color: transparent;
  background: var(--bg-panel-soft);
}

.chip {
  min-height: 30px;
  padding-inline: 9px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 620;
}

.chip:hover,
.model-picker-trigger:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.chip.active {
  border-color: transparent;
  color: var(--focus);
  background: var(--accent-soft);
}

.segmented {
  border-radius: var(--radius);
}

.segment-button,
.option-button,
.visual-tab {
  border-radius: var(--radius-sm);
  font-weight: 650;
}

.segment-button.active,
.option-button.active,
.visual-tab.active {
  box-shadow: var(--shadow-sm);
}

.model-picker-trigger {
  min-height: 32px;
  border-radius: var(--radius);
}

.send-button {
  min-width: 64px;
  min-height: 36px;
  border-radius: var(--radius);
}

.output-popover {
  bottom: calc(100% + 12px);
  padding: 16px;
  border-color: color-mix(in srgb, var(--border-strong) 75%, transparent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.option-button {
  border-color: transparent;
}

.option-button:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.inline-field input {
  border-color: transparent;
}

.inline-field input:focus {
  border-color: var(--focus);
  outline: 0;
}

.visual-shell {
  grid-template-columns: minmax(0, 1fr) 232px;
  gap: 20px;
  padding-bottom: 176px;
}

.visual-main {
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

.visual-tabs {
  gap: 2px;
  margin: 2px 0 0;
  padding: 3px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-panel-soft);
}

.visual-tab {
  min-height: 30px;
  padding-inline: 12px;
  font-size: 12px;
}

.visual-head {
  align-items: center;
  padding: 16px 2px 12px;
  border-bottom-color: color-mix(in srgb, var(--border) 72%, transparent);
}

.visual-head h2 {
  margin-bottom: 4px;
  font-size: 18px;
  font-weight: 720;
}

.visual-head p {
  font-size: 12px;
}

.visual-canvas {
  padding: 14px 0 24px;
}

.visual-grid {
  gap: 20px;
}

.visual-task {
  border-color: color-mix(in srgb, var(--border) 78%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.visual-task:hover {
  border-color: var(--border-strong);
  box-shadow: 0 8px 24px rgba(18, 24, 40, 0.08);
}

.visual-task-header {
  padding: 13px 14px 9px;
}

.task-model {
  font-weight: 700;
}

.task-type,
.task-param-row span {
  border: 0;
  border-radius: 999px;
  font-weight: 620;
}

.task-prompt {
  padding: 0 14px 13px;
}

.task-media-grid {
  gap: 10px;
  padding: 0 14px 14px;
}

.generated-media {
  border: 0;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #ffffff 9%, transparent);
}

.generated-image img,
.generated-video video {
  min-height: 460px;
  max-height: 74vh;
  transition: transform var(--duration) var(--ease), opacity var(--duration) var(--ease);
}

.generated-video video {
  min-height: 0;
}

.generated-image:hover img {
  transform: scale(1.006);
}

.media-open,
.media-continue,
.media-to-video {
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  background: rgba(16, 18, 22, 0.76);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(3px);
}

.generated-media-item:hover .media-continue,
.generated-media-item:hover .media-to-video,
.generated-video:hover .media-open,
.generated-video:hover .media-continue,
.media-open:focus-visible,
.media-continue:focus-visible,
.media-to-video:focus-visible {
  opacity: 1;
  transform: translateY(0);
}

.task-loading,
.task-error {
  min-height: 360px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-panel-soft);
}

.loader-dot {
  width: 28px;
  height: 28px;
  border-width: 2px;
  border-top-color: var(--focus);
}

.task-param-row,
.task-actions,
.task-references {
  padding-inline: 14px;
}

.task-command-row {
  padding: 8px 10px;
  border-top-color: color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--bg-panel-soft) 62%, transparent);
}

.visual-inspector {
  gap: 12px;
}

.inspector-panel {
  border: 0;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-panel-soft) 72%, transparent);
}

.inspector-panel .section-heading {
  padding: 11px 12px 8px;
  border: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.model-summary {
  padding: 8px 12px 12px;
}

.model-name {
  font-size: 14px;
  font-weight: 720;
}

.model-provider {
  margin-top: 4px;
  font-weight: 600;
}

.capability-row {
  gap: 4px;
  margin-top: 10px;
}

.capability-row span {
  min-height: 22px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: var(--bg-panel);
  font-weight: 620;
}

.model-advanced {
  margin-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.model-advanced > summary {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  list-style: none;
}

.model-advanced > summary::-webkit-details-marker {
  display: none;
}

.model-advanced > summary::after {
  content: "+";
  color: var(--text-soft);
  font-size: 16px;
  font-weight: 400;
}

.model-advanced[open] > summary::after {
  content: "−";
}

.model-param-list {
  gap: 2px;
  margin-top: 0;
  padding-bottom: 2px;
}

.model-param-list div {
  min-height: 30px;
  padding: 6px 0;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 66%, transparent);
  border-radius: 0;
  background: transparent;
}

.model-param-list div:last-child {
  border-bottom: 0;
}

.history-list {
  padding: 4px 6px 8px;
}

.history-item {
  margin-bottom: 2px;
  padding: 9px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
}

.history-item:hover {
  background: var(--bg-hover);
}

.history-prompt {
  -webkit-line-clamp: 2;
  font-size: 12px;
}

.history-meta {
  font-size: 10px;
}

.settings-dialog,
.model-picker-dialog {
  border-color: color-mix(in srgb, var(--border-strong) 78%, transparent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.settings-dialog::backdrop,
.model-picker-dialog::backdrop {
  background: rgba(14, 16, 20, 0.42);
  backdrop-filter: blur(5px);
}

.settings-header,
.model-picker-header {
  border-bottom-color: color-mix(in srgb, var(--border) 72%, transparent);
}

.settings-body {
  padding: 20px;
}

.settings-note {
  border: 0;
  background: var(--bg-panel-soft);
}

.field input,
.field textarea,
.field select,
.quick-select,
.model-search-wrap {
  border-color: transparent;
  background: var(--bg-panel-soft);
}

.field input:hover,
.field textarea:hover,
.field select:hover,
.quick-select:hover,
.model-search-wrap:hover {
  border-color: var(--border);
}

.model-vendor-panel {
  border-right-color: color-mix(in srgb, var(--border) 72%, transparent);
}

.model-vendor-button,
.model-result-item {
  border-radius: var(--radius-sm);
}

.model-result-item:hover,
.model-result-item.active {
  background: var(--bg-hover);
}

.media-viewer {
  border-radius: var(--radius-lg);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
}

.viewer-stage img,
.viewer-stage video {
  transition: transform var(--duration) var(--ease);
}

.toast {
  border-color: color-mix(in srgb, var(--border-strong) 75%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  animation: appear var(--duration) var(--ease);
}

.is-loading {
  cursor: progress;
  opacity: 0.68;
}

@media (prefers-color-scheme: dark) {
  .accent-button,
  .send-button,
  .message.user .bubble {
    color: #17181b;
  }

  .primary-action:hover,
  .visual-task:hover {
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.28);
  }

  .composer-card {
    background: color-mix(in srgb, var(--bg-panel) 90%, transparent);
  }
}

@media (max-width: 1120px) {
  .visual-shell {
    grid-template-columns: minmax(0, 1fr) 218px;
    gap: 14px;
  }

  .generated-image img {
    min-height: 400px;
  }
}

@media (max-width: 900px) {
  .sidebar,
  .sidebar.collapsed {
    width: min(292px, 88vw);
    min-width: min(292px, 88vw);
  }

  .topbar {
    min-height: 62px;
    padding: max(12px, env(safe-area-inset-top)) 12px 8px;
  }

  .content-panel {
    padding-inline: 12px;
  }

  .visual-shell {
    grid-template-columns: 1fr;
    gap: 0;
    padding-bottom: 236px;
  }

  .visual-head {
    align-items: flex-start;
  }

  .composer {
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .composer-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
  }

  .messages {
    padding-bottom: 226px;
  }

  .generated-image img {
    min-height: 340px;
    max-height: 66vh;
  }

  .media-open,
  .media-continue,
  .media-to-video {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 560px) {
  .title-block h1 {
    font-size: 16px;
  }

  .composer-card {
    padding: 8px;
  }

  #promptInput {
    min-height: 48px;
    font-size: 14px;
  }

  .composer-row {
    gap: 6px;
  }

  .visual-head {
    gap: 10px;
    padding-top: 12px;
  }

  .visual-head-actions {
    justify-content: flex-start;
  }

  .visual-canvas {
    padding-top: 10px;
  }

  .visual-task-header,
  .task-media-grid {
    padding-inline: 10px;
  }

  .task-prompt,
  .task-param-row,
  .task-actions,
  .task-references {
    padding-inline: 10px;
  }

  .generated-image img,
  .generated-video video {
    min-height: 260px;
    max-height: 58vh;
  }

  .generated-video video {
    min-height: 0;
  }

  .output-popover {
    left: 0;
    right: 0;
    padding: 12px;
  }

  .setting-row,
  .inline-field,
  .toggle-row {
    gap: 6px;
  }
}

@media (hover: none) {
  .session-menu > summary,
  .media-open,
  .media-continue,
  .media-to-video {
    opacity: 1;
  }

  .media-open,
  .media-continue,
  .media-to-video {
    transform: none;
  }
}

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

/* Settings dialog */

.settings-trigger {
  gap: 7px;
}

.settings-trigger > span:first-child {
  font-size: 15px;
  line-height: 1;
}

.settings-dialog {
  position: fixed;
  inset: 0;
  width: min(880px, calc(100vw - 40px));
  height: min(720px, 82dvh);
  max-width: 880px;
  max-height: 82dvh;
  margin: auto;
  padding: 0;
  overflow: hidden;
}

.settings-dialog[open] {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) auto;
}

.settings-header {
  min-width: 0;
  padding: 0 14px 0 20px;
  background: var(--bg-panel);
}

.settings-header > div:first-child {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 720;
}

.settings-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
}

.settings-close:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.status-pill.ok {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 11%, transparent);
}

.status-pill.error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 11%, transparent);
}

.settings-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr);
  overflow: hidden;
}

.settings-nav {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 10px;
  border-right: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  background: color-mix(in srgb, var(--bg-panel-soft) 72%, var(--bg-panel));
}

.settings-nav-button {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 650;
}

.settings-nav-button:hover {
  color: var(--text-main);
  background: color-mix(in srgb, var(--bg-hover) 70%, transparent);
}

.settings-nav-button.active {
  color: var(--text-main);
  background: var(--bg-panel);
  box-shadow: var(--shadow-sm);
}

.settings-body {
  min-height: 0;
  padding: 22px 24px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.settings-section {
  max-width: 640px;
  margin: 0 auto;
  animation: appear var(--duration) var(--ease);
}

.settings-section h3 {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 720;
}

.settings-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.settings-section-title h3 {
  margin: 0;
}

.settings-section-title .tool-button {
  border-color: var(--border);
  background: var(--bg-panel);
}

.settings-grid {
  gap: 14px 16px;
}

.settings-model-grid {
  grid-template-columns: 1fr;
}

.settings-input-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
}

.settings-input-actions input {
  min-width: 0;
}

.input-action {
  min-width: 52px;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  background: var(--bg-panel-soft);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.input-action:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.settings-note {
  margin: 2px 0 14px;
  font-size: 12px;
}

.connection-detail {
  min-height: 42px;
  padding: 11px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  background: var(--bg-panel-soft);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.connection-detail.ok {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 9%, transparent);
}

.connection-detail.error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, transparent);
}

.settings-footer {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-top: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  background: var(--bg-panel);
}

.settings-footer-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-footer .tool-button,
.settings-footer .danger-button,
.settings-footer .accent-button {
  min-height: 36px;
}

.settings-footer .tool-button {
  border-color: var(--border);
  background: var(--bg-panel);
}

.settings-footer .tool-button:hover {
  background: var(--bg-hover);
}

.settings-footer button:disabled,
.settings-section-title button:disabled {
  cursor: wait;
  opacity: 0.64;
  transform: none;
}

.settings-confirm-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(14, 16, 20, 0.38);
  backdrop-filter: blur(3px);
}

.settings-confirm {
  width: min(390px, 100%);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  box-shadow: var(--shadow-lg);
}

.settings-confirm h3 {
  margin: 0 0 20px;
  font-size: 15px;
  font-weight: 680;
  line-height: 1.5;
}

.settings-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.settings-confirm-actions .tool-button,
.settings-confirm-actions .accent-button {
  min-height: 36px;
}

@media (max-width: 700px) {
  .settings-dialog {
    width: calc(100vw - 20px);
    height: 82dvh;
    max-height: 82dvh;
  }

  .settings-dialog[open] {
    grid-template-rows: 58px minmax(0, 1fr) auto;
  }

  .settings-header {
    padding-left: 16px;
  }

  .settings-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .settings-nav {
    flex-direction: row;
    gap: 4px;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }

  .settings-nav-button {
    min-width: 92px;
    min-height: 34px;
    padding-inline: 10px;
    text-align: center;
    white-space: nowrap;
  }

  .settings-body {
    padding: 18px 16px 24px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
  }

  .settings-footer-group {
    width: 100%;
  }

  .settings-footer-primary {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
  }

  .settings-footer-group:first-child .tool-button {
    flex: 1;
  }

  .settings-footer button {
    min-width: 0;
    padding-inline: 10px;
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  .settings-input-actions {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .settings-input-actions .input-action:last-child {
    grid-column: 2;
  }

  .settings-footer-primary {
    grid-template-columns: 1fr 1fr;
  }

  .settings-footer-primary .danger-button {
    grid-column: 1 / -1;
  }
}
