:root {
  --bg: #f4f7fb;
  --bg-soft: #eef3f8;
  --panel: #ffffff;
  --panel-alt: #f9fbfd;
  --text: #163047;
  --muted: #64748b;
  --line: #d4deea;
  --line-strong: #b9c9db;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-soft: rgba(37, 99, 235, 0.08);
  --warm: #e35d47;
  --shadow: 0 20px 48px rgba(15, 23, 42, 0.08);
  --radius: 24px;
  --screen-shadow: 0 28px 70px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.12), transparent 28%),
    linear-gradient(180deg, #fbfdff 0%, #eef4fb 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.home-shell {
  display: grid;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(212, 222, 234, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-panel,
.login-panel,
.teacher-login-panel {
  padding: 40px;
}

.hero-panel h1,
.login-panel h1,
.teacher-login-panel h1,
.record-panel h1,
.teacher-header h1 {
  margin: 8px 0 12px;
  font-size: clamp(2rem, 3vw, 3.2rem);
  line-height: 1.08;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.6;
}

.lead.compact {
  font-size: 0.98rem;
}

.eyebrow {
  margin: 0;
  color: var(--brand-strong);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.entry-actions,
.form-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-top: 28px;
}

.record-form .form-meta {
  align-items: flex-end;
}

.primary-button,
.secondary-button,
.group-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button,
.secondary-button {
  min-height: 52px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.24);
}

.secondary-button {
  color: var(--brand-strong);
  background: var(--brand-soft);
  border: 1px solid rgba(37, 99, 235, 0.12);
}

.primary-button:hover,
.secondary-button:hover,
.group-button:hover {
  transform: translateY(-1px);
}

.text-link {
  color: var(--brand-strong);
  font-weight: 800;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.entry-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.entry-card-grid.single-column {
  grid-template-columns: minmax(0, 1fr);
  max-width: 620px;
}

.entry-link-card {
  display: grid;
  gap: 10px;
  min-height: 170px;
  padding: 22px;
  border-radius: 22px;
  border: 1px solid rgba(201, 214, 230, 0.95);
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.entry-link-card h2 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.1;
}

.entry-card-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.home-note {
  margin: 22px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.student-entry-card {
  background: linear-gradient(180deg, #ffffff 0%, #eef5ff 100%);
}

.teacher-entry-card {
  background: linear-gradient(180deg, #ffffff 0%, #f6f8fc 100%);
}

.entry-link-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 42px rgba(15, 23, 42, 0.1);
  border-color: rgba(37, 99, 235, 0.22);
}

.group-button {
  min-height: 92px;
  padding: 18px;
  color: var(--text);
  background: linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
  border: 1px solid rgba(37, 99, 235, 0.18);
  font-size: 1.15rem;
  font-weight: 800;
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.08);
}

.classroom-entry-panel {
  max-width: 880px;
  margin: 0 auto;
}

.teacher-form,
.teacher-inline-form,
.teacher-create-form,
.teacher-create-page-form {
  display: grid;
  gap: 16px;
}

.teacher-form {
  margin-top: 28px;
  max-width: 420px;
}

.date-field,
.teacher-form label,
.teacher-inline-form label,
.teacher-create-form label,
.teacher-create-page-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.date-field input,
.teacher-form input,
.teacher-inline-form input,
.teacher-inline-form select,
.teacher-create-form input,
.teacher-create-form select,
.teacher-create-page-form input,
.teacher-create-page-form select,
.record-table input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: #fff;
  color: var(--text);
  font: inherit;
}

.date-field input,
.teacher-form input,
.teacher-inline-form input,
.teacher-inline-form select,
.teacher-create-form input,
.teacher-create-form select,
.teacher-create-page-form input,
.teacher-create-page-form select {
  min-height: 48px;
  padding: 0 14px;
}

.status-line,
.error-line {
  min-height: 24px;
  margin: 18px 0 0;
  font-weight: 800;
}

.status-line {
  color: var(--brand-strong);
}

.error-line {
  color: #b42318;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.page-header.compact h2 {
  margin: 8px 0 0;
  font-size: 1.7rem;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 22px;
}

.record-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  border-radius: 22px;
  overflow: hidden;
  background: #fbfcff;
}

.record-table th,
.record-table td {
  border: 1px solid rgba(148, 163, 184, 0.32);
  text-align: center;
  padding: 0;
}

.record-table thead th {
  height: 54px;
  background: #edf4ff;
  font-size: 1.04rem;
}

.record-table tbody th {
  width: 120px;
  background: #f8fbff;
  font-size: 1rem;
}

.record-table input {
  min-height: 56px;
  border: none;
  text-align: center;
  font-size: 1.12rem;
  background: transparent;
}

.record-table input:focus {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  background: #ffffff;
}

.chart-panel {
  min-height: 0;
}

.chart-stage {
  width: 100%;
  min-height: 220px;
}

.chart-stage.large {
  min-height: 420px;
}

.chart-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed rgba(148, 163, 184, 0.45);
  border-radius: 18px;
  color: var(--muted);
  font-weight: 800;
  background: linear-gradient(180deg, #f9fbff 0%, #f4f7fc 100%);
}

.teacher-page,
.student-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.teacher-page-expanded {
  place-items: start center;
  padding-bottom: 32px;
}

.teacher-screen,
.student-screen {
  width: min(100vw - 32px, calc((100vh - 32px) * 16 / 9));
  aspect-ratio: 16 / 9;
  border-radius: 28px;
  box-shadow: var(--screen-shadow);
}

.teacher-screen {
  padding: 24px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
}

.teacher-screen-expanded {
  width: min(100vw - 32px, 1500px);
  min-height: calc(100vh - 32px);
  aspect-ratio: auto;
  align-self: start;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.teacher-screen-light {
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.12), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #f6fafe 100%);
  border: 1px solid rgba(201, 214, 230, 0.95);
}

.teacher-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.teacher-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.teacher-summary {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.teacher-toolbar {
  display: grid;
  grid-template-columns: minmax(320px, 520px) auto;
  gap: 12px;
  align-items: end;
}

.teacher-overlay-toggle {
  justify-self: start;
}

.teacher-inline-form,
.teacher-create-form {
  align-items: end;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(201, 214, 230, 0.95);
  border-radius: 20px;
}

.teacher-inline-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.teacher-create-form {
  grid-template-columns: minmax(0, 1.4fr) 120px auto;
}

.teacher-classroom-shell {
  max-width: 1080px;
}

.teacher-classroom-panel {
  padding: 32px;
}

.teacher-create-page-form {
  grid-template-columns: minmax(0, 1.5fr) minmax(160px, 0.75fr) auto;
  gap: 18px;
  align-items: end;
  margin-top: 28px;
}

.teacher-create-page-form label {
  min-height: 112px;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  border: 1px solid rgba(201, 214, 230, 0.95);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.04);
}

.teacher-link-panel {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  background: linear-gradient(180deg, #f9fcff 0%, #f4f8fd 100%);
  border: 1px solid rgba(201, 214, 230, 0.95);
  border-radius: 20px;
}

.teacher-link-panel.standalone {
  margin-top: 28px;
}

.teacher-history-panel {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.teacher-history-list {
  display: grid;
  gap: 14px;
}

.teacher-history-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid rgba(201, 214, 230, 0.95);
}

.teacher-history-card.current {
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.08);
}

.teacher-history-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.teacher-history-card h2 {
  margin: 0;
  font-size: 1.1rem;
}

.teacher-history-summary {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.teacher-history-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.teacher-link-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.success-line {
  margin: 20px 0 0;
  color: #166534;
  font-weight: 800;
}

.helper-line {
  margin: 22px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.entry-link-pill {
  display: inline-flex;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(37, 99, 235, 0.16);
  color: var(--brand-strong);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teacher-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--teacher-grid-columns, 5), minmax(0, 1fr));
  gap: 12px;
}

.teacher-overlay-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
  padding: 18px;
}

