:root {
  --bg: #f0f2f5;
  --panel: #ffffff;
  --panel2: #f8fafc;
  --text: #1e293b;
  --text-secondary: #64748b;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);
  --radius: 7px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial,
    "Noto Sans", "Liberation Sans", sans-serif;
}

/* ── Thin overlay scrollbars ── */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

*::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
}

/* ── Layout shell ── */
#app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* flow 子页顶栏：仅业务标题 + 运行，全局品牌与用户在壳层 */
#topbar.flow-editor-topbar .flow-editor-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
  letter-spacing: -0.3px;
}

/* ── Generic icon+text button ── */
.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(129, 140, 248, 0.06);
}

.btn-icon svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-icon.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-icon.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(129, 140, 248, 0.04);
}

#layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 0;
}

#palette {
  padding: 16px;
  border-right: 1px solid var(--border);
  background: var(--panel);
}

#canvas {
  min-height: 0;
  position: relative;
}

#drawflow {
  height: 100%;
  width: 100%;
  background:
    radial-gradient(circle at 1px 1px, #d1d5db 1px, transparent 0) 0 0 / 20px 20px,
    #f8f9fb;
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.palette-item {
  border: 1px solid var(--border);
  background: var(--panel2);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s;
}

.palette-item:hover {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.04);
}

.palette-item:active {
  cursor: grabbing;
}

.hint {
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
}

/* 类型不匹配时连接被拒绝的提示 */
/* 画布通用提示（底部居中） */
.canvas-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 18px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.canvas-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#result {
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  background: var(--panel);
}

#result-json {
  margin: 0;
  max-height: 200px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

/* ════════════════════════════════════════
   Node — Langflow-style white card
   ════════════════════════════════════════ */

.drawflow .drawflow-node.python-node {
  min-width: 300px;
  min-height: 120px;
  width: 380px;
}

.drawflow .drawflow-node.python-node .drawflow_content_node {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 0 0 6px 6px;
}

.drawflow .drawflow-node.python-node .node-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
}

.node-body {
  padding: 12px 14px;
}

.node-actions {
  display: flex;
  gap: 8px;
  margin: 10px 0 6px;
}

