html {
  scroll-behavior: smooth;
}
.plain {
  background: none;
  border: 0;
  color: inherit;
  text-align: left;
  padding: 0;
}
.top {
  gap: 16px;
}
.brand {
  min-width: 0;
  flex: 1;
}
.brand h1 {
  font-size: 21px;
}
.brand small {
  font-size: 11px;
}
.logo {
  flex-shrink: 0;
}
.nav {
  flex: initial;
}
.top button {
  white-space: nowrap;
}
.page {
  display: block;
}
.hero {
  min-height: 220px;
}
.hero h2 {
  font-size: 34px;
}
.hero p {
  max-width: 850px;
  position: relative;
  z-index: 1;
}
.entry .card {
  padding: 20px;
}
.entry p {
  margin: 8px 0 14px;
  color: #5c6580;
}
.entry {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  align-items: start;
}
.entry .card:hover {
  transform: none;
}
.home-student-lookup {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}
.home-lookup-step {
  display: grid;
  gap: 10px;
}
.home-lookup-step > b {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--navy);
  font-size: 16px;
}
.home-lookup-step > b span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold-soft);
  color: #795817;
  font-size: 14px;
}
.home-choice-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  gap: 8px;
}
.home-seat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 8px;
}
.home-choice {
  min-width: 44px;
  min-height: 48px;
  border: 1.5px solid #d9d3c1;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  font-size: 19px;
}
.home-choice:hover {
  border-color: var(--b);
  background: #f3fafb;
}
.home-choice.selected {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  box-shadow: 0 5px 12px rgba(12, 91, 109, 0.2);
}
.home-step-reveal {
  animation: homeReveal 0.18s ease-out both;
}
@keyframes homeReveal {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.home-empty {
  padding: 12px;
  border-radius: var(--r-sm);
  background: #f6f2e8;
  margin: 0 !important;
}
.home-student-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 2px solid #b8ddcd;
  border-radius: var(--r);
  padding: 14px 16px;
  background: linear-gradient(135deg, #eff9f4, #fff);
}
.home-student-result span {
  display: grid;
  gap: 1px;
}
.home-student-result small {
  color: var(--muted);
}
.home-student-result strong {
  font-size: 23px;
  color: var(--navy);
}
.home-student-result .primary {
  min-width: 82px;
}
.home-login-form .field {
  margin: 12px 0;
}
.home-login-form .primary {
  width: 100%;
  margin-top: 8px;
}
.home-login-form > small {
  display: block;
  margin-top: 12px;
  line-height: 1.5;
}
.home-signed-in {
  display: grid;
  gap: 12px;
  padding-top: 10px;
}
.home-signed-in strong {
  font-size: 24px;
  color: var(--navy);
}
.side {
  min-height: 650px;
}
.dash {
  grid-template-columns: 240px minmax(0, 1fr);
}
.side .sl {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  margin: 3px 0;
  transition:
    background 0.15s,
    color 0.15s;
}
.side .sl.active {
  background: #eaf1ff;
}
.side .sl.sports-nav {
  background: var(--gold-soft);
  color: #7a5b1c;
  margin-top: 22px;
  border: 1px solid #ecd9ab;
}
.side .sl.sports-nav:hover {
  background: #f0e2bd;
}
.side small {
  display: block;
  color: var(--muted);
}
.content {
  min-width: 0;
}
.section-title {
  margin: 0 0 8px;
  font-size: 27px;
  font-weight: 800;
  color: var(--navy);
}
.sub {
  color: var(--muted);
  font-size: 14.5px;
  margin: 4px 0 18px;
}
.hint {
  padding: 12px 16px;
  background: #eef3fb;
  border-radius: var(--r-sm);
  font-size: 14.5px;
  margin: 12px 0;
  border: 1px solid #dfe7f6;
}
.warn {
  background: #fdf1d6;
  color: #7a5710;
  border-color: #f0dca4;
}
.notice {
  padding: 11px 24px;
  text-align: center;
  font-size: 14.5px;
  background: #fdefc9;
  color: #6f4f10;
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
}
.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 19px;
  box-shadow: var(--sh-sm);
}
.metric b {
  display: block;
  font-size: 32px;
  color: var(--navy);
}
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 14px 0;
}
.toolbar select,
.toolbar input {
  width: auto;
  max-width: 260px;
}
.toolbar label {
  margin: 0;
}
.danger {
  background: #fbebe9;
  color: #a3372f;
  border: 1px solid #f0c8c4;
  border-radius: var(--r-sm);
  padding: 9px 15px;
  font-weight: 700;
}
.danger:hover {
  background: #f7ddd9;
}
.muted {
  color: var(--muted);
}
.tiny {
  font-size: 12.5px;
}
.small {
  font-size: 14.5px;
}
.positive {
  color: var(--g);
  font-weight: 800;
}
.negative {
  color: #b0453f;
  font-weight: 800;
}
button:disabled {
  cursor: default;
  opacity: 0.5;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
.panel {
  margin-bottom: 18px;
}
.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
}
.modal {
  max-height: 90dvh;
  overflow: auto;
}
.modal h2 {
  margin-top: 0;
  color: var(--navy);
}
.modalbg {
  backdrop-filter: blur(3px);
}
.modal .close {
  float: right;
}
.import-drop {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  padding: 18px;
  border: 2px dashed var(--line);
  border-radius: var(--r-md);
  background: var(--soft);
}
.import-drop input {
  margin: 0;
}
.import-preview {
  margin-top: 14px;
  max-height: 360px;
  overflow: auto;
}
.field {
  margin: 15px 0;
}
.field small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-weight: 400;
}
textarea {
  font: inherit;
  width: 100%;
  border: 1px solid #dcd4bd;
  border-radius: var(--r-sm);
  padding: 12px;
  resize: vertical;
  background: #fffefb;
}
textarea:focus {
  outline: none;
  border-color: var(--b);
  box-shadow: 0 0 0 3px #2f6fb02a;
}
input[type="checkbox"] {
  width: 19px;
  height: 19px;
  vertical-align: middle;
  accent-color: var(--b);
}

