:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #18201f;
  --muted: #687572;
  --line: #e1e7e5;
  --accent: #0052d9;
  --accent-dark: #003fae;
  --accent-soft: #eaf0ff;
  --danger: #b33a3a;
  --danger-soft: #fff0ee;
  --warning: #805d13;
  --warning-soft: #fff7df;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
code { padding: 2px 5px; border-radius: 5px; background: #edf1f0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
[hidden] { display: none !important; }

.squircle { border-radius: calc(var(--sq-r) * .54); }
@supports (corner-shape: squircle) {
  .squircle { border-radius: var(--sq-r); corner-shape: squircle; }
}

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { --sq-r: 22px; width: min(420px, 100%); padding: 38px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 20px 60px rgba(26, 54, 46, .09); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.login-card h1 { margin: 4px 0 0; font-size: 25px; }
.login-card .muted { margin: 0 0 26px; }
.login-card label { display: block; margin: 0 0 12px; }
.login-card .button.full { margin-top: 16px; }
.brand-mark { --sq-r: 16px; width: 54px; height: 54px; display: grid; place-items: center; background: var(--accent); color: white; font-size: 27px; font-weight: 800; }
.brand-mark.small { --sq-r: 12px; width: 40px; height: 40px; font-size: 20px; flex: 0 0 auto; }

.app { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px; border-right: 1px solid var(--line); background: #fbfcfc; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.nav { display: grid; gap: 6px; }
.nav-item { --sq-r: 20px; padding: 12px 14px; border: 0; background: transparent; color: #4c5b57; text-align: left; }
.nav-item:hover { background: #eef3f1; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; }
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; padding: 16px 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.text-button { width: fit-content; padding: 0; border: 0; background: transparent; color: var(--accent); }

.content { width: min(1180px, 100%); padding: 32px 38px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.topbar h1 { margin: 4px 0 0; font-size: 28px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.status-badge { --sq-r: 16px; display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px; background: #e9edec; color: #59635f; font-size: 13px; font-weight: 700; }
.status-badge span { width: 8px; height: 8px; border-radius: 50%; background: #8b9692; }
.status-badge.running { background: var(--accent-soft); color: var(--accent-dark); }
.status-badge.running span { background: #1b9b70; box-shadow: 0 0 0 4px rgba(27, 155, 112, .12); }

.section { display: grid; gap: 20px; align-content: start; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card { --sq-r: 18px; padding: 20px; border: 1px solid var(--line); background: var(--panel); }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card span { font-size: 13px; }
.stat-card strong { display: block; overflow: hidden; margin: 12px 0 8px; font-size: 25px; text-overflow: ellipsis; white-space: nowrap; }
.stat-card small { font-size: 11px; }
.panel { --sq-r: 20px; padding: 24px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 2px 5px rgba(22, 46, 38, .02); }
.panel h2 { margin: 0 0 7px; font-size: 18px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.panel > .muted { line-height: 1.8; }

.form-panel { display: grid; gap: 11px; }
.form-panel .panel-heading { margin-bottom: 10px; }
.form-panel .button-row { margin-top: 10px; }
label { margin-top: 5px; font-size: 13px; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid #d5dedb; border-radius: 9px; background: #fff; color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s; }
input, select { min-height: 43px; padding: 10px 12px; }
textarea { padding: 12px; line-height: 1.65; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 82, 217, .1); }
.prompt-editor { min-height: 380px; font-family: ui-monospace, SFMono-Regular, Menlo, "PingFang SC", monospace; font-size: 13px; }
.checkbox-row { display: flex; align-items: flex-start; gap: 9px; margin: 8px 0; font-weight: 500; line-height: 1.5; }
.checkbox-row input { width: 17px; min-height: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--accent); flex: 0 0 auto; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two-columns > div { display: grid; gap: 10px; }

.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button { --sq-r: 18px; min-height: 40px; padding: 9px 16px; border: 1px solid transparent; font-weight: 700; font-size: 13px; transition: background .15s, opacity .15s; }
.button:disabled { cursor: wait; opacity: .55; }
.button.primary { background: var(--accent); color: white; }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { border-color: #c3d4f5; background: var(--accent-soft); color: var(--accent-dark); }
.button.ghost { border-color: var(--line); background: white; color: #42524d; }
.button.full { width: 100%; margin-top: 10px; }
.hint { margin: 2px 0 8px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.steps { display: grid; gap: 13px; margin: 0; padding-left: 22px; color: #42514d; line-height: 1.75; font-size: 14px; }
.alert { padding: 13px 15px; border-radius: 9px; font-size: 13px; line-height: 1.65; }
.alert.error { border: 1px solid #f1cfca; background: var(--danger-soft); color: var(--danger); }
.alert.warning { border: 1px solid #eee0b9; background: var(--warning-soft); color: var(--warning); }
.reply-box { margin-top: 10px; padding: 16px; border-left: 3px solid var(--accent); border-radius: 5px 9px 9px 5px; background: var(--accent-soft); line-height: 1.8; white-space: pre-wrap; }

.example-list { display: grid; gap: 14px; }
.example-card { --sq-r: 16px; display: grid; gap: 9px; padding: 18px; border: 1px solid var(--line); background: #fbfcfc; }
.example-card.active { border-color: #c3d4f5; }
.example-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.tag { padding: 2px 8px; border-radius: 6px; background: #e9edec; color: #4c5b57; font-weight: 700; }
.tag.active { background: var(--accent-soft); color: var(--accent-dark); }
.button-row.compact { margin-top: 0; flex-wrap: nowrap; }
.button-row.compact select { width: auto; margin: 0; }
.history-table td { vertical-align: top; }
.history-table .message-cell { min-width: 180px; max-width: 360px; white-space: pre-wrap; word-break: break-word; }
.history-table .meta { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag-list .tag { border: 0; cursor: pointer; font: inherit; font-size: 13px; }
.example-card details { color: var(--muted); font-size: 12px; }
.example-card details p { margin: 6px 0 0; line-height: 1.7; white-space: pre-wrap; }
.button.danger { border-color: #f1cfca; background: var(--danger-soft); color: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; }
td:first-child { width: 165px; white-space: nowrap; }
td:nth-child(2) { width: 60px; }
.log-error { color: var(--danger); }
.toast { --sq-r: 16px; position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(420px, calc(100vw - 48px)); padding: 13px 18px; background: #1c2b27; color: white; box-shadow: 0 12px 36px rgba(0, 0, 0, .18); font-size: 13px; line-height: 1.6; }
.toast.error { background: #8f3030; }

@media (max-width: 980px) {
  .app { grid-template-columns: 190px minmax(0, 1fr); }
  .content { padding: 26px 22px 50px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .app { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-brand { padding: 0 4px 14px; }
  .nav { display: flex; overflow-x: auto; gap: 5px; }
  .nav-item { --sq-r: 17px; flex: 0 0 auto; padding: 9px 12px; white-space: nowrap; }
  .sidebar-footer { display: none; }
  .content { padding: 22px 14px 40px; }
  .topbar { align-items: flex-start; }
  .topbar h1 { font-size: 23px; }
  .panel { padding: 18px; }
  .two-columns { grid-template-columns: 1fr; }
  .login-card { padding: 28px; }
}
