* { box-sizing: border-box; }

:root {
  --page: #f4f8ff;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #718096;
  --line: #e1e9f5;
  --blue: #2f7cf6;
  --blue-soft: #edf4ff;
  --green: #0b7054;
  --green-soft: #eafaf3;
  --gold: #9a6500;
  --gold-soft: #fff6d9;
  --red: #c83232;
  --red-soft: #fff0f0;
  --shadow: 0 18px 45px rgba(47, 93, 160, 0.11);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(219, 247, 255, 0.95), transparent 34%),
    linear-gradient(180deg, #f2fbff 0%, #f6f8ff 46%, #f8fbff 100%);
  color: var(--ink);
}

h1, h2, p { margin: 0; }
h1 { font-size: 32px; line-height: 1.18; letter-spacing: 0; }
h2 { font-size: 24px; line-height: 1.25; letter-spacing: 0; }
p { color: var(--muted); line-height: 1.7; }

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px;
}

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

.soft-hero {
  padding: 28px;
  border: 1px solid rgba(199, 218, 242, 0.8);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.soft-card { border-radius: 26px; }
.hidden { display: none !important; }

.env-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #526176;
  font-weight: 800;
}

select, input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid #d8e3f2;
  border-radius: 14px;
  padding: 0 14px;
  font-size: 15px;
  background: #f6f9ff;
  color: var(--ink);
  outline: none;
}

select:focus, input:focus {
  border-color: #9fc3ff;
  box-shadow: 0 0 0 4px rgba(47, 124, 246, 0.12);
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: #4e5a6d;
  font-weight: 800;
}

.login-panel {
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.panel-tabs { flex-wrap: wrap; }

.tab, button {
  border: 1px solid #d9e5f5;
  border-radius: 14px;
  min-height: 40px;
  padding: 0 16px;
  background: #fff;
  color: #26354d;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(47, 93, 160, 0.1);
}

button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.tab.active {
  color: var(--blue);
  border-color: #bcd5ff;
  background: var(--blue-soft);
}

.primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.ghost { background: #f8fbff; }
.pill { border-radius: 999px; }

.danger {
  color: var(--red);
  border-color: #ffd0d0;
  background: var(--red-soft);
}

.mini {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.link {
  min-height: auto;
  height: auto;
  padding: 0;
  border: 0;
  color: var(--blue);
  background: transparent;
  box-shadow: none;
}

.link:hover {
  transform: none;
  box-shadow: none;
}

.message {
  min-height: 28px;
  margin-top: 10px;
  color: #a05a00;
  font-weight: 700;
}

.account-line, .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.header-button-row, .group-actions, .student-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#currentName {
  font-size: 22px;
  line-height: 1.2;
}

#currentRole, #groupSummary {
  margin-left: 10px;
  color: var(--muted);
  font-weight: 700;
}

.teacher-form,
.form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin: 18px 0 6px;
}

.teacher-create-grid {
  grid-template-columns: minmax(220px, 1fr) 180px;
}

.teacher-security-grid {
  grid-template-columns: repeat(3, minmax(160px, 1fr)) 160px;
}

.form-grid.compact {
  grid-template-columns: minmax(180px, 1fr) 180px 140px 140px 160px;
}

.teacher-admin-form {
  grid-template-columns: repeat(4, minmax(150px, 1fr)) 180px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #e7eef8;
  border-radius: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th, td {
  padding: 14px 12px;
  border-bottom: 1px solid #edf2f8;
  text-align: left;
  white-space: nowrap;
}

th {
  color: #657086;
  background: #f6f9ff;
  font-weight: 900;
}

tr:last-child td { border-bottom: 0; }
.actions { min-width: 260px; }

.subtle {
  color: #7d8798;
  font-size: 12px;
  margin-top: 4px;
}

.muted { color: #7d8798; }

.group-list {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.group-card {
  border: 1px solid #dce8f7;
  border-radius: 22px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.group-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}

.group-title strong {
  font-size: 20px;
  line-height: 1.2;
}

.code {
  color: var(--green);
  border-color: #bfead8;
  background: #f1fff8;
  font-weight: 900;
  letter-spacing: 1px;
}

.join-code-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  margin: 8px 0 14px;
  border-radius: 20px;
  background: var(--green-soft);
  color: var(--green);
}

.join-code-card strong {
  font-size: 34px;
  letter-spacing: 2px;
}

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

.student-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid #e4edf9;
  border-radius: 20px;
  background: #fbfdff;
}

.student-card { cursor: pointer; }

.student-card:hover {
  border-color: #b8d4ff;
  background: #f7fbff;
}

.student-avatar {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #fff7cf;
  color: #d68900;
  font-weight: 900;
  box-shadow: inset 0 0 0 2px #fff, 0 8px 18px rgba(214, 137, 0, 0.14);
}

.student-main {
  min-width: 0;
}

.student-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

.student-metrics-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 7px;
  color: #43536c;
  font-weight: 800;
}

