:root {
  color-scheme: light;
  --paper: #f7f8f5;
  --surface: #fffefb;
  --ink: #243128;
  --muted: #737a73;
  --line: #dfe3dc;
  --green: #347442;
  --green-dark: #255732;
  --soft: #eaf1e7;
  --danger: #a34032;
  font-family: Inter,"PingFang SC","Microsoft YaHei",system-ui,sans-serif;
  font-size: 15px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

[hidden] {
  display: none!important;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: .6rem .9rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s,box-shadow .15s;
}

button:hover:not(:disabled) {
  background: #f0f4ed;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid #82a77c;
  outline-offset: 3px;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

.primary:hover:not(:disabled) {
  background: var(--green-dark);
}

.outline {
  border-color: var(--green);
  color: var(--green-dark);
}

.text-button {
  border-color: transparent;
  background: transparent;
  color: var(--green-dark);
  font-weight: 600;
}

.wide {
  width: 100%;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: .85rem;
}

.error {
  color: var(--danger);
  line-height: 1.6;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px #25352805;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  letter-spacing: -.03em;
}

p {
  line-height: 1.75;
}

label {
  display: block;
  font-weight: 600;
  margin: .9rem 0 .45rem;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfd6cc;
  border-radius: 8px;
  padding: .75rem;
  background: white;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

form .primary {
  margin-top: 1rem;
}

.topbar {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
  font-size: 25px;
  font-weight: 750;
}

.brand svg,
.bird-mark {
  width: 55px;
  height: 48px;
  fill: none;
  stroke: #35563a;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand svg circle {
  fill: #35563a;
}

.progress-wrap {
  text-align: center;
  max-width: 480px;
  flex: 1;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

progress {
  display: block;
  appearance: none;
  width: 100%;
  height: 9px;
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #e3e5df;
}

progress::-webkit-progress-bar {
  background: #e3e5df;
}

progress::-webkit-progress-value {
  background: var(--green);
  border-radius: 8px;
}

progress::-moz-progress-bar {
  background: var(--green);
}

nav {
  display: flex;
  gap: 12px;
}

nav button {
  border-color: transparent;
}

nav button:first-child {
  border-color: var(--green);
  color: var(--green-dark);
}

.welcome {
  max-width: 1120px;
  min-height: calc(100vh - 80px);
  margin: auto;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  align-items: center;
  gap: 90px;
  padding: 70px 30px;
}

.welcome-copy h1 {
  font-size: 46px;
  line-height: 1.4;
  margin-bottom: 24px;
}

.welcome-copy>p:not(.eyebrow) {
  font-size: 17px;
  color: #647263;
  max-width: 460px;
}

.eyebrow {
  font-size: 13px;
  letter-spacing: .12em;
  color: var(--green);
  margin-bottom: 24px;
}

.welcome-facts {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: #60735e;
  font-size: 12px;
  margin: 30px 0 20px;
}

.entry-card {
  padding: 32px;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}

.tabs button {
  flex: 1;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 12px;
}

.tabs button.active {
  color: var(--green);
  box-shadow: inset 0 -2px var(--green);
  font-weight: 700;
}

.entry-card h2 {
  font-size: 24px;
}

.entry-card p {
  color: var(--muted);
  font-size: 14px;
}

.entry-foot {
  text-align: center;
  border-top: 1px solid var(--line);
  padding-top: 24px;
  margin: 24px 0 0;
  font-size: 12px!important;
}

#review {
  padding: 18px 20px 10px;
}

.review-grid {
  display: grid;
  grid-template-columns: minmax(0,2.25fr) minmax(310px,1fr);
  gap: 16px;
}

.image-panel {
  padding: 12px;
  min-width: 0;
}

.image-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 5px 12px;
}

.image-toolbar h1 {
  font-size: 20px;
  margin: 0;
  white-space: nowrap;
}

.view-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-tools button {
  padding: .35rem .55rem;
  min-height: 33px;
}

.view-tools button:first-child,
.view-tools button:nth-child(2) {
  border-color: transparent;
}

.view-tools output {
  font-size: 12px;
  width: 44px;
  text-align: center;
  color: var(--muted);
}

.viewport {
  position: relative;
  background: #e8eae2;
  border-radius: 7px;
  height: clamp(340px,calc(100vh - 330px),760px);
  overflow: hidden;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  outline-offset: 3px;
}

.viewport.dragging,
.compare-viewport.dragging {
  cursor: grabbing;
}

.viewport img,
.compare-viewport img {
  position: absolute;
  max-width: none;
  max-height: none;
  user-select: none;
  transform-origin: center;
  will-change: transform;
  pointer-events: none;
}

.image-message {
  max-width: 75%;
  text-align: center;
  padding: 24px;
  color: #616e5d;
  line-height: 1.7;
}

#image-retry {
  position: absolute;
  bottom: 28%;
  left: 50%;
  transform: translateX(-50%);
}

.rating-caption {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 4px;
  font-size: 14px;
}

.rating-caption span:last-child {
  color: var(--green);
  font-size: 12px;
}

.score-buttons {
  display: grid;
  grid-template-columns: repeat(5,1fr);
  gap: 9px;
}

.score-buttons button {
  padding: 9px 4px 11px;
  min-height: 74px;
}

.score-buttons button strong {
  font-size: 30px;
  display: block;
  line-height: 1.2;
}

.score-buttons button span {
  display: block;
  font-size: 13px;
  margin-top: 5px;
}

.score-buttons button.selected {
  background: var(--soft);
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}

.save-line {
  font-size: 12px;
  color: var(--muted);
  min-height: 29px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 6px;
}

.save-line button {
  padding: 4px 10px;
}

.reference-panel {
  padding: 18px;
  align-self: stretch;
}

.reference-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.reference-head h2 {
  font-size: 18px;
  color: var(--green-dark);
  margin: 0;
}

.reference-head button {
  border-color: transparent;
  padding: 3px 0;
  color: var(--muted);
  font-size: 13px;
}

.reference-tabs {
  display: grid;
  grid-template-columns: repeat(5,1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.reference-tabs button {
  border: 0;
  border-radius: 0;
  padding: 10px 4px;
  border-right: 1px solid var(--line);
}

.reference-tabs button:last-child {
  border: 0;
}

.reference-tabs button.active,
.reference-tabs button.active:hover:not(:disabled) {
  background: var(--green);
  color: white;
}

.reference-panel h3 {
  font-size: 25px;
  margin: 21px 0 14px;
}

.reference-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 12px;
}

.reference-image {
  position: relative;
  min-width: 0;
  aspect-ratio: 4/3;
  background: #edf0e9;
  padding: 0;
  overflow: hidden;
}

.reference-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.reference-image span {
  position: absolute;
  bottom: 4px;
  left: 5px;
  background: #ffffffe6;
  border-radius: 4px;
  font-size: 10px;
  padding: 3px 5px;
}

.reference-image .reference-error {
  position: static;
  display: block;
  padding: 10px;
  font-size: 11px;
}

.reference-panel #reference-description {
  background: #f4f6f1;
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: 9px;
  font-size: 14px;
  margin: 18px 0 9px;
  white-space: pre-line;
}

.reference-panel>.muted {
  font-size: 12px;
}

#rubric-button {
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding-top: 17px;
}

