:root {
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --ink: #1C1917;
  --muted: #78716C;
  --line: #E7E5E4;
  --accent: #C45C26;
  --accent-soft: #F3E6DE;
  --ok: #3F6212;
  --danger: #9F1239;
  --radius: 5px;
  --font: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100%;
}

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

a { color: var(--accent); }

#app { min-height: 100vh; }

/* ----- Login ----- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 32px;
}
.login-card .brand {
  font-family: var(--font);
  font-size: 28px;
  letter-spacing: 0.04em;
  margin: 0 0 6px;
}
.login-card .sub {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 13px;
}
.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #FFFEFB;
  outline: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #D6D3D1;
}
.err {
  color: var(--danger);
  font-size: 13px;
  margin: 0 0 12px;
  min-height: 1.2em;
}
.ok-msg {
  color: var(--ok);
  font-size: 13px;
  margin: 8px 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #FFFEFB;
  border-radius: var(--radius);
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { opacity: 0.92; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
}
.btn.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn.accent {
  background: var(--accent);
  border-color: var(--accent);
}
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 12px; }

/* ----- Layout ----- */
.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.sidebar .brand {
  font-family: var(--font);
  font-size: 22px;
  margin: 0 0 4px;
  padding: 0 8px;
}
.sidebar .hint {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 24px;
  padding: 0 8px;
}
.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--ink);
  margin-bottom: 2px;
}
.nav-btn:hover { background: var(--bg); }
.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-btn.logout {
  margin-top: 28px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding-top: 18px;
}

.main {
  padding: 28px 32px 48px;
  max-width: 1100px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-family: var(--font);
  font-size: 26px;
  font-weight: 500;
  margin: 0;
}
.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  background: #FBF9F6;
}
tr:last-child td { border-bottom: none; }
.thumb {
  width: 56px;
  height: 36px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.badge.on {
  background: #ECFCCB;
  border-color: #D9F99D;
  color: var(--ok);
}
.badge.off {
  background: #F5F5F4;
  color: var(--muted);
}
.badge.warn {
  background: #FEF3C7;
  border-color: #FDE68A;
  color: #92400E;
}
.badge.risk {
  background: #FFE4E6;
  border-color: #FECDD3;
  color: var(--danger);
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty p { margin: 0 0 16px; }

/* ----- Modal ----- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  overflow: auto;
  z-index: 50;
}
.modal {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 24px;
}
.modal.wide { max-width: 760px; }
.modal h2 {
  font-family: var(--font);
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 18px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ----- Stat cards ----- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px;
}
.stat-num {
  font-family: var(--font);
  font-size: 24px;
  line-height: 1.2;
}
.stat-num.ok { color: var(--ok); }
.stat-num.warn { color: #92400E; }
.stat-num.risk { color: var(--danger); }
.stat-label {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

/* ----- Card / block ----- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}
.meta-line {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ----- Demo banner ----- */
.demo-banner {
  background: #FEF9C3;
  border: 1px solid #FDE68A;
  color: #854D0E;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ----- Student / class chips ----- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
}
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ----- Timeline (submissions) ----- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.timeline li {
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.timeline li:last-child { border-bottom: none; }

/* ----- Mistake tags ----- */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  margin: 2px 4px 2px 0;
}
.tag.subject { background: var(--accent-soft); border-color: #E7C9B5; color: var(--accent); }

/* ----- Mood bar chart ----- */
.mood-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding: 8px 0;
}
.mood-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.mood-bar {
  width: 60%;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
  min-height: 4px;
}
.mood-bar.low { background: var(--danger); }
.mood-bar.mid { background: #D97706; }
.mood-x {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  white-space: nowrap;
}

/* ----- Chat (AI 备课助手) ----- */
.chat-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  height: 62vh;
  min-height: 420px;
}
.chat-msgs {
  flex: 1;
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.ai {
  align-self: flex-start;
  background: #FBF9F6;
  border: 1px solid var(--line);
  border-bottom-left-radius: 2px;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #FFFEFB;
  border-bottom-right-radius: 2px;
}
.chat-msg .who {
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 4px;
  display: block;
}
.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.chat-input textarea {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  background: #FFFEFB;
}
.chat-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.cursor-blink::after {
  content: '▋';
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

/* ----- 实时课堂（智慧纸笔 · 智笔课堂） ----- */
.live-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.live-card-head h3 { margin: 0 0 4px; }
.live-q {
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.live-q:last-child { border-bottom: none; }
.live-q .qno {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  padding: 0 8px;
}
.as {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
}
.as.submitted.ok { background: #ECFCCB; border-color: #D9F99D; color: var(--ok); }
.as.submitted.wrong { background: #FFE4E6; border-color: #FECDD3; color: var(--danger); }
.as.answering { background: #FEF3C7; border-color: #FDE68A; color: #92400E; }
.as.notstart { opacity: 0.5; }
.live-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.live-bar-label { width: 36px; color: var(--muted); font-size: 13px; }
.live-bar-track {
  flex: 1;
  height: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.live-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.live-bar-fill.on { background: #65A30D; }
.live-bar-fill.warn { background: #D97706; }
.live-bar-fill.risk { background: var(--danger); }
.live-bar-val { width: 96px; font-size: 12px; color: var(--muted); text-align: right; }
.live-select {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  background: #FFFEFB;
}
.stroke-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #FBF9F6;
}
.stroke-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.stroke-svg {
  width: 100%;
  max-width: 480px;
  height: auto;
  background: #FFFEFB;
  border: 1px dashed var(--line);
  border-radius: 4px;
}
.stroke-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 2400;
  stroke-dashoffset: 2400;
  animation: strokeDraw 2.4s ease forwards;
}
@keyframes strokeDraw { to { stroke-dashoffset: 0; } }

.expert-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.expert-grid > .card { flex: 1 1 220px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .nav-row { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav-btn { width: auto; flex: 0 0 auto; }
  .nav-btn.logout { margin-top: 8px; border-top: none; padding-top: 10px; }
  .main { padding: 20px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  table { min-width: 520px; }
  .menu-toggle { display: inline-flex; }
  .sidebar.collapsed .nav-row { display: none; }
}
