@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #f5f7f8;
  --surface:       #ffffff;
  --surface2:      #f0f4f6;
  --border:        #e8ecf0;
  --border2:       #d4dbe1;
  --text:          #2d3a41;
  --dim:           rgba(45,58,65,0.5);
  --dim2:          rgba(45,58,65,0.3);
  --accent:        #2198ed;
  --accent2:       #1a80cc;
  --green:         #27ae60;
  --red:           #eb5757;
  --yellow:        #f2c34a;
  --header-bg:     #071c26;
  --header-surf:   #2a3539;
  --header-icon:   #aab2bb;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── App header ─────────────────────────────────────────────────────── */
.app-header {
  display: grid;
  grid-template-columns: 267px 1fr auto;
  align-items: center;
  height: 60px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-surf);
  flex-shrink: 0;
}

.app-header-left {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 15px;
  border-right: 1px solid var(--header-surf);
  height: 100%;
}

.app-header-center {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  padding: 10px 15px;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 15px;
}

/* Brand */
.brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.brand-name-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.brand-name {
  font-size: 13px;
  font-weight: 400;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  border-radius: 3px;
  padding: 1px 3px;
  margin: -1px -3px;
  cursor: text;
  min-width: 4px;
}
.brand-name:hover { background: rgba(255,255,255,0.08); }
.brand-name:focus { background: rgba(255,255,255,0.12); }

.brand-version {
  font-size: 15px;
  color: var(--green);
  line-height: 1;
  flex-shrink: 0;
}

.brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
}

/* New button — blue pill */
.hdr-back {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 9.5px 16px;
  border-radius: 55px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: filter 0.12s;
}
.hdr-back:hover { filter: brightness(1.1); }

/* Separator */
.hdr-sep {
  width: 1px;
  height: 16px;
  background: var(--header-surf);
  flex-shrink: 0;
}

/* Cost pill */
.hdr-cost {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  font-family: 'SF Mono', 'Fira Code', monospace;
  white-space: nowrap;
}

/* Stop button */
.hdr-btn-stop {
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.hdr-btn-stop:hover { background: rgba(235,87,87,0.1); }

/* Download JSON */
.hdr-btn-upgrade {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.55);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, background 0.12s;
}
.hdr-btn-upgrade:hover { color: #fff; background: rgba(255,255,255,0.12); }

/* Copy JSON */
.hdr-btn-cta {
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.12s;
}
.hdr-btn-cta:hover { filter: brightness(1.1); }

/* Done button */
.hdr-btn-done {
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 9.5px 16px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.12s;
}
.hdr-btn-done:hover { filter: brightness(1.1); }

/* Open in Postcards */
.hdr-btn-postcards {
  background: rgba(39,174,96,0.12);
  color: var(--green);
  border: 1px solid rgba(39,174,96,0.28);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}
.hdr-btn-postcards:hover { background: rgba(39,174,96,0.22); }
.hdr-btn-postcards.loading { opacity: 0.6; pointer-events: none; }

/* Undo / Redo icon buttons */
.hdr-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--header-surf);
  border: none;
  color: var(--header-icon);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}
.hdr-icon-btn:hover { color: #fff; background: #5a6f7b; }

/* ── Tab groups (dark header context) ───────────────────────────────── */
.vtabs {
  display: flex;
  gap: 2px;
  background: var(--header-surf);
  border: 1px solid var(--header-surf);
  border-radius: 6px;
  padding: 2px;
  height: 34px;
  align-items: center;
}

.vtab {
  padding: 3px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  background: transparent;
  border: none;
  color: var(--header-icon);
  cursor: pointer;
  height: 100%;
  display: flex;
  align-items: center;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.vtab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.06);
}

.vtab:hover:not(.active) { color: #fff; }

/* Icon-only tab variant — tighter horizontal padding */
.vtab-icon {
  padding: 4px 12px;
}

/* Light-context tabs (inside chat panel) */
.chat-input-area .vtabs {
  background: var(--surface2);
  border-color: var(--border);
  height: 28px;
}
.chat-input-area .vtab {
  color: var(--dim);
  font-size: 11px;
  padding: 2px 10px;
}
.chat-input-area .vtab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.chat-input-area .vtab:hover:not(.active) { color: var(--text); }

/* ── Dot animation ──────────────────────────────────────────────────── */
.hdr-dots, .msg-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}
.hdr-dots span, .msg-dots span {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s ease-in-out infinite;
}
.hdr-dots span:nth-child(2), .msg-dots span:nth-child(2) { animation-delay: 0.2s; }
.hdr-dots span:nth-child(3), .msg-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%,80%,100% { opacity: 0.2; transform: scale(0.8); }
  40%          { opacity: 1;   transform: scale(1.1); }
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════
   Chat panel (left)
