:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --panel: #111418;
  --panel-2: #171b20;
  --line: #2a2f37;
  --text: #f3f4f6;
  --muted: #9aa4b2;
  --accent: #66c2ff;
  --accent-2: #72d69f;
  --warn: #e7b454;
  --danger: #ff6b6b;
  --radius: 8px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-width: 320px;
}

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

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

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

body.sidebar-collapsed .sidebar {
  padding: 0;
  border-right: none;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #0f1216;
  padding: 18px;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

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

.topbar-head {
  min-width: 0;
}

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

.topbar-head h2,
.topbar-head p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill-btn {
  min-height: 32px;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pill-btn:hover {
  border-color: var(--accent);
}

.pill-btn.icon {
  padding: 5px 10px;
  font-size: 15px;
  line-height: 1;
}

.brand-mark {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: #f3f4f6;
  background-size: cover;
  background-position: center;
  color: #0b0d10;
  font-weight: 800;
  overflow: hidden;
  cursor: pointer;
}

.brand-mark:hover {
  box-shadow: 0 0 0 2px var(--accent);
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  letter-spacing: 0;
  white-space: nowrap;
}

h2 {
  font-size: 22px;
  letter-spacing: 0;
  white-space: nowrap;
}

h3 {
  font-size: 16px;
  letter-spacing: 0;
}

.brand p,
.topbar p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

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

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.panel-title {
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.panel-title::after {
  content: "▾";
  color: var(--muted);
  font-size: 12px;
  transition: transform 0.15s ease;
}

.panel.collapsed > .panel-title {
  margin-bottom: 0;
}

.panel.collapsed > .panel-title::after {
  transform: rotate(-90deg);
}

.panel.collapsed > :not(.panel-title) {
  display: none;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #303742;
  background: #0c0f13;
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 11px;
  outline: none;
}

textarea {
  min-height: 74px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(102, 194, 255, 0.16);
}

.field-block {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.segmented button {
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  font-weight: 600;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.segmented button:hover {
  border-color: transparent;
  background: rgba(102, 194, 255, 0.1);
  color: var(--text);
}

.segmented button.active {
  border-color: transparent;
  background: linear-gradient(180deg, #7cccff 0%, #4aa5f0 100%);
  color: #06121f;
  box-shadow: 0 2px 8px rgba(74, 165, 240, 0.35);
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.check-row input {
  width: auto;
}

.main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  min-height: 78px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.model-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: #0d1014;
}

.json-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}

.json-box > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  user-select: none;
}

.json-box > summary button {
  margin-left: 0;
}

.json-box > summary button:first-of-type {
  margin-left: auto;
}

.json-box > summary::-webkit-details-marker {
  display: none;
}

.json-box > summary::before {
  content: "▸";
  margin-right: 6px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.json-box[open] > summary::before {
  transform: rotate(90deg);
}

.json-box .json-result {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  border-top: 1px solid var(--line);
}

.model-strip button {
  display: grid;
  gap: 3px;
  justify-items: start;
  min-height: 52px;
}

.model-strip button strong {
  font-size: 13px;
  letter-spacing: 0;
}

.model-strip button span {
  color: var(--muted);
  font-size: 12px;
}

.model-strip button.active {
  border-color: var(--accent);
  background: #17212b;
}

.status {
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 11px;
  min-width: 74px;
  text-align: center;
  font-size: 13px;
}

.status.ok {
  border-color: rgba(54, 211, 153, 0.45);
  color: var(--accent-2);
}

.status.fail {
  border-color: rgba(255, 107, 107, 0.5);
  color: var(--danger);
}

.status.busy {
  border-color: rgba(245, 165, 36, 0.45);
  color: var(--warn);
}

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

.progress-track {
  flex: 1;
  height: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease;
}

.progress-wrap.done .progress-fill {
  background: var(--accent-2);
}

.progress-wrap.fail .progress-fill {
  background: var(--danger);
}

.progress-label {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 130px;
  text-align: right;
}

.suggestions {
  padding: 2px 0 6px;
}

.suggestions-title {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 6px;
}

.suggestion-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.suggestion-chip {
  text-align: left;
  white-space: normal;
  line-height: 1.4;
  width: 100%;
  font-size: 12px;
  min-height: 0;
  padding: 6px 10px;
}

.suggestion-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 22px 16px;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.prompt-zone,
.advanced,
.result-card {
  min-width: 0;
}

#instructions {
  min-height: 84px;
}

#prompt {
  min-height: 174px;
  font-size: 16px;
  line-height: 1.6;
}

.toolbar {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.toolbar.compact {
  gap: 8px;
}

button {
  min-height: 36px;
  border: 1px solid #343b46;
  background: #171b20;
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  color: #061018;
  border-color: var(--accent);
  font-weight: 750;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.tab {
  flex: 1;
}

.more-panel {
  margin-top: 4px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.more-panel > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  list-style: none;
  user-select: none;
}

.more-panel > summary::-webkit-details-marker {
  display: none;
}

.more-panel > summary::before {
  content: "▸ ";
}

.more-panel[open] > summary::before {
  content: "▾ ";
}

.more-panel > summary:hover {
  color: var(--accent);
}

.more-panel > * + * {
  margin-top: 10px;
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent);
}

.tab-panel {
  display: none;
}

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

#toolsJson,
#extraBody,
#rawBody {
  min-height: 150px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}

.results {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 18px 22px 24px;
  min-height: 0;
}

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

.result-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.result-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.metrics {
  color: var(--muted);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  white-space: nowrap;
}

.text-result {
  padding: 14px;
  white-space: pre-wrap;
  line-height: 1.55;
  min-height: 180px;
}

.reasoning-box {
  margin: 0 14px 4px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.reasoning-box > summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}

.reasoning-text {
  padding: 0 12px 12px;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 13px;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 0 14px 14px;
}

.image-grid img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #06101c;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.image-grid a {
  color: var(--accent);
  font-size: 13px;
}

.image-grid video {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #06101c;
}

.conversation-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  max-height: 680px;
  overflow-y: auto;
}

.conversation-history:empty::after {
  content: attr(data-i18n);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 40px 20px;
}

.conversation-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  overflow: hidden;
}