.review-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding-top: 12px;
}

.navigation,
.footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.navigation form {
  display: flex;
  align-items: center;
  gap: 7px;
}

.navigation label {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.navigation input {
  width: 76px;
  padding: 8px;
}

.review-footer button {
  font-size: 13px;
  padding: 9px 11px;
}

.keyboard-hint {
  font-size: 11px;
  text-align: center;
  color: #8a9285;
  margin: 10px 0 0;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  background: #f3f0e6;
  border: 1px solid #dbd4bb;
  border-radius: 8px;
  padding: 10px 15px;
  margin-bottom: 12px;
  line-height: 1.6;
  font-size: 13px;
}

.notice button {
  padding: 5px 10px;
  white-space: nowrap;
}

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #2e4731;
  color: white;
  box-shadow: 0 5px 24px #0002;
  border-radius: 10px;
  padding: 15px 24px;
  z-index: 50;
  max-width: 80%;
  line-height: 1.6;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
  max-width: min(630px,90vw);
  width: 560px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 90px #1b2c1b35;
}

dialog::backdrop {
  background: #16251b70;
  backdrop-filter: blur(3px);
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.dialog-heading h2 {
  margin: 0;
  font-size: 23px;
}

.dialog-heading button {
  padding: 3px 9px;
  border: 0;
  font-size: 25px;
  background: transparent;
}

.dialog-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.dialog-actions button {
  flex: 1;
}

.code-view {
  font-family: ui-monospace,monospace;
  font-size: 18px;
  word-break: break-all;
  line-height: 1.8;
  padding: 20px;
  border: 1px dashed #8ca687;
  border-radius: 9px;
  background: var(--soft);
  user-select: all;
}

#participant-dialog #logout {
  margin-top: 25px;
}