══════════════════════════════════════════════════════════ */
.chat-panel {
  width: 267px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}

/* ── Resize handle — Figma pill style ───────────────────────────────── */
.resizer {
  width: 1px;
  flex-shrink: 0;
  position: relative;
  cursor: col-resize;
  z-index: 20;
  overflow: visible;
  background: var(--border);
}
/* Expanded hit area */
.resizer::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: -8px; right: -8px;
}
/* Centered draggable pill */
.resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 5px;
  height: 30px;
  background: #fff;
  border-radius: 30px;
  border: 1px solid var(--border);
  transition: background 0.15s;
}
.resizer:hover::after,
.resizer.dragging::after {
  background: var(--header-surf);
}

/* ── Messages list ──────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* Empty state */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 32px 20px;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.4;
}
.chat-empty-sub {
  font-size: 11px;
  color: var(--dim2);
  line-height: 1.5;
}
.chat-empty-actions { display: flex; gap: 8px; margin-top: 4px; }
.empty-action-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--dim);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.empty-action-btn:hover {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--border2);
}

/* ── Message bubbles ────────────────────────────────────────────────── */
.chat-msg {
  max-width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
  animation: msgIn 0.18s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* User message — blue bubble, full-width */
.chat-msg-user {
  background: var(--accent);
  color: #fff;
  align-self: stretch;
  border-radius: 10px 10px 10px 2px;
  padding: 11px 14px;
}
.chat-msg-images { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chat-msg-thumb {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
}

.enhanced-toggle {
  font-size: 11px;
  opacity: 0.7;
  cursor: pointer;
  margin-top: 8px;
  user-select: none;
}
.enhanced-toggle:hover { opacity: 1; }
.enhanced-detail {
  font-size: 11px;
  line-height: 1.5;
  opacity: 0.8;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.2);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

/* ── Questionnaire ──────────────────────────────────────────────────── */
.questionnaire-bubble { padding: 14px 16px !important; }
.question-card { margin-bottom: 14px; }
.question-card:last-of-type { margin-bottom: 16px; }
.question-text { font-size: 13px; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.option-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.option-chip {
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid var(--border2);
  border-radius: 16px;
  background: none;
  color: var(--dim);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.option-chip:hover { border-color: var(--accent); color: var(--text); background: rgba(33,152,237,0.07); }
.option-chip.selected { border-color: var(--accent); background: var(--accent); color: #fff; }
.option-custom {
  width: 100%;
  max-width: 220px;
  padding: 5px 10px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.option-custom:focus { border-color: var(--accent); }
.option-custom::placeholder { color: var(--dim2); }
.questionnaire-submit {
  display: block;
  width: 100%;
  padding: 9px 0;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s;
}
.questionnaire-submit:hover:not(:disabled) { opacity: 0.85; }
.questionnaire-submit:disabled { opacity: 0.4; cursor: default; }

/* AI response — plain text, no bubble */
.chat-msg-assistant {
  background: transparent;
  border: none;
  color: var(--text);
  align-self: flex-start;
  padding: 0;
  font-size: 13px;
  line-height: 1.4;
}

/* Loading state */
.chat-msg-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--dim);
  font-size: 12px;
  padding: 4px 0;
}
.msg-status-text { color: var(--dim); font-size: 12px; }

/* Result bubble */
.msg-result { display: flex; flex-direction: column; gap: 8px; }
.msg-result-meta { display: flex; align-items: center; gap: 7px; }
.msg-done-icon { color: var(--green); font-size: 13px; }
.msg-cost { font-size: 12px; color: var(--dim); font-family: 'SF Mono', 'Fira Code', monospace; }
.msg-result-actions { display: flex; gap: 6px; }

.msg-btn {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.msg-btn-copy {
  background: rgba(33,152,237,0.08);
  color: var(--accent);
  border: 1px solid rgba(33,152,237,0.22);
}
.msg-btn-copy:hover { background: rgba(33,152,237,0.16); }
.msg-btn-dl {
  background: var(--surface2);
  color: var(--dim);
  border: 1px solid var(--border);
}
.msg-btn-dl:hover { color: var(--text); background: var(--border); }

.msg-summary-text { font-size: 12px; color: var(--dim); line-height: 1.5; }
.msg-error { color: var(--red); font-size: 12px; }

/* ── Postcards login modal ──────────────────────────────────────────── */
.postcards-login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.postcards-login-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}
.postcards-login-modal h3 { margin: 0 0 16px; font-size: 16px; font-weight: 600; color: var(--text); }
.postcards-login-modal label { display: block; font-size: 12px; font-weight: 500; color: var(--dim); margin-bottom: 4px; }
.postcards-login-modal input {
  width: 100%; padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--border2); border-radius: 6px;
  background: var(--surface2); color: var(--text);
  margin-bottom: 12px; outline: none;
  font-family: inherit;
}
.postcards-login-modal input:focus { border-color: var(--accent); }
.postcards-login-actions { display: flex; gap: 8px; margin-top: 4px; }
.postcards-login-actions button {
  flex: 1; padding: 8px 0; border-radius: 6px;
  font-size: 13px; font-weight: 600;
  font-family: inherit;
  cursor: pointer; transition: background 0.12s;
}
.postcards-login-submit { background: var(--accent); color: #fff; border: none; }
.postcards-login-submit:hover { opacity: 0.9; }
.postcards-login-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.postcards-login-cancel { background: var(--surface2); color: var(--dim); border: 1px solid var(--border); }
.postcards-login-cancel:hover { color: var(--text); }
.postcards-login-error { font-size: 12px; color: var(--red); margin-bottom: 8px; }

/* ══════════════════════════════════════════════════════════
   Chat input area
══════════════════════════════════════════════════════════ */
.chat-input-area {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 15px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
}
.status-text { font-size: 12px; color: var(--dim); }
.hdr-tokens { font-size: 11px; color: var(--dim2); font-family: 'SF Mono', 'Fira Code', monospace; }

/* ── Prompt box — pixel-perfect match to Figma Chat Area ────────────── */
.prompt-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #e8ecf0;
  border-radius: 15px;
  background: #fff;
  padding: 10px 15px;
  overflow: visible;
  transition: border-color 0.15s;
}
.prompt-wrap:focus-within { border-color: #d4dbe1; }
.prompt-wrap.drag-over { border-color: var(--accent); }

/* Attached images strip */
.attached-images {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  margin: -10px -15px 0;
  padding: 8px 15px 6px;
  border-bottom: 1px solid #e8ecf0;
  border-radius: 15px 15px 0 0;
}
.attached-images.has-images { display: flex; }

.attached-image-chip {
  position: relative; width: 52px; height: 52px;
  border-radius: 6px; overflow: hidden;
  border: 1px solid #d4dbe1; flex-shrink: 0;
}
.attached-image-chip img { width: 100%; height: 100%; object-fit: cover; }
.attached-image-chip .remove-image {
  position: absolute; top: 2px; right: 2px;
  width: 16px; height: 16px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 10px;
  line-height: 16px; text-align: center; cursor: pointer; padding: 0;
  opacity: 0; transition: opacity 0.15s;
}
.attached-image-chip:hover .remove-image { opacity: 1; }

/* Textarea */
#promptInput {
  width: 100%;
  background: transparent;
  border: none;
  color: #2d3a41;
  padding: 0;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
  min-height: 42px;
  max-height: 400px;
  overflow-y: auto;
  display: block;
  flex: 1 0 0;
}
#promptInput::placeholder { color: rgba(45,58,65,0.5); }

/* ── Inner toolbar (below textarea, no border separator) ─────────────── */
.prompt-inner-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.prompt-toolbar-left {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 15px;
}

.prompt-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Attach trigger — exact Figma: #aab2bb pill, px-8 py-2, 16×16 icon */
.attach-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #aab2bb;
  color: #fff;
  border-radius: 110px;
  padding: 2px 8px;
  cursor: pointer;
  transition: background 0.12s;
  flex-shrink: 0;
  height: 20px;
}
.attach-trigger:hover { background: #95a0aa; }
.attach-trigger.active { background: var(--accent); }

.attach-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 148px;
  background: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px;
  box-shadow: 0px 4px 15px 0px rgba(0,46,83,0.1), 0px 0px 2px 0px rgba(169,179,187,0.5);
  z-index: 100;
}
.attach-dropdown.hidden { display: none; }
.attach-dropdown-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 7px 10px; border: none;
  background: none; color: #585d63; font-size: 13px; font-family: inherit;
  text-align: left; border-radius: 5px; cursor: pointer; white-space: nowrap;
}
.attach-dropdown-item + .attach-dropdown-item { border-top: 1px solid #f3f5f9; }
.attach-dropdown-item:hover:not(.disabled) { background: rgba(33,152,237,0.07); color: var(--text); }
.attach-dropdown-item.disabled { opacity: 0.35; cursor: default; }

/* ── Preset trigger (now in-flow) ───────────────────────────────────── */
.preset-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--dim);
  border-radius: 5px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.preset-trigger:hover { color: var(--accent); background: rgba(33,152,237,0.07); }
.preset-trigger.active { color: var(--accent); }

.preset-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 160px;
  background: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px;
  box-shadow: 0px 4px 15px 0px rgba(0,46,83,0.1), 0px 0px 2px 0px rgba(169,179,187,0.5);
  z-index: 100;
}
.preset-dropdown.hidden { display: none; }
.preset-dropdown-item {
  display: block; width: 100%; padding: 7px 10px; border: none;
  background: none; color: #585d63; font-size: 13px; font-family: inherit;
  text-align: left; border-radius: 5px; cursor: pointer; white-space: nowrap;
}
.preset-dropdown-item:hover { background: rgba(33,152,237,0.07); color: var(--text); }
.preset-dropdown-item.selected { color: var(--accent); }
.preset-add-json {
  border-top: 1px solid #f3f5f9;
  margin-top: 4px;
  padding-top: 8px;
  color: #585d63;
  font-style: italic;
}

