:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --surface: #ffffff;
  --text: #171717;
  --text-secondary: #4d4d4d;
  --text-muted: #666666;
  --border-shadow: rgba(0, 0, 0, 0.08) 0 0 0 1px;
  --card-shadow: rgba(0, 0, 0, 0.08) 0 0 0 1px, rgba(0, 0, 0, 0.04) 0 2px 2px, rgba(0, 0, 0, 0.04) 0 8px 8px -8px;
  --accent-bg: #ebf5ff;
  --accent-text: #0068d6;
  --btn-bg: #171717;
  --btn-text: #ffffff;
  --code-bg: #f5f5f5;
  --err-bg: #fff1f2;
  --err-text: #be123c;
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

body.dark {
  --bg: #0a0a0a;
  --bg-subtle: #111111;
  --surface: #141414;
  --text: #ededed;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --border-shadow: rgba(255, 255, 255, 0.12) 0 0 0 1px;
  --card-shadow: rgba(255, 255, 255, 0.12) 0 0 0 1px, rgba(0, 0, 0, 0.5) 0 6px 16px;
  --accent-bg: rgba(10, 114, 239, 0.16);
  --accent-text: #60a5fa;
  --btn-bg: #ededed;
  --btn-text: #0a0a0a;
  --code-bg: #1a1a1a;
  --err-bg: rgba(190, 18, 60, 0.15);
  --err-text: #fda4af;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.font-mono { font-family: var(--font-mono); }

.center-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-subtle);
}

.vercel-card {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  padding: 26px;
}

.center-card { width: 100%; max-width: 440px; }
.config-card { width: 100%; max-width: 680px; }
.config-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

.brand-row { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; letter-spacing: -0.02em; }
.brand-tri {
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid var(--text);
  display: inline-block;
}

.heading-md { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.2; }
.muted-text { margin: 0; font-size: 13.5px; color: var(--text-secondary); line-height: 1.55; }
.mono-micro { font-family: var(--font-mono); font-size: 11px; }

.pill-blue {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px;
  border-radius: 9999px; background: var(--accent-bg); color: var(--accent-text);
  font-size: 11px; font-weight: 500; font-family: var(--font-mono); white-space: nowrap;
}
.pill-mono {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px;
  border-radius: 9999px; box-shadow: var(--border-shadow); font-size: 11px; color: var(--text-secondary);
}

.stack-form { display: flex; flex-direction: column; gap: 12px; }
.field-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }

.v-input, .v-textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 0;
  box-shadow: var(--border-shadow); border-radius: 6px; font-family: inherit; font-size: 13.5px;
  outline: none; transition: box-shadow 0.15s;
}
.v-input { height: 38px; padding: 0 11px; }
select.v-input {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.v-textarea { padding: 10px 11px; resize: vertical; line-height: 1.45; }
.v-input:focus, .v-textarea:focus { box-shadow: hsla(212, 100%, 48%, 1) 0 0 0 2px; }

.v-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 6px; border: 0; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.v-btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.v-btn.full { width: 100%; }
.v-btn.primary { background: var(--btn-bg); color: var(--btn-text); }
.v-btn.ghost { background: var(--surface); color: var(--text); box-shadow: var(--border-shadow); }
.v-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.err-box { padding: 9px 12px; border-radius: 6px; background: var(--err-bg); color: var(--err-text); font-size: 12.5px; }
.cfg-limits-strip { font-size: 12px; color: var(--text-secondary); padding: 10px 12px; border-radius: 6px; background: var(--bg-subtle); }
.cfg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* WORKSPACE SHELL */
.studio-shell { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.studio-topbar {
  height: 52px; flex-shrink: 0; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); box-shadow: var(--border-shadow); z-index: 5;
}
.topbar-left, .topbar-meters, .topbar-actions { display: flex; align-items: center; gap: 8px; }
.meter-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 6px;
  background: var(--bg-subtle); box-shadow: var(--border-shadow); font-size: 11px; line-height: 1.2;
}
.meter-lbl { font-weight: 600; color: var(--accent-text); }