.btn-parse {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  background: var(--accent) !important;
  color: #fff !important;
  border: none !important;
  padding: 7px 14px !important;
  border-radius: 6px !important;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-parse:hover {
  background: var(--accent-hover) !important;
}

.btn-parse svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.node-error {
  margin-top: 4px;
  color: var(--danger);
  font-size: 11px;
  white-space: pre-wrap;
  line-height: 1.4;
}

.node-error:empty {
  display: none;
}

/* ── Ports info panel ── */
.ports-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.ports-info .port-list {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 8px;
  background: var(--panel2);
}

.ports-info .port-list .title {
  font-weight: 600;
  font-size: 11px;
  margin-bottom: 6px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ports-info .port-list .items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ports-info .tag {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
}

/* ── Input controls ── */
.input-controls {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

/* 子元素左侧曲线竖线：标出控件占用的高度 */
.input-controls > * {
  position: relative;
  padding-left: 10px;
}
.input-controls > *::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 0;
  bottom: 0;
  width: 1px;
  border-radius: 2px;
  background: var(--border, #bdc2c8);
}

.input-controls label,
.input-controls .ace-field-container,
.input-controls .file-field-label,
.input-controls .input-row-label-only {
  display: grid;
  gap: 3px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* 控件总标题：加粗且高度一致 */
.input-controls label > div:first-child,
.input-controls .file-field-label,
.input-controls .input-row-label-only .input-label-text,
.input-controls .ace-field-container .ace-label-text,
.input-controls .list-ui-wrap .list-ui-header .list-ui-label {
  font-weight: 700;
}
.input-controls label > div:first-child {
  min-height: 32px;
  display: flex;
  align-items: center;
}
.input-controls .file-field-label {
  min-height: 32px;
  align-items: center;
}

/* 未指定 ui_type 的输入：仅显示标签，数据仅能通过连线传入 */
.input-controls .input-row-label-only {
  align-items: center;
  min-height: 32px;
}
.input-controls .input-row-label-only .input-label-text {
  color: var(--text-secondary);
  font-size: 12px;
}
.input-controls .ace-field-container .ace-label-row {
  min-height: 32px;
  display: flex;
  align-items: center;
}

/* 输入端点已连线：整行置灰且不可编辑 */
.input-controls .input-row-connected {
  opacity: 0.75;
  pointer-events: none;
}
.input-controls .input-row-connected .input-label-text,
.input-controls .input-row-connected label > div:first-child {
  color: var(--text-muted, #94a3b8);
}
/* 输入框/文本框：只读置灰 */
.input-controls .input-row-connected input:not([type=hidden]),
.input-controls .input-row-connected textarea {
  background: var(--panel2, #f1f5f9);
  color: var(--text-secondary);
  cursor: not-allowed;
}
/* 下拉选择框 */
.input-controls .input-row-connected .searchable-select {
  opacity: 0.8;
  cursor: not-allowed;
}
.input-controls .input-row-connected .searchable-select .ss-trigger {
  background: var(--panel2, #f1f5f9);
}
/* 滑块 */
.input-controls .input-row-connected .slider-wrap {
  opacity: 0.85;
}
.input-controls .input-row-connected .slider-wrap input[type="range"] {
  cursor: not-allowed;
}
.input-controls .input-row-connected .slider-wrap .slider-val {
  background: var(--panel2, #f1f5f9);
  color: var(--text-secondary);
}
/* 布尔开关 */
.input-controls .input-row-connected .input-control-bool-wrap.disabled {
  opacity: 0.8;
  cursor: not-allowed;
}
.input-controls .input-row-connected .bool-toggle-track {
  background: var(--border);
}
/* 密码框 */
.input-controls .input-row-connected .password-wrap {
  opacity: 0.85;
}
.input-controls .input-row-connected .pw-input {
  background: var(--panel2, #f1f5f9);
}
/* 文件上传区：已在 JS 中设置 pointer-events 与 opacity，此处补充视觉 */
.input-controls .input-row-connected .file-dropzone {
  background: var(--panel2, #f1f5f9);
  border-color: var(--border);
}
/* Ace 编辑器区域 */
.input-controls .input-row-connected .ace-field-container {
  opacity: 0.85;
}
.input-controls .input-row-connected .ace-inline-editor {
  background: var(--panel2, #f1f5f9);
}
.input-controls .input-row-connected .ace-btn-maximize {
  cursor: not-allowed;
  opacity: 0.7;
}

.input-controls input,
.input-controls textarea,
.input-controls select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  padding: 7px 10px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  transition: border-color 0.15s;
}

.input-controls input:focus,
.input-controls textarea:focus,
.input-controls select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.15);
}

.input-controls textarea {
  min-height: 48px;
  resize: vertical;
}

/* ── 列表端点：input / textarea / keyvalue ── */
.input-controls .list-ui-wrap {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.input-controls .list-ui-wrap .list-ui-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}
.input-controls .list-ui-wrap .list-ui-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.input-controls .list-ui-wrap .list-ui-item .list-ui-input,
.input-controls .list-ui-wrap .list-ui-item .list-ui-textarea {
  flex: 1;
  min-width: 0;
}
.input-controls .list-ui-wrap .list-ui-item .list-ui-textarea {
  min-height: 44px;
  resize: vertical;
}
.input-controls .list-ui-wrap .list-ui-del {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  line-height: 1;
  font-size: 14px;
  border-radius: 50%;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--panel2);
}
.input-controls .list-ui-wrap .list-ui-del:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.06);
}
.input-controls .list-ui-wrap .list-ui-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 32px;
}
.input-controls .list-ui-wrap .list-ui-header .list-ui-label {
  margin: 0;
}
.input-controls .list-ui-wrap .list-ui-add {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  line-height: 1;
  font-size: 16px;
  font-weight: 600;
  border-radius: 4px;
  border-style: dashed;
  color: #6366f1;
  border-color: #6366f1;
  background: transparent;
}
.input-controls .list-ui-wrap .list-ui-add:hover {
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
  border-color: #4f46e5;
}
/* keyvalue 自由键值：键/值 标题与输入同一行，左侧两行、删除在右侧居中 */
.input-controls .list-ui-wrap .list-ui-item-keyvalue {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.input-controls .list-ui-wrap .list-ui-item-keyvalue .list-kv-rows {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.input-controls .list-ui-wrap .list-ui-item-keyvalue .list-kv-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.input-controls .list-ui-wrap .list-ui-item-keyvalue .list-kv-row .list-kv-keylabel {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-secondary);
}
.input-controls .list-ui-wrap .list-ui-item-keyvalue .list-kv-key,
.input-controls .list-ui-wrap .list-ui-item-keyvalue .list-kv-value {
  flex: 1;
  min-width: 0;
}
.input-controls .list-ui-wrap .list-ui-item-keyvalue .list-kv-value {
  min-height: 44px;
  resize: vertical;
}
.input-controls .list-ui-wrap .list-ui-item-keyvalue .list-ui-del {
  align-self: center;
}
/* keyvalue 固定 keys：姓名、简介等各占一行，删除按钮在右侧垂直居中 */
.input-controls .list-ui-wrap .list-ui-item-keyvalue-keys {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.input-controls .list-ui-wrap .list-ui-item-keyvalue-keys .list-kv-keys-cells {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.input-controls .list-ui-wrap .list-ui-item-keyvalue-keys .list-kv-keycell {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.input-controls .list-ui-wrap .list-ui-item-keyvalue-keys .list-ui-del {
  flex-shrink: 0;
  align-self: center;
}
.input-controls .list-ui-wrap .list-kv-keycell .list-kv-keylabel {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-secondary);
}
.input-controls .list-ui-wrap .list-kv-keycell .list-kv-field {
  flex: 1;
  min-width: 0;
}
.input-controls .list-ui-wrap .list-kv-keycell textarea.list-kv-field {
  min-height: 36px;
  resize: vertical;
}
.input-controls .input-row-connected .list-ui-wrap .list-ui-add,
.input-controls .input-row-connected .list-ui-wrap .list-ui-del {
  pointer-events: none;
  opacity: 0.7;
}
.input-controls .input-row-connected .list-ui-wrap input,
.input-controls .input-row-connected .list-ui-wrap textarea {
  background: var(--panel2);
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* ── Slider / range ── */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-wrap input[type="range"] {
  flex: 1;
  padding: 0;
  height: 6px;
  border: none;
  border-radius: 3px;
  background: var(--border);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  cursor: pointer;
}

.slider-wrap input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  cursor: pointer;
}

.slider-wrap .slider-val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  min-width: 36px;
  text-align: right;
  background: var(--panel2);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ── Color input ── */
.input-controls input[type="color"] {
  padding: 2px;
  height: 34px;
  cursor: pointer;
}

/* ── Date input ── */
.input-controls input[type="date"] {
  cursor: pointer;
}

/* ── Bool toggle (modern pill switch, no checkbox look) ── */
.input-control-bool-wrap {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  cursor: pointer;
  user-select: none;
  outline: none;
}
.input-control-bool-wrap:focus-visible .bool-toggle-track {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}
.input-controls .bool-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  appearance: none;
  pointer-events: none;
}
.bool-toggle-track {
  display: inline-flex;
  align-items: center;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--border);
  transition: background 0.2s ease, box-shadow 0.15s ease;
  position: relative;
  flex-shrink: 0;
}
.bool-toggle-thumb {
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.bool-toggle-input:checked + .bool-toggle-track {
  background: var(--accent);
}
.bool-toggle-input:checked + .bool-toggle-track .bool-toggle-thumb {
  transform: translate(18px, -50%);
}

/* ── Python node: input dots aligned with controls ── */
.drawflow .drawflow-node.python-node .inputs {
  position: relative;
  justify-content: flex-start;
}

.drawflow .drawflow-node.python-node .inputs .input {
  position: absolute;
}

.drawflow .drawflow-node.python-node .outputs {
  position: relative;
}

.drawflow .drawflow-node.python-node .outputs .output {
  position: absolute;
  left: auto;
  right: -9px;
}

/* ── Node minimized state ── */
.drawflow .drawflow-node.python-node.minimized {
  min-width: 0 !important;
  width: fit-content !important;
  max-width: 260px;
  min-height: 0 !important;
  height: auto !important;
}

.drawflow .drawflow-node.python-node.minimized .drawflow-node-header {
  border-radius: 7px;
  border-bottom: none;
}

.drawflow .drawflow-node.python-node.minimized .node-body {
  display: none;
}

.drawflow .drawflow-node.python-node.minimized .drawflow-node-resize-handle {
  display: none;
}

.drawflow .drawflow-node.python-node.minimized .inputs {
  position: relative;
}

.drawflow .drawflow-node.python-node.minimized .inputs .input {
  position: absolute !important;
  top: 50% !important;
  margin-top: -6px;
}

.drawflow .drawflow-node.python-node.minimized .outputs {
  position: relative;
  padding-bottom: 0;
  gap: 0;
}

.drawflow .drawflow-node.python-node.minimized .outputs .output {
  position: absolute !important;
  top: 50% !important;
  left: auto !important;
  right: -9px !important;
  margin-top: -6px;
}

/* maximized state */
.drawflow .drawflow-node.python-node.maximized-view {
  z-index: 10;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.drawflow .drawflow-node.python-node.maximized-view .drawflow-node-resize-handle {
  display: none;
}

.drawflow .drawflow-node.python-node.maximized-view .drawflow-node-header {
  cursor: default;
}

/* ── Ace Editor inline controls ── */
.ace-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  width: 100%;
  box-sizing: border-box;
}
.ace-label-row .ace-label-text {
  flex: 1;
  min-width: 0;
}
.ace-label-row .ace-btn-maximize {
  flex-shrink: 0;
  position: relative;
  margin-left: auto;
}

.ace-control-wrap {
  border: 1px solid #2d333b;
  border-radius: 6px;
  overflow: hidden;
  background: #282c34;
}

.ace-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 8px;
  background: #21252b;
  border-bottom: 1px solid #2d333b;
}

.ace-mode-label {
  font-size: 10px;
  font-weight: 600;
  color: #636d83;
  letter-spacing: 0.5px;
}

.ace-btn-maximize {
  background: none;
  border: none;
  color: #636d83;
  padding: 2px;
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  align-items: center;
  transition: all 0.12s;
}

.ace-btn-maximize:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #abb2bf;
}

.ace-btn-maximize svg {
  width: 12px;
  height: 12px;
  right: 6px;
}

.ace-inline-editor {
  width: 100%;
  min-height: 60px;
  font-size: 12px;
}

.input-control-ace {
  border: none !important;
  padding: 0 !important;
  background: none !important;
}

/* ── Password control ── */
.password-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
}

.password-wrap .pw-input {
  flex: 1;
  padding-right: 36px !important;
}

.password-wrap .pw-toggle {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.12s;
}

.password-wrap .pw-toggle:hover {
  opacity: 1;
  background: none;
  border: none;
}

/* ── File upload control ── */
.file-upload-wrap {
  width: 100%;
}

.file-hidden-input {
  display: none !important;
}

.file-dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--panel2);
}

.file-dropzone:hover {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.04);
}

