:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #6b6b6b;
  --line: #dddddd;
  --paper: #f7f7f5;
  --panel: #ffffff;
  --accent: #0f766e;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --warn: #9a3412;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(920px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 44px 0;
}

.wide-shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 44px 0 96px;
}

.result-edit-shell {
  width: min(1320px, calc(100vw - 24px));
  padding: 8px 0 58px;
}

.result-edit-shell .topbar {
  margin-bottom: 6px;
}

.result-edit-shell h1 {
  font-size: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  font-weight: 650;
  letter-spacing: 0;
}

h1 {
  font-size: 38px;
}

h2 {
  font-size: 20px;
  margin-bottom: 14px;
}

.ghost,
.batch-list a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.notice,
.result {
  margin: 0 0 18px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.upload {
  display: grid;
  grid-template-columns: 160px 1fr 120px;
  gap: 12px;
  align-items: stretch;
}

.month,
.dropzone {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.month span {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  font: inherit;
  background: transparent;
}

.dropzone {
  min-height: 120px;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.dropzone .drop-title {
  font-size: 22px;
  font-weight: 650;
}

.dropzone .drop-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.dropzone:hover,
.dropzone.has-files {
  border-color: var(--accent);
  background: #f8fffd;
}

.dropzone.has-files {
  transform: translateY(-1px);
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.secondary {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
}

.danger {
  color: var(--warn);
}

button.danger {
  border-color: #f1c7b4;
}

.icon-button {
  min-height: 34px;
  padding: 0 10px;
  background: transparent;
  color: var(--warn);
  border: 1px solid #f1c7b4;
  border-radius: 7px;
  font-size: 13px;
}

.primary-next {
  background: var(--blue);
}

.primary-next:hover {
  background: var(--blue-dark);
}

button:disabled {
  opacity: 0.72;
  cursor: wait;
}

.requirements,
.files,
.file-list,
.history,
.review,
.judge-panel,
.actions,
.selected-files {
  margin-top: 24px;
}

.requirements,
.files,
.file-list,
.selected-files {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.requirement,
.file-row,
.selected-item,
.selected-files header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.uploaded-item,
.selected-item {
  align-items: center;
}

.uploaded-item,
.selected-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px 92px;
  column-gap: 24px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.uploaded-item form,
.selected-item button {
  flex: 0 0 auto;
}

.requirement:last-child,
.file-row:last-child,
.uploaded-item:last-child,
.selected-item:last-child {
  border-bottom: 0;
}

.requirement strong,
.file-list strong,
.selected-files strong {
  color: var(--muted);
  font-size: 14px;
}

.selected-files h2 {
  font-size: 18px;
}

.selected-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.uploaded-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-item strong,
.uploaded-meta {
  justify-self: start;
  min-width: 0;
  white-space: nowrap;
}

.selected-item button,
.uploaded-item form {
  justify-self: end;
}

.ok {
  color: var(--accent);
}

.missing {
  color: var(--warn);
}

.batch-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.actions form {
  min-width: 180px;
}

.actions button,
.sticky-actions button {
  min-height: 52px;
  padding: 0 18px;
}

.preview {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.judge-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.judge-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.judge-panel h2 {
  margin-bottom: 4px;
}

.judge-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.judge-panel td {
  max-width: 260px;
  white-space: normal;
  line-height: 1.45;
}

.progress-track {
  height: 4px;
  background: #ececea;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.22s ease;
}

.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.preview header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.preview p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  min-width: 110px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: #f0f0ee;
  font-weight: 650;
}

.editor-table {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.editor-table input {
  min-width: 120px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
}

.editor-table input:focus {
  border-color: var(--accent);
  background: #f8fffd;
}

.result-carousel {
  display: grid;
  gap: 4px;
}

.result-carousel-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.result-carousel-bar div {
  display: grid;
  gap: 3px;
  text-align: center;
}

.result-carousel-bar span {
  color: var(--muted);
  font-size: 12px;
}

.result-carousel-stage {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  align-items: stretch;
  gap: 8px;
}

.card-hit-area {
  min-height: calc(100vh - 150px);
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.card-hit-area:hover {
  background: #ededeb;
  border-color: var(--line);
  color: var(--ink);
}

.card-hit-area::before {
  display: block;
  font-size: 24px;
  font-weight: 650;
}

.card-hit-left::before {
  content: "<";
}

.card-hit-right::before {
  content: ">";
}

.card-hit-left {
  grid-column: 1;
  grid-row: 1;
}

.card-hit-right {
  grid-column: 3;
  grid-row: 1;
}

.result-card {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: visible;
}

.result-title {
  font-weight: 650;
}

.result-status {
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
}

.result-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 6px;
  padding: 6px 12px 8px;
}

.result-fields + .result-fields {
  padding-top: 0;
}

.result-fields-compact {
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  background: #fbfbfa;
}

.result-fields label {
  display: grid;
  gap: 3px;
}

.result-fields span {
  color: var(--muted);
  font-size: 12px;
}

.result-fields input,
.result-fields textarea {
  width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: white;
  font: inherit;
}

.result-fields textarea {
  min-height: 38px;
  line-height: 1.28;
  resize: vertical;
  white-space: pre-wrap;
}

.wide-field {
  grid-column: 1 / -1;
}

.wide-field textarea {
  min-height: 58px;
}

.readonly-field input,
.readonly-field textarea {
  color: var(--muted);
  background: #f1f1ef;
  cursor: default;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  padding: 10px 0;
  background: linear-gradient(to top, var(--paper) 70%, rgba(247, 247, 245, 0));
}

.busy {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(247, 247, 245, 0.78);
  z-index: 20;
}

.busy p {
  margin: 62px 0 0;
  font-weight: 650;
}

.spinner {
  position: absolute;
  width: 42px;
  height: 42px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.is-busy .busy {
  display: grid;
}

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

form + .result {
  margin-top: 18px;
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 24px, 920px);
    padding: 24px 0;
  }

  .topbar,
  .upload {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 30px;
  }

  button {
    min-height: 52px;
  }

  .actions form,
  .actions button {
    width: 100%;
  }

  .uploaded-item,
  .selected-item {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 8px;
  }

  .uploaded-item strong,
  .selected-item strong {
    grid-column: 1;
  }

  .uploaded-item form,
  .selected-item button {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .result-carousel-bar {
    grid-template-columns: 1fr;
    flex-wrap: wrap;
  }

  .result-carousel-bar div {
    order: -1;
    width: 100%;
  }

  .result-carousel-bar button {
    flex: 1 1 0;
  }

  .result-carousel-stage {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .card-hit-area {
    min-height: 46px;
    grid-row: 2;
  }

  .card-hit-left {
    grid-column: 1;
  }

  .card-hit-right {
    grid-column: 2;
  }

  .result-card {
    grid-column: 1 / -1;
  }

  .result-fields,
  .result-fields-compact {
    grid-template-columns: 1fr;
  }
}
