:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --panel: #ffffff;
  --ink: #182023;
  --muted: #667378;
  --line: #d9e2e5;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --danger: #b91c1c;
  --soft: #e7f3f1;
  --shadow: 0 12px 30px rgba(15, 35, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

[hidden] {
  display: none !important;
}

.mode-nav {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.mode-nav strong {
  display: block;
  font-size: 16px;
}

.mode-nav span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.mode-actions {
  display: flex;
  gap: 8px;
}

.mode-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fbfb;
  color: var(--ink);
  font-weight: 700;
}

.mode-button.active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.case-library {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.case-library-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 24px;
}

.case-library-head h1 {
  font-size: 28px;
}

.case-library-head p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.library-count {
  min-width: 96px;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: #fff;
}

.library-count strong {
  display: block;
  color: var(--accent);
  font-size: 28px;
}

.library-count span {
  color: var(--muted);
  font-size: 13px;
}

.training-entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.judge-launch,
.pilot-launch {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 16px;
  border: 1px solid #f2d39b;
  border-left: 4px solid #b45309;
  border-radius: 8px;
  background: #fffbeb;
}

.judge-launch span,
.judge-launch strong,
.pilot-launch span,
.pilot-launch strong {
  display: block;
}

.judge-launch span,
.pilot-launch span {
  color: #92400e;
  font-size: 12px;
  font-weight: 800;
}

.judge-launch strong,
.pilot-launch strong {
  margin-top: 3px;
  font-size: 15px;
}

.judge-launch .primary,
.pilot-launch .primary {
  width: auto;
  min-width: 148px;
  margin: 0;
  padding: 0 18px;
  background: #92400e;
}

.pilot-launch {
  border-color: #99c9c2;
  border-left-color: #0f766e;
  background: #eef8f6;
}

.pilot-launch span {
  color: #0f766e;
}

.pilot-launch .primary {
  background: #0f766e;
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.case-card {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.case-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.case-number {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.difficulty {
  padding: 4px 7px;
  border-radius: 4px;
  background: #eef6f5;
  color: #0f5f58;
  font-size: 12px;
}

.case-card h2 {
  margin-top: 20px;
  font-size: 19px;
}

.case-card > p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.case-chief {
  margin-top: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.case-tags {
  min-height: 58px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  margin: 14px 0;
}

.case-tags span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
}

.start-case {
  width: 100%;
  margin-top: auto;
}

.case-return {
  width: 100%;
  margin-top: 12px;
}

#app {
  display: grid;
  grid-template-columns: 300px minmax(420px, 1fr) 360px;
  min-height: calc(100vh - 64px);
}

.sidebar,
.workbench {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--line);
  background: #fbfdfd;
}

.workbench {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 2px 10px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 22px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 17px;
  line-height: 1.25;
}

.brand p,
.label,
#case-meta {
  color: var(--muted);
  font-size: 13px;
}

.label {
  margin-bottom: 8px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.compact {
  box-shadow: none;
}

.chief {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--soft);
  color: #0f4f49;
  line-height: 1.45;
}

.stage-list {
  display: grid;
  gap: 8px;
}

.stage {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.stage.active {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--soft);
}

.facts-list,
#missed-list {
  padding-left: 18px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: 74px 1fr;
}

.workspace.judge-mode {
  grid-template-rows: auto 74px 1fr;
}

.workspace.pilot-mode {
  grid-template-rows: auto 74px 1fr;
}

.training-mode-strip {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  border-bottom: 1px solid #f2d39b;
  background: #fffbeb;
}

.mode-strip-title strong,
.mode-strip-title span {
  display: block;
}

.mode-strip-title strong {
  color: #92400e;
  font-size: 14px;
}

