:root {
  --bg: #111827;
  --panel: #18212f;
  --panel-2: #223047;
  --line: #31445f;
  --text: #f5f7fb;
  --muted: #a8b3c6;
  --accent: #7dd3fc;
  --accent-2: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, Arial, sans-serif;
  background: linear-gradient(180deg, #0b1220 0%, #101827 100%);
  color: var(--text);
}
a { color: var(--accent); }
.container {
  width: min(1560px, 96vw);
  margin: 0 auto;
  padding: 20px;
}
h1, h2, h3 { margin: 0 0 12px; }
p { color: var(--muted); line-height: 1.5; }
.topbar {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.grid {
  display: grid;
  grid-template-columns: 320px 1fr 380px;
  gap: 18px;
}
.stack {
  display: grid;
  gap: 18px;
}
.panel {
  background: rgba(24, 33, 47, 0.88);
  border: 1px solid rgba(125, 211, 252, 0.12);
  border-radius: 18px;
  padding: 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.small {
  font-size: 12px;
  color: var(--muted);
}
.controls, .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  background: #0f1726;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
input[type="range"] { width: 100%; }
input[type="checkbox"] { accent-color: #0ea5e9; }
label.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(15, 23, 38, 0.6);
  border: 1px solid var(--line);
  border-radius: 12px;
}
textarea { min-height: 110px; resize: vertical; }
button {
  background: #0f1726;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: linear-gradient(135deg, #0ea5e9, #22c55e); color: white; border: none; }
button.danger { border-color: var(--danger); color: #fecaca; }
button.ghost { background: transparent; }
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.category-block { margin-bottom: 18px; }
.term-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.term-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #0f1726;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.term-chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.term-chip.pose { border-color: rgba(52, 211, 153, 0.35); }
.term-chip.selected {
  background: rgba(14, 165, 233, 0.15);
  border-color: var(--accent);
}
.term-chip.blocked {
  opacity: 0.35;
  cursor: not-allowed;
}
.term-chip .badge {
  font-size: 11px;
  color: var(--muted);
}
.builder-dropzone {
  min-height: 180px;
  border: 1px dashed rgba(125, 211, 252, 0.4);
  border-radius: 16px;
  padding: 12px;
  background: rgba(15, 23, 38, 0.65);
}
.prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
}
.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(14, 165, 233, 0.16);
  border: 1px solid rgba(125, 211, 252, 0.35);
  border-radius: 999px;
  padding: 8px 10px;
}
.selected-chip .remove {
  border: none;
  background: transparent;
  color: #fca5a5;
  padding: 0;
}
.prompt-output {
  width: 100%;
  min-height: 150px;
  white-space: pre-wrap;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #0f1726;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.conflict-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.conflict-list li {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: #fecaca;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
}
.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.image-card {
  background: #0f1726;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.image-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.image-card .meta {
  padding: 10px;
}
.muted { color: var(--muted); }
.inline {
  display: flex;
  gap: 8px;
  align-items: center;
}
.pill {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.16);
  color: #bbf7d0;
  font-size: 12px;
}
.log-item {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}
.status-ok { color: #bbf7d0; }
.status-warn { color: #fde68a; }
.status-error { color: #fecaca; }
.preview-canvas-wrap {
  position: relative;
  background: #0f1726;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  max-width: 100%;
}
.preview-stage img, .preview-stage canvas {
  display: block;
  max-width: 100%;
}
.preview-stage canvas {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}
.helper-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.tip-box {
  border: 1px dashed rgba(52, 211, 153, 0.35);
  border-radius: 14px;
  padding: 12px;
  background: rgba(52, 211, 153, 0.05);
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
@media (max-width: 1260px) {
  .grid { grid-template-columns: 1fr; }
}
