/* Hallmark · macrostructure: app-shell (rail + workspace) · theme: Dojo-paper · no avatars
 * 设计约束：不用任何头像/吉祥物；身份一律 monogram（.mark）。
 * 每个交互元素都写了 default / hover / focus-visible / active / disabled / loading / error / success 状态。
 */

/* ── 1. 基础 ─────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img,
svg,
video {
  max-width: 100%;
  display: block;
}

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

:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--r-xs);
}

a {
  color: var(--accent-2);
  text-underline-offset: 3px;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.15;
  overflow-wrap: anywhere;
  min-width: 0;
}

p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--sp-3);
  top: -100px;
  z-index: 60;
  padding: var(--sp-2) var(--sp-4);
  background: var(--ink);
  color: var(--ink-invert);
  border-radius: var(--r-full);
  transition: top var(--dur) var(--ease-out);
}

.skip-link:focus-visible {
  top: var(--sp-3);
}

/* ── 2. 通用组件 ─────────────────────────────────────────────────────── */

.btn {
  --btn-bg: var(--paper-2);
  --btn-ink: var(--ink);
  --btn-bd: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-4);
  border: var(--bd) solid var(--btn-bd);
  border-radius: var(--r-full);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sticker-sm);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--btn-bd);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--btn-bd);
}

.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-sticker-sm);
}

.btn--primary {
  --btn-bg: var(--accent);
  --btn-ink: var(--accent-ink);
  --btn-bd: var(--ink);
}

.btn--primary:hover {
  background: var(--accent-2);
}

.btn--pos {
  --btn-bg: var(--pos);
  --btn-ink: var(--ink);
}

.btn--neg {
  --btn-bg: var(--neg);
  --btn-ink: var(--ink-invert);
}

.btn--ghost {
  --btn-bg: transparent;
  --btn-bd: transparent;
  box-shadow: none;
  min-height: 40px;
  padding: 0 var(--sp-3);
}

.btn--ghost:hover {
  --btn-bg: var(--paper-3);
  box-shadow: none;
  transform: none;
}

.btn--ghost:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn--sm {
  min-height: 36px;
  padding: 0 var(--sp-3);
  font-size: var(--text-sm);
}

.btn--icon {
  width: 44px;
  min-width: 44px;
  padding: 0;
}

.btn[data-state='loading'] {
  pointer-events: none;
  color: transparent;
  position: relative;
}

.btn[data-state='loading']::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2px solid var(--btn-ink);
  border-right-color: transparent;
  border-radius: var(--r-full);
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.field {
  display: grid;
  gap: var(--sp-2);
}

.field > label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-2);
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 48px;
  padding: var(--sp-3) var(--sp-4);
  border: var(--bd) solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--paper-2);
  color: var(--ink);
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}

.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.6;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ink-3);
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--ink-3);
}

.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.input[aria-invalid='true'],
.textarea[aria-invalid='true'] {
  border-color: var(--neg);
  background: var(--neg-soft);
}

.field__hint {
  font-size: var(--text-xs);
  color: var(--ink-3);
}

.field__error {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--neg);
}

.card {
  background: var(--paper-2);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sticker-sm);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-full);
  background: var(--paper-2);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sticker-sm);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}

.chip:hover {
  transform: translateY(-1px);
}

.chip:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.chip[data-cat='positive'] {
  background: var(--pos-soft);
}

.chip[data-cat='needs'] {
  background: var(--neg-soft);
}

.chip[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-ink);
}

.chip[data-state='loading'] {
  pointer-events: none;
  opacity: 0.6;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-width: 34px;
  justify-content: center;
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
  border: var(--bd) solid var(--ink);
  background: var(--paper-2);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.badge[data-sign='pos'] {
  background: var(--pos);
}

.badge[data-sign='neg'] {
  background: var(--neg);
  color: var(--ink-invert);
}

.badge[data-sign='zero'] {
  background: var(--paper-3);
  color: var(--ink-2);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-2);
  border-radius: var(--r-xs);
  background: var(--paper-3);
  font-size: var(--text-xs);
  color: var(--ink-2);
}

/* ── 3. monogram：全站唯一的身份图形（替代头像）────────────────────── */