.conversation-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.conversation-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.conversation-item-time {
  font-family: Consolas, "SFMono-Regular", monospace;
}

.conversation-item-mode {
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(102, 194, 255, 0.15);
  color: var(--accent);
  font-weight: 600;
}

.conversation-item-prompt {
  padding: 10px 12px;
  font-size: 13px;
  color: #e8f1fb;
  border-bottom: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
  background: var(--panel-2);
}

.conversation-item-result {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.conversation-item-text {
  padding: 10px 12px;
  font-size: 13px;
  color: #d7e8fb;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.5;
}

.conversation-item-text.error {
  color: #f87171;
}

.conversation-item-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.conversation-item-images img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #06101c;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  cursor: pointer;
}

.conversation-item-images img:hover {
  border-color: var(--accent);
}

.conversation-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-size: 12px;
}

.conversation-item-buttons {
  display: flex;
  gap: 6px;
}

.conversation-item-buttons button {
  padding: 4px 8px;
  font-size: 12px;
  min-height: auto;
}


.conversation-item-video {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conversation-item-video video {
  width: 100%;
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #06101c;
}

.conversation-video-download {
  align-self: flex-start;
  font-size: 12px;
  color: var(--accent);
}

/* ===== Test connection inline status ===== */
.conn-test-row {
  align-items: center;
}

.conn-status {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.conn-status.ok {
  color: var(--accent-2);
}

.conn-status.fail {
  color: var(--danger);
}

.conn-status.testing {
  color: var(--muted);
}

/* ===== Chat thread (ChatGPT / Codex style) ===== */
.chat-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.conv-select {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 60%;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
}

.chat-thread {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 16px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-row {
  display: flex;
  width: 100%;
}

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

.chat-row.assistant {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 86%;
  border-radius: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  line-height: 1.6;
}

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

.chat-bubble.assistant {
  background: var(--panel-2);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-bubble.assistant.pending {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(102, 194, 255, 0.22);
}

.chat-role {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.75;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.chat-role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-role-row .chat-role {
  margin-bottom: 0;
}

.chat-copy {
  min-height: auto;
  padding: 2px 7px;
  font-size: 12px;
  line-height: 1;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.12s ease, border-color 0.12s ease;
}

.chat-bubble:hover .chat-copy {
  opacity: 0.9;
}

.chat-copy:hover {
  opacity: 1;
  border-color: var(--accent);
}

.chat-copy.copied {
  opacity: 1;
  color: var(--accent-2);
  border-color: var(--accent-2);
}

.chat-bubble.user .chat-copy {
  border-color: rgba(255, 255, 255, 0.4);
}

.chat-bubble.user .chat-copy:hover {
  border-color: #ffffff;
}

.chat-bubble.user .chat-role {
  color: rgba(255, 255, 255, 0.85);
}

.chat-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  color: inherit;
}

.chat-text.error {
  color: var(--danger);
}

.chat-bubble.assistant .chat-text.muted {
  color: var(--muted);
}

.chat-reasoning {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: var(--muted);
  background: rgba(102, 194, 255, 0.06);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.chat-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.chat-image-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-image-item img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #06101c;
  object-fit: contain;
  cursor: pointer;
}

.chat-image-item img:hover {
  border-color: var(--accent);
}

.chat-image-dl {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
}

.chat-image-dl:hover {
  border-color: var(--accent);
}

.chat-video {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-video video {
  width: 100%;
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #06101c;
}

.chat-video-download {
  align-self: flex-start;
  font-size: 12px;
  color: var(--accent);
}

.chat-foot {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  font-family: Consolas, "SFMono-Regular", monospace;
}

.chat-bubble.user .chat-foot {
  color: rgba(255, 255, 255, 0.7);
}

.conversation-empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 20px;
  font-size: 13px;
}

/* ===== Composer (Codex-style input) ===== */
.composer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.composer-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
  padding: 8px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(102, 194, 255, 0.22);
}

.composer-box #prompt {
  min-height: 52px;
  max-height: 40vh;
  border: none;
  background: transparent;
  padding: 4px 2px;
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  resize: none;
  outline: none;
  color: var(--text);
  box-shadow: none;
}

.composer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-spacer {
  flex: 1;
}

/* "+" upload button (bottom-left of the composer) */
.plus-btn {
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
}

.plus-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Hidden only in video mode (no upload there). */
body[data-mode="video"] .plus-btn {
  display: none;
}

.composer-mini {
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.composer-mini:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.composer-box.dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(102, 194, 255, 0.28);
}

.composer-send {
  border-radius: 999px;
  min-width: 104px;
  font-weight: 700;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 50%;
  flex: 0 0 auto;
}

.icon-btn svg {
  display: block;
}

.icon-btn.send-btn {
  color: #ffffff;
}

.icon-btn.cancel-btn {
  color: var(--text);
}

.icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.composer .upload-zone {
  margin-bottom: 0;
}

.composer .attach-list {
  margin-top: 0;
}

/* ===== Bottom panels (collapsed JSON + prices) ===== */
.bottom-panels {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== Usage strip (single row under progress) ===== */
.usage-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin: 8px 22px 0;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.usage-strip[hidden] {
  display: none;
}

.usage-strip-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.usage-strip .usage-cell {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.usage-strip .usage-cell b {
  font-size: 15px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.usage-strip .usage-cell i {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.usage-strip .link-btn {
  margin-left: auto;
}

.image-options,
.edit-options,
.video-options {
  display: none;
}

body[data-mode="images"] .image-options,
body[data-mode="image-edit"] .image-options {
  display: grid;
}

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

body[data-mode="images"] .edit-options,
body[data-mode="image-edit"] .edit-options {
  display: block;
}

body[data-mode="video"] .video-options {
  display: block;
}

.edit-options > label,
.video-options > .two {
  margin-bottom: 10px;
}

.edit-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.edit-preview:not([hidden]) {
  margin-bottom: 4px;
}

.edit-thumb {
  position: relative;
  width: 60px;
  height: 60px;
}

.edit-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #06101c;
}

.edit-thumb-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--danger);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.edit-thumb-remove:hover {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.edit-thumb-tag {
  position: absolute;
  left: 3px;
  bottom: 3px;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}

.upload-zone {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.upload-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.upload-head > span:first-child {
  font-weight: 700;
  color: #e8f1fb;
}

.upload-sub {
  color: var(--muted);
  font-size: 12px;
}

.upload-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 110px;
  padding: 18px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: #06101c;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.upload-drop:hover {
  border-color: var(--accent);
}

.upload-drop.dragover {
  border-color: var(--accent);
  background: rgba(102, 194, 255, 0.08);
}

.upload-cta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-cta strong {
  color: var(--accent);
  font-size: 15px;
}

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

.mask-row {
  margin-top: 12px;
}

.metrics-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

.metric-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  color: #d7e8fb;
}

.metric-chip b {
  color: var(--muted);
  font-weight: 600;
}

.token-viz {
  flex: 1;
  min-width: 220px;
}

.token-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #06101c;
  border: 1px solid var(--line);
}

.token-seg {
  height: 100%;
}

.token-seg.in {
  background: var(--accent);
}

.token-seg.out {
  background: var(--accent-2);
}

.token-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.token-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}

.token-legend .dot.in {
  background: var(--accent);
}

.token-legend .dot.out {
  background: var(--accent-2);
}

.token-total {
  margin-left: auto;
  color: #d7e8fb;
  font-weight: 600;
}

.json-result {
  margin: 0;
  padding: 14px;
  overflow: auto;
  max-height: 640px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #d7e8fb;
}

.table-wrap {
  overflow: auto;
}

.table-result {
  padding: 0 14px 14px;
  overflow: auto;
}

.table-result table {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-result td {
  font-size: 13px;
  color: #e3eefb;
}

.table-result td,
.table-result th {
  white-space: pre-wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: var(--panel-2);
}

@media (max-width: 1120px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }

  .main {
    height: auto;
    overflow: visible;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace,
  .results {
    grid-template-columns: 1fr;
  }

  .chat-card {
    flex: none;
  }

  .chat-thread {
    max-height: 62vh;
  }
}

@media (max-width: 640px) {
  .sidebar,
  .topbar,
  .workspace,
  .results {
    padding-left: 14px;
    padding-right: 14px;
  }

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

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

.attach-zone {
  display: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 12px;
}

body[data-mode="responses"] .attach-zone,
body[data-mode="chat"] .attach-zone,
body[data-mode="deep-research"] .attach-zone {
  display: block;
}

.attach-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.attach-head > span:first-child {
  font-weight: 700;
  font-size: 12px;
  color: #e8f1fb;
}

.attach-sub {
  color: var(--muted);
  font-size: 11px;
}

.attach-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: #06101c;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.attach-drop:hover {
  border-color: var(--accent);
}

.attach-drop.dragover {
  border-color: var(--accent);
  background: rgba(102, 194, 255, 0.08);
}

.attach-cta {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.attach-cta strong {
  color: var(--accent);
  font-size: 13px;
}

.attach-cta span {
  color: var(--muted);
  font-size: 11px;
}

.attach-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attach-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.attach-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 12px;
}

.attach-tag {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(102, 194, 255, 0.15);
  color: var(--accent);
}

.attach-tag.image {
  background: rgba(114, 214, 159, 0.18);
  color: var(--accent-2);
}

.attach-tag.file {
  background: rgba(231, 180, 84, 0.18);
  color: var(--warn);
}

.attach-tag.office {
  background: rgba(124, 92, 255, 0.18);
  color: #8b7bff;
}

.attach-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-size {
  flex-shrink: 0;
  color: var(--muted);
}

.attach-remove {
  flex-shrink: 0;
  min-height: 0;
  padding: 0 7px;
  line-height: 1.5;
  border-radius: 6px;
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
}

.attach-remove:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Cumulative usage totals */
.usage-totals {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.usage-totals-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #e8f1fb;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}

.usage-totals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
}

.usage-totals-grid span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #06101c;
}

.usage-totals-grid b {
  font-size: 18px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.usage-totals-grid i {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

/* Price panel */
.price-panel {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.price-panel > summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #e8f1fb;
  user-select: none;
}

.price-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 10px;
}

.price-controls input {
  flex: 1 1 180px;
  min-width: 140px;
}

.price-controls select {
  width: auto;
}

.price-status {
  padding: 0 14px 8px;
  font-size: 12px;
}

.price-table {
  max-height: 360px;
  overflow: auto;
  padding: 0 14px 14px;
}

.price-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.price-table th,
.price-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.price-table th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
}

.price-table .price-num {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--accent-2);
}

.price-meter {
  font-size: 12px;
}

.price-prod {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* ===== Light theme ===== */
body.theme-light {
  color-scheme: light;
  --bg: #eef1f6;
  --panel: #ffffff;
  --panel-2: #f4f6fa;
  --line: #d4dae3;
  --text: #1b2330;
  --muted: #5b6675;
  --accent: #1565d8;
  --accent-2: #1f9d57;
  --warn: #b5790f;
  --danger: #d23b34;
}

body.theme-light .sidebar {
  background: #f6f8fb;
}

body.theme-light .brand-mark {
  background: var(--accent);
  color: #ffffff;
}

body.theme-light input,
body.theme-light select,
body.theme-light textarea {
  background: #ffffff;
  border-color: #c9d1dc;
}

body.theme-light button {
  background: #f0f3f8;
  border-color: #cdd5e0;
}

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

body.theme-light .metric-chip,
body.theme-light .token-total,
body.theme-light .json-result,
body.theme-light .table-result td {
  color: var(--text);
}

body.theme-light .model-strip {
  background: #e9eef5;
}

body.theme-light .model-strip button.active {
  background: #dce9fb;
}

body.theme-light .image-grid img,
body.theme-light .image-grid video,
body.theme-light .usage-totals-grid span,
body.theme-light .upload-drop,
body.theme-light .attach-drop {
  background: #f1f4f9;
}

body.theme-light .upload-drop.dragover {
  background: rgba(21, 101, 216, 0.08);
}

body.theme-light .upload-head > span:first-child,
body.theme-light .attach-head > span:first-child,
body.theme-light .usage-totals-head,
body.theme-light .price-panel > summary {
  color: #16314f;
}

body.theme-light .reasoning-box {
  background: rgba(20, 30, 45, 0.03);
}



/* ---- View switch + AI Services panel ---- */
.view-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.view-switch button {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.view-switch button.active {
  background: var(--accent);
  color: #06101c;
}

body.view-services .chat-card,
body.view-services .bottom-panels,
body.view-services #usageTotals { display: none; }
body:not(.view-services) .services-card { display: none; }

.services-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card, var(--panel));
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
}

.svc-head h3 { margin: 0 0 4px; font-size: 16px; }
.svc-head p { margin: 0; font-size: 12px; }

.svc-conn {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr;
  gap: 10px;
}

.svc-conn label,
.svc-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.svc-conn input,
.svc-panel input,
.svc-panel select,
.svc-panel textarea {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
}

.svc-panel textarea { resize: vertical; }

.svc-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 4px; }