/* ── Model dropdown ─────────────────────────────────────────────────── */
.model-dropdown {
  position: relative;
}
.model-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 4px;
  font-family: inherit;
  transition: background 0.12s;
  color: #2d3a41;
}
.model-dropdown-trigger:hover { background: rgba(0,0,0,0.04); }
.model-dropdown-label {
  font-size: 12px;
  white-space: nowrap;
  opacity: 0.5;
  line-height: 1.2;
}
.model-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 11px);
  right: -4px;
  background: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 0;
  box-shadow: 0px 4px 15px 0px rgba(0,46,83,0.1), 0px 0px 2px 0px rgba(169,179,187,0.5);
  z-index: 100;
  min-width: 166px;
  overflow: visible;
}
/* Caret pointing down toward the trigger */
.model-dropdown-menu::after {
  content: '';
  position: absolute;
  bottom: -5px;
  right: 19px;
  width: 9px;
  height: 9px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 2px 2px 3px rgba(169,179,187,0.25);
}
.model-dropdown-menu.hidden { display: none; }
.model-dropdown-menu .vtab {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 15px;
  border-radius: 0;
  font-size: 13px;
  color: #585d63;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  height: auto;
  box-shadow: none;
}
.model-dropdown-menu .vtab + .vtab {
  border-top: 1px solid #f3f5f9;
}
.model-dropdown-menu .vtab:hover { background: rgba(33,152,237,0.06); color: var(--text); }
.model-dropdown-menu .vtab.active { color: var(--accent); background: rgba(33,152,237,0.06); }
.model-dropdown-menu .model-opt-name {
  display: block;
  font-size: 13px;
  line-height: 1.3;
}
.model-dropdown-menu .model-opt-price {
  display: block;
  font-size: 11px;
  opacity: 0.5;
  margin-top: 2px;
  line-height: 1.3;
}

