:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #172333;
  --muted: #66758a;
  --line: #dce4ee;
  --primary: #176b87;
  --primary-dark: #0f526a;
  --accent: #e6f5f7;
  --success: #18794e;
  --warning: #9a6700;
  --danger: #c62828;
  --shadow: 0 12px 32px rgba(23, 45, 70, .09);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: linear-gradient(160deg, #eef8f8 0, var(--bg) 38%, #f8f5ef 100%); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  min-height: 64px; padding: 10px max(18px, calc((100vw - 1080px) / 2));
  color: white; background: rgba(15, 82, 106, .96); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: white; color: var(--primary-dark); font-weight: 800; }
.brand-title { font-weight: 750; line-height: 1.3; }
.brand-subtitle { font-size: 12px; opacity: .82; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 14px; }

.container { width: min(100% - 28px, 1080px); margin: 28px auto 70px; }
.narrow { width: min(100% - 28px, 620px); }
.card { background: var(--surface); border: 1px solid rgba(220, 228, 238, .9); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; }
.hero { padding: 28px; }
.hero h1 { margin: 0 0 12px; font-size: clamp(25px, 5vw, 38px); letter-spacing: -.03em; }
.hero p { color: var(--muted); line-height: 1.8; }
.notice { margin: 16px 0; padding: 14px 16px; border-radius: 12px; background: #f7fafc; border-left: 4px solid var(--primary); line-height: 1.7; color: #34455a; }
.notice.warning { border-color: #d69e2e; background: #fffaf0; }
.notice.timer-warning { border: 2px solid var(--danger); border-left-width: 7px; background: #fff1f1; color: #7f1d1d; font-size: 16px; }
.notice.success { border-color: var(--success); background: #f0fff4; }

.form-grid { display: grid; gap: 16px; }
label { display: grid; gap: 7px; font-weight: 650; }
input, textarea, select {
  width: 100%; padding: 12px 13px; border: 1px solid #c9d4e1; border-radius: 10px; color: var(--text); background: white;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23, 107, 135, .12); }
textarea { resize: vertical; min-height: 120px; line-height: 1.65; }
.check { display: flex; align-items: flex-start; gap: 9px; font-weight: 500; line-height: 1.55; }
.check input { width: 18px; margin-top: 3px; }

.btn { border: 0; border-radius: 10px; padding: 11px 17px; font-weight: 700; color: white; background: var(--primary); }
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { color: var(--primary-dark); background: var(--accent); }
.btn.ghost { color: inherit; background: transparent; border: 1px solid currentColor; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 7px 11px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 7px; min-width: 245px; }
.row-inactive { opacity: .68; background: #f7f8fa; }
.draft-status { margin-top: 18px; font-size: 13px; }
.site-footer {
  width: min(100% - 28px, 1080px); margin: -34px auto 26px; padding: 14px 18px;
  text-align: center; color: var(--muted); font-size: 13px;
}
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--primary-dark); text-decoration: underline; }

.section-head { display: flex; justify-content: space-between; gap: 15px; align-items: end; margin: 28px 0 14px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 5px 0 0; color: var(--muted); }
.progress-line { height: 9px; overflow: hidden; border-radius: 20px; background: #dfe9ef; }
.progress-line span { display: block; height: 100%; background: linear-gradient(90deg, #176b87, #38a3a5); }

.task-list { display: grid; gap: 13px; }
.task-card { display: grid; grid-template-columns: 48px 1fr auto; gap: 15px; align-items: center; padding: 18px; background: white; border: 1px solid var(--line); border-radius: 15px; }
.task-card.locked { opacity: .65; background: #f7f9fb; }
.task-num { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--primary-dark); background: var(--accent); font-weight: 800; }
.task-card h3 { margin: 0 0 5px; font-size: 17px; }
.task-card p { margin: 0; color: var(--muted); font-size: 14px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 700; background: #edf2f7; color: #526274; }
.badge.done { background: #e8f7ef; color: var(--success); }
.badge.active { background: #fff5d9; color: var(--warning); }

.task-view { display: grid; gap: 18px; }
.task-title h1 { margin: 0 0 7px; font-size: clamp(23px, 4vw, 33px); }
.task-title p { margin: 0; color: var(--muted); }
.scenario { padding: 18px; border-radius: 14px; background: #f8fbfd; border: 1px solid var(--line); }
.scenario h3 { margin-top: 0; }
.clean-list { margin: 8px 0; padding-left: 22px; line-height: 1.8; }
.case-block { display: grid; gap: 15px; padding: 20px; border: 1px solid var(--line); border-radius: 15px; }
.case-block h3 { margin: 0; }
.static-stage { border-width: 2px; }
.static-stage.stage-open { border-color: #4d96aa; box-shadow: 0 8px 22px rgba(15, 82, 106, .08); }
.static-stage.stage-locked { background: #f7f9fb; }
.patient-narrative { padding: 16px; border-radius: 12px; background: #fffdf7; border-left: 4px solid #d8aa36; line-height: 1.9; }
.node { padding: 15px; border-left: 3px solid #79aebc; background: #f9fbfc; }
.node strong { display: block; margin-bottom: 7px; }
.prompt { margin: 9px 0; color: var(--primary-dark); font-weight: 650; }
.word-hint { text-align: right; color: var(--muted); font-size: 12px; }

.chat-shell { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #f7fafc; }
.chat-messages { display: grid; gap: 12px; min-height: 360px; max-height: 58vh; overflow-y: auto; padding: 17px; }
.message { max-width: 86%; padding: 11px 14px; border-radius: 15px; line-height: 1.6; white-space: pre-wrap; }
.message.patient { justify-self: start; background: white; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.message.student { justify-self: end; color: white; background: var(--primary); border-bottom-right-radius: 4px; }
.message small { display: block; margin-bottom: 4px; opacity: .65; }
.chat-input { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; padding: 12px; background: white; border-top: 1px solid var(--line); }
.chat-input textarea { min-height: 72px; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 40; transform: translateX(-50%); max-width: min(90vw, 520px); padding: 12px 17px; border-radius: 10px; color: white; background: #243547; box-shadow: var(--shadow); }
.toast.error { background: #a32222; }
.hidden { display: none !important; }
.loading { opacity: .65; pointer-events: none; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.stat { padding: 18px; border-radius: 14px; background: white; border: 1px solid var(--line); }
.stat strong { display: block; font-size: 28px; margin-top: 7px; }
.stat span { color: var(--muted); font-size: 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; background: white; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f6f9fb; color: #43546a; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.tab { padding: 9px 13px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.tab.active { color: white; background: var(--primary); border-color: var(--primary); }
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: start center; padding: 28px 14px; overflow-y: auto; background: rgba(17, 31, 45, .55); }
.modal-panel { width: min(100%, 960px); border-radius: 18px; background: white; box-shadow: var(--shadow); padding: 22px; }
.modal-head { display: flex; justify-content: space-between; gap: 15px; align-items: center; }
.score-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.score-row { display: grid; grid-template-columns: 1fr 90px; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.feedback-report { background: linear-gradient(180deg, #ffffff 0, #f7fbfc 100%); }
.feedback-heading { display: flex; justify-content: space-between; align-items: center; }
.feedback-heading h3 { margin: 9px 0 0; font-size: 23px; }
.feedback-domains { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.feedback-domain { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.feedback-domain > div:first-child { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.feedback-domain span { color: var(--muted); font-weight: 700; }
.feedback-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.feedback-columns > div { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.feedback-columns h4 { margin: 0 0 7px; }
.next-focus { padding: 14px 16px; border-radius: 12px; color: #174c3c; background: #eaf8f1; }
.example-response { padding: 16px; border-radius: 12px; border-left: 4px solid var(--primary); background: #eef7fa; }
.example-response p { margin: 9px 0 0; line-height: 1.8; }
pre.json { white-space: pre-wrap; word-break: break-word; padding: 15px; border-radius: 10px; background: #172333; color: #dce8f2; max-height: 500px; overflow: auto; }

@media (max-width: 760px) {
  .topbar { min-height: 58px; }
  .brand-subtitle, .user-name { display: none; }
  .container { margin-top: 18px; }
  .card, .hero { padding: 17px; }
  .task-card { grid-template-columns: 42px 1fr; }
  .task-card > :last-child { grid-column: 2; justify-self: start; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score-grid { grid-template-columns: 1fr; }
  .feedback-domains, .feedback-columns { grid-template-columns: 1fr; }
  .chat-input { grid-template-columns: 1fr; }
  .chat-input .btn { width: 100%; }
}
.inline-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 390px;
}

.inline-controls select {
  width: 82px;
  flex: 0 0 82px;
}

.inline-controls input {
  min-width: 180px;
}