.file-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.08);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.12);
}

.file-drop-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.file-drop-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.file-drop-text .file-browse {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.file-list {
  margin-top: 4px;
}

.file-list:empty {
  display: none;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--panel2);
  border: 1px solid var(--border-light);
  border-radius: 5px;
  margin-top: 3px;
  font-size: 11px;
}

.file-item .file-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-all;
  white-space: normal;
  color: var(--text);
  font-family: var(--mono);
}

.file-item .file-size {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.file-item .file-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.12s;
}

.file-item .file-remove:hover {
  opacity: 1;
  background: none;
  border: none;
}

/* ══════════════════════════════════════════
   Floating toolbar (node selected)
   ══════════════════════════════════════════ */
#node-toolbar {
  position: absolute;
  z-index: 100;
  display: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  gap: 2px;
  align-items: center;
  animation: toolbar-pop 0.18s ease-out;
  pointer-events: auto;
}

#node-toolbar.visible {
  display: inline-flex;
}

@keyframes toolbar-pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#node-toolbar .tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.12s;
  white-space: nowrap;
}

#node-toolbar .tb-btn:hover {
  background: var(--panel2);
  border-color: var(--border);
  color: var(--text);
}

#node-toolbar .tb-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

#node-toolbar .tb-btn.tb-danger:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