.svc-panel { display: none; flex-direction: column; gap: 12px; }
.svc-panel.active { display: flex; }

.svc-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.svc-grow { flex: 1 1 240px; }
.svc-inline { flex-direction: column; }

.svc-run {
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  margin-left: auto;
}

.svc-file-btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

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

.svc-result {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
}

.svc-result.error { border-color: var(--danger); color: var(--danger); }
.svc-result audio { width: 100%; margin-top: 6px; }
.svc-result pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; }
.svc-result .svc-meta { color: var(--muted); font-size: 11px; margin-top: 8px; }
.svc-result table { border-collapse: collapse; width: 100%; margin-top: 6px; }
.svc-result th, .svc-result td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; }
.svc-result mark { background: rgba(231, 180, 84, 0.35); color: inherit; padding: 0 2px; border-radius: 3px; }

body.theme-light .svc-run,
body.theme-light .view-switch button.active { color: #fff; }
body.theme-light .view-switch button.active { background: #1565d8; }

@media (max-width: 720px) {
  .svc-conn { grid-template-columns: 1fr; }
  .view-switch button { padding: 6px 10px; }
}

/* ---- Speech modules: audio input, voice gallery, pronunciation ---- */
.audio-input {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.audio-rec {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--danger);
  font-weight: 600;
  cursor: pointer;
}

.audio-rec.recording {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  animation: recPulse 1.1s ease-in-out infinite;
}

@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(255, 107, 107, 0); }
}

