:root {
  color-scheme: light;
  --bg: #f5f8fc;
  --surface: #ffffff;
  --surface-subtle: #f8faff;
  --surface-blue: #f1f6ff;
  --line: #e5eaf2;
  --line-strong: #d7deea;
  --text: #172033;
  --text-soft: #3e4a60;
  --muted: #7a8699;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eaf1ff;
  --success: #16845b;
  --success-soft: #eaf8f2;
  --warning: #b56808;
  --warning-soft: #fff7e6;
  --danger: #d14343;
  --danger-soft: #fff0f0;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 31, 51, .03), 0 4px 14px rgba(20, 31, 51, .035);
  --shadow-md: 0 18px 48px rgba(27, 46, 82, .12);
  font-family: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); overflow-x: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; }

.shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: relative; min-height: 72px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; color: #fff; font-size: 10px; font-weight: 800; letter-spacing: -.02em; background: linear-gradient(145deg, #2f73f3, #1853c9); box-shadow: 0 6px 14px rgba(37, 99, 235, .22); }
.brand-mark.large { width: 52px; height: 52px; margin: 0 auto 18px; border-radius: 15px; font-size: 14px; }
.brand strong { display: block; font-size: 15px; line-height: 1.25; letter-spacing: -.015em; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.main-nav { display: flex; align-items: center; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: #edf1f7; }
.nav-item { padding: 7px 16px; border-radius: 7px; color: #677286; font-size: 12px; font-weight: 600; text-decoration: none; transition: .16s ease; }
.nav-item:hover { color: var(--text); }
.nav-item.active { color: var(--primary); background: #fff; box-shadow: 0 1px 3px rgba(20, 31, 51, .09); }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.health { display: flex; align-items: center; gap: 7px; margin-right: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.health i { width: 6px; height: 6px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.health.online i { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

.button { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px 13px; color: var(--text-soft); background: var(--surface); font-size: 12px; font-weight: 600; line-height: 1; text-decoration: none; box-shadow: 0 1px 1px rgba(20, 31, 51, .02); transition: color .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.button:hover { color: var(--text); border-color: #c5cedd; box-shadow: 0 3px 10px rgba(20, 31, 51, .07); transform: translateY(-1px); }
.button:active { transform: translateY(0); box-shadow: none; }
.button:focus-visible, .icon-button:focus-visible, .task-item:focus-visible, .nav-item:focus-visible { outline: 3px solid rgba(37, 99, 235, .18); outline-offset: 2px; }
.button.primary { color: #fff; border-color: var(--primary); background: var(--primary); box-shadow: 0 4px 12px rgba(37, 99, 235, .18); }
.button.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); box-shadow: 0 6px 16px rgba(37, 99, 235, .24); }
.button.ghost { background: transparent; box-shadow: none; }
.button.ghost:hover { background: var(--surface); }
.button.danger { color: var(--danger); border-color: #f0caca; background: var(--danger-soft); box-shadow: none; }
.button.danger:hover { color: #b93131; border-color: #e9b0b0; background: #ffe9e9; }
.button.full { width: 100%; margin-top: 8px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0 14px; }
.stat-card { position: relative; min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 14px 18px; background: var(--surface); box-shadow: var(--shadow-sm); }
.stat-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: #4c82ef; }
.stat-card.queued::before { background: #e2a33f; }
.stat-card.completed::before { background: #3aa27a; }
.stat-card.failed::before { background: #df6b6b; }
.stat-card span, .stat-card small { display: block; }
.stat-card span { color: var(--text-soft); font-size: 12px; font-weight: 650; }
.stat-card small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.stat-card strong { color: #24416f; font-size: 25px; font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }

.workspace { min-height: 0; flex: 1; display: grid; grid-template-columns: 316px minmax(0, 1fr); gap: 14px; padding-bottom: 20px; }
.panel { min-height: 580px; height: calc(100vh - 184px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel-head, .detail-head { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); padding: 15px 18px; }
.eyebrow { margin: 0 0 4px; color: var(--primary); font-size: 9px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.panel h1, .panel h2 { margin: 0; color: var(--text); letter-spacing: -.025em; }
.panel h1 { font-size: 17px; font-weight: 680; }
.panel-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.icon-button { width: 32px; height: 32px; display: grid; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 0; color: #68758a; background: var(--surface); font-size: 17px; line-height: 1; transition: .16s ease; }
.icon-button:hover { color: var(--primary); border-color: #c7d6f2; background: var(--primary-soft); }

.task-list { height: calc(100% - 78px); overflow-y: auto; padding: 7px; scrollbar-width: thin; scrollbar-color: #ccd5e3 transparent; }
.task-item { position: relative; width: 100%; display: block; border: 1px solid transparent; border-radius: 10px; padding: 12px 11px; color: inherit; text-align: left; background: transparent; transition: background .15s ease, border-color .15s ease; }
.task-item + .task-item { margin-top: 2px; }
.task-item:hover { background: #f7f9fc; }
.task-item.selected { border-color: #d7e3fb; background: var(--surface-blue); }
.task-item.selected::before { content: ""; position: absolute; left: -1px; top: 13px; bottom: 13px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.task-item-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.task-item h3 { margin: 8px 0 6px; color: #273247; font-size: 12px; font-weight: 620; line-height: 1.48; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-item small { color: var(--muted); font-size: 9px; line-height: 1.4; }
.status-pill { display: inline-flex; align-items: center; width: max-content; min-height: 20px; padding: 3px 7px; border-radius: 999px; color: #647086; background: #f0f3f7; font-size: 9px; font-weight: 700; letter-spacing: .02em; }
.status-pill.running { color: var(--primary); background: var(--primary-soft); }
.status-pill.completed, .status-pill.published { color: var(--success); background: var(--success-soft); }
.status-pill.failed, .status-pill.timed_out { color: var(--danger); background: var(--danger-soft); }
.status-pill.queued, .status-pill.draft { color: var(--warning); background: var(--warning-soft); }
.status-pill.disabled { color: #697489; background: #eff2f6; }

.detail-panel { display: flex; flex-direction: column; }
.empty { display: grid; place-items: center; color: var(--muted); text-align: center; }
.empty.compact { height: 160px; font-size: 11px; }
.empty.hero { flex: 1; padding: 32px; align-content: center; background: radial-gradient(circle at center, #f6f9ff 0, #fff 46%); }
.empty.hero h2 { margin: 13px 0 7px; color: var(--text); font-size: 19px; font-weight: 680; }
.empty.hero p { max-width: 420px; margin: 0 0 20px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; border: 1px solid #d8e4fb; border-radius: 15px; color: var(--primary); font-size: 21px; background: var(--surface-blue); box-shadow: 0 8px 22px rgba(37, 99, 235, .09); }
.detail-title { min-width: 0; }
.detail-title h2 { max-width: 720px; margin-top: 6px; font-size: 17px; font-weight: 680; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-title .meta { margin: 5px 0 0; color: var(--muted); font-size: 9px; }
.detail-actions { display: flex; flex: 0 0 auto; gap: 7px; }
.detail-scroll { overflow-y: auto; padding: 18px; scrollbar-width: thin; scrollbar-color: #ccd5e3 transparent; }
.prompt-card, .result-card { border: 1px solid var(--line); border-radius: 11px; background: var(--surface-subtle); padding: 15px; }
.prompt-text { margin: 0; color: var(--text-soft); font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 23px 1px 10px; }
.section-title h3 { margin: 0; color: #273247; font-size: 12px; font-weight: 680; }
.live-indicator { display: inline-flex; align-items: center; gap: 4px; color: var(--primary); font-size: 8px; font-weight: 750; letter-spacing: .08em; }
.result-card { border-color: #d9e6fb; background: linear-gradient(145deg, #f4f8ff, #fbfdff); }
.result-summary { margin: 0 0 9px; font-size: 15px; font-weight: 680; }
.result-details { color: var(--text-soft); font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.artifact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; margin-top: 14px; }
.artifact { display: block; border: 1px solid #dce5f3; border-radius: 9px; padding: 11px; color: var(--text); background: #fff; text-decoration: none; transition: .16s ease; }
.artifact:hover { border-color: #bfcff0; box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.artifact strong, .artifact small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact strong { color: var(--primary); font-size: 11px; }
.artifact small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.next-steps { margin-top: 14px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.next-steps ul { margin: 7px 0 0; padding-left: 18px; }
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 7px; bottom: 7px; width: 1px; background: #dde4ee; }
.event { position: relative; padding: 0 0 16px; }
.event:last-child { padding-bottom: 2px; }
.event::before { content: ""; position: absolute; left: -18px; top: 5px; width: 7px; height: 7px; border: 2px solid #fff; border-radius: 50%; background: #97a4b7; box-shadow: 0 0 0 1px #cdd5e0; }
.event.error::before { background: var(--danger); box-shadow: 0 0 0 1px #e9b4b4; }
.event.warning::before { background: #d69025; box-shadow: 0 0 0 1px #efcf9d; }
.event-message { margin: 0; color: var(--text-soft); font-size: 11px; line-height: 1.5; white-space: pre-wrap; }
.event-time { margin-top: 3px; color: #99a3b2; font-size: 8px; }

.dialog { width: min(620px, calc(100% - 30px)); max-height: calc(100vh - 40px); overflow-y: auto; border: 1px solid var(--line-strong); border-radius: 16px; padding: 0; color: var(--text); background: #fff; box-shadow: var(--shadow-md); }
.dialog::backdrop { background: rgba(28, 39, 59, .42); backdrop-filter: blur(3px); }
.dialog form { padding: 22px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.dialog h2 { margin: 0; font-size: 19px; font-weight: 680; letter-spacing: -.025em; }
.dialog-subtitle { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.dialog label, .editor-section label { display: grid; gap: 6px; margin: 12px 0; color: #5f6b7d; font-size: 10px; font-weight: 550; }
.dialog input, .dialog select, .dialog textarea, .editor-section input, .editor-section select, .editor-section textarea, .token-create input { width: 100%; min-height: 38px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 11px; outline: none; color: var(--text); background: #fff; font-size: 12px; font-weight: 400; transition: border-color .15s ease, box-shadow .15s ease; }
.dialog textarea, .editor-section textarea { min-height: auto; resize: vertical; line-height: 1.55; }
.dialog input:hover, .dialog select:hover, .dialog textarea:hover, .editor-section input:hover, .editor-section select:hover, .editor-section textarea:hover { border-color: #c3cddd; }
.dialog input:focus, .dialog select:focus, .dialog textarea:focus, .editor-section input:focus, .editor-section select:focus, .editor-section textarea:focus, .token-create input:focus { border-color: #79a3f5; box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.field-hint { margin: -5px 0 3px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.dialog .check-label { align-content: center; }
.check-label span { display: flex; align-items: center; gap: 8px; color: var(--text-soft); font-size: 11px; }
.dialog .check-label input, .editor-section .check-label input { width: 15px; height: 15px; min-height: 0; margin: 0; padding: 0; accent-color: var(--primary); }
.check-label small { color: var(--muted); font-size: 9px; font-weight: 400; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-error { min-height: 14px; margin: 7px 0; color: var(--danger); font-size: 10px; }
.login-dialog { width: min(400px, calc(100% - 30px)); text-align: center; }
.login-dialog form { padding: 30px; }
.login-dialog p { color: var(--muted); font-size: 11px; line-height: 1.65; }
.login-dialog label { text-align: left; }
.login-dialog .hint { margin: -4px 0 8px; text-align: left; }
code { border-radius: 5px; padding: 2px 5px; color: var(--primary); background: var(--primary-soft); }
.hidden { display: none !important; }

.agent-shell { width: min(1580px, calc(100% - 48px)); }
.agent-workspace { min-height: 0; flex: 1; display: grid; grid-template-columns: 292px minmax(0, 1fr); gap: 14px; padding: 18px 0 20px; }
.agent-list-panel, .agent-editor { height: calc(100vh - 110px); }
.agent-editor { overflow: hidden; }
.agent-form { height: 100%; display: flex; flex-direction: column; }
.agent-editor-head { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding: 16px 20px; background: #fff; }
.agent-editor-head h1 { margin: 7px 0 3px; font-size: 19px; font-weight: 680; letter-spacing: -.025em; }
.agent-title-row, .agent-actions { display: flex; align-items: center; gap: 7px; }
.agent-actions { flex-wrap: wrap; justify-content: flex-end; }
.version-label, .save-state, .section-note { color: var(--muted); font-size: 9px; }
.save-state { margin: 0; }
.agent-form-scroll { overflow-y: auto; padding: 0 22px 36px; scrollbar-width: thin; scrollbar-color: #ccd5e3 transparent; }
.editor-section { padding: 9px 0 22px; border-bottom: 1px solid var(--line); }
.editor-section:last-child { border-bottom: 0; }
.editor-section .section-title { margin: 16px 0 10px; }
.editor-section input, .editor-section select, .editor-section textarea { background: #fbfcfe; }
.code-editor, .api-example { font: 10px/1.62 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; tab-size: 2; }
.workflow-steps { display: grid; gap: 10px; }
.workflow-step { border: 1px solid var(--line); border-radius: 11px; padding: 13px; background: var(--surface-subtle); }
.step-head { display: flex; align-items: center; justify-content: space-between; }
.step-number { display: inline-flex; align-items: center; min-height: 21px; border-radius: 999px; padding: 3px 8px; color: var(--primary); background: var(--primary-soft); font-size: 9px; font-weight: 750; }
.step-buttons { display: flex; gap: 5px; }
.step-buttons .icon-button { width: 26px; height: 26px; font-size: 12px; background: #fff; }
.field-label { display: block; margin-bottom: 7px; color: #5f6b7d; font-size: 10px; font-weight: 550; }
.skill-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 7px; max-height: 220px; overflow-y: auto; }
.skill-picker .skill-option { display: flex; grid-template-columns: none; align-items: flex-start; gap: 8px; margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: 9px; background: #fff; cursor: pointer; transition: .15s ease; }
.skill-picker .skill-option:hover { border-color: #c6d5f1; background: #f8fbff; }
.skill-option input { flex: 0 0 auto; width: 14px; height: 14px; min-height: 0; margin: 1px 0 0; padding: 0; accent-color: var(--primary); }
.skill-option span, .skill-option strong, .skill-option small { display: block; min-width: 0; }
.skill-option strong { color: var(--text-soft); font-size: 10px; }
.skill-option small { margin-top: 3px; color: var(--muted); font-size: 8px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.api-endpoint { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--surface-subtle); }
.api-endpoint span { border-radius: 5px; padding: 3px 6px; color: var(--success); background: var(--success-soft); font-size: 8px; font-weight: 800; }
.api-endpoint code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.api-example { overflow-x: auto; margin: 9px 0; border: 1px solid var(--line); border-radius: 8px; padding: 12px; color: #46536a; background: #f6f8fb; }
.token-create { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin: 9px 0; }
.token-once { display: grid; gap: 8px; margin: 9px 0; border: 1px solid #eed6a9; border-radius: 8px; padding: 10px; background: var(--warning-soft); }
.token-once strong { color: var(--warning); font-size: 9px; }
.token-value { display: block; overflow-wrap: anywhere; user-select: all; }
.token-list { display: grid; gap: 7px; margin-top: 9px; }
.token-row, .version-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fff; }
.token-row strong, .token-row small { display: block; }
.token-row strong, .version-row strong { font-size: 10px; }
.token-row small, .version-row span { margin-top: 3px; color: var(--muted); font-size: 8px; }
.token-row .button, .version-row .button { min-height: 29px; padding: 6px 9px; font-size: 9px; }

@media (max-width: 980px) {
  .shell, .agent-shell { width: min(100% - 28px, 880px); }
  .topbar { grid-template-columns: 1fr auto; }
  .main-nav { order: 3; grid-column: 1 / -1; justify-self: center; margin-top: -5px; margin-bottom: 9px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .workspace, .agent-workspace { grid-template-columns: 1fr; }
  .panel { height: auto; min-height: 380px; }
  .task-panel, .agent-list-panel { height: 330px; min-height: 330px; }
  .detail-panel, .agent-editor { height: auto; min-height: 650px; }
}

@media (max-width: 620px) {
  .shell, .agent-shell { width: calc(100% - 20px); }
  .topbar { min-height: 66px; gap: 10px; }
  .brand small, .health, .icon-text span { display: none; }
  .brand strong { font-size: 13px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
  .top-actions .button { min-height: 34px; padding: 8px 10px; }
  .main-nav { width: 100%; }
  .nav-item { flex: 1; text-align: center; }
  .stats { gap: 8px; margin: 12px 0 10px; }
  .stat-card { min-height: 68px; padding: 11px 12px 11px 15px; }
  .stat-card small { display: none; }
  .stat-card strong { font-size: 21px; }
  .workspace, .agent-workspace { gap: 9px; padding-bottom: 10px; }
  .panel-head, .detail-head { min-height: 70px; padding: 13px; }
  .detail-head, .agent-editor-head { align-items: flex-start; flex-direction: column; }
  .detail-title h2 { max-width: calc(100vw - 48px); }
  .detail-actions, .agent-actions { width: 100%; }
  .detail-actions .button, .agent-actions .button { flex: 1; }
  .detail-scroll { padding: 13px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .dialog form { padding: 18px; }
  .agent-editor-head { min-height: auto; padding: 14px; }
  .agent-form-scroll { padding: 0 14px 28px; }
  .section-title { align-items: flex-start; }
  .section-note { max-width: 46%; text-align: right; line-height: 1.4; }
  .token-create { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