.teacher-overlay-panel[hidden] {
  display: none;
}

.teacher-overlay-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.teacher-overlay-header h2 {
  margin: 0;
  font-size: 1.28rem;
}

.teacher-overlay-note,
.teacher-overlay-caption {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.teacher-overlay-summary {
  margin: 0;
  color: var(--brand-strong);
  font-weight: 800;
  white-space: nowrap;
}

.teacher-overlay-meta {
  display: grid;
  gap: 12px;
}

.teacher-overlay-line-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.overlay-line-key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
}

.overlay-line-swatch {
  display: inline-block;
  width: 30px;
  border-top: 4px solid var(--text);
  border-radius: 999px;
}

.overlay-line-swatch.dashed {
  border-top-style: dashed;
}

.teacher-overlay-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.overlay-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(201, 214, 230, 0.95);
  color: var(--text);
  font-weight: 700;
}

.overlay-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
  background: var(--overlay-group-color);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.92),
    0 0 0 4px rgba(37, 99, 235, 0.08);
}

.chart-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  border-radius: 20px;
  padding: 12px;
}

.chart-card-light {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid rgba(201, 214, 230, 0.95);
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
}

.chart-card h2 {
  margin: 0;
  font-size: 1.12rem;
}

.chart-date {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.teacher-grid .chart-stage,
.teacher-grid .chart-empty {
  min-height: 176px;
}

.teacher-overlay-panel .chart-stage.large,
.teacher-overlay-panel .chart-empty {
  min-height: 400px;
}

.record-panel,
.chart-panel {
  padding: 26px;
}

.student-screen {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(246, 250, 255, 0.98) 100%);
  border: 1px solid rgba(201, 214, 230, 0.95);
}

@media (max-width: 1100px) {
  .teacher-page,
  .student-page {
    display: block;
    padding: 12px;
  }

  .teacher-screen,
  .student-screen {
    width: 100%;
    aspect-ratio: auto;
    min-height: calc(100vh - 24px);
  }

  .teacher-toolbar,
  .student-screen {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 900px) {
  .group-grid,
  .teacher-grid,
  .entry-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .teacher-inline-form,
  .teacher-create-form {
    grid-template-columns: 1fr;
  }

  .record-table {
    min-width: 520px;
  }

  .chart-stage.large {
    min-height: 320px;
  }

  .teacher-overlay-header {
    flex-direction: column;
  }

  .teacher-overlay-summary {
    white-space: normal;
  }

  .teacher-history-meta {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 20px 14px 32px;
  }

  .hero-panel,
  .login-panel,
  .teacher-login-panel,
  .record-panel,
  .chart-panel {
    padding: 22px;
  }

  .group-grid,
  .teacher-grid,
  .entry-card-grid {
    grid-template-columns: 1fr;
  }

  .group-button {
    min-height: 76px;
  }
}