.pickers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  gap: 10px;
}
.pick {
  padding: 14px 10px;
  border-radius: var(--r-sm);
  border: 1.5px solid #e2dcc9;
  background: #fff;
  color: var(--ink);
  min-height: 60px;
  font-weight: 700;
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.1s;
}
.pick:hover {
  border-color: var(--gold);
}
.pick.selected {
  background: #eaf3ec;
  border: 2px solid var(--g);
  padding: 13px 9px;
}
.pick.completed {
  background: #f2f1ec;
  color: #84806f;
  border-color: #e6e1d3;
  opacity: 1;
}
.pick .seat {
  font-size: 12.5px;
  color: var(--muted);
  display: block;
}
.grade-row {
  display: flex;
  gap: 12px;
  margin: 14px 0;
}
.grade {
  width: 62px;
  height: 56px;
  font-size: 24px;
  border-radius: var(--r-sm);
  border: 1.5px solid #e2dcc9;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  transition:
    background 0.15s,
    color 0.15s;
}
.grade.selected {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.grade:disabled {
  opacity: 0.3;
}
.progress-track {
  height: 12px;
  background: #eee8d8;
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: 10px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--g), #54b581);
  border-radius: var(--r-pill);
}
.medals {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.medal {
  border: 1px solid var(--gold-2);
  border-radius: var(--r-sm);
  background: var(--gold-soft);
  padding: 15px;
  text-align: center;
  min-width: 110px;
}
.medal .symbol {
  font-size: 30px;
}
.history-table tr.void {
  color: #9a927e;
}
.history-table tr.void .reason {
  text-decoration: line-through;
}
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 16px 0;
}
.tabs button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 15px;
  color: var(--ink);
  font-weight: 600;
  transition:
    background 0.15s,
    color 0.15s;
}
.tabs button.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.setting-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px 90px;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line-2);
  padding: 14px 0;
}
.setting-row label {
  margin: 0;
}
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  white-space: nowrap;
}
.switch input {
  width: 40px;
  height: 23px;
  appearance: none;
  background: #d4cdb8;
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.switch input:checked {
  background: var(--g);
}
.switch input:after {
  content: "";
  position: absolute;
  width: 17px;
  height: 17px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: white;
  transition: left 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.switch input:checked:after {
  left: 20px;
}
.setting-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}
.setting-card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 17px;
  background: #fff;
}
.setting-card h3 {
  margin: 0 0 10px;
  color: var(--navy);
}
.code {
  font-family: monospace;
  font-size: 19px;
  letter-spacing: 1px;
}
.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-xs);
  background: #eef3f8;
  font-size: 12.5px;
}