#node-toolbar .tb-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 2px;
  flex-shrink: 0;
}

/* 节点类型：可搜索下拉 */
#node-toolbar .tb-type-dropdown {
  position: relative;
}

#node-toolbar .tb-type-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 140px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.12s;
}

#node-toolbar .tb-type-trigger:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(129, 140, 248, 0.06);
}

#node-toolbar .tb-type-trigger-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

#node-toolbar .tb-type-trigger-icon svg {
  width: 13px;
  height: 13px;
}

#node-toolbar .tb-type-trigger-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#node-toolbar .tb-type-trigger-arrow {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

#node-toolbar .tb-type-trigger-arrow svg {
  width: 12px;
  height: 12px;
  transition: transform 0.15s;
}

#node-toolbar .tb-type-dropdown.open .tb-type-trigger-arrow svg {
  transform: rotate(180deg);
}

#node-toolbar .tb-type-panel {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 180px;
  max-width: 240px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}

#node-toolbar .tb-type-dropdown.open .tb-type-panel {
  display: block;
}

#node-toolbar .tb-type-search {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: none;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  outline: none;
  background: var(--panel2);
}

#node-toolbar .tb-type-search::placeholder {
  color: var(--text-secondary);
}

#node-toolbar .tb-type-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 0;
}

#node-toolbar .tb-type-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background 0.1s;
}

