:root {
  color-scheme: light;
  --background: #f4f6fa;
  --white: #fff;
  --ink: #15233b;
  --muted: #52627b;
  --faint: #e0e6ef;
  --line: #d6deeb;
  --accent: #224fb9;
  --accent-dark: #173e9b;
  --accent-light: #edf3ff;
  --success: #156549;
  --success-bg: #e7f5ee;
  --error: #a52c3a;
  --shadow: 0 8px 22px rgba(34, 53, 89, 0.045);
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); line-height: 1.55; }
button, input { font: inherit; }
button, summary { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }
button, a, summary, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: clamp(1.45rem, 2.35vw, 1.95rem); line-height: 1.38; font-weight: 700; }
h2 { font-size: 1rem; line-height: 1.45; font-weight: 700; }

.masthead { background: var(--white); border-bottom: 1px solid var(--faint); }
.masthead-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 13px 28px;
  min-height: 67px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.masthead-title {
  font-size: clamp(0.89rem, 1.65vw, 1.12rem);
  font-weight: 750;
  line-height: 1.35;
  color: #163267;
  padding-left: 13px;
  border-left: 3px solid var(--accent);
}
.session-controls { display: flex; align-items: center; gap: 12px; flex: none; }
.session-controls:empty { display: none; }
.session-role { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }

.page { width: min(100%, 1240px); padding: 28px 28px 48px; margin: 0 auto; }
.panel {
  background: var(--white);
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.loading { color: var(--muted); text-align: center; margin: 55px auto; }
.button {
  min-height: 39px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
  background: transparent;
  text-decoration: none;
  font-size: 0.86rem;
}
.primary { background: var(--accent); border-color: var(--accent); color: var(--white); }
.primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.secondary { background: var(--white); border-color: var(--line); }
.secondary:hover:not(:disabled), .ghost:hover:not(:disabled) { background: var(--accent-light); color: var(--accent-dark); }
.ghost { color: var(--accent-dark); }
.form-message {
  min-height: 1.3em;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}
.form-message:empty { min-height: 0; }
.form-message.error { color: var(--error); }

.login-page { display: grid; justify-items: center; padding-top: clamp(52px, 12vh, 119px); }
.login-panel { width: min(100%, 406px); padding: 32px clamp(21px, 6vw, 33px) 35px; }
.login-panel h1 { margin-bottom: 26px; font-size: 1.6rem; }
#login-form { display: grid; gap: 18px; }
.login-field { display: grid; gap: 7px; font-size: 0.88rem; font-weight: 650; }
.login-field input {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 46px;
  width: 100%;
  padding: 9px 12px;
  background: #fbfcff;
  color: var(--ink);
  font-size: 1rem;
}
.login-submit { min-height: 44px; }
#login-error:empty { display: none; }

.judge-page { display: grid; grid-template-columns: minmax(250px, 304px) minmax(0, 1fr); align-items: start; gap: 20px; }
.project-rail { position: sticky; top: 18px; min-width: 0; }
.rail-header { padding: 16px 15px 13px; display: grid; gap: 10px; border-bottom: 1px solid var(--faint); }
.rail-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.rail-heading > span { white-space: nowrap; font-size: 0.8rem; color: var(--muted); }
.rail-heading strong { color: var(--accent-dark); }
progress { width: 100%; height: 6px; display: block; appearance: none; border: 0; border-radius: 12px; background: var(--accent-light); color: var(--accent); }
progress::-webkit-progress-bar { background: var(--accent-light); border-radius: 12px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 12px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 12px; }
.project-list { max-height: min(68vh, 634px); overflow-y: auto; scrollbar-width: thin; padding: 7px; overscroll-behavior: contain; }
.project-button {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) 15px;
  gap: 7px;
  padding: 10px 8px;
  min-height: 46px;
  width: 100%;
  text-align: left;
  background: transparent;
  border-radius: 7px;
  border: 1px solid transparent;
  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1.48;
}
.project-button:hover { background: #f5f7fc; }
.project-button[aria-current] { background: var(--accent-light); color: var(--accent-dark); border-color: #d7e4ff; }
.project-button[aria-current] .project-name { font-weight: 670; }
.project-number { color: var(--muted); font-size: 0.75rem; line-height: 1.7; font-variant-numeric: tabular-nums; }
.project-name { overflow-wrap: anywhere; }
.project-done { color: var(--success); font-weight: 700; }

.rating-panel { overflow: hidden; }
.rating-head, .form-section, .form-footer { padding: 22px clamp(19px, 2.9vw, 30px); }
.rating-head { display: grid; gap: 8px; padding-top: 24px; padding-bottom: 18px; }
.project-heading, .section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.section-index { font-size: 0.8rem; color: var(--muted); }
.status-pill {
  color: var(--muted);
  background: #eff2f8;
  border-radius: 99px;
  padding: 3px 9px;
  font-size: 0.75rem;
  font-weight: 650;
  white-space: nowrap;
}
.status-pill.good { color: var(--success); background: var(--success-bg); }
.project-info, .standards { font-size: 0.83rem; }
.project-info { margin-top: 4px; }
details summary { cursor: pointer; width: max-content; color: var(--accent-dark); font-weight: 630; }
details[open] > summary { margin-bottom: 10px; }
.project-info dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  color: var(--muted);
  padding: 11px 13px;
  background: var(--background);
  border-radius: 8px;
}
.project-info dt { font-size: 0.75rem; }
.project-info dd { overflow-wrap: anywhere; color: var(--ink); }
.form-section, .form-footer { border-top: 1px solid var(--faint); }
.section-heading { margin-bottom: 13px; }
.section-heading > span { color: var(--muted); font-size: 0.83rem; white-space: nowrap; }
.section-heading output { color: var(--accent-dark); font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.section-note { margin: -4px 0 14px; color: var(--muted); font-size: 0.82rem; }

.score-cards { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 860px) {
  .score-cards { grid-template-columns: 1fr 1fr; }
}
.score-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 16px 16px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfcff 0%, #f7f9fd 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset;
}
.score-card.is-unset { background: #fbfcff; }
.score-card:has([aria-invalid]) { border-color: var(--error); }
.score-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.score-card-head h3 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 780;
  line-height: 1.3;
}
.score-now {
  margin: 0;
  color: var(--accent-dark);
  font-size: 1.85rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}
.score-now.unset { color: var(--muted); font-size: 1.45rem; font-weight: 750; }
.score-max { margin-left: 2px; color: var(--muted); font-size: 0.78rem; font-weight: 550; }

.score-slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 10px;
  align-items: center;
}
.score-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 36px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.score-slider:focus-visible { outline: none; }
.score-slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(34, 79, 185, 0.22); }
.score-slider:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px rgba(34, 79, 185, 0.22); }
.score-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--fill, 0%), #d7e0ef var(--fill, 0%));
}
.score-card.is-unset .score-slider::-webkit-slider-runnable-track {
  background: #d7e0ef;
}
.score-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -8px;
  border: 3px solid var(--white);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 5px rgba(23, 45, 94, 0.28);
}
.score-card.is-unset .score-slider::-webkit-slider-thumb { background: #8a97ae; }
.score-slider::-moz-range-track {
  height: 8px;
  border: 0;
  border-radius: 99px;
  background: #d7e0ef;
}
.score-slider::-moz-range-progress {
  height: 8px;
  border-radius: 99px;
  background: var(--accent);
}
.score-card.is-unset .score-slider::-moz-range-progress { background: #d7e0ef; }
.score-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 3px solid var(--white);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 5px rgba(23, 45, 94, 0.28);
}
.score-fine {
  width: 100%;
  min-height: 40px;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  text-align: center;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
}
.score-fine::placeholder { font-size: 0.74rem; font-weight: 550; color: #8a97ae; }
.score-fine:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.score-fine[aria-invalid] { border-color: var(--error); }

.score-standard { margin-top: 2px; font-size: 0.82rem; }
.score-standard summary {
  display: flex;
  align-items: center;
  gap: 7px;
  width: max-content;
  list-style: none;
  color: var(--accent-dark);
  font-weight: 650;
}
.score-standard summary::-webkit-details-marker { display: none; }
.standard-arrow {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--accent-dark);
  transform: rotate(-90deg);
  transition: transform 0.15s ease;
}
.score-standard[open] .standard-arrow { transform: rotate(0deg); }
.score-standard[open] > summary { margin-bottom: 8px; }
.band-list, .standard-note {
  margin: 0;
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--faint);
  border-radius: 8px;
  color: var(--muted);
}
.band-list { list-style: none; display: grid; gap: 6px; }
.band-list li { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 6px; align-items: start; }
.band { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.form-footer {
  background: #f9fbfe;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 12px;
  padding-top: 16px;
  padding-bottom: 16px;
}
.total { white-space: nowrap; color: var(--ink); font-weight: 650; }
.total strong { font-size: 1.65rem; font-variant-numeric: tabular-nums; color: var(--accent-dark); margin-left: 4px; }
.total > span { font-size: 0.81rem; color: var(--muted); font-weight: 500; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
#rating-message { grid-column: 1 / -1; }
#rating-message button { min-height: 32px; padding: 3px 8px; }

.admin-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin: 19px 0; }
.stat { padding: 15px 17px; min-width: 0; }
.stat dt { color: var(--muted); font-size: 0.82rem; font-weight: 620; }
.stat dd { font-size: clamp(1.4rem, 3.1vw, 2rem); font-weight: 750; font-variant-numeric: tabular-nums; }
.stat dd span { color: var(--muted); font-size: 0.75rem; font-weight: 500; white-space: nowrap; }
.stat progress { margin: 4px 0; }
.summary-panel { overflow: hidden; }
.summary-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 0 15px; border-bottom: 1px solid var(--faint); }
.tabs { display: flex; gap: 13px; }
.tab { color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 12px 7px; font-size: 0.9rem; font-weight: 650; }
.tab[aria-pressed="true"] { color: var(--accent-dark); border-bottom-color: var(--accent); }
.tab:hover { color: var(--accent-dark); }
.summary-note { color: var(--muted); font-size: 0.84rem; padding: 12px 19px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 530px; border-collapse: collapse; text-align: left; font-size: 0.87rem; }
th, td { padding: 10px clamp(9px, 2vw, 21px); border-bottom: 1px solid var(--faint); }
thead th { font-size: 0.82rem; font-weight: 650; color: var(--muted); background: #f6f8fc; white-space: nowrap; }
tbody th { width: 63%; font-weight: 540; }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover > * { background: #f9fbff; }
td.number { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
td.result { color: var(--ink); font-weight: 650; }
.judge-table tbody th { width: 30%; }
.judge-table td:last-child { width: 34%; }

@media (max-width: 910px) {
  .judge-page { grid-template-columns: minmax(210px, 250px) minmax(0, 1fr); gap: 13px; }
  .masthead-inner, .page { padding-left: 18px; padding-right: 18px; }
}
@media (max-width: 760px) {
  .masthead-inner { gap: 10px; min-height: 58px; padding-top: 9px; padding-bottom: 9px; }
  .masthead-title { padding-left: 8px; }
  .session-controls { gap: 2px; }
  .session-controls .button { padding-left: 7px; padding-right: 7px; }
  .session-role { font-size: 0.76rem; }
  .page { padding-top: 15px; padding-bottom: 27px; }
  .login-page { padding-top: clamp(40px, 12vh, 105px); }
  .judge-page { grid-template-columns: 1fr; }
  .project-rail { position: static; }
  .project-list { max-height: 156px; }
  .rail-header { padding: 10px 12px; gap: 6px; }
  .rating-head, .form-section, .form-footer { padding-left: 15px; padding-right: 15px; }
  .stats-grid { gap: 7px; margin: 13px 0; }
  .stat { padding: 10px 8px; }
  .stat dd span { display: block; }
}
@media (max-width: 550px) {
  .score-cards { grid-template-columns: 1fr; }
  .score-now { font-size: 1.55rem; }
  .form-footer { grid-template-columns: 1fr; }
  .form-actions { justify-content: flex-start; flex-wrap: nowrap; }
  .form-actions > .primary { flex: 1; }
  table { min-width: 0; }
  th, td { padding-left: 6px; padding-right: 6px; }
  th:first-child, td:first-child { padding-left: 12px; }
  th:last-child, td:last-child { padding-right: 10px; }
  tbody th { width: auto; }
  table, thead th { font-size: 0.75rem; }
}
