:root {
  --bg: #0E0F12;
  --panel: #16181D;
  --panel-2: #1E2128;
  --border: #2A2E37;
  --text: #E6E8EC;
  --text-dim: #9AA0AC;
  --primary: #7C9CFF;     /* chip 选中 蓝紫，区分尊享金 */
  --accent: #FFD479;      /* 执行按钮 */
  --error: #FF6B6B;
  --radius: 10px;
}

* { box-sizing: border-box; }
/* Author CSS sets explicit display on .bbox-overlay/.skill-context, which would
   otherwise override the UA `hidden` style — force-hide [hidden] elements. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  display: flex;
  flex-direction: column;
}

/* Header */
.studio-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.header-left, .header-right { display: flex; align-items: center; gap: 14px; }
.link-back { color: var(--text-dim); text-decoration: none; font-size: 14px; }
.link-back:hover { color: var(--text); }
.brand { font-size: 16px; letter-spacing: .5px; }
.mode-pill { font-size: 13px; color: var(--text-dim); }
#mode-indicator { color: var(--primary); font-weight: 600; }
.credits { font-size: 13px; color: var(--accent); }
.login-link { color: var(--primary); text-decoration: none; font-size: 14px; }

/* Main: chat + side panel */
.studio-main { flex: 1; display: flex; min-height: 0; }
.chat-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-stream { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }

.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg .bubble {
  max-width: 70%; padding: 10px 14px; border-radius: var(--radius);
  line-height: 1.5; font-size: 14px; white-space: pre-wrap; word-break: break-word;
}
.msg.user .bubble { background: var(--panel-2); }
.msg.assistant .bubble { background: var(--panel); border: 1px solid var(--border); }
.msg.error .bubble { background: rgba(255,107,107,.12); border: 1px solid var(--error); color: #FFC9C9; }
.msg.warn .bubble { background: rgba(255,212,121,.12); border: 1px solid var(--accent); color: #FFE6B0; }

.job-card { display: block; }
.job-card .card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); padding: 12px; max-width: 70%;
}
.job-card .badge { font-size: 12px; padding: 2px 8px; border-radius: 12px; background: var(--panel-2); }
.job-card .badge.succeeded { color: #7CFFB0; }
.job-card .badge.failed { color: var(--error); }
.job-card .badge.running, .job-card .badge.queued { color: var(--accent); }
.job-card img { max-width: 100%; border-radius: 8px; margin-top: 8px; display: block; }
.job-card .row { display: flex; gap: 8px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.thumb-inline { max-width: 160px; border-radius: 8px; margin-top: 6px; }

/* Side panel */
.side-panel {
  width: 280px; border-left: 1px solid var(--border); background: var(--panel);
  padding: 16px; overflow-y: auto;
}
.side-panel h3 { font-size: 12px; text-transform: uppercase; color: var(--text-dim); margin: 16px 0 8px; letter-spacing: .5px; }
.side-panel h3:first-child { margin-top: 0; }
.current-image { border: 1px dashed var(--border); border-radius: 8px; min-height: 120px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.current-image.empty .placeholder { color: var(--text-dim); font-size: 13px; }
.current-image img { width: 100%; display: block; }
.job-status { font-size: 13px; color: var(--text-dim); }
.version-chain { margin: 0; padding-left: 18px; font-size: 12px; color: var(--text-dim); }
.version-chain a { color: var(--primary); text-decoration: none; }

/* Input */
.studio-input { border-top: 1px solid var(--border); background: var(--panel); padding: 12px 16px; }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.icon-btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; width: 40px; height: 40px; font-size: 18px; cursor: pointer; }
#chat-input {
  flex: 1; resize: none; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px 12px; font-size: 14px; max-height: 160px;
  font-family: inherit;
}
.send-btn { background: var(--accent); color: #1a1a1a; border: none; border-radius: 8px; padding: 0 18px; height: 40px; font-weight: 600; cursor: pointer; }
.send-btn:disabled { opacity: .5; cursor: not-allowed; }

.skill-strip-wrap { overflow-x: auto; margin-top: 10px; }
.skill-strip { display: flex; gap: 8px; padding-bottom: 4px; }
.skill-chip {
  flex: 0 0 auto; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 20px; padding: 6px 14px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.skill-chip[aria-selected="true"] { background: var(--primary); color: #0E0F12; border-color: var(--primary); font-weight: 600; }
.skill-chip.disabled { opacity: .45; cursor: not-allowed; }

.skill-context { margin-top: 12px; padding: 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; }
.skill-context .field { margin-bottom: 10px; }
.skill-context label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.skill-context input[type=range] { width: 100%; }
.skill-context select, .skill-context input[type=text] { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 6px 8px; }
.skill-context .pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.skill-context .pill { background: var(--bg); border: 1px solid var(--border); border-radius: 16px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.skill-context .pill[aria-pressed="true"] { background: var(--primary); color: #0E0F12; }
.skill-context .ctx-action { margin-top: 6px; }

.agreement { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; font-size: 12px; color: var(--text-dim); }
.agreement input { margin-top: 2px; }

/* bbox overlay */
.bbox-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.78); display: flex; align-items: center; justify-content: center; z-index: 100; }
.bbox-dialog { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px; max-width: 92vw; max-height: 92vh; display: flex; flex-direction: column; }
.bbox-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 13px; color: var(--text-dim); }
.bbox-canvas-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
#bbox-canvas { display: block; cursor: crosshair; }
.bbox-list { margin-top: 8px; font-size: 12px; color: var(--text-dim); font-family: monospace; }
.ghost-btn { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.primary-btn { background: var(--accent); border: none; color: #1a1a1a; border-radius: 6px; padding: 6px 14px; font-weight: 600; cursor: pointer; }

@media (max-width: 760px) {
  .side-panel { display: none; }
  .msg .bubble, .job-card .card { max-width: 88%; }
}