#node-toolbar .tb-type-option:hover {
  background: var(--panel2);
}

#node-toolbar .tb-type-option-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

#node-toolbar .tb-type-option-icon svg {
  width: 13px;
  height: 13px;
}

#node-toolbar .tb-type-option-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#node-toolbar .tb-type-no-result {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

/* ══════════════════════════════════════════
   Canvas controls (bottom-left)
   ══════════════════════════════════════════ */
#canvas-controls {
  position: absolute;
  left: 8px;
  bottom: 6px;
  z-index: 50;
  display: flex;
  gap: 3px;
}

#canvas-controls .mc-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 400;
  transition: all 0.12s;
  white-space: nowrap;
}

#canvas-controls .mc-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 255, 255, 0.9);
}

#canvas-controls .mc-btn svg {
  width: 10px;
  height: 10px;
}

/* ══════════════════════════════════════════
   Box selection & multi-select
   ══════════════════════════════════════════ */
#selection-box {
  display: none;
  position: absolute;
  border: 1.5px dashed var(--accent);
  background: rgba(129, 140, 248, 0.08);
  border-radius: 3px;
  pointer-events: none;
  z-index: 60;
}
#selection-box.active {
  display: block;
}

.drawflow .drawflow-node.multi-selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.15);
}

/* ══════════════════════════════════════════
   Searchable select dropdown
   ══════════════════════════════════════════ */
.searchable-select {
  position: relative;
  width: 100%;
}

.searchable-select .ss-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  padding: 7px 10px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
  min-height: 32px;
  gap: 4px;
}

.searchable-select .ss-trigger:hover {
  border-color: var(--accent);
}

.searchable-select .ss-trigger .ss-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.searchable-select .ss-trigger .ss-arrow {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.15s;
}
.searchable-select .ss-trigger .ss-arrow svg {
  display: block;
  width: 1em;
  height: 1em;
}

.searchable-select.open .ss-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.15);
}

.searchable-select.open .ss-trigger .ss-arrow {
  transform: rotate(180deg);
}

.searchable-select .ss-dropdown {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 220px;
  overflow: hidden;
  flex-direction: column;
}

.searchable-select.open .ss-dropdown {
  display: flex;
}

.searchable-select .ss-search {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 12px;
  font-family: var(--sans);
  outline: none;
  background: var(--panel2);
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
}

.searchable-select .ss-options {
  overflow-y: auto;
  max-height: 176px;
  padding: 4px 0;
}