.mark {
  --mark-size: 48px;
  --tone: var(--mark-1);
  display: inline-grid;
  place-items: center;
  width: var(--mark-size);
  height: var(--mark-size);
  flex: none;
  border-radius: 30%;
  background: var(--tone);
  border: var(--bd) solid var(--ink);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: calc(var(--mark-size) * 0.42);
  line-height: 1;
  user-select: none;
  overflow: hidden;
}

.mark--sm { --mark-size: 34px; border-radius: 26%; }
.mark--lg { --mark-size: 72px; }
.mark--xl { --mark-size: 96px; }

.mark[data-tone='1']  { --tone: var(--mark-1); }
.mark[data-tone='2']  { --tone: var(--mark-2); }
.mark[data-tone='3']  { --tone: var(--mark-3); }
.mark[data-tone='4']  { --tone: var(--mark-4); }
.mark[data-tone='5']  { --tone: var(--mark-5); }
.mark[data-tone='6']  { --tone: var(--mark-6); }
.mark[data-tone='7']  { --tone: var(--mark-7); }
.mark[data-tone='8']  { --tone: var(--mark-8); }
.mark[data-tone='9']  { --tone: var(--mark-9); }
.mark[data-tone='10'] { --tone: var(--mark-10); }
.mark[data-tone='11'] { --tone: var(--mark-11); }
.mark[data-tone='12'] { --tone: var(--mark-12); }

/* ── 4. 登录 / 注册 ──────────────────────────────────────────────────── */

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}

.auth__brand {
  position: relative;
  padding: var(--sp-9) var(--sp-8);
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--sp-8);
  overflow: hidden;
}

.auth__logo {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--paper);
}

.auth__logo-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 30%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 20px;
}

.auth__headline {
  font-size: var(--text-display);
  max-width: 16ch;
  color: var(--paper);
}

.auth__lede {
  margin-top: var(--sp-4);
  max-width: 34ch;
  color: oklch(88% 0.02 90);
  font-size: var(--text-md);
}

.auth__points {
  display: grid;
  gap: var(--sp-3);
  max-width: 40ch;
}

.auth__point {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3) 0;
  border-top: 1px solid oklch(40% 0.03 258);
  font-size: var(--text-sm);
  color: oklch(90% 0.015 90);
}

.auth__point-dot {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--pos);
}

.auth__point:nth-child(2) .auth__point-dot { background: var(--warn); }
.auth__point:nth-child(3) .auth__point-dot { background: var(--accent); }

/* 无头像装饰：纯几何色块拼贴 */
.auth__art {
  position: absolute;
  right: -80px;
  bottom: -60px;
  width: 320px;
  height: 320px;
  opacity: 0.9;
  pointer-events: none;
}

.auth__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8) var(--sp-6);
  background: var(--paper);
}

.auth__card {
  width: min(100%, 460px);
  display: grid;
  gap: var(--sp-5);
}

.auth__title {
  font-size: var(--text-2xl);
}

.auth__sub {
  color: var(--ink-2);
  font-size: var(--text-base);
}

.tabs {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: var(--r-full);
  background: var(--paper-3);
  border: var(--bd) solid var(--line-soft);
}

.tabs__btn {
  min-height: 38px;
  padding: 0 var(--sp-4);
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.tabs__btn:hover {
  color: var(--ink);
}

.tabs__btn[aria-selected='true'] {
  background: var(--ink);
  color: var(--paper);
}

.roles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-2);
}

.role {
  position: relative;
  display: grid;
  gap: var(--sp-1);
  justify-items: center;
  padding: var(--sp-3) var(--sp-2);
  border: var(--bd) solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--paper-2);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.role:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

.role input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.role__icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 30%;
  background: var(--paper-3);
  color: var(--ink);
}

.role__name {
  font-size: var(--text-sm);
  font-weight: 700;
}

.role__hint {
  font-size: var(--text-xs);
  color: var(--ink-3);
}

.role:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent);
}

.role:has(input:focus-visible) {
  box-shadow: var(--shadow-focus);
}

.auth__actions {
  display: grid;
  gap: var(--sp-3);
}