.mob-pane-bar { display: none; }
.split-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 420px minmax(0, 1fr); }

.pane-chat {
  display: flex; flex-direction: column; min-height: 0; background: var(--surface);
  border-right: 1px solid rgba(127, 127, 127, 0.14);
}
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg-bubble { padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.msg-user { align-self: flex-end; max-width: 88%; background: var(--btn-bg); color: var(--btn-text); }
.msg-ai { align-self: flex-start; max-width: 96%; background: var(--bg-subtle); box-shadow: var(--border-shadow); color: var(--text); }
.trace-card {
  align-self: stretch; padding: 7px 10px; border-radius: 6px; font-family: var(--font-mono); font-size: 11px;
  background: var(--code-bg); color: var(--text-secondary); box-shadow: var(--border-shadow);
}
.trace-ok { color: #059669; }
.trace-err { color: var(--err-text); }

.chat-composer { padding: 10px 12px; border-top: 1px solid rgba(127, 127, 127, 0.14); display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.v-textarea.compact { min-height: 54px; max-height: 140px; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; }

.pane-preview { display: flex; flex-direction: column; min-height: 0; background: var(--bg-subtle); }
.preview-toolbar {
  min-height: 44px; padding: 6px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid rgba(127, 127, 127, 0.14);
}
.subtab-group, .preview-controls { display: flex; align-items: center; gap: 6px; }
.subtab {
  height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent;
  color: var(--text-secondary); font-family: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
}
.subtab.active { background: var(--code-bg); color: var(--text); box-shadow: var(--border-shadow); }
.port-input { width: 70px; height: 30px; padding: 0 8px; font-size: 12px; text-align: center; }

.rtab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.iframe-stage { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: stretch; padding: 10px; }
.iframe-stage iframe { width: 100%; height: 100%; border: 0; border-radius: 8px; background: #fff; box-shadow: var(--card-shadow); transition: width 0.2s; }
.iframe-stage.mobile-mode iframe { width: 390px; max-width: 100%; }

.files-split { display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.file-tree { overflow-y: auto; padding: 10px; background: var(--surface); border-right: 1px solid rgba(127, 127, 127, 0.14); font-size: 12px; display: flex; flex-direction: column; gap: 3px; }
.file-item { padding: 5px 8px; border-radius: 5px; cursor: pointer; color: var(--text-secondary); word-break: break-all; }
.file-item:hover, .file-item.active { background: var(--code-bg); color: var(--text); }
.file-viewer { margin: 0; padding: 14px; overflow: auto; font-size: 12px; line-height: 1.5; background: var(--bg-subtle); color: var(--text); }

.media-grid { padding: 14px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; align-content: start; }
.media-card { background: var(--surface); border-radius: 8px; box-shadow: var(--card-shadow); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.media-card video, .media-card img { width: 100%; border-radius: 6px; background: #000; max-height: 220px; object-fit: contain; }

@media (max-width: 900px) {
  .field-row-2 { grid-template-columns: 1fr; }
  .studio-topbar { height: auto; flex-wrap: wrap; padding: 8px 10px; }
  .brand-txt { display: none; }
  .mob-pane-bar {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px 10px;
    background: var(--surface); border-bottom: 1px solid rgba(127, 127, 127, 0.14);
  }
  .mob-pane-btn {
    height: 32px; border: 0; border-radius: 6px; background: var(--bg-subtle); color: var(--text-secondary);
    font-family: inherit; font-size: 12px; font-weight: 500;
  }
  .mob-pane-btn.active { background: var(--btn-bg); color: var(--btn-text); }
  .split-main { grid-template-columns: 1fr; }
  .pane-chat.mob-hidden, .pane-preview.mob-hidden { display: none; }
  .files-split { grid-template-columns: 1fr; grid-template-rows: 160px 1fr; }
}
