:root {
  --board: #22473b;
  --board-deep: #183429;
  --board-line: rgba(242, 239, 228, 0.22);
  --chalk: #f2efe4;
  --chalk-2: rgba(242, 239, 228, 0.78);
  --chalk-3: rgba(242, 239, 228, 0.5);
  --brand: #2b8ef8;
  --brand-light: #4fb0ff;
  --brand-deep: #1c72d9;
  --brand-ink: #1a6ad0;
  --brand-soft: #eaf4ff;
  --brand-soft-2: #dcecff;
  --surface: #fff;
  --surface-2: #f3f7fc;
  --track: #e7eff9;
  --line: #e2eaf4;
  --ink: #1d2b3a;
  --ink-2: #55657a;
  --ink-3: #8b98a9;
  --gold: #ffb52e;
  --gold-ink: #b26b00;
  --gold-soft: #fff4dc;
  --praise: #f2652e;
  --praise-ink: #d24a14;
  --praise-soft: #ffeee5;
  --improve: #5a7fd3;
  --improve-ink: #3d63b4;
  --improve-soft: #ebf0fb;
  --danger: #ef4e4e;
  --danger-ink: #cf3030;
  --danger-soft: #ffeded;
  --grad-brand: linear-gradient(180deg, var(--brand-light), var(--brand));
  --grad-score: linear-gradient(180deg, #ffbf4d, #ff8f1f);
  --shadow-card: 0 1px 2px rgba(29, 84, 150, 0.06), 0 10px 22px -14px rgba(29, 84, 150, 0.35);
  --shadow-float: 0 18px 44px -14px rgba(20, 70, 140, 0.4);
  --font: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", system-ui, sans-serif;
  --font-num: "Arial Rounded MT Bold", "Nunito", "Varela Round", "SF Pro Rounded", var(--font);
  --gutter: 24px;
  --dock-space: 6.5rem;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  font-size: clamp(15px, 0.55vw + 9px, 19px);
  -webkit-text-size-adjust: 100%;
  /* Windows draws a light gray scrollbar on the chalkboard otherwise. */
  scrollbar-color: rgba(242, 239, 228, 0.32) transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--chalk);
  line-height: 1.5;
  background-color: var(--board);
  background-image:
    radial-gradient(ellipse 60% 40% at 18% 8%, rgba(255, 255, 255, 0.07), transparent 70%),
    radial-gradient(ellipse 50% 50% at 85% 90%, rgba(255, 255, 255, 0.05), transparent 70%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .07 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
p, h1, h2, h3 { margin: 0; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sheet :focus-visible, .panel :focus-visible, .welcome :focus-visible, .popover :focus-visible, .selectbar :focus-visible, .dock :focus-visible, .team :focus-visible { outline-color: var(--brand); }
.picker-stage :focus-visible { outline-color: var(--gold); }

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

.ico { width: 1.2em; height: 1.2em; flex: none; }
.pet { display: block; width: 100%; height: auto; aspect-ratio: 1; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.6rem 1.6rem;
  flex-wrap: wrap;
  min-height: 4rem;
  padding: 0.55rem var(--gutter);
  background: rgba(24, 52, 41, 0.86);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--chalk);
  box-shadow: 0 1px 0 var(--board-line);
}

.brand { display: flex; align-items: center; min-width: 0; }
.brand-name { font-size: 1.4rem; font-weight: 800; letter-spacing: 0.04em; }

.class-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 40vw;
  padding: 0.3rem 0.7rem 0.3rem 0.2rem;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--chalk);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.class-btn:hover { background: rgba(255, 255, 255, 0.08); }
.class-btn .class-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.class-btn .ico { width: 1rem; height: 1rem; opacity: 0.85; }

.tabs { display: flex; gap: 0.3rem; }
.tab {
  padding: 0.38rem 1rem;
  border-radius: 999px;
  color: var(--chalk-2);
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover { color: var(--chalk); background: rgba(255, 255, 255, 0.08); }
.tab.active { background: var(--chalk); color: var(--board); }

.top-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.top-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border: 1.5px solid var(--board-line);
  border-radius: 999px;
  background: transparent;
  color: var(--chalk);
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}
.top-btn:hover { background: rgba(255, 255, 255, 0.08); }
.top-btn span { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }

/* ---------- dock ---------- */

.dock {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 40;
  display: flex;
  gap: 0.2rem;
  max-width: calc(100vw - 24px);
  padding: 0.4rem 0.6rem;
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow-float), 0 0 0 1px rgba(43, 142, 248, 0.08);
  transform: translateX(-50%);
}
body.has-selectbar .dock { display: none; }
.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 4.8rem;
  padding: 0.35rem 0.5rem 0.3rem;
  border: 0;
  border-radius: 16px;
  background: none;
  color: var(--ink-2);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background-color 0.12s, transform 0.08s;
}
.dock-btn:hover { background: var(--surface-2); color: var(--ink); }
.dock-btn:active { transform: scale(0.94); }
.dock-btn.on { background: var(--brand-soft); color: var(--brand-ink); }
.dock-ico {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 14px;
  background: var(--c, var(--brand));
  color: #fff;
  box-shadow: 0 6px 12px -6px var(--c, var(--brand));
}
.dock-ico .ico { width: 1.35rem; height: 1.35rem; }
.dock-ico.pick { --c: #8b6cff; }
.dock-ico.timer { --c: #ff9a1f; }
.dock-ico.all { --c: #f25c7a; }
.dock-ico.multi { --c: #2b8ef8; }
.dock-ico.undo { --c: #19b394; }

/* ---------- shared controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.12s, filter 0.12s, transform 0.08s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; }
.btn.primary { background: var(--grad-brand); color: #fff; box-shadow: 0 6px 14px -8px rgba(43, 142, 248, 0.9); }
.btn.primary:hover:not(:disabled) { filter: brightness(0.95); }
.btn.ghost { background: var(--brand-soft); color: var(--brand-ink); }
.btn.ghost:hover:not(:disabled) { background: var(--brand-soft-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-ghost { background: var(--danger-soft); color: var(--danger-ink); }
.btn.glass { background: rgba(255, 255, 255, 0.16); color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.4); }
.btn.glass:hover { background: rgba(255, 255, 255, 0.26); }
.btn.small { padding: 0.38rem 0.85rem; font-size: 0.9rem; }
.btn.big { padding: 0.85rem 1.8rem; font-size: 1.1rem; }
.btn.huge { padding: 1rem 3rem; font-size: 1.6rem; }
.btn.wide { width: 100%; margin-top: 0.75rem; }
.file-btn { cursor: pointer; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.small { width: 1.9rem; height: 1.9rem; }
.icon-btn.small .ico { width: 1rem; height: 1rem; }

.link { color: var(--brand-ink); font-weight: 700; text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--line);
}
.seg-btn {
  padding: 0.4rem 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 700;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--grad-brand); color: #fff; box-shadow: 0 4px 10px -6px rgba(43, 142, 248, 0.9); }
.seg-btn small { margin-left: 0.35rem; font-size: 0.8em; opacity: 0.75; }

/* Controls sitting straight on the chalkboard */
.seg.glass, .board-head .seg { background: rgba(0, 0, 0, 0.18); box-shadow: inset 0 0 0 1px var(--board-line); }
.seg.glass .seg-btn, .board-head .seg-btn { color: var(--chalk-2); }
.seg.glass .seg-btn:hover, .board-head .seg-btn:hover { color: var(--chalk); }
.seg.glass .seg-btn.active, .board-head .seg-btn.active { background: var(--chalk); color: var(--board); box-shadow: none; }
.board-head .btn.ghost, .empty-board .btn.ghost { background: transparent; color: var(--chalk); box-shadow: inset 0 0 0 1.5px var(--board-line); }
.board-head .btn.ghost:hover, .empty-board .btn.ghost:hover { background: rgba(255, 255, 255, 0.08); }
.empty-board .btn.primary { background: var(--gold); color: var(--ink); box-shadow: none; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.85rem;
  font-weight: 700;
}
.chip.gold { background: var(--grad-score); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.chip-btn {
  padding: 0.32rem 0.9rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
.chip-btn:hover { border-color: var(--brand-light); }
.chip-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-btn.glass { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.4); color: #fff; }
.chip-btn.glass.on { background: #fff; border-color: #fff; color: var(--brand-ink); }

.page-select, .date-range input {
  padding: 0.42rem 0.9rem;
  border: 1.5px solid var(--board-line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--chalk);
  font-weight: 700;
}
.page-select option { color: var(--ink); }
.date-range { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--chalk-2); }
.date-range input { color-scheme: dark; border-radius: 10px; }

.hint { font-size: 0.85rem; color: var(--ink-3); }
.page-note { color: var(--chalk-2); }
.page-note b { color: var(--chalk); font-family: var(--font-num); font-size: 1.15em; }
.sep { display: inline-block; width: 1px; height: 0.9em; margin: 0 0.75em; background: var(--chalk-3); vertical-align: -0.1em; }
.empty-note { color: var(--ink-3); padding: 0.75rem 0; }
.loading { color: var(--chalk-2); padding: 3rem var(--gutter); text-align: center; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.section-title { font-size: 1rem; font-weight: 800; color: var(--ink-2); margin: 1.1rem 0 0.4rem; }

/* ---------- board ---------- */

.view { padding-top: 0.9rem; padding-bottom: 2rem; }
body.has-dock .view { padding-bottom: var(--dock-space); }
body.has-selectbar .view { padding-bottom: 7rem; }

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.2rem var(--gutter) 1rem;
}
.board-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem; }
.board-tip { text-align: center; color: var(--chalk-3); font-size: 0.9rem; padding: 0 var(--gutter); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.4rem, 1fr));
  gap: 1rem;
  padding: 0.4rem var(--gutter) 1.5rem;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.9rem 0.6rem 0.75rem;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 1px 2px rgba(29, 84, 150, 0.06), 0 16px 28px -14px rgba(29, 84, 150, 0.45); }
.card:active { transform: scale(0.96); }
.card .pet {
  width: 80%;
  max-width: 7.2rem;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #f6fbff, #deecfc);
}
.card-name {
  max-width: 100%;
  margin-top: 0.45rem;
  font-size: 1.12rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-lv {
  margin-top: 0.15rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 0.72rem;
  font-weight: 700;
}
.card-score {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  display: grid;
  place-items: center;
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 0.45rem;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--grad-score);
  color: #fff;
  font-family: var(--font-num);
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 4px 10px -4px rgba(255, 128, 20, 0.8);
}
.card-score.neg { background: linear-gradient(180deg, #a4b4cb, #8195b1); box-shadow: 0 4px 10px -4px rgba(80, 100, 130, 0.8); }
.card-check {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  display: none;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  border: 2px solid #c9d7e8;
  background: #fff;
  color: transparent;
}
.selecting .card-check { display: grid; }
.card.selected { box-shadow: 0 0 0 3px var(--brand), var(--shadow-card); }
.card.selected .card-check { background: var(--brand); border-color: var(--brand); color: #fff; }
.card-check .ico { width: 1rem; height: 1rem; stroke-width: 3; }

.empty-board { max-width: 38rem; margin: 9vh auto; padding: 0 var(--gutter); text-align: center; }
.empty-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 0.6rem; }
.empty-board .page-note { margin-bottom: 1.6rem; }
.empty-board .row-actions { justify-content: center; }

/* ---------- teams ---------- */

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr));
  gap: 1.2rem;
  padding: 0 var(--gutter) 1.5rem;
}
.team {
  overflow: hidden;
  padding: 0 1.1rem 0.9rem;
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}
.team.loose { background: rgba(255, 255, 255, 0.7); }
.team-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0 -1.1rem 0.6rem;
  padding: 0.75rem 1.1rem;
  background: linear-gradient(90deg, var(--brand-soft), rgba(234, 244, 255, 0));
}
.team.loose .team-head { background: none; }
.team-head h3 { font-size: 1.25rem; font-weight: 800; }
.team-score { color: var(--ink-2); }
.team-score b { font-family: var(--font-num); font-size: 1.45rem; color: #f07d00; margin-right: 0.15rem; }
.team-score span { margin-left: 0.6rem; font-size: 0.85rem; color: var(--ink-3); }
.team-head .btn { margin-left: auto; align-self: center; }
.team-members { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.8rem, 1fr)); gap: 0.35rem; }
.mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.35rem 0.2rem;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
}
.mini:hover { background: var(--surface-2); }
.mini .pet { width: 3.5rem; border-radius: 50%; background: radial-gradient(circle at 50% 38%, #f6fbff, #deecfc); }
.mini-name { max-width: 100%; margin-top: 0.15rem; font-size: 0.92rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-score { font-family: var(--font-num); font-size: 0.85rem; font-weight: 800; color: #f07d00; }
.mini-score.neg { color: var(--improve-ink); }

/* ---------- panels ---------- */

.panel {
  margin: 0 var(--gutter) 1.2rem;
  padding: 1.1rem 1.3rem;
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}
.panel-head h2 { position: relative; padding-left: 0.75rem; font-size: 1.15rem; font-weight: 800; }
.panel-head h2::before { content: ""; position: absolute; left: 0; top: 0.25em; bottom: 0.25em; width: 4px; border-radius: 4px; background: var(--brand); }
.panel-head h2 small { margin-left: 0.5rem; font-size: 0.85rem; font-weight: 600; color: var(--ink-3); }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; margin: 0 var(--gutter) 1.2rem; align-items: start; }
.two-col .panel { margin: 0; }
.panel.wide { grid-column: 1 / -1; }
.manage-body { max-width: 1320px; }
.manage-body > .page-note { padding: 0 var(--gutter); font-size: 0.9rem; }

.subnav { display: flex; flex-wrap: wrap; gap: 0.45rem; padding: 0.2rem var(--gutter) 1.1rem; }
.subnav-item {
  padding: 0.42rem 1.1rem;
  border-radius: 999px;
  color: var(--chalk-2);
  font-weight: 700;
  text-decoration: none;
  box-shadow: inset 0 0 0 1.5px var(--board-line);
}
.subnav-item:hover { color: var(--chalk); }
.subnav-item.active { background: var(--chalk); color: var(--board); box-shadow: none; }

.table-wrap { overflow-x: auto; margin: 0 -0.3rem; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th {
  padding: 0.55rem 0.6rem;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}
.table th:first-child { border-radius: 10px 0 0 10px; }
.table th:last-child { border-radius: 0 10px 10px 0; }
.table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tbody tr:hover { background: #f6faff; }
.table td.neg { color: var(--improve-ink); }
.table .num { font-family: var(--font-num); font-weight: 800; }
.th-sort { padding: 0; border: 0; background: none; font-weight: inherit; color: inherit; }
.th-sort.on { color: var(--brand-ink); }

.roster td { padding: 0.25rem 0.4rem; }
.cell {
  width: 100%;
  min-width: 7rem;
  padding: 0.38rem 0.55rem;
  border: 1.5px solid transparent;
  border-radius: 9px;
  background: transparent;
}
.cell.short { min-width: 4.5rem; width: 6rem; }
.cell:hover { border-color: var(--line); }
.cell:focus { outline: none; border-color: var(--brand); background: #fff; }
.cell.saved { animation: saved 0.9s ease; }
@keyframes saved { 0% { background: #dff3e6; } 100% { background: transparent; } }
.avatar-btn { display: block; width: 3rem; height: 3rem; padding: 0.15rem; border: 0; border-radius: 50%; background: none; }
.avatar-btn:hover { background: var(--brand-soft); }

.item-list { list-style: none; margin: 0; padding: 0; }
.item {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) auto 2.25rem 2.25rem;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item-icon { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--praise-soft); font-size: 1.3rem; }
.item.improve .item-icon { background: var(--improve-soft); }
.item.reward .item-icon { background: var(--gold-soft); }
.item-name { font-weight: 700; }
.item-points { font-family: var(--font-num); font-weight: 800; color: var(--praise-ink); }
.item.improve .item-points { color: var(--improve-ink); }
.item.reward .item-points { color: var(--gold-ink); }

.team-admin { list-style: none; margin: 0; padding: 0; }
.team-admin-row { padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.team-admin-row:last-child { border-bottom: 0; }
.team-admin-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.team-admin-head h3 { font-size: 1.1rem; font-weight: 800; }
.team-admin-head .row-actions { margin-left: auto; }
.member-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.setting:last-of-type { border-bottom: 0; }
.setting-name { font-weight: 700; }
label.setting { cursor: pointer; }
.switch {
  appearance: none;
  flex: none;
  position: relative;
  width: 2.9rem;
  height: 1.65rem;
  margin: 0;
  border-radius: 999px;
  background: #d5dfeb;
  cursor: pointer;
  transition: background-color 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(1.25rem); }
.lan-main { display: flex; align-items: center; gap: 1rem; margin: 0.8rem 0; }
.qr-btn { flex: none; width: 8.5rem; padding: 0; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; cursor: zoom-in; }
.qr { display: block; width: 100%; height: auto; }
.lan-main .hint { margin-top: 0.4rem; }
.sheet-qr { width: min(560px, 100%); }
.sheet-qr .qr { width: min(100%, 62vh); margin: 0 auto; border-radius: 12px; }
.qr-url { margin-top: 0.8rem; text-align: center; font-family: var(--font-num); font-size: 1.6rem; font-weight: 800; word-break: break-all; }
.url-list { list-style: none; margin: 0.4rem 0 0; padding: 0; display: grid; gap: 0.4rem; }
.url-list code, code.url {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-family: var(--font-num);
  font-size: 1.15rem;
  user-select: all;
}
.data-dir { margin-top: 0.4rem; word-break: break-all; }

/* ---------- rank ---------- */

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 1.4rem; padding: 0.4rem var(--gutter) 0; }
.podium-spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--chalk);
}
.podium-pet { width: 7.2rem; }
.place-1 .podium-pet { width: 9.5rem; }
.podium-name { font-size: 1.3rem; font-weight: 800; }
.podium-score { font-family: var(--font-num); font-size: 1.35rem; font-weight: 800; color: var(--gold); margin-bottom: 0.5rem; }
.podium-block {
  display: grid;
  place-items: center;
  width: 9rem;
  height: 4rem;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(180deg, #eef3f9, #d9e3ef);
  color: #6b7c92;
  box-shadow: var(--shadow-card);
}
.podium-block b { font-family: var(--font-num); font-size: 2.2rem; }
.place-1 .podium-block { height: 6.5rem; background: linear-gradient(180deg, #ffd567, #ffad1f); color: #fff; }
.place-2 .podium-block { height: 5rem; }
.place-3 .podium-block { height: 4rem; background: linear-gradient(180deg, #ffd9b5, #f4b27a); color: #fff; }
.podium + .panel { border-top-left-radius: 8px; border-top-right-radius: 8px; }

.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-row {
  display: grid;
  grid-template-columns: 2.4rem 2.8rem minmax(4.5rem, 9rem) minmax(7rem, auto) minmax(4rem, 1fr) 3.6rem;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  padding: 0.4rem 0.3rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink);
  text-align: left;
}
button.rank-row:hover { background: #f6faff; }
.rank-list li:last-child .rank-row { border-bottom: 0; }
.rank-no { font-family: var(--font-num); font-size: 1.1rem; font-weight: 800; color: var(--ink-3); text-align: center; }
.teams li:nth-child(-n+3) .rank-no { color: #f07d00; }
.rank-pet { width: 2.8rem; border-radius: 50%; background: radial-gradient(circle at 50% 38%, #f6fbff, #deecfc); }
.rank-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-counts { font-size: 0.85rem; color: var(--ink-2); white-space: nowrap; }
.rank-counts span { margin-left: 0.7rem; }
.rank-bar { height: 10px; }
.rank-bar i { display: block; height: 100%; border-radius: 0 5px 5px 0; background: linear-gradient(90deg, #ffcf5c, #ff9a1f); }
.rank-net { font-family: var(--font-num); font-size: 1.15rem; font-weight: 800; text-align: right; }
.rank-net.neg { color: var(--improve-ink); }
.pet-stack { display: flex; }
.pet-stack .pet { width: 3.2rem; margin-left: -0.9rem; }
.pet-stack .pet:first-child { margin-left: 0; }
.pet-stack.small .pet { width: 1.9rem; margin-left: -0.7rem; }
.pet-stack.small .pet:first-child { margin-left: 0; }

/* ---------- records ---------- */

.tiles-stat { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.2rem; margin: 0 var(--gutter) 1.2rem; }
.stat { padding: 1rem 1.2rem; border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }
.stat-label { font-size: 0.9rem; font-weight: 700; color: var(--ink-2); }
.stat-value { font-family: var(--font-num); font-size: 2.2rem; font-weight: 800; line-height: 1.25; }
.stat-value small { margin-left: 0.2rem; font-family: var(--font); font-size: 0.9rem; font-weight: 600; color: var(--ink-3); }
.stat-sub { font-size: 0.85rem; color: var(--ink-3); }

.legend { display: flex; gap: 1rem; font-size: 0.85rem; color: var(--ink-2); }
.key { display: inline-block; width: 10px; height: 10px; margin-right: 0.35rem; border-radius: 3px; vertical-align: -0.05em; }
.key.praise { background: var(--praise); }
.key.improve { background: var(--improve); }

.trend { position: relative; height: 13rem; margin-top: 0.4rem; }
.trend-grid {
  position: absolute;
  inset: 0 0 1.6rem 2.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.trend-grid span { position: relative; border-top: 1px solid var(--line); }
.trend-grid span::before {
  content: attr(data-v);
  position: absolute;
  left: -2.2rem;
  top: -0.65em;
  width: 1.8rem;
  font-size: 0.75rem;
  color: var(--ink-3);
  text-align: right;
}
.trend-cols { position: absolute; inset: 0 0 0 2.2rem; display: flex; }
.trend-col { flex: 1; display: flex; flex-direction: column; min-width: 0; border-radius: 6px; outline-offset: -2px; }
.trend-col:hover { background: rgba(43, 142, 248, 0.06); }
.trend-stack { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.trend-stack i { display: block; width: min(24px, 64%); }
.trend-stack i:first-child { border-radius: 4px 4px 0 0; }
.trend-stack i + i { margin-top: 2px; }
.seg-praise { background: var(--praise); }
.seg-improve { background: var(--improve); }
.trend-x { height: 1.6rem; line-height: 1.6rem; font-size: 0.72rem; color: var(--ink-3); text-align: center; white-space: nowrap; overflow: visible; }
.trend-tip {
  position: absolute;
  top: -0.3rem;
  transform: translate(-50%, -100%);
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 0.8rem;
  white-space: nowrap;
  pointer-events: none;
}

.bars-wrap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem 2rem; }
.bars .section-title { margin-top: 0; }
.bar-row { display: grid; grid-template-columns: 8rem minmax(0, 1fr); align-items: center; gap: 0.75rem; margin: 0.4rem 0; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.95rem; }
.bar-label span { margin-right: 0.35rem; }
.bar-track { display: grid; grid-template-columns: minmax(0, 1fr) 3.4rem; align-items: center; gap: 0.5rem; }
.bar-area i { display: block; height: 14px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--praise); }
.bars.improve .bar-area i { background: var(--improve); }
.bar-track b { font-size: 0.85rem; font-weight: 700; color: var(--ink-2); white-space: nowrap; }

.filters { display: flex; gap: 0.5rem; align-items: center; }
.filters select { padding: 0.35rem 0.7rem; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; }
.list-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 0.75rem; color: var(--ink-3); font-size: 0.9rem; }

.history-list { list-style: none; margin: 0; padding: 0; }
.history-row {
  display: grid;
  grid-template-columns: 2rem auto minmax(0, 1fr) auto 3rem 1.9rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0.42rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.sheet-student .history-row { grid-template-columns: 2rem minmax(0, 1fr) auto 3rem 1.9rem; }
.history-row:last-child { border-bottom: 0; }
.history-icon { font-size: 1.25rem; text-align: center; }
.history-who { font-weight: 800; }
.history-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-row time { font-size: 0.85rem; color: var(--ink-3); white-space: nowrap; }
.history-points { font-family: var(--font-num); font-weight: 800; text-align: right; color: var(--praise-ink); }
.history-row.improve .history-points { color: var(--improve-ink); }
.history-row.redeem .history-points { color: var(--gold-ink); }

/* ---------- sheets ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 26, 20, 0.58);
  animation: fade-in 0.16s ease;
}
.scrim.leaving { animation: fade-out 0.16s ease forwards; }
.sheet, .popover, .table-wrap { scrollbar-color: #c5d4e6 transparent; }
.sheet {
  width: min(720px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 70px -20px rgba(16, 50, 100, 0.55);
  animation: sheet-in 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.sheet-small { width: min(460px, 100%); }
.sheet-picker { width: min(940px, 100%); }
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem 0.6rem;
  background: var(--surface);
}
.sheet-title { font-size: 1.2rem; font-weight: 800; }
.sheet-body { padding: 0.4rem 1.25rem 1.3rem; }
.sheet-actions { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.2rem; }
.sheet-actions .hint { margin-right: auto; }
.dialog-text { color: var(--ink-2); line-height: 1.7; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

.form { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.35rem; }
.field > span, .inline-field > span { font-size: 0.9rem; font-weight: 700; color: var(--ink-2); }
.field.grow { flex: 1; }
.form input:not([type="checkbox"]), .form select, .form textarea, .picker-controls select {
  width: 100%;
  padding: 0.62rem 0.85rem;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
.form textarea { resize: vertical; line-height: 1.65; }
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(43, 142, 248, 0.18);
}
.form-error { color: var(--danger-ink); font-size: 0.9rem; font-weight: 700; }
.form-error:empty { display: none; }
.check { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--brand); }
.inline-field { display: inline-flex; align-items: center; gap: 0.6rem; }
.inline-field select { width: auto; }

.welcome {
  max-width: 40rem;
  margin: 4vh auto 3rem;
  padding: 2rem 2.2rem;
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}
.welcome-pets { display: flex; justify-content: center; align-items: flex-end; margin-bottom: 0.6rem; }
.welcome-pets .pet { width: 6rem; }
.welcome-pets .pet:nth-child(2) { width: 8rem; }
.welcome h1 { font-size: 1.8rem; font-weight: 800; text-align: center; margin-bottom: 0.4rem; }
.welcome .lead { color: var(--ink-2); text-align: center; margin-bottom: 1.4rem; }
.welcome .sheet-actions .btn { width: 100%; }
.roster-count { display: block; margin-top: 0.2rem; }
.auth { max-width: 30rem; }
.auth-tabs { display: flex; margin-bottom: 1.2rem; }
.auth-tabs .seg-btn { flex: 1; padding: 0.55rem; }
.auth-download { margin-top: 1.4rem; padding-top: 1.3rem; border-top: 1px solid var(--line); text-align: center; }
.auth-download .btn { width: 100%; }
.auth-download .hint { margin-top: 0.6rem; }

.fatal { max-width: 32rem; margin: 15vh auto; padding: 0 var(--gutter); text-align: center; }
.fatal h1 { font-size: 1.8rem; margin-bottom: 0.6rem; }
.fatal p { color: var(--chalk-2); margin-bottom: 1.4rem; }

/* rate sheet */
.rate-who { display: flex; align-items: center; gap: 1rem; }
.rate-who > .pet { width: 5.4rem; flex: none; border-radius: 50%; background: radial-gradient(circle at 50% 38%, #f6fbff, #deecfc); }
.rate-who-text { flex: 1; min-width: 0; display: grid; gap: 0.3rem; }
.rate-name { font-size: 1.5rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rate-tabs {
  display: flex;
  gap: 2.2rem;
  width: 100%;
  margin: 1rem 0 0.9rem;
  padding: 0 0.4rem;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
  box-shadow: none;
}
.rate-tabs .seg-btn { position: relative; padding: 0.55rem 0.2rem; border-radius: 0; font-size: 1.08rem; }
.rate-tabs .seg-btn.active { background: none; box-shadow: none; color: var(--brand-ink); }
.rate-tabs .seg-btn.active::after {
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: -1px;
  height: 3px;
  border-radius: 3px;
  background: var(--brand);
}
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.2rem, 1fr)); gap: 0.5rem; }
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.85rem 0.4rem 0.7rem;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--ink);
  transition: background-color 0.12s, transform 0.08s;
}
.tile:hover:not(:disabled) { background: var(--praise-soft); }
.tiles.improve .tile:hover:not(:disabled) { background: var(--improve-soft); }
.tiles.rewards .tile:hover:not(:disabled) { background: var(--gold-soft); }
.tile:active:not(:disabled) { transform: scale(0.94); }
.tile:disabled { opacity: 0.5; }
.tile-icon {
  display: grid;
  place-items: center;
  width: 3.8rem;
  height: 3.8rem;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff6f0, #ffe1d1);
  box-shadow: inset 0 0 0 2px #fff, 0 6px 12px -8px rgba(242, 101, 46, 0.7);
  font-size: 2rem;
  line-height: 1;
}
.tiles.improve .tile-icon, .tile-icon.improve { background: linear-gradient(180deg, #f5f8ff, #dfe7f8); box-shadow: inset 0 0 0 2px #fff, 0 6px 12px -8px rgba(90, 127, 211, 0.7); }
.tiles.rewards .tile-icon, .tile-icon.reward { background: linear-gradient(180deg, #fffaf0, #ffecc2); box-shadow: inset 0 0 0 2px #fff, 0 6px 12px -8px rgba(255, 170, 30, 0.7); }
.tile-icon.big { width: 4.6rem; height: 4.6rem; font-size: 2.5rem; flex: none; }
.tile-name { font-weight: 800; text-align: center; line-height: 1.3; }
.tile-points { font-family: var(--font-num); font-size: 1.1rem; font-weight: 800; color: var(--praise-ink); }
.tiles.improve .tile-points { color: var(--improve-ink); }
.tiles.rewards .tile-points { color: var(--gold-ink); }
.tile-lack { font-size: 0.75rem; color: var(--ink-3); }
.rate-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 1.1rem; padding-top: 0.9rem; border-top: 1px solid var(--line); }
.redeem-balance { margin-bottom: 0.9rem; color: var(--ink-2); }
.redeem-balance b { font-family: var(--font-num); font-size: 1.6rem; color: #f07d00; margin-left: 0.3rem; }
.sheet-redeem .hint { margin-top: 1rem; }

/* student sheet */
.student-head { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0.4rem 1.2rem; align-items: center; }
.student-pet .pet { width: 7.5rem; border-radius: 50%; background: radial-gradient(circle at 50% 38%, #f6fbff, #deecfc); }
.student-info { display: grid; gap: 0.35rem; }
.student-name { font-size: 1.6rem; font-weight: 800; }
.level-line { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.92rem; color: var(--ink-2); }
.level-line b { color: var(--ink); white-space: nowrap; }
.meter { height: 10px; border-radius: 999px; background: var(--track); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #ffcf5c, #ff9a1f); }
.student-stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem; margin: 0.9rem 0 0; }
.student-stats div { padding: 0.55rem 0.75rem; border-radius: 14px; background: var(--surface-2); }
.student-stats dt { font-size: 0.8rem; color: var(--ink-2); font-weight: 700; }
.student-stats dd { margin: 0; font-family: var(--font-num); font-size: 1.5rem; font-weight: 800; }
.student-stats small { margin-left: 0.15rem; font-family: var(--font); font-size: 0.8rem; color: var(--ink-3); }
.student-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

/* editor */
.editor-top { display: flex; align-items: flex-end; gap: 1rem; }
.stepper { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.stepper .btn { width: 2.6rem; height: 2.6rem; padding: 0; font-size: 1.3rem; }
.form .stepper input { width: 5rem; text-align: center; font-family: var(--font-num); font-size: 1.25rem; font-weight: 800; }
.stepper .chip-btn:first-of-type { margin-left: 0.6rem; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); gap: 0.25rem; }
.emoji { height: 2.6rem; padding: 0; border: 2px solid transparent; border-radius: 12px; background: none; font-size: 1.4rem; line-height: 1; }
.emoji:hover { background: var(--surface-2); }
.emoji.on { border-color: var(--brand); background: var(--brand-soft); }
.form .inline-field .emoji-input { width: 6rem; text-align: center; font-size: 1.2rem; }
.inline-field > span { white-space: nowrap; }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: 0.45rem; }
.pick {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.65rem;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.pick input { width: 1.05rem; height: 1.05rem; accent-color: var(--brand); flex: none; }
.pick:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.pick-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick small { margin-left: auto; font-size: 0.72rem; color: var(--ink-3); white-space: nowrap; }

/* ---------- popover, select bar, toasts ---------- */

.popover {
  position: fixed;
  z-index: 60;
  min-width: 15rem;
  max-height: 70vh;
  overflow: auto;
  padding: 0.4rem;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-float);
  animation: sheet-in 0.14s ease;
}
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 0;
  border-radius: 10px;
  background: none;
  font-weight: 600;
  text-align: left;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.current { font-weight: 800; color: var(--brand-ink); }
.menu-item.current span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 0.5rem; border-radius: 50%; background: var(--brand); vertical-align: 0.1em; }
.menu-item small { color: var(--ink-3); }
.menu-label { padding: 0.5rem 0.8rem 0.4rem; border-bottom: 1px solid var(--line); margin-bottom: 0.3rem; font-size: 0.85rem; color: var(--ink-3); }
.menu-item.add { justify-content: flex-start; gap: 0.5rem; margin-top: 0.3rem; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; color: var(--brand-ink); font-weight: 800; }

.selectbar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 40;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: calc(100vw - 24px);
  padding: 0.5rem 0.5rem 0.5rem 1.2rem;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-float), 0 0 0 1px rgba(43, 142, 248, 0.08);
  transform: translateX(-50%);
}
.selectbar-count { margin-right: 0.4rem; font-weight: 700; }
.selectbar-count b { font-family: var(--font-num); font-size: 1.3rem; color: var(--brand-ink); }

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: max-content;
  max-width: calc(100vw - 24px);
  transform: translateX(-50%);
  pointer-events: none;
}
body.has-dock .toasts, body.has-selectbar .toasts { bottom: 6.8rem; }
.toast {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0.8rem 0.7rem 1.2rem;
  border-radius: 14px;
  background: rgba(29, 43, 58, 0.94);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 12px 30px -10px rgba(16, 40, 80, 0.6);
  pointer-events: auto;
  animation: toast-in 0.2s ease;
}
.toast.error { background: #c93a3a; }
.toast.leaving { animation: fade-out 0.2s ease forwards; }
.toast-action { padding: 0.25rem 0.6rem; border: 0; border-radius: 999px; background: none; color: #8fcbff; font-weight: 800; }
.toast-action:hover { background: rgba(255, 255, 255, 0.12); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- celebration ---------- */

.celebrate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, rgba(27, 58, 47, 0.9), rgba(12, 30, 23, 0.95));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in 0.18s ease;
  cursor: pointer;
}
.celebrate.leaving { animation: fade-out 0.22s ease forwards; }
.cel-card { position: relative; text-align: center; color: #fff; padding: 1rem; }
.cel-pets { display: flex; justify-content: center; align-items: flex-end; flex-wrap: wrap; gap: 0.5rem; max-width: 80vw; margin: 0 auto; }
.cel-pet { width: min(40vmin, 16rem); animation: pet-pop 0.55s cubic-bezier(0.3, 1.6, 0.5, 1) both; animation-delay: calc(var(--i, 0) * 50ms); }
.cel-pets.many .cel-pet { width: min(18vmin, 8.5rem); }
.improve .cel-pet { animation: pet-shake 0.5s ease both; }
.cel-more { align-self: center; font-family: var(--font-num); font-size: 2rem; font-weight: 800; color: rgba(255, 255, 255, 0.8); }
.cel-points {
  font-family: var(--font-num);
  font-size: clamp(4rem, 13vmin, 8.5rem);
  font-weight: 800;
  line-height: 1.05;
  color: var(--gold);
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
  animation: points-in 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) 0.08s both;
}
.improve .cel-points { color: #a9cbf3; }
.cel-what { display: flex; justify-content: center; align-items: center; gap: 0.6rem; font-size: clamp(1.4rem, 4vmin, 2.2rem); font-weight: 800; }
.cel-who { margin-top: 0.3rem; font-size: clamp(1rem, 2.6vmin, 1.4rem); color: rgba(255, 255, 255, 0.82); }
.cel-level {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.45rem 1.3rem;
  border-radius: 999px;
  background: var(--grad-score);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  animation: points-in 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) 0.35s both;
}
.burst { position: absolute; left: 50%; top: 42%; width: 0; height: 0; }
.burst i {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px;
  border-radius: 60% 0 60% 0;
  background: var(--c);
  animation: petal 1.2s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
@keyframes petal {
  0% { transform: translate(0, 0) scale(0.3); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(var(--s)); opacity: 0; }
}
@keyframes pet-pop {
  0% { transform: scale(0.4) translateY(30px); opacity: 0; }
  60% { transform: scale(1.08) translateY(-12px); opacity: 1; }
  100% { transform: none; }
}
@keyframes pet-shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-10px) rotate(-4deg); }
  40% { transform: translateX(9px) rotate(3deg); }
  60% { transform: translateX(-6px) rotate(-2deg); }
  80% { transform: translateX(4px); }
}
@keyframes points-in { from { transform: scale(0.5); opacity: 0; } }

/* ---------- picker ---------- */

.picker-stage {
  --n: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.4rem;
  min-height: 17rem;
  margin-bottom: 1rem;
  padding: 1.5rem 1rem;
  border-radius: 20px;
  background: var(--board);
  color: var(--chalk);
}
.slot { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.slot-pet { width: clamp(5.5rem, calc(26rem / var(--n)), 11rem); }
.slot-pet .pet { border-radius: 50%; background: radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.95), rgba(220, 236, 253, 0.9)); }
.slot-pet.empty {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 3px dashed var(--board-line);
  border-radius: 50%;
  font-family: var(--font-num);
  font-size: 3.5rem;
  color: var(--chalk-3);
}
.slot-name { min-height: 2.4rem; margin-top: 0.4rem; font-size: clamp(1.3rem, calc(4rem / var(--n)), 2.2rem); font-weight: 800; white-space: nowrap; }
.slot.revealed .slot-pet { animation: pet-pop 0.55s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.slot.revealed .slot-name { color: var(--gold); }
.picker-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem 1.6rem; }
.picker-actions { margin-top: 1rem; }
.picker-actions [data-act="reset"] { margin-right: auto; }

/* ---------- timer ---------- */

.timer-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 1.2rem;
  padding: 18px var(--gutter) 2.4rem;
  background: inherit;
  background-color: var(--board);
  color: var(--chalk);
  animation: fade-in 0.16s ease;
}
.timer-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.6rem; }
.timer-face { display: grid; place-items: center; align-content: center; }
.timer-digits {
  font-family: var(--font-num);
  font-size: clamp(5rem, 23vw, 22rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.timer-overlay.urgent .timer-digits { color: #ffb8ad; }
.timer-overlay.done .timer-digits { color: var(--gold); animation: blink 1s steps(2, start) infinite; }
.timer-done-text { display: none; font-size: 2.4rem; font-weight: 800; color: var(--gold); }
.timer-overlay.done .timer-done-text { display: block; }
.timer-overlay .btn.primary { background: var(--gold); color: var(--ink); box-shadow: none; }
.timer-presets { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; min-height: 2.6rem; }
.timer-presets .chip-btn { font-size: 1.05rem; padding: 0.45rem 1.1rem; }
.timer-adjust { display: inline-flex; flex-wrap: wrap; gap: 0.6rem; margin-left: 1.2rem; }
.timer-controls { display: flex; justify-content: center; align-items: center; gap: 1rem; }
.timer-mini {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border: 2px solid var(--chalk-3);
  border-radius: 999px;
  background: var(--board);
  color: var(--chalk);
  font-family: var(--font-num);
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.6);
}
.timer-mini.urgent { color: #ffb8ad; border-color: #ffb8ad; }
.timer-mini.done { color: var(--gold); border-color: var(--gold); animation: blink 1s steps(2, start) infinite; }
body.has-dock .timer-mini, body.has-selectbar .timer-mini { bottom: 6.8rem; }
@keyframes blink { to { opacity: 0.35; } }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .tiles-stat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  :root { --gutter: 14px; --dock-space: 5.8rem; }
  .topbar { gap: 0.45rem 0.75rem; padding-top: 0.45rem; padding-bottom: 0.5rem; }
  .class-btn { font-size: 1.25rem; max-width: 55vw; }
  .top-btn { padding: 0.35rem 0.6rem; }
  .top-btn span { display: none; }
  .tabs { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tab { font-size: 0.98rem; padding: 0.32rem 0.85rem; }
  .dock { left: 8px; right: 8px; bottom: 8px; justify-content: space-around; transform: none; max-width: none; }
  .dock-btn { min-width: 0; flex: 1; font-size: 0.75rem; padding: 0.25rem 0.2rem; }
  .dock-ico { width: 2.2rem; height: 2.2rem; border-radius: 12px; }
  body.has-dock .toasts, body.has-selectbar .toasts, body.has-dock .timer-mini, body.has-selectbar .timer-mini { bottom: 6rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(6.6rem, 1fr)); gap: 0.75rem; }
  .card-name { font-size: 1rem; }
  .two-col, .bars-wrap { grid-template-columns: minmax(0, 1fr); }
  .team-grid { grid-template-columns: minmax(0, 1fr); }
  .podium { gap: 0.6rem; }
  .podium-block { width: 6rem; }
  .podium-pet { width: 5rem; }
  .place-1 .podium-pet { width: 6.5rem; }
  .podium-name { font-size: 1.05rem; }
  .rank-row { grid-template-columns: 1.8rem 2.4rem minmax(0, 1fr) minmax(3rem, 5rem) 3rem; gap: 0.5rem; }
  .rank-counts { display: none; }
  .student-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-row { grid-template-columns: 1.7rem auto minmax(0, 1fr) 2.6rem 1.9rem; }
  .history-row time { display: none; }
  .sheet-student .history-row { grid-template-columns: 1.7rem minmax(0, 1fr) auto 2.6rem 1.9rem; }
  .sheet-student .history-row time { display: inline; font-size: 0.78rem; }
  .timer-adjust { margin-left: 0; }
  .welcome { padding: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .burst { display: none; }
}