.auth__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--text-sm);
  color: var(--ink-2);
  flex-wrap: wrap;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.auth__demo {
  padding: var(--sp-3) var(--sp-4);
  border: var(--bd) dashed var(--line-soft);
  border-radius: var(--r-md);
  font-size: var(--text-xs);
  color: var(--ink-2);
  display: grid;
  gap: 2px;
}

.auth__demo code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink);
}

/* ── 5. 应用外壳 ─────────────────────────────────────────────────────── */

.shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  padding: var(--sp-5) var(--sp-4);
  background: var(--paper-2);
  border-right: var(--bd) solid var(--ink);
  z-index: 20;
}

.rail__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-md);
  text-decoration: none;
  color: var(--ink);
}

.rail__mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 30%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 18px;
  box-shadow: var(--shadow-sticker-sm);
}

.rail__nav {
  display: grid;
  gap: var(--sp-1);
}

.rail__link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 44px;
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--text-base);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.rail__link svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.rail__link:hover {
  background: var(--paper-3);
  color: var(--ink);
}

.rail__link[aria-current='page'] {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sticker-sm);
}

.rail__link[aria-current='page']:hover {
  background: var(--accent-2);
}

.rail__foot {
  margin-top: auto;
  display: grid;
  gap: var(--sp-2);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line-soft);
}

.rail__user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.rail__user-meta {
  min-width: 0;
  display: grid;
}

.rail__user-name {
  font-size: var(--text-sm);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail__user-role {
  font-size: var(--text-xs);
  color: var(--ink-3);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 68px;
  padding: var(--sp-3) var(--sp-6);
  background: color-mix(in oklab, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}

.topbar__class {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.topbar__select {
  min-height: 40px;
  padding: 0 var(--sp-3);
  border: var(--bd) solid var(--line-soft);
  border-radius: var(--r-full);
  background: var(--paper-2);
  font-weight: 700;
  max-width: 220px;
}

.topbar__spacer {
  flex: 1;
}

.topbar__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px var(--sp-3);
  border-radius: var(--r-full);
  background: var(--paper-2);
  border: var(--bd) solid var(--line-soft);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-2);
}

.content {
  padding: var(--sp-6);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  display: grid;
  gap: var(--sp-6);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.page-head__title {
  font-size: var(--text-2xl);
}

.page-head__sub {
  margin-top: var(--sp-1);
  color: var(--ink-2);
  font-size: var(--text-sm);
}

.tabbar {
  display: none;
}

/* ── 6. 班级页 ───────────────────────────────────────────────────────── */

.class-hero {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding: var(--sp-5);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-xl);
  background: var(--paper-2);
  box-shadow: var(--shadow-sticker);
}

.class-hero__main {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-width: 0;
  flex: 1;
}

.class-hero__name {
  font-size: var(--text-xl);
}

.class-hero__meta {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-1);
  font-size: var(--text-sm);
  color: var(--ink-2);
}

.class-hero__stats {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.stat-pill {
  display: grid;
  gap: 2px;
  min-width: 92px;
  padding: var(--sp-2) var(--sp-3);
  border: var(--bd) solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--paper);
}

.stat-pill__num {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-pill__label {
  font-size: var(--text-xs);
  color: var(--ink-3);
}

.toolbar {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  align-items: center;
}

.search-field {
  position: relative;
  flex: 1 1 220px;
  max-width: 260px;
}

.search-field .input {
  min-height: 40px;
  padding-left: 38px;
}

.search-field__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: var(--ink-3);
  pointer-events: none;
}

.roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr));
  gap: var(--sp-3);
}

.student-card {
  position: relative;
  display: grid;
  gap: var(--sp-2);
  justify-items: center;
  padding: var(--sp-4) var(--sp-3) var(--sp-3);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-lg);
  background: var(--paper-2);
  box-shadow: var(--shadow-sticker-sm);
  cursor: pointer;
  text-align: center;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.student-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--ink);
}

.student-card:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 var(--ink);
}

.student-card[data-selected='true'] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-sticker-sm);
  background: var(--accent-soft);
}

.student-card[data-archived='true'] {
  opacity: 0.55;
}