.searchable-select .ss-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s;
  color: var(--text);
}

.searchable-select .ss-option:hover {
  background: rgba(129, 140, 248, 0.08);
}

.searchable-select .ss-option.selected {
  background: rgba(129, 140, 248, 0.12);
  font-weight: 600;
}

.searchable-select .ss-option .ss-check {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
  color: transparent;
  transition: all 0.1s;
}

.searchable-select .ss-option.selected .ss-check {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.searchable-select .ss-option .ss-no-result {
  color: var(--text-secondary);
  font-style: italic;
  padding: 8px 0;
  text-align: center;
  width: 100%;
}

/* Multi-select tags in trigger */
.searchable-select .ss-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.searchable-select .ss-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(129, 140, 248, 0.12);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

/* ══════════════════════════════════════════
   Code editor modal
   ══════════════════════════════════════════ */
#code-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

#code-modal.open {
  display: flex;
}

#code-modal .modal-box {
  background: var(--panel);
  border-radius: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

#code-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
}

#code-modal .modal-title {
  font-weight: 700;
  font-size: 14px;
}

#code-modal .modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
}

#code-modal .modal-close:hover {
  background: var(--panel2);
  color: var(--text);
}

#code-modal .modal-body {
  flex: 1;
  min-height: 300px;
  overflow: hidden;
  position: relative;
}

#modal-ace-editor {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 13px;
}

#code-modal .modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-top: 1px solid var(--border);
}

#code-modal .modal-error {
  flex: 1;
  font-size: 12px;
  color: var(--danger);
}

#code-modal .modal-error:empty {
  display: none;
}

/* ── Code control modal (maximize inline editors) ── */
#code-control-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

#code-control-modal.open {
  display: flex;
}

#code-control-modal .modal-box {
  background: var(--panel);
  border-radius: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#code-control-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
}

#code-control-modal .modal-title {
  font-weight: 700;
  font-size: 14px;
}

#code-control-modal .modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
}

#code-control-modal .modal-close:hover {
  background: var(--panel2);
  color: var(--text);
}

#code-control-modal .modal-body {
  flex: 1;
  min-height: 300px;
  overflow: hidden;
  position: relative;
}

#cc-modal-ace-editor {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 13px;
}

#code-control-modal .modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* ── Header color picker ── */
.hdr-color-wrap {
  position: relative;
  display: inline-flex;
}

.hdr-color-popup {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  padding: 6px 8px;
  z-index: 50;
  white-space: nowrap;
}

.hdr-color-popup.visible {
  display: block;
}

.hdr-color-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.hdr-color-row span {
  min-width: 22px;
}

.hdr-color-row input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
  background: none;
}

.hdr-color-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 1px;
}

.hdr-color-row input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.hdr-color-input {
  position: absolute;
  width: 0;
  height: 0;
  padding: 0;
  border: none;
  opacity: 0;
  pointer-events: none;
}

/* ── Node title: double-click to edit ──
.drawflow .drawflow-node .drawflow-node-title {
  cursor: text;
} */

/* ── Node type icon (left of title) ── */
.drawflow .drawflow-node .node-type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-right: 4px;
  flex-shrink: 0;
  color: inherit;
}

.drawflow .drawflow-node .node-type-icon svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* ── Node description area ── */
.node-description {
  padding: 5px 0 8px;
  margin-bottom: 6px;
  border-bottom: 1px dashed var(--border);
  min-height: 18px;
}

.node-desc-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
}

.node-desc-text.node-desc-placeholder {
  font-style: italic;
  color: var(--border);
  cursor: text;
}

/* ── Inline editing inputs ── */
.node-inline-edit {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  outline: none;
  font-family: var(--sans);
  color: var(--text);
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.18);
  padding: 2px 6px;
}

.node-title-edit {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.1px;
  height: 22px;
  line-height: 1.4;
}

.node-desc-edit {
  font-size: 12px;
  line-height: 1.5;
  resize: none;
  min-height: 40px;
}

/* ══════════════════════════════════════════
   Node locked / processing state
   ══════════════════════════════════════════ */
