:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f5f8fb;
  --ink: #17202a;
  --muted: #5d6b7a;
  --line: #d6dee8;
  --line-strong: #aebbc9;
  --accent: #0b6b62;
  --accent-2: #c2473a;
  --accent-3: #355f9f;
  --accent-4: #9a6b09;
  --role-source: #355f9f;
  --role-normalized: #0b6b62;
  --role-derived: #6366a8;
  --role-property: #8a5f0a;
  --role-state: #7c4f9b;
  --role-maintenance: #3f7d51;
  --role-algorithm: #b24b35;
  --role-target: #1b7a86;
  --role-proof: #af3e5d;
  --known: #0b6b62;
  --felt: #54758d;
  --stuck: #c2473a;
  --gain: #9a6b09;
  --shadow: 0 18px 46px rgba(28, 43, 61, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(53, 95, 159, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(11, 107, 98, 0.045) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
}

body.modal-open {
  overflow: hidden;
}

button,
select,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
}

textarea {
  resize: vertical;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #17211f;
  color: #eef6f1;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f3d36b;
  color: #16211f;
  font-weight: 800;
}

.brand-title {
  font-weight: 800;
}

.brand-subtitle {
  margin-top: 2px;
  color: #a9b8b2;
  font-size: 12px;
}

.side-block {
  display: grid;
  gap: 8px;
  margin-bottom: 26px;
}

.side-block.compact {
  gap: 10px;
}

.side-label {
  color: #a9b8b2;
  font-size: 12px;
  letter-spacing: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 10px;
  color: #dce9e4;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.08);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: #17211f;
  background: #f3d36b;
  font-size: 12px;
  font-weight: 800;
}