.mode-strip-title span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.judge-step-list {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(54px, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.judge-step-list li {
  min-height: 30px;
  display: grid;
  place-items: center;
  padding: 4px 6px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.judge-step-list li.completed {
  border-color: #99c9c2;
  background: var(--soft);
  color: var(--accent);
}

.judge-step-list li.active {
  border-color: #b45309;
  background: #fef3c7;
  color: #92400e;
  font-weight: 800;
}

.training-mode-strip.pilot {
  border-bottom-color: #99c9c2;
  background: #eef8f6;
}

.training-mode-strip.pilot .mode-strip-title strong {
  color: #0f766e;
}

.pilot-mode-details {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.pilot-mode-details span {
  white-space: nowrap;
}

.pilot-mode-details strong,
.pilot-mode-details code {
  margin-left: 4px;
  color: var(--ink);
  font-weight: 800;
}

.pilot-mode-details code {
  padding: 4px 7px;
  border: 1px solid #99c9c2;
  border-radius: 5px;
  background: #fff;
}

.pilot-mode-details button {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 1px solid #99c9c2;
  border-radius: 6px;
  background: #fff;
  color: #0f766e;
  font-size: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.timer {
  text-align: right;
}

.agent-status {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
  text-align: center;
}

.agent-status span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.agent-status strong {
  display: block;
  margin-top: 2px;
  color: var(--accent);
  font-size: 14px;
}

.timer strong {
  display: block;
  font-size: 24px;
  color: var(--accent);
}

.chat-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto;
}

.chat {
  overflow: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.6;
  white-space: pre-wrap;
  box-shadow: 0 4px 16px rgba(15, 35, 42, 0.06);
}

.message.user {
  align-self: flex-end;
  color: #fff;
  background: var(--accent-2);
}

.message.patient {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
}

.message.system {
  align-self: flex-start;
  background: #fefce8;
  border: 1px solid #fde68a;
}

.message.tutor {
  align-self: flex-start;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
}

.message .who {
  display: block;
  margin-bottom: 4px;
  color: inherit;
  opacity: 0.7;
  font-size: 12px;
}

.message-form {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
  padding: 16px 24px 22px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.message-form input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
  background: #fff;
  color: var(--ink);
}

.message-form input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.message-form button,
.primary {
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.control-copy {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.quick-grid button {
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fbfb;
  color: var(--ink);
}

.secondary {
  width: 100%;
  min-height: 42px;
  margin-top: 10px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--soft);
  color: var(--accent);
  font-weight: 700;
}

.judge-next-stage {
  border-color: #b45309;
  background: #fffbeb;
  color: #92400e;
}

.report-action {
  width: auto;
  padding: 0 14px;
  margin-top: 10px;
}

.inline-feedback {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fbfb;
  color: var(--muted);
  line-height: 1.55;
}

.quick-grid button:hover {
  border-color: var(--accent);
  background: var(--soft);
}

.submit-panel {
  display: grid;
  gap: 12px;
}

.submit-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.submit-panel textarea {
  resize: vertical;
  min-height: 48px;
  color: var(--ink);
}

.primary {
  min-height: 44px;
  margin-top: 4px;
}

.small-button {
  width: auto;
  min-height: 38px;
  padding: 0 16px;
  margin-top: 0;
}

.teacher-head-actions {
  display: flex;
  gap: 8px;
}

.teacher-head-actions .secondary {
  margin: 0;
}

.teacher-view {
  min-height: calc(100vh - 64px);
  padding: 24px;
}

.teacher-login {
  max-width: 680px;
  margin: 64px auto;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 18px;
  align-items: start;
}

.login-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
}

.teacher-login h3 {
  font-size: 20px;
}

.teacher-login p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.teacher-login-form {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 10px;
  align-items: end;
  margin-top: 18px;
}

.teacher-login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.teacher-login-form input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.teacher-login-form .primary {
  margin: 0;
}

.form-feedback {
  min-height: 20px;
  color: var(--danger) !important;
  font-size: 13px;
}

.data-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1440px;
  margin: 0 auto 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.data-filter > span {
  margin-right: 4px;
  color: var(--muted);
  font-size: 13px;
}

.data-filter small {
  margin-left: auto;
  color: var(--muted);
}

.case-filter-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  color: var(--muted);
  font-size: 13px;
}

.case-filter-label select {
  min-height: 34px;
  max-width: 240px;
  padding: 0 30px 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.teacher-source-banner {
  max-width: 1440px;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto 16px;
  padding: 12px 14px;
  border-left: 4px solid #b45309;
  background: #fff8eb;
}

.teacher-source-banner.pilot {
  border-left-color: #0f766e;
  background: #eef8f6;
}

.teacher-source-banner.all,
.teacher-source-banner.live {
  border-left-color: #607579;
  background: #f1f5f5;
}

.teacher-source-banner > div:first-child {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.teacher-source-banner strong {
  font-size: 14px;
  line-height: 1.5;
}

.source-status {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid #e7b75e;
  border-radius: 6px;
  color: #92400e;
  font-size: 12px;
  font-weight: 800;
}

.source-status.pilot {
  border-color: #70b8ae;
  color: #0f766e;
}

.source-status.all,
.source-status.live {
  border-color: #aab7ba;
  color: #45565a;
}

.pilot-export-controls,
.pilot-export-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pilot-export-controls label {
  color: var(--muted);
  font-size: 12px;
}

.pilot-export-controls select {
  min-height: 36px;
  max-width: 240px;
  padding: 0 30px 0 9px;
  border: 1px solid #99c9c2;
  border-radius: 6px;
  background: #fff;
}

.export-button {
  width: auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 0 12px;
}

.export-button span {
  font-size: 17px;
  line-height: 1;
}

.case-distribution {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.distribution-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdfd;
}

.distribution-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.distribution-row small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.filter-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.filter-button.active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
  font-weight: 700;
}

.filter-button.demo-filter.active {
  border-color: #c2410c;
  background: #fff7ed;
  color: #9a3412;
}

.filter-button.judge-filter.active {
  border-color: #b45309;
  background: #fef3c7;
  color: #92400e;
}

.filter-button.pilot-filter.active {
  border-color: #047857;
  background: #ecfdf5;
  color: #047857;
}

.architecture-view {
  min-height: calc(100vh - 64px);
  padding: 28px;
  background: #f4f7f8;
}

.project-view {
  min-height: calc(100vh - 64px);
  padding: 28px;
}

.project-head {
  max-width: 1360px;
  margin: 0 auto 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.project-head h2 {
  max-width: 850px;
  font-size: 30px;
  line-height: 1.25;
}

.project-head p {
  max-width: 850px;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.65;
}

.project-version {
  min-width: 170px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-2);
  border-radius: 8px;
  background: #fff;
}

.project-version span,
.project-version small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.project-version strong {
  display: block;
  margin: 4px 0;
  font-size: 20px;
}

.project-band,
.project-section {
  max-width: 1360px;
  margin: 0 auto 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.problem-band {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 24px;
  align-items: start;
  border-left: 4px solid #b45309;
}

.problem-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.problem-grid article {
  padding: 14px;
  border-left: 3px solid #d97706;
  background: #fffbeb;
}

.problem-grid p,
.project-steps p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.project-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.project-steps article {
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
}

.project-steps span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.project-steps strong {
  display: block;
  margin-top: 8px;
}

.project-grid {
  max-width: 1360px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.project-grid .project-section {
  width: 100%;
  margin: 0 0 16px;
}

.project-section ul {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.7;
}

.usage-path {
  display: grid;
  grid-template-columns: repeat(7, auto);
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.usage-path span {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
  text-align: center;
  font-size: 13px;
}

.usage-path b {
  color: var(--accent);
}

.notice-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  border-left: 4px solid var(--accent);
}

.notice-section > p {
  max-width: 650px;
  color: var(--muted);
  line-height: 1.6;
}

.architecture-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto 18px;
}

.architecture-head h2 {
  font-size: 28px;
}

.architecture-head p {
  max-width: 780px;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.runtime-badge {
  min-width: 180px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
}

.runtime-badge span,
.runtime-badge small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.runtime-badge strong {
  display: block;
  margin: 3px 0;
  color: var(--accent);
  font-size: 20px;
}

.architecture-metrics {
  max-width: 1440px;
  margin: 0 auto 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.architecture-metrics article {
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.architecture-metrics span {
  color: var(--muted);
  font-size: 13px;
}

.architecture-metrics strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 24px;
}

.architecture-section {
  max-width: 1440px;
  margin: 0 auto 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h3,
.architecture-section h3 {
  font-size: 18px;
}

.layer-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.layer-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.legend-dot.generation,
.flow-node.generation,
.agent-card.generation,
.boundary-row.generation {
  --layer-color: #2563eb;
  --layer-soft: #eff6ff;
}

.legend-dot.rules,
.flow-node.rules,
.agent-card.rules,
.boundary-row.rules {
  --layer-color: #0f766e;
  --layer-soft: #ecfdf5;
}

.legend-dot.teaching,
.flow-node.teaching,
.agent-card.teaching,
.boundary-row.teaching {
  --layer-color: #a16207;
  --layer-soft: #fffbeb;
}

.legend-dot {
  background: var(--layer-color);
}

.agent-flow {
  display: grid;
  grid-template-columns: 160px 90px 190px 90px minmax(420px, 1fr);
  gap: 12px;
  align-items: center;
}

.flow-person,
.flow-core {
  min-height: 106px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.flow-core {
  border: 2px solid var(--accent);
  background: var(--soft);
}

.flow-person span,
.flow-core span {
  color: var(--muted);
  font-size: 12px;
}

.flow-person strong,
.flow-core strong {
  margin: 5px 0;
}

.flow-person small,
.flow-core small {
  color: var(--muted);
  line-height: 1.4;
}

.flow-arrow {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}

.flow-arrow b {
  display: block;
  margin-top: 5px;
  color: var(--accent);
  font-size: 24px;
}

.flow-arrow.vertical {
  display: none;
}

.flow-branches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.flow-node {
  min-height: 48px;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 1px solid var(--layer-color);
  border-radius: 8px;
  background: var(--layer-soft);
  color: var(--layer-color);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.flow-evaluation {
  grid-column: 5;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.flow-split {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.flow-split span {
  padding: 9px;
  border-radius: 8px;
  background: #f8fbfb;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.agent-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.agent-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--layer-color);
  border-radius: 8px;
  background: #fff;
}

.agent-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.agent-index {
  color: var(--layer-color);
  font-size: 12px;
  font-weight: 800;
}

.agent-role-tag {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--layer-soft);
  color: var(--layer-color);
  font-size: 11px;
  font-weight: 700;
}

.agent-card h4 {
  margin: 12px 0 7px;
  font-size: 16px;
}

.agent-card > p {
  min-height: 66px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.agent-card dl {
  margin: 12px 0;
  display: grid;
  gap: 7px;
}

.agent-card dl div {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 7px;
  font-size: 12px;
  line-height: 1.45;
}

.agent-card dt {
  color: var(--muted);
}

.agent-card dd {
  margin: 0;
}

.safeguard-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.safeguard-list span {
  padding: 4px 6px;
  border-radius: 5px;
  background: var(--layer-soft);
  color: var(--layer-color);
  font-size: 11px;
}

.architecture-grid {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.architecture-grid .architecture-section {
  width: 100%;
  margin: 0;
}

.architecture-list {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.boundary-stack {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.boundary-row {
  padding: 11px 12px;
  border-left: 4px solid var(--layer-color);
  border-radius: 6px;
  background: var(--layer-soft);
}

.boundary-row strong {
  display: block;
  color: var(--layer-color);
  font-size: 13px;
}

.boundary-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.teacher-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.teacher-head h2 {
  font-size: 24px;
}

.teacher-head p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.empty-state {
  color: var(--muted);
  line-height: 1.6;
}

.teacher-dashboard {
  display: grid;
  gap: 16px;
}

.pilot-analytics {
  display: grid;
  gap: 18px;
  padding: 18px 20px;
  border-top: 2px solid #70b8ae;
  border-bottom: 1px solid #b9d7d2;
  background: #eef8f6;
}

.pilot-analytics > header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.pilot-analytics h3 {
  margin-top: 4px;
  font-size: 19px;
}

.pilot-analytics h4 {
  font-size: 15px;
}

.pilot-analytics header small {
  color: var(--muted);
}

.pilot-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.pilot-metric-grid > div {
  min-width: 0;
  padding: 5px 12px 7px;
  border-left: 3px solid #70b8ae;
}

.pilot-metric-grid span,
.pilot-metric-grid strong {
  display: block;
}

.pilot-metric-grid span {
  color: var(--muted);
  font-size: 12px;
}

.pilot-metric-grid strong {
  margin-top: 4px;
  color: #0f766e;
  font-size: 24px;
}

.pilot-evidence-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
}

.pilot-evidence-grid .score-bars {
  margin-top: 10px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: var(--accent);
  font-size: 28px;
}

.teacher-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.teacher-list {
  padding-left: 18px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.record-table {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.record-row {
  display: grid;
  grid-template-columns: 110px 70px 1fr 110px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
  color: var(--muted);
  font-size: 14px;
}

.record-row strong {
  color: var(--ink);
}

.source-badge {
  display: inline-block;
  margin-right: 4px;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 11px;
  font-style: normal;
}

.source-badge.demo {
  background: #fff7ed;
  color: #9a3412;
}

.source-badge.live {
  background: #ecfdf5;
  color: #047857;
}

.source-badge.judge_demo {
  background: #fef3c7;
  color: #92400e;
}

.source-badge.pilot {
  background: #ecfdf5;
  color: #047857;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 70px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 16px;
  border-radius: 8px;
  background: #153e3a;
  color: #fff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}

.toast.error {
  background: #991b1b;
}

.site-footer {
  min-height: 48px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.filing-placeholder {
  color: #879398;
}

dialog {
  width: min(920px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  background: rgba(10, 20, 24, 0.45);
}

.pilot-consent-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.pilot-consent-form {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 24px;
}

.pilot-consent-form h2 {
  margin: 4px 42px 0 0;
  font-size: 23px;
}

.pilot-consent-lead,
.pilot-consent-points {
  color: var(--muted);
  line-height: 1.6;
}

.pilot-consent-lead {
  margin: 8px 0 0;
}

.pilot-consent-points {
  margin: 0;
  padding: 14px 18px 14px 34px;
  border-left: 3px solid #0f766e;
  background: #eef8f6;
}

.pilot-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pilot-consent-form > label,
.pilot-form-grid label,
.survey-comment {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.pilot-consent-form input:not([type="checkbox"]),
.pilot-consent-form select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.pilot-consent-form input:focus,
.pilot-consent-form select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.pilot-consent-check {
  display: grid !important;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 10px !important;
  color: var(--ink) !important;
  line-height: 1.5;
}

.pilot-consent-check input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.pilot-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.pilot-dialog-actions button {
  width: auto;
  min-width: 150px;
  min-height: 42px;
  margin: 0;
  padding: 0 16px;
}

.pilot-dialog-actions button:disabled {
  cursor: not-allowed;
}

.report {
  position: relative;
  padding: 24px;
  display: grid;
  gap: 18px;
}

.pilot-survey {
  padding-top: 18px;
  border-top: 2px solid #99c9c2;
}

.pilot-survey h3 {
  margin: 4px 0 14px;
}

.survey-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.survey-grid fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.survey-grid legend {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.rating-scale {
  display: grid;
  grid-template-columns: repeat(5, minmax(36px, 1fr));
  gap: 5px;
}

.rating-scale label {
  position: relative;
  min-width: 0;
}

.rating-scale input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.rating-scale span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.rating-scale input:checked + span {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
  font-weight: 800;
}

.rating-scale input:focus-visible + span {
  outline: 3px solid rgba(15, 118, 110, 0.2);
  outline-offset: 1px;
}

.rating-scale input:disabled + span {
  cursor: default;
  opacity: 0.7;
}

.survey-comment {
  margin-top: 16px;
}

.report-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.score-badge {
  min-width: 110px;
  padding: 12px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--accent);
  text-align: center;
}

.score-badge strong {
  display: block;
  font-size: 34px;
}

.score-bars {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 52px;
  gap: 10px;
  align-items: center;
  font-size: 14px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e8eef0;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.evidence-chain {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.prescription-list {
  display: grid;
  gap: 10px;
}

.safety-findings {
  display: grid;
  gap: 8px;
}

.safety-finding {
  padding: 12px;
  border-left: 3px solid var(--danger);
  background: #fff7f7;
}

.safety-finding p {
  margin-top: 5px;
  line-height: 1.5;
}

.safety-finding small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.safety-finding.contradiction {
  border-left-color: #b45309;
  background: #fffaf0;
}

.prescription-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.prescription-card strong {
  color: var(--accent);
}

.prescription-card p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.55;
}

.evidence-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
}

.evidence-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.evidence-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 13px;
}

.icon-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #eef2f3;
  color: var(--muted);
  font-size: 24px;
}

@media (max-width: 1050px) {
  .case-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #app {
    grid-template-columns: 1fr;
  }

  .mode-nav,
  .teacher-head,
  .architecture-head,
  .section-heading,
  .project-head,
  .notice-section {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .teacher-grid,
  .architecture-metrics,
  .architecture-grid,
  .agent-card-grid,
  .project-grid,
  .problem-grid,
  .project-steps {
    grid-template-columns: 1fr;
  }

  .problem-band {
    grid-template-columns: 1fr;
  }

  .usage-path {
    grid-template-columns: 1fr;
  }

  .usage-path b {
    text-align: center;
    transform: rotate(90deg);
  }

  .data-filter {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .teacher-source-banner,
  .teacher-source-banner > div:first-child,
  .pilot-analytics > header {
    align-items: flex-start;
    flex-direction: column;
  }

  .pilot-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pilot-evidence-grid {
    grid-template-columns: 1fr;
  }

  .training-mode-strip {
    grid-template-columns: 1fr;
  }

  .pilot-mode-details {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .case-filter-label {
    margin-left: 0;
  }

  .data-filter small {
    width: 100%;
    margin-left: 0;
  }

  .teacher-login-form {
    grid-template-columns: 1fr;
  }

  .agent-flow {
    grid-template-columns: 1fr;
  }

  .flow-arrow b {
    transform: rotate(90deg);
  }

  .flow-evaluation {
    grid-column: auto;
  }

  .agent-card > p {
    min-height: 0;
  }

  .record-row {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .workbench {
    border: 0;
  }

  .workspace {
    min-height: 650px;
  }

  .message {
    max-width: 92%;
  }

  .evidence-chain {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .case-library {
    width: min(100% - 24px, 1180px);
    padding-top: 24px;
  }

  .case-library-head {
    align-items: stretch;
    flex-direction: column;
  }

  .training-entry-grid,
  .pilot-form-grid,
  .survey-grid {
    grid-template-columns: 1fr;
  }

  .judge-launch,
  .pilot-launch {
    align-items: stretch;
    flex-direction: column;
  }

  .judge-launch .primary,
  .pilot-launch .primary {
    width: 100%;
  }

  .training-mode-strip {
    padding: 10px 14px;
  }

  .judge-step-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .case-library-head h1 {
    font-size: 23px;
  }

  .case-grid,
  .case-distribution {
    grid-template-columns: 1fr;
  }

  .mode-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-button {
    padding: 0 8px;
  }

  .teacher-login {
    grid-template-columns: 1fr;
    margin: 24px auto;
  }

  .pilot-export-controls,
  .pilot-export-controls label {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .pilot-export-controls select,
  .export-button {
    width: 100%;
    max-width: none;
  }

  .architecture-view,
  .project-view,
  .teacher-view {
    padding: 16px;
  }

  .pilot-consent-form {
    padding: 18px;
  }

  .pilot-consent-form h2 {
    font-size: 20px;
  }

  .pilot-dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .pilot-dialog-actions button {
    width: 100%;
  }

  .report {
    padding: 18px;
  }

  .rating-scale {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (min-width: 1051px) and (max-width: 1320px) {
  .agent-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