.drawflow .drawflow-node.python-node .drawflow_content_node {
  position: relative;
  z-index: 0;
}

.node-lock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(148, 163, 184, 0.38);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 0;
  gap: 8px;
  pointer-events: all;
  cursor: not-allowed;
}

.lock-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: lock-spin 0.7s linear infinite;
}

@keyframes lock-spin {
  to { transform: rotate(360deg); }
}

.lock-text {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.drawflow .drawflow-node.node-locked {
  border-color: #94a3b8 !important;
  animation: node-lock-pulse 1.8s ease-in-out infinite;
}

@keyframes node-lock-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(148, 163, 184, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(148, 163, 184, 0); }
}

.drawflow .drawflow-node.node-locked .header-btns .hdr-btn {
  pointer-events: none;
  opacity: 0.4;
}

.drawflow .drawflow-node.node-locked .drawflow-node-title {
  pointer-events: none;
}

.drawflow .drawflow-node.node-locked .node-desc-text {
  pointer-events: none;
}

.drawflow .drawflow-node.node-locked .input-controls input,
.drawflow .drawflow-node.node-locked .input-controls textarea,
.drawflow .drawflow-node.node-locked .input-controls select,
.drawflow .drawflow-node.node-locked .input-controls .searchable-select,
.drawflow .drawflow-node.node-locked .input-controls .list-ui-wrap .list-ui-add,
.drawflow .drawflow-node.node-locked .input-controls .list-ui-wrap .list-ui-del {
  pointer-events: none;
  opacity: 0.5;
}

/* ══════════════════════════════════════════
   Auth: topbar user + settings modal
   ══════════════════════════════════════════ */
#topbar .topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-menu-slot {
  display: flex;
  align-items: center;
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.user-menu-trigger:hover {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.06);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-chevron {
  font-size: 10px;
  color: var(--text-secondary);
  margin-left: -2px;
}

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 168px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
}

.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}

.user-menu-item:hover {
  background: var(--panel2);
}

.user-menu-item-danger {
  color: var(--danger);
}

#auth-settings-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

#auth-settings-modal.open {
  display: flex;
}

#auth-settings-modal .auth-settings-box {
  display: flex;
  flex-direction: column;
  width: min(440px, 92vw);
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
}

/* ── 通用弹窗增强：拖拽/缩放（overlay modal-box） ── */
.modal-box.cp-flex-host {
  /* JS 会把它固化为 fixed；这里仅补齐手柄与提示 */
  overflow: visible;
}

.modal-box.cp-flex-fixed {
  /* 固化后允许内部内容随宽度自适应 */
  box-sizing: border-box;
  max-width: none !important;
  max-height: none !important;
}

.modal-box .modal-header.cp-flex-drag-handle,
.modal-box.cp-flex-host .modal-header {
  cursor: move;
  user-select: none;
}

.modal-box.cp-flex-host.cp-flex-moving {
  cursor: move;
}

.modal-box.cp-flex-host > .cp-flex-resize {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
  border-radius: 4px;
  opacity: 0.55;
  background:
    linear-gradient(135deg, transparent 46%, rgba(0, 0, 0, 0.22) 46% 56%, transparent 56%),
    linear-gradient(135deg, transparent 60%, rgba(0, 0, 0, 0.14) 60% 70%, transparent 70%);
}

.modal-box.cp-flex-host > .cp-flex-resize:hover {
  opacity: 0.9;
}

#auth-settings-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

#auth-settings-modal .modal-title {
  font-weight: 700;
  font-size: 15px;
}

#auth-settings-modal .modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
}

#auth-settings-modal .modal-close:hover {
  background: var(--panel2);
  color: var(--text);
}

#auth-settings-modal .auth-settings-body {
  padding: 16px 18px;
  overflow: auto;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.auth-input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--panel);
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.2);
}

.auth-hint {
  margin: -6px 0 14px;
  font-size: 12px;
  color: var(--text-secondary);
}

.auth-settings-msg {
  min-height: 1.2em;
  font-size: 13px;
}

.auth-settings-msg.is-error {
  color: var(--danger);
}

.auth-settings-msg.is-ok {
  color: var(--success);
}

#auth-settings-modal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