.rubric-row {
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.rubric-row strong {
  color: var(--green-dark);
  font-size: 18px;
}

.rubric-row p {
  margin: 8px 0 0;
  white-space: pre-line;
  font-size: 14px;
}

.records-list {
  display: grid;
  grid-template-columns: repeat(5,1fr);
  gap: 8px;
  max-height: 50vh;
  overflow: auto;
}

.records-list button {
  font-variant-numeric: tabular-nums;
  min-height: 58px;
}

.records-list small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.compare-dialog {
  width: 96vw;
  max-width: 96vw;
  height: 90vh;
}

.compare-tools {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.compare-tools span {
  flex: 1;
  color: var(--muted);
  font-size: 13px;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  height: calc(100% - 120px);
}

.compare-grid section {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.compare-grid h3 {
  margin: 4px 0 10px;
  font-size: 15px;
  height: 24px;
}

.compare-reference-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
}

.compare-reference-head button {
  padding: 3px 10px;
  font-size: 12px;
}

.compare-viewport {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #e8eae2;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}

.viewport:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

.mobile-only {
  display: none;
}

.admin-main {
  max-width: 1250px;
  margin: 30px auto;
  padding: 0 25px;
}

.admin-login {
  max-width: 480px;
  margin: 80px auto;
  padding: 30px;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 22px 0;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 12px;
}

.admin-stat {
  padding: 22px;
}

.admin-stat strong {
  font-size: 30px;
  display: block;
  margin-top: 5px;
}

.admin-table {
  overflow: auto;
  margin: 20px 0;
}

.admin-table table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  text-align: left;
}

.admin-table th,
.admin-table td {
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.admin-table th {
  background: #f1f4ee;
}

.admin-table button {
  padding: 5px 8px;
}

.admin-section-title {
  margin: 30px 0 12px;
  font-size: 20px;
}

a {
  color: var(--green-dark);
}

@media(min-width:1700px) {
  :root {
    font-size: 17px;
  }
  .viewport {
    height: calc(100vh - 350px);
  }
  .reference-images {
    grid-template-columns: 1fr;
  }
  .reference-image {
    aspect-ratio: 16/9;
  }
  .topbar {
    height: 88px;
  }
  .review-grid {
    grid-template-columns: minmax(0,2.35fr) minmax(360px,1fr);
  }
}

@media(max-width:1150px) {
  .topbar {
    padding: 0 18px;
    gap: 15px;
  }
  .brand {
    font-size: 21px;
  }
  .brand svg {
    width: 40px;
  }
  .reference-panel {
    padding: 13px;
  }
  .review-grid {
    grid-template-columns: minmax(0,1.7fr) 300px;
  }
  .review-footer {
    align-items: start;
    flex-direction: column;
  }
  .footer-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .viewport {
    height: calc(100vh - 385px);
  }
  .view-tools {
    gap: 2px;
  }
  .view-tools button {
    padding: 5px;
  }
  .welcome {
    gap: 40px;
  }
  .welcome-copy h1 {
    font-size: 38px;
  }
  .score-buttons button span {
    font-size: 12px;
  }
}

@media (min-width: 901px) and (max-height: 850px) {
  #review {
    padding-top: 12px;
  }

  .viewport {
    height: max(250px, calc(100dvh - 420px));
  }

  .reference-panel {
    max-height: calc(100dvh - 210px);
    overflow-y: auto;
  }

  .reference-panel h3 {
    margin-top: 15px;
    margin-bottom: 10px;
    font-size: 23px;
  }

  .reference-panel #reference-description {
    margin-top: 12px;
    padding: 12px;
  }

  .review-footer {
    padding-top: 9px;
  }

  .keyboard-hint {
    margin-top: 6px;
  }
}

@media (min-width: 901px) and (max-width: 1150px) and (max-height: 850px) {
  .viewport {
    height: max(230px, calc(100dvh - 455px));
  }
}

@media(max-width:900px),(pointer:coarse) and (max-width:1100px) {
  .desktop-only {
    display: none!important;
  }
  .mobile-only {
    display: flex;
    min-height: 100dvh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 35px;
    max-width: 520px;
    margin: auto;
  }
  .mobile-only h1 {
    font-size: 27px;
    margin: 25px 0 10px;
  }
  .mobile-only p {
    color: var(--muted);
  }
  .mobile-only button {
    margin: 15px 0;
  }
  .bird-mark {
    width: 85px;
    height: 70px;
  }
  .admin-main {
    display: none;
  }
  .admin-mobile {
    display: block!important;
  }
}