/* ---------- sports registration station ---------- */
.station-shell {
  max-width: 1500px;
  margin: 18px auto;
  padding: 0 20px;
}
.station-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.station-head h2 {
  margin: 0;
  font-size: 24px;
  color: var(--navy);
}
.station-head small {
  color: var(--muted);
}
.station {
  display: grid;
  grid-template-columns: 32% minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100dvh - 210px);
}
.station-left,
.station-right {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--sh-sm);
}
.station-left h3,
.station-right h3 {
  margin: 0 0 14px;
  font-size: 19px;
  color: var(--navy);
}
.activity-list {
  display: grid;
  gap: 12px;
}
.activity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 105px;
  border: 2px solid #e6e0cf;
  border-radius: var(--r);
  background: #fefdf9;
  text-align: left;
  padding: 16px;
  color: var(--ink);
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.1s;
}
.activity:hover {
  transform: translateY(-1px);
}
.activity.selected {
  background: #e9f3ec;
  border-color: var(--g);
}
.activity .icon {
  font-size: 40px;
  min-width: 54px;
  text-align: center;
}
.activity strong {
  font-size: 22px;
  display: block;
}
.activity small {
  display: block;
  font-size: 13.5px;
  color: #7c8698;
}
.activity .pts {
  margin-left: auto;
  font-weight: 800;
  white-space: nowrap;
  color: #2a7a51;
}
.station-right {
  display: flex;
  flex-direction: column;
}
.station-right .pickers {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  flex: 1;
}
.station-right .pick {
  min-height: 76px;
  font-size: 20px;
}
.station-bottom {
  display: flex;
  gap: 15px;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 20px;
}
.finish {
  min-width: 150px;
  min-height: 64px;
  font-size: 24px;
  background: linear-gradient(135deg, var(--g), #357a55);
  color: #fff;
}
.station-placeholder {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: #96907d;
  min-height: 220px;
}
.feedback {
  position: fixed;
  inset: 0;
  background: #f7fbf6f5;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 30px;
  text-align: center;
  backdrop-filter: blur(4px);
}
.feedback .big {
  font-size: 150px;
  line-height: 1.15;
  font-weight: 800;
  color: var(--g);
}
.feedback.failed {
  background: #fdf5f4f5;
}
.feedback.failed .big {
  color: #c0554e;
}
.feedback h2 {
  font-size: 32px;
  margin: 12px;
  color: var(--navy);
}
.feedback p {
  font-size: 22px;
  margin: 5px;
}
.feedback .toolbar {
  justify-content: center;
}
.spinner {
  height: 48px;
  width: 48px;
  border: 5px solid #e6e0cf;
  border-top-color: var(--b);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: var(--navy-3);
  color: white;
  padding: 13px 24px;
  border-radius: var(--r-pill);
  display: none;
  max-width: 90vw;
  box-shadow: var(--sh-lg);
}
#toast.show {
  display: block;
}
#printRoot {
  display: none;
}
.report-preview {
  background: white;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.report-preview h2 {
  text-align: center;
  color: var(--navy);
}
.report-preview table {
  font-size: 14px;
  min-width: 600px;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.photo-grid img {
  width: 100%;
  height: 180px;
  object-fit: contain;
}
.period-chip {
  background: #eef3fb;
  border-radius: var(--r-xs);
  padding: 8px 12px;
  font-size: 14.5px;
}
.form-error {
  color: #a93a2f;
  background: #fbeae7;
  padding: 12px;
  border-radius: var(--r-sm);
  margin-top: 12px;
}
.demo-tag {
  font-size: 11.5px;
  background: var(--gold-soft);
  color: #7a5b1c;
  padding: 3px 7px;
  border-radius: 5px;
}
.save-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  position: sticky;
  bottom: 0;
  background: #f8f5eef0;
  padding: 16px 0;
  margin-top: 15px;
  border-top: 1px solid var(--line);
}

@media (max-width: 1100px) {
  .dash {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  .side {
    min-height: auto;
  }
  .station {
    grid-template-columns: 32% minmax(0, 1fr);
  }
  .station-right .pickers {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .brand small {
    display: none;
  }
  .activity strong {
    font-size: 20px;
  }
  .activity .icon {
    font-size: 32px;
    min-width: 40px;
  }
  .activity {
    padding: 12px;
    gap: 8px;
  }
  .cards {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 700px) {
  .top {
    padding: 10px 14px;
    gap: 10px;
  }
  .brand h1 {
    font-size: 15px;
  }
  .brand .logo {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
  .top .nav {
    display: none;
  }
  .dash {
    grid-template-columns: 1fr;
  }
  .side {
    padding: 10px;
  }
  .side .sg {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 6px;
  }
  .side .st {
    width: 100%;
    font-size: 13.5px;
  }
  .side .sl {
    width: auto;
    font-size: 13.5px;
    margin: 0;
  }
  .side .sl.sports-nav {
    margin: 8px 0;
  }
  .hero h2 {
    font-size: 27px;
  }
  .hero p {
    font-size: 17px;
  }
  .hero:after {
    display: none;
  }
  .entry h3 {
    font-size: 21px;
  }
  .cards {
    grid-template-columns: 1fr 1fr;
  }
  .setting-grid {
    grid-template-columns: 1fr;
  }
  .setting-row {
    grid-template-columns: 1fr 85px 66px;
    gap: 8px;
  }
  .station-shell {
    padding: 0 10px;
  }
  .station {
    grid-template-columns: 34% minmax(0, 1fr);
    gap: 9px;
  }
  .station-left,
  .station-right {
    padding: 10px;
    border-radius: var(--r-sm);
  }
  .activity {
    flex-direction: column;
    gap: 4px;
    text-align: center;
    min-height: 120px;
    padding: 10px 5px;
  }
  .activity .pts {
    margin: 0;
  }
  .activity small {
    display: none;
  }
  .activity strong {
    font-size: 17px;
  }
  .grade-row {
    gap: 5px;
    flex-wrap: wrap;
  }
  .grade {
    width: 40px;
    height: 42px;
    font-size: 21px;
  }
  .station-right .pickers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }
  .station-right .pick {
    font-size: 16px;
    min-height: 66px;
  }
  .station-head h2 {
    font-size: 19px;
  }
  .station-head {
    flex-wrap: wrap;
  }
  .station-bottom {
    flex-direction: column;
    align-items: stretch;
  }
  .finish {
    width: 100%;
    min-width: 0;
  }
  .station-left h3,
  .station-right h3 {
    font-size: 15px;
  }
  .feedback .big {
    font-size: 105px;
  }
  .row {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
  }
}
@media print {
  @page {
    size: A4;
    margin: 14mm;
  }
  body {
    background: white;
    font:
      11pt/1.5 "Noto Sans TC",
      "Microsoft JhengHei",
      sans-serif;
  }
  body > * {
    display: none !important;
  }
  #printRoot {
    display: block !important;
    color: #111;
  }
  #printRoot table {
    min-width: 0 !important;
    width: 100%;
    font-size: 9pt;
  }
  #printRoot th,
  #printRoot td {
    padding: 6px 5px;
    border: 1px solid #ccc;
  }
  #printRoot thead {
    display: table-header-group;
  }
  #printRoot tr {
    break-inside: avoid;
  }
  #printRoot h2 {
    font-size: 18pt;
    text-align: center;
  }
  #printRoot h3 {
    break-after: avoid;
  }
  #printRoot .photo-grid img {
    height: 160px;
  }
  .no-print {
    display: none !important;
  }
  .page-break {
    break-before: page;
  }
}