.student-metrics-line span {
  min-width: fit-content;
}

.empty {
  padding: 18px;
  color: #7d8798;
  background: #f7faff;
  border: 1px dashed #d5e1f2;
  border-radius: 18px;
}

.code-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.code-pill {
  color: var(--green);
  border-color: #b7ead8;
  background: #effbf6;
}

.service-layout {
  display: grid;
  grid-template-columns: 220px minmax(260px, 1fr);
  gap: 18px;
  align-items: start;
}

.qr-preview {
  width: 220px;
  height: 220px;
  border: 1px dashed #c9d5e7;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7d8798;
  background: #f8fafc;
  overflow: hidden;
}

.qr-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.form-stack {
  display: grid;
  gap: 12px;
  max-width: 520px;
}

.feedback-list { display: grid; gap: 12px; }

.feedback-item {
  border: 1px solid #e0e7f2;
  border-radius: 18px;
  padding: 16px;
  background: #fbfdff;
}

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

.web-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 28px;
}

.web-modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(22, 32, 46, 0.46);
  backdrop-filter: blur(5px);
}

.web-sheet {
  position: relative;
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 56px));
  overflow: auto;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(12, 20, 33, 0.28);
}

.word-sheet { width: min(860px, 100%); }

.web-sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 26px 28px 20px;
  border-bottom: 1px solid #eef2f8;
  background: rgba(255, 255, 255, 0.96);
}

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

.metric-card {
  display: grid;
  gap: 18px;
  min-height: 132px;
  padding: 22px;
  text-align: left;
  border-radius: 20px;
  border: 1px solid #dfe9f6;
  background: #f8fbff;
  color: var(--ink);
}

.metric-card span {
  color: #627086;
  font-size: 17px;
}

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

.metric-card.clickable {
  border-color: #c7dcff;
  background: #f2f7ff;
}

.word-list {
  display: grid;
  gap: 12px;
  padding: 24px 28px 28px;
}

.word-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  border: 1px solid #e6edf7;
  border-radius: 18px;
  background: #fbfdff;
}

.word-list-row strong {
  font-size: 22px;
}

.word-list-row p {
  margin-top: 4px;
  color: #606d80;
}

.word-list-row span {
  display: block;
  margin-top: 4px;
  color: #91a0b4;
}

.word-list-row em {
  color: var(--blue);
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .shell { padding: 16px; }
  .topbar, .account-line, .section-head { flex-direction: column; align-items: stretch; }
  .teacher-form, .form-grid, .form-grid.compact, .teacher-admin-form, .teacher-create-grid, .teacher-security-grid, .service-layout {
    grid-template-columns: 1fr;
  }
  .student-row {
    grid-template-columns: 46px minmax(0, 1fr);
  }
  .student-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }
  .student-actions button { flex: 1; }
  .join-code-card {
    grid-template-columns: 1fr;
  }
  .join-code-card strong {
    font-size: 30px;
  }
  .metric-grid {
    grid-template-columns: 1fr;
    padding: 18px;
  }
  .web-modal { padding: 12px; align-items: end; }
  .web-sheet { max-height: 88vh; border-radius: 24px; }
  .web-sheet-head { padding: 20px; }
  .word-list { padding: 18px; }
  .word-list-row { grid-template-columns: 1fr; }
  .qr-preview { width: 100%; }
}