.svc-dl {
  display: inline-block;
  margin-top: 8px;
  margin-left: 10px;
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
}
.svc-dl:hover { text-decoration: underline; }

.voice-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  margin-top: 4px;
}

.voice-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.voice-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.voice-info b { font-size: 13px; }
.voice-info span { font-size: 11px; }
.voice-info code { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.voice-play {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}
.voice-play:hover { background: var(--accent); color: #06121f; }

.pron-scores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 16px;
  margin-bottom: 12px;
}

.pron-score {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.pron-score span { flex: 0 0 64px; color: var(--muted); }
.pron-score b { flex: 0 0 28px; text-align: right; }

.pron-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}
.pron-bar > div {
  height: 100%;
  background: linear-gradient(90deg, #72d69f, #4aa5f0);
}

.pron-words {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  line-height: 1.9;
}
.pron-word {
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(114, 214, 159, 0.14);
}
.pron-word.bad {
  background: rgba(255, 107, 107, 0.18);
  color: var(--danger);
  text-decoration: underline wavy var(--danger);
}

/* ---- Voice browser (inside TTS) + doc-translate note ---- */
.voice-browser { margin-top: 4px; }
.voice-browser > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--accent);
  padding: 4px 0;
  user-select: none;
}
.voice-browser[open] > summary { margin-bottom: 8px; }

.voice-info { cursor: pointer; }
.voice-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.svc-note {
  font-size: 11px;
  margin: 2px 0 0;
  line-height: 1.5;
}