/* Tablet station: keep the finish button in view while long class lists scroll. */
body.station-mode {
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.station-mode .top {
  flex: 0 0 auto;
  position: relative;
}
.station-mode #connection,
.station-mode .footer {
  display: none;
}
.station-mode #main {
  flex: 1;
  min-height: 0;
  display: flex;
}
.station-mode .station-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 12px auto;
}
.station-mode .station-head {
  flex: 0 0 auto;
}
.station-mode .station {
  flex: 1;
  min-height: 0;
}
.station-mode .station-left {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.station-mode .station-right {
  min-height: 0;
  overflow: hidden;
}
.station-mode .station-right .pickers {
  overflow: auto;
  min-height: 0;
  padding: 3px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.station-mode .activity-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 3px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.station-mode .station-right > h3,
.station-mode .station-right > .tiny {
  flex: 0 0 auto;
}
.station-mode .station-ordered .station-left .grade-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  overflow: visible;
}
.station-mode .station-ordered .station-left .grade {
  width: 100%;
  min-width: 0;
  max-width: none;
}
.station-mode .station-placeholder {
  min-height: 0;
}
.station-mode .station-bottom {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--panel);
  padding-bottom: max(4px, env(safe-area-inset-bottom));
}
.station-mode #syncStatus {
  flex: 0 0 auto;
  margin: 6px 0 0;
}