.student-card__name {
  font-weight: 700;
  font-size: var(--text-base);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.student-card__row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.student-card__quick {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.student-card:hover .student-card__quick,
.student-card:focus-within .student-card__quick {
  opacity: 1;
  transform: none;
}

.qbtn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-full);
  background: var(--paper-2);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}

.qbtn--pos { background: var(--pos); }
.qbtn--neg { background: var(--neg); color: var(--ink-invert); }

.qbtn:hover {
  transform: scale(1.08);
}

.qbtn:active {
  transform: scale(0.94);
}

.qbtn[data-state='loading'] {
  opacity: 0.5;
}

.student-card__check {
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-2);
  width: 22px;
  height: 22px;
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-xs);
  background: var(--paper-2);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}

.student-card[data-selected='true'] .student-card__check {
  background: var(--accent);
  color: var(--accent-ink);
}

.roster-empty {
  display: grid;
  justify-items: center;
  gap: var(--sp-3);
  padding: var(--sp-9) var(--sp-4);
  border: var(--bd) dashed var(--line-soft);
  border-radius: var(--r-lg);
  color: var(--ink-2);
  text-align: center;
}

.roster-empty__art {
  width: 120px;
  height: 96px;
  position: relative;
}

.roster-empty__art span {
  position: absolute;
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-md);
  background: var(--mark-4);
}

.roster-empty__art span:nth-child(1) { inset: 8px 52px 40px 0; background: var(--mark-9); }
.roster-empty__art span:nth-child(2) { inset: 0 0 52px 66px; background: var(--mark-3); }
.roster-empty__art span:nth-child(3) { inset: 52px 20px 0 26px; background: var(--mark-6); }

/* ── 7. 行为面板 / 学生抽屉 / 通用浮层 ──────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: oklch(25.5% 0.052 258 / 0.42);
  backdrop-filter: blur(2px);
  animation: fade-in var(--dur) var(--ease-out);
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.sheet {
  width: min(100%, 560px);
  max-height: min(88dvh, 720px);
  overflow: auto;
  display: grid;
  gap: var(--sp-4);
  padding: var(--sp-5);
  background: var(--paper-2);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  animation: pop-in var(--dur) var(--ease-out);
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.sheet__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.sheet__title {
  font-size: var(--text-lg);
  flex: 1;
  min-width: 0;
}

.sheet__score {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.sheet__section {
  display: grid;
  gap: var(--sp-2);
}

.sheet__label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.behavior-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 148px), 1fr));
  gap: var(--sp-2);
}

.behavior {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  min-height: 52px;
  padding: var(--sp-2) var(--sp-3);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-md);
  background: var(--paper-2);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}

.behavior[data-cat='positive'] { background: var(--pos-soft); }
.behavior[data-cat='needs'] { background: var(--neg-soft); }

.behavior:hover { transform: translateY(-1px); }
.behavior:active { transform: translateY(1px); }

.behavior__delta {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-base);
  color: var(--ink-2);
}

.behavior__label {
  overflow-wrap: anywhere;
}

.detail {
  display: grid;
  gap: var(--sp-4);
}

.detail__hero {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.detail__meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.detail__name {
  font-size: var(--text-xl);
}

.detail__sub {
  color: var(--ink-3);
  font-size: var(--text-sm);
}

.detail__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-2);
}

.detail__stat {
  padding: var(--sp-2) var(--sp-3);
  border: var(--bd) solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--paper);
  text-align: center;
}

.detail__stat b {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-variant-numeric: tabular-nums;
}

.detail__stat span {
  font-size: var(--text-xs);
  color: var(--ink-3);
}

.event-list {
  display: grid;
  gap: var(--sp-1);
  max-height: 260px;
  overflow: auto;
}

.event-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
}

.event-row:nth-child(odd) {
  background: var(--paper);
}

.event-row__label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.event-row__time {
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.event-row[data-undone='true'] {
  opacity: 0.5;
  text-decoration: line-through;
}

/* ── 8. Toast ────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sp-6) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 60;
  display: grid;
  gap: var(--sp-2);
  width: min(94vw, 420px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-full);
  background: var(--ink);
  color: var(--paper);
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow-pop);
  animation: toast-in var(--dur) var(--ease-out);
}

.toast[data-kind='error'] {
  background: var(--neg);
  color: var(--ink-invert);
}

.toast[data-kind='success'] {
  background: var(--pos-2);
  color: var(--ink-invert);
}

.toast__text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast__action {
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
  padding: var(--sp-1) var(--sp-2);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* 加分浮标 */