.model-cost { display: none; }

/* ── Generate button — blue circle (20px, matches Figma Send) ───────── */
.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter 0.12s, transform 0.1s;
  padding: 0;
}
.btn-generate:hover { filter: brightness(1.1); }
.btn-generate:active { transform: scale(0.92); }
.btn-generate:disabled { background: #aab2bb; cursor: default; filter: none; }

/* ── Improve prompt row ─────────────────────────────────────────────── */
.enhance-row {
  display: flex;
  align-items: center;
}
.enhance-check label {
  font-size: 11px; color: var(--dim2); cursor: pointer;
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.enhance-check input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

/* ── Footer row (API key only) ──────────────────────────────────────── */
.chat-input-footer {
  display: flex; align-items: center; gap: 8px;
}
.key-area { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; }

#apiKeyInput {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--dim);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  flex: 1; min-width: 0; outline: none;
  transition: border-color 0.15s, color 0.15s;
}
#apiKeyInput:focus { border-color: var(--accent); color: var(--text); }
#apiKeyInput::placeholder { color: var(--dim2); font-family: inherit; }

.key-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border2); flex-shrink: 0;
  transition: background 0.2s;
}
.key-dot.ok { background: var(--green); }

/* ══════════════════════════════════════════════════════════
   Preview panel (right)
══════════════════════════════════════════════════════════ */
.preview-panel {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: #eef1f3;
}

.preview-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  color: var(--dim2); font-size: 13px;
  background: #eef1f3;
  z-index: 1;
}

.preview-loading {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center; justify-content: center;
  background: #f5f7f8;
  color: var(--dim); font-size: 13px; gap: 12px;
  z-index: 2;
}
.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.preview-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.preview-frames {
  position: relative; flex: 1; min-height: 600px;
}
.preview-frames iframe {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  min-height: 600px;
  border: none; display: block;
  color-scheme: light;
}

/* Mobile view */
.preview-scroll.mobile-view {
  background: var(--bg);
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 0;
}
.preview-scroll.mobile-view .preview-frames {
  flex: none; width: 375px; min-height: 600px;
  box-shadow: 0 0 0 1px var(--border2), 0 8px 32px rgba(0,0,0,0.12);
  border-radius: 4px; overflow: hidden;
}

button { cursor: pointer; }