/* The home page is visible before the first state request finishes. */
.login-skeleton {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.login-skeleton span {
  display: block;
  height: 46px;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, #f1eee6 25%, #faf8f2 45%, #f1eee6 65%);
  background-size: 240% 100%;
  animation: login-loading 1.2s ease-in-out infinite;
}
.login-skeleton span:last-child {
  width: 120px;
  border-radius: var(--r-pill);
  background-color: #dce9f7;
}
@keyframes login-loading {
  to { background-position: -160% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .login-skeleton span { animation: none; }
}

/* Keep the footer anchored to the viewport floor on short pages. */
html {
  min-height: 100%;
}
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
#main {
  flex: 1 0 auto;
  width: 100%;
}
.footer {
  margin-top: auto;
  flex: 0 0 auto;
}

/* Permission controls and the student-first sports registration order. */
.title-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}
.permission-toggle {
  border: 1px solid #ded6ba;
  background: #f4efe0;
  color: #7c7256;
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-weight: 800;
  min-width: 92px;
}
.permission-toggle.on {
  background: #e6f3ea;
  border-color: #83b399;
  color: #2f7650;
}
.permission-toggle small {
  display: block;
  font-size: 10px;
  font-weight: 500;
}
.activity.completed {
  background: #f2f1ec;
  border-color: #e6e1d3;
  color: #89846f;
  opacity: 1;
}
.activity.completed .pts {
  color: #89846f;
}
.station-ordered .station-left .pickers {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.station-ordered .station-left .pick {
  min-height: 70px;
  font-size: 17px;
}
@media (max-width: 700px) {
  .title-row {
    align-items: stretch;
    flex-direction: column;
  }
  .station-ordered .station-left .pickers {
    grid-template-columns: 1fr;
  }
  .station-ordered .station-left .pick {
    font-size: 14px;
    padding: 8px;
  }
}

.policy-page {
  max-width: 1120px;
  padding-bottom: 32px;
}
.policy-index {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
}
.policy-index a {
  display: inline-block;
  padding: 10px 15px;
  background: #eef3ea;
  color: #28603c;
  border: 1px solid #d6e6d8;
  border-radius: var(--r-sm);
  text-decoration: none;
  font-weight: 600;
}
.policy-index a:hover {
  background: #deebe0;
}
.policy-topic {
  scroll-margin-top: 100px;
  margin-top: 22px;
  border-top: 4px solid var(--gold-2);
}
.policy-topic h2 {
  font-size: 21px;
  margin: 0 0 10px;
  color: var(--navy);
}
.policy-topic h3 {
  margin-top: 22px;
  color: var(--navy);
}
.policy-list {
  padding-left: 22px;
  line-height: 1.9;
}
.policy-list li {
  margin: 8px 0;
}
.policy-topic td:first-child {
  white-space: normal;
  min-width: 150px;
}
.policy-topic .hint {
  margin-top: 18px;
}
.auth-page {
  max-width: 650px;
  margin: 36px auto;
}
.auth-page input[type="password"] {
  font-size: 22px;
  letter-spacing: 3px;
}
.auth-page .panel {
  margin-top: 18px;
}
.login-paused {
  background: linear-gradient(135deg, #f2f0e6, #fff) !important;
  color: #726c58;
}
.login-paused button {
  width: 100%;
  color: #726c58;
  background: #eeece2;
}
.trial-start {
  padding: 24px 26px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #eef4fb, #fff 60%);
  border-color: #d3e2f2;
}
.trial-start h2 {
  margin: 6px 0;
  font-size: 25px;
  color: var(--navy);
}
.trial-start p {
  margin: 0;
  color: #586780;
}
.trial-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.trial-actions button {
  border: 1px solid #dbe4ee;
  background: #fff;
  color: var(--ink);
  border-radius: var(--r);
  padding: 15px;
  text-align: left;
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.1s;
}
.trial-actions button:hover {
  border-color: var(--b);
  background: #f4f8fd;
  transform: translateY(-2px);
}
.trial-actions .badge-path {
  border-color: var(--gold-2);
  background: var(--gold-soft);
}
.trial-actions b,
.trial-actions small {
  display: block;
}
.trial-actions b {
  font-size: 16.5px;
}
.trial-actions small {
  color: #6d7c86;
  margin-top: 4px;
  font-size: 12.5px;
}

/* Clear hierarchy for staff navigation. */
.side .menu-group-title {
  color: #7c7462;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 2px 4px 8px;
  text-transform: none;
}
.side .sl {
  color: #3d4560;
  border-left: 3px solid transparent;
  padding-left: 12px;
}
.side .sl.active {
  color: #164e88;
  background: #e6f0ff;
  border-left-color: var(--b);
}
.side .sl:not(.active):hover {
  background: #f3f0e6;
  color: #28304a;
}

/* One reusable grade-and-name picker for point entry and certification. */
.student-select-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}
.student-picker-grades {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.student-picker-grades .grade {
  width: 52px;
  height: 46px;
  font-size: 20px;
}
.student-picker-names .pickers {
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
}
.student-picker-names .pick {
  min-height: 66px;
}
.certification-panel {
  max-width: 980px;
}
.compact-field {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
}
.compact-field select {
  width: min(280px, 70vw);
}
.certify-equation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  background: #f5f1e6;
  border: 1px solid #e9e0c8;
  border-radius: var(--r);
  margin-top: 20px;
  padding: 22px;
  font-size: 17px;
}
.certify-equation i {
  font-size: 26px;
  font-style: normal;
  color: #8a8267;
}
.certify-equation label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.certify-equation input {
  width: 100px;
  font-size: 21px;
  text-align: center;
}
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}

