:root {
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #3556c7;
  --danger: #b42318;
  --bg: #f6f7f9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
  max-width: 720px;
}

#login-form { width: 320px; display: flex; flex-direction: column; gap: 12px; }
#login-form h1 { font-size: 18px; margin: 0; }
.subtitle { color: var(--muted); margin: 0 0 8px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }

input, select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
}

button {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--danger); padding: 4px 10px; font-size: 13px; }
button.linkish { background: transparent; color: var(--brand); padding: 4px 6px; }

.error { color: var(--danger); font-size: 14px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; }
.who { color: var(--muted); margin-left: auto; }

main { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

#users-table { border-collapse: collapse; width: 100%; font-size: 14px; }
#users-table th, #users-table td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
}
#users-table th { color: var(--muted); font-weight: 500; }

.badge-disabled { color: var(--danger); }
.badge-ok { color: #067647; }

/* ---- 领域工作台 ---- */
.row-head { display: flex; align-items: center; gap: 12px; }
.row-head h2 { margin: 0; font-size: 17px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.course-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px; border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; color: var(--ink); background: #fff;
}
.course-card:hover { border-color: var(--brand); }
.muted { color: var(--muted); font-size: 13px; font-weight: 400; }
.stage { margin-top: 14px; }
.stage h3 { font-size: 15px; margin: 0 0 6px; }
.badge { padding: 1px 8px; border-radius: 999px; font-size: 12px; }
.badge.success { background: #e7f6ec; color: #067647; }
.badge.failed { background: #fdecea; color: var(--danger); }
.badge.running { background: #e8f1fd; color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 10px; }
.ghost-link { margin-left: 12px; color: var(--brand); text-decoration: none; font-size: 14px; }
.artifact-pre {
  background: #0f1420; color: #d8e0ee; padding: 14px; border-radius: 8px;
  overflow: auto; max-height: 70vh; font-size: 13px;
}

/* ---- 用户面板 ---- */
.panel { max-width: 760px; margin: 0 auto; }
.panel-card {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; text-decoration: none; color: var(--ink);
}
.panel-card h2 { margin: 0 0 6px; font-size: 17px; }
.panel-card:hover { border-color: var(--brand); }
#profile-form input { max-width: 320px; }

/* ---- 课程卡片 ---- */
.course-title { font-weight: 600; color: var(--ink); text-decoration: none; }
.course-title:hover { color: var(--brand); }
.card-actions { display: flex; gap: 6px; margin-top: 4px; }

/* ---- 大画布 ---- */
.course-page main { padding: 14px 16px; }
.canvas-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; }
.canvas { position: relative; }
.stage-band {
  position: absolute; border-left: 4px solid var(--brand);
  background: linear-gradient(90deg, rgba(53,86,199,.05), transparent 60%);
  border-radius: 4px;
}
.stage-band.kind-input { border-left-color: #546e7a; }
.stage-band.kind-structure { border-left-color: #1e88e5; }
.stage-band.kind-unit_prep { border-left-color: #43a047; }
.band-label { position: absolute; top: 8px; left: 10px; font-weight: 700; font-size: 14px; }
.band-label em { font-style: normal; color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.band-btn { position: absolute; top: 6px; right: 12px; font-size: 13px; color: var(--brand); text-decoration: none; }
.layer-frame {
  position: absolute; border: 1px dashed #c8ccd4; border-radius: 8px; background: #fff;
}
.layer-label { position: absolute; top: 10px; left: 14px; font-weight: 600; font-size: 13px; color: var(--ink); }
.layer-btn { position: absolute; top: 8px; right: 12px; font-size: 12px; color: var(--brand); text-decoration: none; }
.layer-btn.ghost { right: 84px; color: var(--muted); }
.layer-empty { position: absolute; top: 30px; left: 14px; color: var(--muted); font-size: 12px; }
svg.edges { position: absolute; left: 0; top: 0; pointer-events: none; }
svg.edges text { font-size: 12px; fill: #444; }
.node {
  position: absolute; box-sizing: border-box; background: #fff;
  border: 2px solid var(--brand); border-radius: 8px; padding: 6px 8px;
  display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.06); overflow: hidden;
}
.node:hover { filter: brightness(1.03); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.node-top { display: flex; justify-content: space-between; align-items: center; font-size: 11px; }
.node-kind { color: var(--muted); }
.node-name { font-weight: 600; font-size: 13px; line-height: 1.25; overflow: hidden; max-height: 2.5em; }
.node-foot { font-size: 11px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.node.destroyed { opacity: .45; }
.node.destroyed .node-name { text-decoration: line-through; }
.node.inactive { border-style: dashed; }
.badge.none { background: #eef0f3; color: var(--muted); }
.badge.pending, .badge.blocked { background: #fff6e5; color: #9a6700; }

/* ---- 表单页 ---- */
.form-page { max-width: 900px; margin: 0 auto; }
.card.narrow { max-width: 560px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; font-family: ui-monospace, monospace; }
.form-section { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 14px 16px; }
.form-section h3 { margin: 0 0 10px; font-size: 15px; }
.form-section h4 { margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.form-actions { display: flex; gap: 8px; }
.check { flex-direction: row; align-items: center; gap: 6px; }
button.brand { background: #067647; }
button:disabled { opacity: .5; cursor: not-allowed; }
.mode-tabs { display: flex; gap: 8px; margin-bottom: 8px; }
.mode-tabs .tab { background: #eef0f3; color: var(--ink); }
.mode-tabs .tab.on { background: var(--brand); color: #fff; }
.io-row { display: grid; grid-template-columns: 1.1fr .7fr 1fr 1.6fr auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.io-row textarea { width: 100%; }
.phase-block textarea { width: 100%; }
.status { color: #067647; font-size: 14px; }
.step-actions.actions-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
#exec-table { border-collapse: collapse; width: 100%; font-size: 13px; }
#exec-table td { border-bottom: 1px solid var(--line); padding: 5px 8px; }
.actions-cell { white-space: nowrap; }
.actions-cell button { margin-right: 4px; }
#artifact-links { margin: 0; padding-left: 18px; }
td .button-gap, td button + button { margin-left: 6px; }
