:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --soft: #e8efff;
  --soft-green: #e9fbe9;
  --good: #16a34a;
  --warn: #f97316;
  --danger: #dc2626;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #eef4ff, #fff7ed);
  color: var(--ink);
  min-height: 100vh;
}

.app { max-width: 1080px; margin: 0 auto; padding: 24px; }
.shell { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }

header, .panel, .role-card, .notice {
  background: var(--card);
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(31, 41, 55, .08);
}

.hero, .topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 24px;
}

.student-topbar { align-items: stretch; }

.back-link {
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 14px;
  white-space: nowrap;
}

.eyebrow { margin: 0 0 6px; color: var(--primary); font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(28px, 5vw, 44px); }
h2 { margin-top: 0; }
.subtitle, .hint, .teacher-note { color: var(--muted); }

.brand-mark {
  display: grid;
  place-items: center;
  min-width: 92px;
  min-height: 92px;
  border-radius: 28px;
  background: var(--soft);
  color: var(--primary);
  font-size: 36px;
  font-weight: 900;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin: 18px 0;
}

.role-card {
  color: inherit;
  text-decoration: none;
  padding: 28px;
  border: 1px solid transparent;
  transition: .18s ease;
}

.role-card:hover { transform: translateY(-3px); border-color: #bfdbfe; }
.role-icon { font-size: 42px; }
.role-card strong { color: var(--primary); }
.notice { padding: 20px 24px; }
.notice li { margin: 8px 0; }

.teacher-layout, .student-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr);
  gap: 18px;
  margin-top: 18px;
}

.student-layout { grid-template-columns: minmax(280px, .75fr) minmax(0, 1.25fr); }

.panel { padding: 24px; }
.panel.active { display: block; }

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

label { display: grid; gap: 7px; font-weight: 700; }
.block-label { margin-top: 16px; }
.block-label .hint { font-weight: 400; }

textarea, input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 13px 15px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
}

textarea { min-height: 170px; line-height: 1.6; resize: vertical; }
.small-textarea { min-height: 90px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 0; }

button, .button-link {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover, .button-link:hover { transform: translateY(-1px); }
.primary { background: var(--primary); color: white; border-color: var(--primary); }
.primary:hover { background: var(--primary-dark); }
.danger-light { color: var(--danger); }
.disabled { opacity: .45; pointer-events: none; }

.share-panel { align-self: start; }
.qr-box {
  border: 1px dashed #bfdbfe;
  background: #fbfdff;
  border-radius: 20px;
  min-height: 280px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
}
.qr-box img { width: 220px; height: 220px; }
.qr-box p { margin: 10px 0 0; color: var(--muted); }
.muted-box { color: var(--muted); }
.link-box { margin-top: 16px; display: grid; gap: 8px; }
.teacher-note { margin-top: 16px; line-height: 1.6; }

.score-card {
  min-width: 110px;
  text-align: center;
  background: var(--soft);
  border-radius: 20px;
  padding: 16px;
}
.score-card span { display: block; color: var(--muted); font-size: 14px; }
.score-card strong { display: block; color: var(--primary); font-size: 44px; }

.task-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.pill { background: var(--soft); color: var(--primary-dark); border-radius: 999px; padding: 7px 12px; font-weight: 700; }
ul { margin: 8px 0 0; padding-left: 22px; }
li { margin: 8px 0; }

.chat {
  height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  background: #fcfcfd;
  margin-bottom: 16px;
}
.message { max-width: 82%; padding: 12px 14px; margin: 10px 0; border-radius: 18px; line-height: 1.45; }
.ai { background: var(--soft); }
.student { background: #dcfce7; margin-left: auto; }
.feedback { background: #fff7ed; color: #9a3412; }
.student-input { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; }
.report {
  white-space: pre-line;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 18px;
  padding: 18px;
  font-size: 17px;
  line-height: 1.7;
  margin-top: 16px;
}
.results-panel { margin-top: 18px; }
.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.compact-actions { margin-top: 0; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 18px 0;
}
.stat-card {
  background: #fbfdff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
}
.stat-card span { display: block; color: var(--muted); font-size: 14px; }
.stat-card strong { display: block; margin-top: 6px; color: var(--primary); font-size: 28px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 18px; }
.results-table { width: 100%; border-collapse: collapse; min-width: 850px; background: #fff; }
.results-table th, .results-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.results-table th { background: #f8fafc; color: var(--muted); font-size: 14px; }
.empty-cell { text-align: center !important; color: var(--muted); padding: 28px !important; }
.submit-box {
  margin-top: 16px;
  background: #fbfdff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
}
.submit-box h3 { margin: 0 0 8px; }
.submit-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; }
.classroom-tips {
  margin-top: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: 16px;
  padding: 12px 14px;
  line-height: 1.6;
}
.classroom-tips ol { margin: 6px 0 0; }
.submit-status { color: var(--good); font-weight: 700; min-height: 24px; }
.hidden { display: none; }

@media (max-width: 820px) {
  .app { padding: 14px; }
  .hero, .topbar { flex-direction: column; align-items: stretch; }
  .home-grid, .teacher-layout, .student-layout, .form-grid, .stats-grid, .submit-row { grid-template-columns: 1fr; }
  .student-input { grid-template-columns: 1fr; }
  .message { max-width: 100%; }
  .shell { justify-content: flex-start; }
}

.voice-practice {
  display: grid;
  gap: 14px;
  justify-items: center;
  margin: 16px 0;
}
.record-web-btn {
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 900;
  font-size: 20px;
  box-shadow: 0 18px 40px rgba(37, 99, 235, .24);
}
.record-web-btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 18px 40px rgba(220, 38, 38, .24);
}
.fallback-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