/* Keep the long policy's topic controls available while reading. */
.policy-index {
  position: sticky;
  top: 81px;
  z-index: 18;
  flex-wrap: nowrap;
  overflow-x: auto;
  white-space: nowrap;
  background: #f8f5eef2;
  padding: 10px 0;
  margin: 14px 0 20px;
  box-shadow: 0 8px 12px -12px rgba(25, 25, 15, 0.3);
  backdrop-filter: blur(8px);
}
.policy-topic {
  scroll-margin-top: 160px;
}

@media (max-width: 700px) {
  .side .menu-group-title {
    width: 100%;
    margin-top: 6px;
    color: #736b58;
  }
  .side .sl {
    border-left: 0;
    border-bottom: 3px solid transparent;
    padding: 8px 10px;
  }
  .side .sl.active {
    border-bottom-color: var(--b);
  }
  .policy-index {
    top: 59px;
  }
  .policy-topic {
    scroll-margin-top: 140px;
  }
  .student-select-title {
    align-items: flex-start;
  }
  .certify-equation {
    gap: 10px;
    font-size: 15px;
    padding: 16px;
  }
  .certify-equation i {
    font-size: 21px;
  }
}
@media (max-width: 700px) {
  .trial-actions {
    grid-template-columns: 1fr;
  }
  .trial-start {
    padding: 20px;
  }
  .trial-start h2 {
    font-size: 21px;
  }
}

/* Trial issue reporter and root-only dashboard */
.odd-flag {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  border: 1px solid #e7a43b;
  background: #fff8e8;
  color: #744600;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 800;
  box-shadow: 0 8px 24px #4b35152e;
}
.odd-flag[hidden] {
  display: none;
}
.issue-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.issue-summary .card {
  padding: 16px;
  display: grid;
  gap: 4px;
}
.issue-summary b {
  font-size: 28px;
  color: var(--b);
}
.issue-status {
  white-space: nowrap;
  font-weight: 700;
}
.issue-error td:first-child,
.issue-critical td:first-child {
  border-left: 4px solid #c83c3c;
}
.issue-warning td:first-child {
  border-left: 4px solid #df9b22;
}
@media (max-width: 760px) {
  .issue-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .odd-flag {
    right: 12px;
    bottom: 12px;
  }
}
@media (max-width: 700px) {
  .entry {
    grid-template-columns: 1fr;
  }
  .home-choice-row {
    grid-template-columns: repeat(6, minmax(38px, 1fr));
    gap: 6px;
  }
  .home-choice {
    min-width: 38px;
    padding: 7px;
  }
  .home-student-result {
    padding: 12px;
  }
  .home-student-result strong {
    font-size: 21px;
  }
}
.school-year-side {
  margin: -4px -4px 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #e6f5f4;
  color: #075c68;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.04em;
}