.float-score {
  position: fixed;
  z-index: 55;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  color: var(--pos-2);
  pointer-events: none;
  animation: float-up 900ms var(--ease-out) forwards;
  text-shadow: 0 2px 0 var(--paper-2);
}

.float-score[data-sign='neg'] {
  color: var(--neg);
}

@keyframes float-up {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.8); }
  25%  { opacity: 1; transform: translate(-50%, -14px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -64px) scale(1); }
}

.score-pulse {
  animation: pulse var(--dur-slow) var(--ease-out);
}

@keyframes pulse {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}

/* ── 9. 故事 / 消息 / 报告 / 设置 ────────────────────────────────────── */

.feed {
  display: grid;
  gap: var(--sp-3);
}

.composer {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-lg);
  background: var(--paper-2);
  box-shadow: var(--shadow-sticker-sm);
}

.composer__row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.composer__preview {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: var(--r-md);
  overflow: hidden;
  border: var(--bd) solid var(--ink);
}

.composer__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.composer__preview button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border-radius: var(--r-full);
  border: var(--bd) solid var(--ink);
  background: var(--paper-2);
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
}

.story {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-lg);
  background: var(--paper-2);
}

.story__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.story__meta {
  display: grid;
  min-width: 0;
}

.story__author {
  font-weight: 700;
  font-size: var(--text-sm);
}

.story__time {
  font-size: var(--text-xs);
  color: var(--ink-3);
}

.story__text {
  font-size: var(--text-base);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.story__image {
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--paper-3);
}

.story__image img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
}

.story__foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.like {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 36px;
  padding: 0 var(--sp-3);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-full);
  background: var(--paper);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}

.like:hover { transform: translateY(-1px); }

.like[aria-pressed='true'] {
  background: var(--neg-soft);
}

.like svg { width: 16px; height: 16px; }

.messages {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: start;
}

.thread-list {
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-lg);
  background: var(--paper-2);
  max-height: min(70dvh, 640px);
  overflow: auto;
}

.thread {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.thread:hover { background: var(--paper-3); }

.thread[aria-current='true'] {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.thread__meta { min-width: 0; flex: 1; display: grid; }

.thread__name {
  font-weight: 700;
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread__last {
  font-size: var(--text-xs);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--neg);
  flex: none;
}

.chat {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-lg);
  background: var(--paper-2);
  min-height: 420px;
}

.chat__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
}

.chat__body {
  display: grid;
  gap: var(--sp-2);
  align-content: start;
  max-height: min(58dvh, 520px);
  overflow: auto;
  padding: var(--sp-1);
}

.bubble {
  max-width: min(78%, 460px);
  padding: var(--sp-2) var(--sp-3);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-md);
  background: var(--paper);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.bubble[data-mine='true'] {
  justify-self: end;
  background: var(--accent-soft);
}

.bubble__time {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.chat__form {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-end;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: var(--sp-3);
}

.report-card {
  padding: var(--sp-4);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-lg);
  background: var(--paper-2);
  display: grid;
  gap: var(--sp-1);
}

.report-card__num {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.report-card__label {
  font-size: var(--text-sm);
  color: var(--ink-2);
}

.panel {
  padding: var(--sp-4);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-lg);
  background: var(--paper-2);
  display: grid;
  gap: var(--sp-3);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.panel__title {
  font-size: var(--text-lg);
}

.rank {
  display: grid;
  gap: var(--sp-1);
}

.rank__row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2);
  border-radius: var(--r-sm);
}

.rank__row:nth-child(odd) { background: var(--paper); }

