/* ---------- tabs / shared additions ---------- */
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 9px; border: 1px solid var(--border); }
.tab {
  appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  padding: 5px 14px; border-radius: 6px; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
button.pill { cursor: pointer; font: inherit; font-size: 12.5px; color: var(--text); }

.agent-card { margin: 12px 12px 4px; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg); }
.agent-card.warn { border-color: var(--warn); background: var(--warn-soft); }
.agent-card-title { font-weight: 700; font-size: 13px; }
.agent-card p { margin: 4px 0 10px; color: var(--muted); }

.dialog {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(5, 8, 11, .55); }
.dialog h1 { font-size: 21px; margin-bottom: 8px; }
.dialog-close { position: absolute; right: 12px; top: 12px; margin: 0; }

.field input[type="text"] {
  font: inherit; font-size: 13px; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px; width: 100%;
}
.btn.danger { color: var(--danger); margin-top: 4px; }
.error-text { color: var(--danger); margin: 0; }

/* ---------- builder layout ---------- */
.builder {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 170px minmax(0, 1fr) 320px;
}
.palette { border-right: 1px solid var(--border); }
.palette-hint { margin: -4px 14px 6px; }
.palette-list { overflow: auto; padding: 0 10px 16px; }
.palette-list h3 { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 12px 4px 6px; }
.palette-item {
  padding: 7px 10px; margin-bottom: 4px; border-radius: 8px; cursor: grab; user-select: none;
  background: var(--bg); border: 1px solid var(--border); border-left: 3px solid var(--cat, var(--muted)); font-size: 13px; font-weight: 500;
}
.palette-item:hover { background: var(--surface-2); }

.c-input { --cat: #a78bfa; }
.c-pre { --cat: #38bdf8; }
.c-seg { --cat: #f59e0b; }
.c-feat { --cat: #22c55e; }
.c-judge { --cat: #f43f5e; }

.builder-center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.builder-toolbar { gap: 8px; }
.builder-toolbar select { font: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 4px 6px; max-width: 220px; }
.field-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow); padding: 4px;
}
.menu-list button { display: block; width: 100%; text-align: left; appearance: none; border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.menu-list button:hover { background: var(--surface-2); }

.split { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(200px, 1fr) minmax(220px, 1.15fr); }
.graph-wrap { position: relative; min-height: 0; border-bottom: 1px solid var(--border); }
.graph {
  position: absolute; inset: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 18px 18px;
}
.graph-zoom { position: absolute; right: 8px; top: 8px; display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.graph-zoom .icon-btn { width: 28px; height: 28px; font-size: 15px; color: var(--text); }
.goal {
  position: absolute; left: 8px; bottom: 8px; right: 110px; margin: 0; pointer-events: none;
  font-size: 12.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; max-width: 640px;
}

.preview { display: flex; flex-direction: column; min-height: 0; }
.preview-head { display: flex; justify-content: space-between; gap: 8px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.preview-head .muted { font-weight: 400; font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }
#previewStage { min-height: 0; }

/* ---------- drawflow nodes ---------- */
#drawflow .drawflow-node.vnode {
  width: 196px; min-height: 0; padding: 0; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
#drawflow .drawflow-node.vnode.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); background: var(--surface); }
#drawflow .drawflow-node .drawflow_content_node { width: 100%; }
#drawflow .drawflow-node .input, #drawflow .drawflow-node .output {
  width: 14px; height: 14px; border: 2px solid var(--surface); background: var(--muted);
}
#drawflow .drawflow-node .output { right: -8px; }
#drawflow .drawflow-node .input { left: -8px; }
#drawflow .drawflow-node .output:hover, #drawflow .drawflow-node .input:hover { background: var(--accent); }
#drawflow .drawflow .connection .main-path { stroke: var(--muted); stroke-width: 3px; }
#drawflow .drawflow .connection .main-path:hover, #drawflow .drawflow .connection .main-path.selected { stroke: var(--accent); }
#drawflow .drawflow-delete {
  background: var(--danger); color: #fff; border: 2px solid var(--surface); line-height: 26px; font-family: inherit;
}
.vn { border-top: 3px solid var(--cat, var(--muted)); border-radius: 9px 9px 0 0; }
.vn-head { display: flex; justify-content: space-between; gap: 6px; padding: 6px 8px 4px; font-size: 12.5px; font-weight: 700; }
.vn-ms { color: var(--muted); font-weight: 500; font-family: ui-monospace, Consolas, monospace; font-size: 11px; }
.vn-thumb { display: block; width: 180px; height: auto; margin: 0 8px; border-radius: 5px; background: var(--stage); }
.vn-thumb[hidden] { display: none; }
.vn-sum { padding: 4px 8px 7px; font-size: 11.5px; color: var(--muted); min-height: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vn-error .vn-sum { color: var(--danger); white-space: normal; }
.vn-blocked { opacity: .55; }
.vn-ok .vn-sum { color: var(--accent); font-weight: 700; }
.vn-ng .vn-sum { color: var(--danger); font-weight: 700; }

/* ---------- builder side panel ---------- */
.builder-right { border-left: 1px solid var(--border); overflow: auto; }
.side-section { border-top: 1px solid var(--border); }
.side-section .params { overflow: visible; }
.props-help { margin: -2px 14px 8px; }
.verdict { display: flex; gap: 12px; align-items: center; padding: 14px; }
.verdict-badge {
  width: 64px; height: 64px; border-radius: 12px; flex: none; display: grid; place-items: center;
  font-size: 22px; font-weight: 800; letter-spacing: .02em; background: var(--surface-2); color: var(--muted);
}
.verdict-badge.ok { background: var(--accent); color: var(--accent-ink); }
.verdict-badge.ng { background: var(--danger); color: #fff; }
.verdict-title { font-weight: 700; }
.verdict-list { list-style: none; margin: 4px 0 0; padding: 0; font-size: 12.5px; }
.verdict-list li.ok { color: var(--accent); }
.verdict-list li.ng { color: var(--danger); }
.verdict-list li::before { content: "● "; }

.data-view { padding: 0 14px 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 8px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-family: ui-monospace, Consolas, monospace; }
.table-wrap { max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 11.5px; font-family: ui-monospace, Consolas, monospace; }
.table-wrap th, .table-wrap td { padding: 4px 6px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-wrap th { position: sticky; top: 0; background: var(--surface-2); font-family: "Pretendard", system-ui, sans-serif; font-weight: 600; }
.log-row { display: flex; justify-content: space-between; align-items: center; padding: 0 14px 14px; gap: 8px; }
.switch.small { font-size: 12.5px; }

@media (max-width: 1100px) {
  .builder { grid-template-columns: 150px minmax(0, 1fr) 280px; }
}
@media (max-width: 860px) {
  .builder { grid-template-columns: 1fr; overflow: auto; }
  .palette { border-right: 0; border-bottom: 1px solid var(--border); }
  .palette-list { display: flex; flex-wrap: wrap; gap: 4px; max-height: 160px; }
  .palette-list h3 { width: 100%; margin: 6px 4px 2px; }
  .palette-item { margin: 0; }
  .split { grid-template-rows: 340px 300px; }
  .builder-right { border-left: 0; overflow: visible; }
  .tabs { order: 3; width: 100%; }
  .tab { flex: 1; }
}