/* v2.1: student-number identity and compact administration forms */
.home-student-list{display:grid;gap:10px;max-height:330px;overflow:auto;padding-right:4px}
.home-login-form>.primary{margin-bottom:20px}
.login-secondary-actions{display:flex;gap:14px;align-items:center;justify-content:space-between}
.reason-inline{display:grid;grid-template-columns:repeat(3,minmax(150px,1fr)) minmax(190px,.8fr) minmax(180px,1fr);gap:12px;align-items:end}
.points-control>span:last-child{display:flex;align-items:center;gap:7px}
.points-control input{width:86px;text-align:center}
.round-sign{width:34px;height:34px;border-radius:50%;border:2px solid #d9e6e8;background:#eef7f7;color:var(--b);font-size:21px;padding:0}
.round-sign.active{background:var(--b);color:#fff;border-color:var(--b)}
.roster-groups{display:grid;gap:18px}
.roster-grade h3{margin-top:0;padding:12px 16px;border:1px solid #ddd2b4;border-radius:18px;background:#fbfaf4}
.student-edit-rows{display:grid;gap:12px;margin:16px 0}
.student-edit-row{display:grid;grid-template-columns:1fr 1fr auto;gap:14px;align-items:end}
.student-edit-row>label{padding-bottom:14px;white-space:nowrap}
.quantity-unit{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.icon-danger{border:0;background:transparent;color:#a63838;font-size:19px;padding:6px;cursor:pointer}
.branding-schedule{margin-top:22px}
@media(max-width:1100px){.reason-inline{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:700px){.reason-inline,.student-edit-row{grid-template-columns:1fr}.login-secondary-actions{align-items:stretch;flex-direction:column}.login-secondary-actions button{width:100%}}
.student-code {
  font-size: 15px !important;
  font-weight: 800;
}
.modal .close {
  color: #17253a !important;
  border-color: #526172 !important;
  background: #fff !important;
  font-size: 18px !important;
}
.reason-item-select {
  font-family: ui-monospace, "Noto Sans Mono CJK TC", monospace;
  font-variant-numeric: tabular-nums;
}
.hidden {
  display: none !important;
}
.favorite-choices {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}
.favorite-choices label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid #d7e1e5;
  border-radius: 10px;
}
.activity-target details {
  position: relative;
}
.activity-target summary {
  padding: 11px;
  border: 1px solid #ccd8dc;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}
.grade-checks {
  position: absolute;
  z-index: 5;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  padding: 10px;
  background: #fff;
  border: 1px solid #bccbd0;
  border-radius: 10px;
  box-shadow: 0 10px 25px #17384626;
  display: grid;
  gap: 7px;
}
.reason-category-input {
  margin-bottom: 6px;
  background: #f1f0ff !important;
  border-color: #c4bce8 !important;
  font-weight: 800;
}
.achievement-add-top {
  display: block;
  margin: -48px 10px 18px auto;
  position: relative;
}
.gift-grid {
  display: grid;
  gap: 12px;
}
.gift-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid #d9e4e5;
  border-radius: 12px;
}
.gift-card div {
  display: grid;
}
.gift-card small {
  color: #65757b;
}
.ph > .outline[data-action="downloadRosterExample"] {
  background: var(--primary, #0d7180);
  border-color: var(--primary, #0d7180);
  color: #fff;
}
/* v2.2 共用班級、學生與報表元件 */
.picker-class{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.picker-class label{display:grid;gap:6px}.student-card-grid,.home-student-list{display:grid!important;grid-template-columns:repeat(5,minmax(0,1fr));gap:12px}.home-student-result{display:flex;min-width:0;flex-direction:column;align-items:center;justify-content:center;gap:4px;border:1px solid var(--line);border-radius:14px;background:var(--surface,#fff);padding:12px;min-height:72px;color:var(--text)}.home-student-result.selected{border:2px solid var(--b);background:#e8f4ff}.home-enter-row{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));justify-content:end;margin-top:14px}.home-enter-row button{grid-column:5}.login-secondary-actions.two{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;margin-top:18px}.login-secondary-actions.two button{width:100%}.five-equal{display:grid!important;grid-template-columns:repeat(5,minmax(0,1fr));gap:12px}.points-readonly{display:flex;align-items:center;min-height:44px;border:1px solid var(--line);border-radius:12px;padding:0 12px;font-weight:800;background:#f4f7f8}.spaced-summary{margin-top:18px}.quick-reasons{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px}.class-edit-grid{display:grid;gap:12px}.class-name-row{display:grid;grid-template-columns:minmax(150px,.8fr) auto minmax(160px,1fr) 80px 40px;gap:10px;align-items:end}.class-name-row label{display:grid;gap:5px}.class-name-row .suffix{padding-bottom:13px}.saved-class-summary{display:grid;gap:8px;margin:18px 0;padding:14px;border-radius:14px;background:#f4f8f5}.saved-class-summary b{color:#21825b}.action-gap{display:flex;gap:18px}.student-edit-row{grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto!important;gap:14px!important}.unit-layout{display:grid;grid-template-columns:240px minmax(0,1fr);gap:20px}.saved-unit-summary{display:grid;align-content:start;gap:8px}.saved-unit-summary button{display:grid;text-align:left;gap:3px;border:1px solid var(--line);border-radius:12px;padding:12px;background:#fff}.saved-unit-summary button.selected{border-color:var(--b);background:#e8f4ff}.reason-category{border:1px solid var(--line);border-radius:14px;padding:14px;margin-bottom:14px}.activity-image-preview img{width:100px;height:80px;object-fit:cover;border-radius:12px}.activity-list{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;overflow:auto;min-height:0}.activity-list .activity{display:grid;grid-template-rows:110px auto;padding:0;overflow:hidden}.activity-list .activity>img,.activity-image-placeholder{width:100%;height:110px;object-fit:cover;background:linear-gradient(135deg,#dff4fa,#eef7f3)}.activity-list .activity>span:last-child{display:flex;justify-content:space-between;gap:8px;padding:12px}.station-today{margin-top:14px;border-top:1px solid var(--line);padding-top:10px;max-height:170px;overflow:auto}.station-today>div{display:grid;grid-template-columns:70px 1fr auto;gap:10px;padding:6px 0;border-bottom:1px solid #eee}.report-filter-row{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:12px;align-items:end}.report-filter-row label{display:grid;gap:5px}.check-inline{display:flex!important;flex-direction:row;align-items:center;padding-bottom:12px}.report-type-flow{display:flex;align-items:center;gap:12px;margin-top:16px}.report-type-buttons{display:flex;flex:1;flex-wrap:wrap;gap:8px}.report-type-buttons button.selected{background:var(--b);color:white}.report-actions{display:flex;justify-content:flex-end;gap:10px;margin-bottom:12px}.report-chart>div{display:grid;grid-template-columns:140px 1fr 70px;gap:8px;align-items:center;margin:7px 0}.report-chart i{height:18px;background:var(--b);border-radius:9px}.report-generated{text-align:right;margin-top:28px}.signature-row{display:grid;grid-template-columns:repeat(3,1fr);gap:24px;margin-top:20px}.pre{white-space:pre-wrap}
@media(max-width:900px){.student-card-grid,.home-student-list{grid-template-columns:repeat(3,minmax(0,1fr))}.home-enter-row{grid-template-columns:repeat(3,minmax(0,1fr))}.home-enter-row button{grid-column:3}.five-equal,.report-filter-row{grid-template-columns:repeat(2,minmax(0,1fr))}.unit-layout{grid-template-columns:1fr}.saved-unit-summary{grid-template-columns:repeat(2,minmax(0,1fr))}.activity-list{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:600px){.student-card-grid,.home-student-list{grid-template-columns:repeat(2,minmax(0,1fr))}.home-enter-row{grid-template-columns:repeat(2,minmax(0,1fr))}.home-enter-row button{grid-column:2}.picker-class,.five-equal,.report-filter-row{grid-template-columns:1fr}.activity-list{grid-template-columns:1fr}.class-name-row{grid-template-columns:1fr auto}.class-name-row output,.class-name-row>span:not(.suffix){grid-column:1/-1}.saved-unit-summary{grid-template-columns:1fr}.signature-row{grid-template-columns:1fr}}

/* 運動卡片依內容高度排列，避免被右欄剩餘高度拉成長條。 */
.station-mode .activity-list{
  flex:0 1 auto;
  max-height:min(420px,44dvh);
  align-content:start;
  grid-auto-rows:max-content;
}
.station-mode .activity-list .activity{
  min-height:0;
  height:auto;
  align-self:start;
}

/* 固定運動登錄的學生、得分與確認按鈕，不受今日紀錄筆數影響。 */
.station-mode .station-bottom{
  margin-top:auto;
  width:100%;
}
.station-mode .station-today{
  flex:0 1 170px;
  min-height:0;
}

/* 登錄與補登頁的五欄控制項維持相同高度。 */
.five-equal select,
.five-equal input,
.five-equal .points-readonly{
  height:52px;
  min-height:52px;
}

/* 運動任務圖片固定為 1:1，完整顯示、不裁切。 */
.activity-image-preview img{width:100px;height:100px;object-fit:contain}
.activity-list .activity{grid-template-rows:auto auto}
.activity-list .activity>img,.activity-image-placeholder{display:block;width:100%;height:auto;aspect-ratio:1/1;object-fit:contain}

/* 創世管理員可就地調整顯示文字，不更動內部功能代碼。 */
.ui-text-editing [data-ui-phrase]{outline:2px dashed #f59e0b;outline-offset:3px;cursor:text;border-radius:4px}
.ui-text-editor-bar{position:fixed;z-index:1200;left:50%;bottom:18px;transform:translateX(-50%);display:flex;align-items:center;gap:14px;max-width:calc(100vw - 32px);padding:12px 16px;border-radius:16px;background:#fff7df;box-shadow:0 10px 35px #102c3a44;border:1px solid #e9bd54;color:#49370f}
.ui-text-editor-bar span{white-space:nowrap}
@media(max-width:700px){.ui-text-editor-bar{align-items:stretch;flex-direction:column}.ui-text-editor-bar span{white-space:normal}}

/* 班級編輯：年級、班名與新增按鈕同列等寬；摘要左右分區。 */
.class-editor-controls{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;align-items:end}
.class-editor-controls>label{display:grid;gap:6px}
.class-editor-controls>button{width:100%;height:52px}
.class-name-entry{display:grid;grid-template-columns:1fr auto;gap:8px;align-items:center}
.class-summary-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.class-summary-grid .saved-class-summary{align-content:start}
.class-summary-grid h4{margin:0 0 8px}
.class-draft-row{display:grid;grid-template-columns:minmax(120px,1fr) minmax(150px,1fr) 70px 38px;gap:10px;align-items:center}
.class-draft-row>div{display:grid;grid-template-columns:1fr auto;align-items:center;gap:6px}
.class-draft-row input{min-width:0}
@media(max-width:800px){.class-editor-controls,.class-summary-grid{grid-template-columns:1fr}.class-draft-row{grid-template-columns:1fr auto}.class-draft-row output,.class-draft-row>span{grid-column:1/-1}}