.select {
  min-height: 38px;
  width: 100%;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sidebar .select {
  color: #eef6f1;
  background: #23302d;
  border-color: rgba(255, 255, 255, 0.12);
}

.file-drop {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 12px;
  color: #eef6f1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px dashed rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  cursor: pointer;
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-drop-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #f3d36b;
  color: #17211f;
  font-size: 22px;
  line-height: 1;
}

.side-note {
  margin: 0;
  color: #a9b8b2;
  font-size: 12px;
  line-height: 1.6;
}

.api-status,
.sidebar-action {
  min-height: 36px;
  padding: 0 10px;
  color: #17211f;
  background: #f3d36b;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.35;
}

.sidebar-action {
  cursor: pointer;
  font-weight: 800;
}

.sidebar-action:disabled {
  cursor: progress;
  opacity: 0.72;
}

.api-status {
  color: #eaf4f1;
  background: rgba(11, 107, 98, 0.28);
  border: 1px solid rgba(234, 244, 241, 0.14);
  font-size: 13px;
  font-weight: 800;
}

.api-status.is-offline {
  color: #17211f;
  background: #f3d36b;
}

.admin-shell {
  min-height: 100vh;
  padding: 24px;
}

.admin-login {
  display: grid;
  gap: 18px;
  width: min(460px, calc(100vw - 32px));
  margin: 12vh auto 0;
}

.admin-login-form {
  display: grid;
  gap: 10px;
}

.admin-login-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-input {
  min-height: 38px;
  width: 100%;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-input:focus {
  outline: 2px solid rgba(11, 107, 98, 0.22);
  outline-offset: 1px;
}

.admin-error {
  padding: 10px 12px;
  color: #9f2d23;
  background: #fff1ee;
  border: 1px solid #e7b7af;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.admin-app {
  display: grid;
  gap: 16px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-actions .admin-input {
  width: min(320px, 36vw);
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.admin-student-manager {
  display: grid;
  gap: 12px;
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.student-create-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 8px;
}

.admin-student-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}

.admin-student-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  background: #fbfcff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-student-chip div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.admin-student-chip strong,
.admin-student-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-student-chip span {
  color: var(--muted);
  font-size: 12px;
}

.admin-metric {
  min-height: 88px;
}

.admin-problem-list {
  display: grid;
  gap: 14px;
}

.admin-problem-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: rgba(255, 254, 250, 0.94);
  border: 1px solid var(--line);
  border-left: 6px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.admin-problem-card.has-public-issue {
  border-left-color: var(--stuck);
}

.admin-problem-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.admin-problem-index {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-issue-badge {
  flex: 0 0 auto;
  padding: 5px 9px;
  color: #9f2d23;
  background: #fff1ee;
  border: 1px solid #e7b7af;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.admin-problem-card:not(.has-public-issue) .admin-issue-badge {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--line);
}

.admin-problem-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.admin-problem-metrics div {
  display: grid;
  gap: 3px;
  padding: 10px;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-problem-metrics strong {
  font-size: 20px;
}

.admin-problem-metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-issues {
  display: grid;
  gap: 10px;
}

.admin-issue {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #fbfcf9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-issue.public {
  background: #fff6f4;
  border-color: #e7b7af;
}

.admin-issue-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.admin-issue-top strong {
  color: var(--ink);
}

.admin-issue-top span {
  flex: 0 0 auto;
  color: var(--stuck);
  font-size: 12px;
  font-weight: 900;
}

.admin-issue p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.admin-issue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-issue-meta span {
  padding: 3px 7px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
}

.admin-note-list {
  display: grid;
  gap: 6px;
}

.admin-note-list p {
  padding: 7px 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(115, 128, 138, 0.18);
  border-radius: 7px;
}

.admin-note-list b {
  margin-right: 6px;
  color: var(--accent-3);
}

.admin-students {
  display: grid;
  gap: 6px;
  overflow: auto;
}

.admin-student-row {
  display: grid;
  grid-template-columns: 140px 78px 78px 58px 58px minmax(180px, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 760px;
  padding: 8px 10px;
  background: #fbfcff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.admin-student-row.header {
  color: var(--ink);
  background: #edf2f7;
  font-weight: 900;
}

.admin-student-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -22px -22px 16px;
  padding: 16px 22px 14px;
  background: rgba(238, 242, 246, 0.92);
  border-bottom: 1px solid rgba(174, 187, 201, 0.72);
  box-shadow: 0 12px 28px rgba(28, 43, 61, 0.08);
  backdrop-filter: blur(14px);
}

.eyebrow,
.panel-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

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

h1 {
  margin-top: 4px;
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  margin-top: 4px;
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  font-size: 15px;
  line-height: 1.35;
}

.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-actions .select {
  width: min(360px, 34vw);
}

.icon-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.icon-button {
  width: 38px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}

.icon-button:hover,
.secondary-button:hover {
  border-color: var(--line-strong);
}

.primary-button {
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  background: #075b53;
}

.primary-button.is-complete {
  background: #235d8f;
}

.primary-button.is-complete:hover {
  background: #1d4e79;
}

.secondary-button {
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}

.danger-button {
  color: #9f2d23;
  border-color: #e7b7af;
}

.button-icon {
  font-weight: 800;
}

.save-state {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 9px;
  color: var(--muted);
  background: rgba(255, 254, 250, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.save-state.is-dirty {
  color: #7a4d09;
  background: #fff7df;
  border-color: #ebd28d;
}

.save-state.is-saving {
  color: #315a72;
  background: #edf6fb;
  border-color: #c6ddeb;
}

.save-state.is-error {
  color: #9f2d23;
  background: #fff1ee;
  border-color: #e7b7af;
}

.flow-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.flow-step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  color: var(--muted);
  background: rgba(255, 254, 250, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.flow-step span {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  color: #fff;
  background: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.flow-step strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.flow-step.active,
.flow-step:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
}

.flow-step.active span {
  background: var(--accent);
}

.problem-dock {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  background: rgba(255, 254, 250, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.problem-dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.problem-list {
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.problem-session-group {
  display: grid;
  gap: 8px;
}

.problem-session-title {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  color: var(--ink);
  background: rgba(255, 254, 250, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(23, 33, 31, 0.05);
}

.problem-session-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 900;
}

.problem-session-title span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.problem-session-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.problem-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 11px;
  color: var(--ink);
  background: #fbfcf9;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.problem-card:hover,
.problem-card.active {
  border-color: var(--accent);
  border-left-color: var(--accent);
  box-shadow: 0 8px 20px rgba(23, 33, 31, 0.09);
}

.problem-card.completed {
  border-left-color: var(--known);
  background: #f2faf7;
}

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

.problem-index {
  min-width: 0;
  color: var(--accent-3);
  font-size: 12px;
  font-weight: 900;
}

.problem-state {
  flex: 0 0 auto;
  padding: 2px 7px;
  color: var(--muted);
  background: #edf2f7;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.problem-card.completed .problem-state {
  color: #0b5e56;
  background: #dff3ed;
}

.problem-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
  line-height: 1.25;
}

.problem-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.problem-meta span {
  max-width: 100%;
  padding: 3px 6px;
  color: var(--muted);
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.25;
}

.problem-progress {
  display: grid;
  gap: 5px;
}

.problem-progress-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.progress-bar {
  overflow: hidden;
  height: 6px;
  background: #e5ebf0;
  border-radius: 999px;
}

.progress-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 18px;
  background: rgba(255, 254, 250, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.material-panel {
  grid-column: 1 / -1;
}

.solution-panel {
  grid-column: 1 / -1;
}

.dag-panel,
.analysis-panel,
.trend-panel {
  grid-column: 1 / -1;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.ok {
  color: #0b5e56;
  background: #e7f5f1;
  border-color: #b8ded5;
}

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

.material-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.material-column {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.material-title,
.coach-note label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.material-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
}

.material-copy-button {
  width: 30px;
  min-height: 30px;
  font-size: 13px;
}

.std-top-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.std-top-button:disabled,
.material-copy-button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.coach-note textarea,
.note-input {
  width: 100%;
  min-height: 170px;
  padding: 12px;
  color: var(--ink);
  background: #fbfcf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.55;
}

.coach-note textarea:focus,
.note-input:focus,
.select:focus {
  outline: 2px solid rgba(11, 107, 98, 0.22);
  outline-offset: 1px;
}

.material-document {
  min-height: 260px;
  max-height: 430px;
  overflow: auto;
  padding: 16px;
  color: var(--ink);
  background: #fbfcff;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.72;
}

.material-document h3,
.material-document h4,
.material-document h5 {
  margin: 14px 0 8px;
  color: var(--ink);
  line-height: 1.35;
}

.material-document h3:first-child,
.material-document h4:first-child,
.material-document h5:first-child {
  margin-top: 0;
}

.material-document h3 {
  font-size: 17px;
}

.material-document h4,
.material-document h5 {
  font-size: 15px;
}

.material-document p {
  margin: 0 0 10px;
  color: #263342;
  font-size: 14px;
}

.material-document strong {
  color: var(--ink);
}

.material-document code {
  padding: 1px 5px;
  color: #1d4f72;
  background: #eef5fb;
  border: 1px solid #d6e4ef;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.material-document .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
}

.material-document ul,
.material-document ol {
  margin: 0 0 12px 1.25em;
  padding: 0;
}

.material-document li {
  margin: 4px 0;
  color: #263342;
  font-size: 14px;
  line-height: 1.7;
}

.material-document pre {
  overflow: auto;
  margin: 0 0 12px;
  padding: 12px;
  color: #dce8f4;
  background: #182331;
  border-radius: 8px;
  line-height: 1.55;
}

.material-document pre code {
  display: block;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
}

.doc-bullet {
  position: relative;
  padding-left: 18px;
}

.doc-bullet::before {
  position: absolute;
  left: 2px;
  color: var(--accent);
  content: "•";
  font-weight: 800;
}

.doc-bullet.ordered::before {
  content: "·";
}

.empty-doc {
  color: var(--muted);
}

.solution-reader {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.solution-section {
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 14px;
  background: #fbfcf9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.solution-section h3 {
  color: var(--accent);
}

.solution-section p,
.solution-section li {
  color: var(--muted);
  line-height: 1.72;
}

.solution-section ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

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

.dag-panel .panel-header {
  align-items: flex-start;
  flex-wrap: wrap;
}

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

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

.legend-swatch {
  width: 24px;
  height: 14px;
  border-radius: 5px;
}

.node-swatch {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 5px solid var(--accent-3);
}

.relation-swatch {
  background: #fff4cf;
  border: 2px dashed #a27612;
}

.main-swatch {
  background: #e7f5f1;
  border: 2px solid var(--accent);
}

.status-known {
  background: var(--known);
}

.status-stuck {
  background: var(--stuck);
}

.status-gain {
  background: var(--gain);
}

.structure-overview {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.structure-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 14px;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.structure-kicker {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.structure-hero p,
.structure-panel p {
  color: var(--ink);
  line-height: 1.66;
}

.structure-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  gap: 8px;
}

.metric-card {
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 76px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card strong {
  font-size: 26px;
  line-height: 1;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.structure-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  align-items: start;
}

.structure-panel {
  min-width: 0;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.structure-panel h3 {
  margin-bottom: 8px;
}

.main-path-panel p {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.role-cloud,
.feature-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.role-count,
.feature-cloud span,
.empty-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 26px;
  padding: 4px 8px;
  color: var(--muted);
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.35;
}

.role-count strong {
  color: var(--ink);
}

.dag-canvas {
  position: relative;
  min-height: 620px;
  overflow: auto;
  padding-bottom: 14px;
  background:
    linear-gradient(90deg, rgba(30, 47, 67, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(30, 47, 67, 0.045) 1px, transparent 1px),
    #f8fafc;
  background-size: 28px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dag-stage {
  position: absolute;
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  align-content: start;
  gap: 7px;
  width: 320px;
  min-height: 236px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 5px solid var(--muted);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(23, 33, 31, 0.11);
}

.dag-state-node {
  background: var(--surface);
}

.dag-relation-node {
  align-content: start;
  grid-template-rows: auto auto auto auto;
  min-height: 210px;
  background: #fff8e8;
  border: 2px dashed rgba(154, 107, 9, 0.68);
  border-left: 2px dashed rgba(154, 107, 9, 0.68);
  box-shadow: 0 8px 22px rgba(154, 107, 9, 0.13);
}

.dag-relation-node::before {
  position: absolute;
  left: calc(50% - 14px);
  top: -16px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #fff;
  background: var(--accent-4);
  border: 2px solid #fff8e8;
  border-radius: 50%;
  content: "转";
  font-size: 12px;
  font-weight: 800;
}

.dag-stage[data-status="known"] {
  border-left-color: var(--known);
}

.dag-stage[data-status="felt"] {
  border-left-color: var(--felt);
}

.dag-stage[data-status="stuck"] {
  border-left-color: var(--stuck);
}

.dag-stage[data-status="gain"] {
  border-left-color: var(--gain);
}

.dag-relation-node[data-status="known"] {
  background: #e9f7f3;
  border-color: var(--known);
}

.dag-relation-node[data-status="felt"] {
  background: #edf4f8;
  border-color: var(--felt);
}

.dag-relation-node[data-status="stuck"] {
  background: #fff1ee;
  border-color: var(--stuck);
}

.dag-relation-node[data-status="gain"] {
  background: #fff7dc;
  border-color: var(--gain);
}

.dag-state-node.on-main-path {
  box-shadow: 0 0 0 2px rgba(11, 107, 98, 0.18), 0 10px 26px rgba(23, 33, 31, 0.11);
}

.dag-relation-node.on-main-path {
  background: #eaf7f4;
  border-color: rgba(11, 107, 98, 0.7);
}

.dag-stage-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.node-id,
.role-pill {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  padding: 3px 7px;
  background: #edf2f7;
  border-radius: 6px;
}

.role-pill {
  color: #fff;
  background: var(--muted);
}

.role-count.role-source_problem,
.role-source_problem .role-pill {
  background: var(--role-source);
  border-left-color: var(--role-source);
}

.dag-state-node.role-source_problem {
  border-left-color: var(--role-source);
}

.role-count.role-normalized_problem,
.role-normalized_problem .role-pill {
  background: var(--role-normalized);
  border-left-color: var(--role-normalized);
}

.dag-state-node.role-normalized_problem {
  border-left-color: var(--role-normalized);
}

.role-count.role-derived_problem,
.role-derived_problem .role-pill {
  background: var(--role-derived);
  border-left-color: var(--role-derived);
}

.dag-state-node.role-derived_problem {
  border-left-color: var(--role-derived);
}

.role-count.role-property_view,
.role-property_view .role-pill {
  background: var(--role-property);
  border-left-color: var(--role-property);
}

.dag-state-node.role-property_view {
  border-left-color: var(--role-property);
}

.role-count.role-state_model,
.role-state_model .role-pill {
  background: var(--role-state);
  border-left-color: var(--role-state);
}

.dag-state-node.role-state_model {
  border-left-color: var(--role-state);
}

.role-count.role-maintenance_model,
.role-maintenance_model .role-pill {
  background: var(--role-maintenance);
  border-left-color: var(--role-maintenance);
}

.dag-state-node.role-maintenance_model {
  border-left-color: var(--role-maintenance);
}

.role-count.role-auxiliary_subproblem,
.role-auxiliary_subproblem .role-pill {
  background: #64748b;
  border-left-color: #64748b;
}

.dag-state-node.role-auxiliary_subproblem {
  border-left-color: #64748b;
}

.role-count.role-algorithmic_subproblem,
.role-algorithmic_subproblem .role-pill {
  background: var(--role-algorithm);
  border-left-color: var(--role-algorithm);
}

.dag-state-node.role-algorithmic_subproblem {
  border-left-color: var(--role-algorithm);
}

.role-count.role-target_problem,
.role-target_problem .role-pill {
  background: var(--role-target);
  border-left-color: var(--role-target);
}

.dag-state-node.role-target_problem {
  border-left-color: var(--role-target);
}

.role-count.role-proof_obligation,
.role-proof_obligation .role-pill {
  background: var(--role-proof);
  border-left-color: var(--role-proof);
}

.dag-state-node.role-proof_obligation {
  border-left-color: var(--role-proof);
}

.role-count.role-source_problem,
.role-count.role-normalized_problem,
.role-count.role-derived_problem,
.role-count.role-property_view,
.role-count.role-state_model,
.role-count.role-maintenance_model,
.role-count.role-auxiliary_subproblem,
.role-count.role-algorithmic_subproblem,
.role-count.role-target_problem,
.role-count.role-proof_obligation {
  color: #fff;
  border-color: transparent;
}

.dag-card-title {
  overflow-wrap: anywhere;
  white-space: normal;
  font-size: 15px;
  text-align: center;
}

.dag-stage p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  text-align: left;
}

.dag-relation-node .dag-stage-title {
  color: #6d4c0d;
  font-size: 12px;
}

.dag-relation-node p {
  color: #6a5a32;
}

.dag-card-io {
  display: grid;
  gap: 5px;
  text-align: left;
}

.dag-card-io span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.dag-card-io b {
  margin-right: 5px;
  color: var(--ink);
}

.dag-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-self: end;
  text-align: left;
}

.dag-card-foot span {
  padding: 2px 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(115, 128, 138, 0.22);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.dag-svg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.dag-edge {
  fill: none;
  stroke: #73808a;
  stroke-width: 2.1;
}

.dag-edge.side-path {
  stroke-dasharray: 7 6;
}

.dag-edge.main-path {
  stroke: var(--accent);
  stroke-width: 3;
}

.dag-edge.stuck {
  stroke: var(--stuck);
  stroke-width: 3;
}

.dag-edge.gain {
  stroke: var(--gain);
  stroke-width: 3;
}

.dag-annotation {
  display: grid;
  gap: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(115, 128, 138, 0.22);
  text-align: left;
}

.dag-status-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
}

.dag-status-select {
  min-height: 32px;
  padding: 0 9px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12px;
}

.dag-critical {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.dag-note {
  width: 100%;
  min-height: 58px;
  padding: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
}

.dag-note:focus,
.dag-status-select:focus {
  outline: 2px solid rgba(11, 107, 98, 0.22);
  outline-offset: 1px;
}

.dag-overall-note {
  max-width: 720px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(13, 22, 30, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.std-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1120px, calc(100vw - 48px));
  max-height: calc(100vh - 64px);
  padding: 18px;
  background: rgba(255, 254, 250, 0.98);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(9, 17, 28, 0.28);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.std-popup-document {
  min-height: min(620px, calc(100vh - 180px));
  max-height: none;
}

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

.reflection-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  padding: 14px;
  background: #fbfcf9;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent-3);
  border-radius: 8px;
}

.reflection-item.is-relation {
  margin-left: 28px;
  background: #fffaf0;
  border-left-color: var(--accent-4);
}

.reflection-item.is-relation .reflection-type {
  background: var(--accent-4);
}

.reflection-item.is-state .reflection-type {
  background: var(--accent-3);
}

.reflection-item.is-relation .reflection-summary {
  color: #69572d;
}

.reflection-item.flash {
  border-color: var(--accent-4);
  box-shadow: 0 0 0 3px rgba(138, 106, 18, 0.18);
}

.reflection-main {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
}

.reflection-type {
  width: fit-content;
  padding: 3px 7px;
  color: #fff;
  background: var(--accent-3);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
}

.reflection-summary,
.proof-need {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.proof-need {
  color: #7c4e10;
}

.reflection-meta {
  display: grid;
  gap: 6px;
  margin-top: 2px;
}

.meta-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 8px;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.meta-row span {
  color: var(--accent-3);
  font-size: 12px;
  font-weight: 800;
}

.meta-row p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.reflection-controls {
  display: grid;
  gap: 8px;
}

.status-select {
  min-height: 34px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.note-input {
  min-height: 82px;
}

.coach-note {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.coach-note textarea {
  min-height: 96px;
}

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

.analysis-block {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: #fbfcf9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.analysis-block strong {
  color: var(--accent);
}

.analysis-block ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.analysis-block li,
.analysis-block p {
  color: var(--muted);
  line-height: 1.62;
}

.trend-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.trend-chart {
  min-height: 210px;
  padding: 12px;
  background: #fbfcf9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.trend-svg {
  width: 100%;
  min-height: 190px;
}

.trend-axis {
  stroke: #aab4af;
  stroke-width: 1;
}

.trend-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
}

.trend-point {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 3;
}

.trend-bar {
  fill: rgba(182, 63, 47, 0.22);
}

.trend-insights {
  display: grid;
  gap: 10px;
}

.trend-insight {
  padding: 13px;
  background: #fbfcf9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.trend-insight strong {
  color: var(--accent-3);
}

.trend-insight p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    height: auto;
  }

  .brand {
    margin-bottom: 0;
  }

  .side-block {
    margin-bottom: 0;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .analysis-output,
  .trend-body {
    grid-template-columns: 1fr;
  }

  .structure-hero {
    grid-template-columns: 1fr;
  }

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

  .admin-summary,
  .admin-problem-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .student-create-form {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-actions .admin-input {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 14px;
  }

  .sidebar {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .topbar,
  .panel-header,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    margin: -14px -14px 14px;
    padding: 12px 14px;
  }

  .top-actions .select {
    width: 100%;
  }

  .save-state,
  .top-actions .primary-button,
  .top-actions .secondary-button {
    width: 100%;
  }

  .flow-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .problem-dock-header {
    align-items: stretch;
    flex-direction: column;
  }

  .problem-list {
    max-height: 420px;
  }

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

  .admin-shell {
    padding: 14px;
  }

  .admin-actions,
  .admin-problem-head {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-actions .primary-button,
  .admin-actions .secondary-button {
    width: 100%;
  }

  .admin-summary,
  .admin-problem-metrics {
    grid-template-columns: 1fr;
  }

  .material-layout {
    grid-template-columns: 1fr;
  }

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

  .structure-panels {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 62px;
  }

  .metric-card strong {
    font-size: 22px;
  }

  .reflection-item {
    grid-template-columns: 1fr;
  }

  .reflection-item.is-relation {
    margin-left: 0;
  }

  .panel {
    padding: 14px;
  }

  h1 {
    font-size: 26px;
  }
}