.rank__idx {
  width: 24px;
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.rank__name { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.bars { display: grid; gap: var(--sp-2); }

.bar {
  display: grid;
  grid-template-columns: minmax(0, 148px) minmax(0, 1fr) 40px;
  gap: var(--sp-2);
  align-items: center;
  font-size: var(--text-sm);
}

.bar__label { overflow-wrap: anywhere; }

.bar__track {
  display: block;
  height: 14px;
  border-radius: var(--r-full);
  background: var(--paper-3);
  overflow: hidden;
  border: 1px solid var(--line-soft);
}

.bar__fill {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: var(--pos);
  transition: width var(--dur-slow) var(--ease-out);
}

.bar__fill[data-cat='needs'] { background: var(--neg); }

.bar__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.chart {
  width: 100%;
  height: 180px;
}

.chart text {
  font-family: var(--font-body);
  font-size: 11px;
  fill: var(--ink-3);
}

.settings {
  display: grid;
  gap: var(--sp-4);
}

.behavior-manage {
  display: grid;
  gap: var(--sp-2);
}

.behavior-manage__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--paper);
}

.behavior-manage__row > span:nth-child(2) {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: var(--text-sm);
}

.switch input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

/* 工具浮层：计时器 / 随机点名 / 分组 */
.timer {
  display: grid;
  gap: var(--sp-4);
  justify-items: center;
  text-align: center;
}

.timer__display {
  font-family: var(--font-display);
  font-size: clamp(3rem, 12vw, 5.5rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.timer__presets {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  justify-content: center;
}

.picker {
  display: grid;
  gap: var(--sp-4);
  justify-items: center;
  text-align: center;
}

.picker__mark {
  --mark-size: 128px;
  font-size: 52px;
}

.picker__name {
  font-size: var(--text-2xl);
}

.groups {
  display: grid;
  gap: var(--sp-3);
}

.group {
  padding: var(--sp-3);
  border: var(--bd) solid var(--ink);
  border-radius: var(--r-md);
  background: var(--paper);
}

.group__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  font-weight: 700;
  font-size: var(--text-sm);
}

.group__names {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.group__name {
  padding: 2px var(--sp-2);
  border-radius: var(--r-xs);
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  font-size: var(--text-sm);
}

/* ── 10. 响应式 ──────────────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .auth {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth__brand {
    padding: var(--sp-7) var(--sp-5) var(--sp-8);
  }

  .auth__art {
    width: 220px;
    height: 220px;
    right: -60px;
    bottom: -50px;
  }

  .messages {
    grid-template-columns: minmax(0, 1fr);
  }

  .thread-list {
    max-height: 260px;
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  }

  .rail {
    display: none;
  }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 2px;
    padding: var(--sp-2) var(--sp-2) calc(var(--sp-2) + env(safe-area-inset-bottom, 0px));
    background: var(--paper-2);
    border-top: var(--bd) solid var(--ink);
  }

  .tabbar__link {
    display: grid;
    justify-items: center;
    gap: 2px;
    min-height: 48px;
    padding: var(--sp-1);
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--ink-2);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
  }

  .tabbar__link svg {
    width: 22px;
    height: 22px;
  }

  .tabbar__link[aria-current='page'] {
    color: var(--accent-2);
    background: var(--accent-soft);
  }

  .topbar {
    padding: var(--sp-2) var(--sp-4);
  }

  .content {
    padding: var(--sp-4);
    gap: var(--sp-4);
  }

  .overlay {
    place-items: end stretch;
    padding: 0;
  }

  .sheet {
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding-bottom: calc(var(--sp-5) + env(safe-area-inset-bottom, 0px));
  }

  .toasts {
    bottom: calc(var(--tabbar-h) + var(--sp-3) + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 640px) {
  .search-field {
    flex: 1 1 100%;
    max-width: none;
  }
}

@media (max-width: 520px) {
  .page-head__title { font-size: var(--text-xl); }
  .class-hero { padding: var(--sp-4); }
  .roster { grid-template-columns: repeat(auto-fill, minmax(min(100%, 132px), 1fr)); }
  .student-card { padding: var(--sp-3) var(--sp-2); }
  .mark { --mark-size: 42px; }
  .detail__stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-1); }
  .bar { grid-template-columns: minmax(0, 96px) minmax(0, 1fr) 32px; }
  .auth__brand { padding: var(--sp-6) var(--sp-4) var(--sp-7); }
  .auth__panel { padding: var(--sp-5) var(--sp-4) var(--sp-7); }
  .roles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .role__hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .float-score {
    animation: fade-in 150ms var(--ease-out) forwards;
  }
}
