:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --ink: #1c1d1f;
  --muted: #62666d;
  --line: #d9d3c8;
  --panel: #fffdf8;
  --panel-strong: #ffffff;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --brick: #b34535;
  --gold: #b7791f;
  --blue: #2f5f98;
  --green: #4d7c3f;
  --shadow: 0 18px 44px rgba(28, 29, 31, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.86), rgba(246, 244, 239, 0.96)),
    repeating-linear-gradient(90deg, rgba(28, 29, 31, 0.03) 0, rgba(28, 29, 31, 0.03) 1px, transparent 1px, transparent 96px);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 56px);
  line-height: 1.02;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.15fr) minmax(320px, 0.95fr);
  grid-template-areas:
    "submission judges config"
    "results results results";
  gap: 16px;
  align-items: start;
}

.submission-panel {
  grid-area: submission;
}

.judges-panel {
  grid-area: judges;
}

.config-panel {
  grid-area: config;
}

.results-panel {
  grid-area: results;
}

.panel {
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.panel-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.step-badge {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #fffdf8;
  font-weight: 800;
  flex: 0 0 auto;
}

.form-stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #c9c2b7;
  border-radius: 6px;
  background: #fffefa;
  color: var(--ink);
  outline: none;
  padding: 11px 12px;
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.split-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  border-radius: 6px;
  border: 1px solid transparent;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  background: var(--teal);
  color: white;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.secondary-button {
  background: var(--ink);
  color: white;
}

.secondary-button.compact {
  min-height: 36px;
  padding-inline: 12px;
  font-size: 13px;
}

.model-check-button {
  margin-top: 12px;
  width: 100%;
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.icon-button {
  width: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-color: var(--line);
  background: #fffefa;
  color: var(--ink);
  font-size: 20px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.status-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed #c9c2b7;
  border-radius: 6px;
  color: var(--muted);
  background: #fbf8f1;
  line-height: 1.45;
  font-size: 13px;
}

.anchor-card {
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 6px;
  background: rgba(15, 118, 110, 0.08);
}

.anchor-card strong,
.review-anchor {
  display: block;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.45;
}

.anchor-card p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status-box.good {
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.08);
  color: var(--teal-dark);
}

.status-box.error {
  border-color: rgba(179, 69, 53, 0.4);
  background: rgba(179, 69, 53, 0.08);
  color: #8e2d20;
}

.status-box.checking {
  border-color: rgba(183, 121, 31, 0.42);
  background: rgba(183, 121, 31, 0.1);
  color: #79500e;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.submission-preview {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  font-size: 13px;
}

.preview-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(217, 211, 200, 0.72);
}

.preview-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.preview-row span {
  color: var(--muted);
  font-weight: 800;
}

.preview-row strong {
  word-break: break-word;
}

.judge-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.inline-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.judges-list {
  display: grid;
  gap: 10px;
}

.judge-card {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.judge-card.disabled {
  opacity: 0.58;
}

.avatar {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  font-size: 17px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 -14px 0 rgba(0, 0, 0, 0.12);
}

.judge-main {
  min-width: 0;
}

.judge-main h3 {
  margin: 0 0 5px;
  font-size: 15px;
}

.judge-role {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.judge-focus {
  margin-top: 6px;
  color: #313336;
  font-size: 12px;
  line-height: 1.45;
}

.judge-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.switch {
  position: relative;
  width: 44px;
  height: 26px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c9c2b7;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: white;
  transition: transform 0.16s ease;
}

.switch input:checked + span {
  background: var(--teal);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.scoreboard > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fffefa;
}

.scoreboard span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.scoreboard strong {
  font-size: 28px;
}

.review-timeline {
  display: grid;
  gap: 12px;
}

.empty-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbf8f1;
  font-weight: 700;
}

.review-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fffefa;
}

.review-card.running {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.09);
}

.review-content {
  min-width: 0;
}

.review-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.review-head h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.review-head p {
  color: var(--muted);
  font-size: 13px;
}

.score-pill {
  width: 62px;
  height: 62px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: white;
  font-size: 22px;
  font-weight: 900;
  flex: 0 0 auto;
}

.verdict {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  margin: 4px 0 12px;
  border-radius: 999px;
  background: rgba(183, 121, 31, 0.13);
  color: #79500e;
  font-weight: 900;
  font-size: 13px;
}

.review-summary {
  font-size: 15px;
  line-height: 1.65;
  margin-bottom: 12px;
}

.review-anchor {
  margin: 0 0 10px;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.review-block {
  border-top: 1px solid rgba(217, 211, 200, 0.84);
  padding-top: 10px;
}

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

.review-block ul {
  margin: 0;
  padding-left: 18px;
  color: #313336;
  line-height: 1.55;
  font-size: 14px;
}

.scores-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.score-item {
  padding: 9px;
  border-radius: 6px;
  background: #f7f2e8;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}

.score-item strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
  margin-top: 3px;
}

.loading-line {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--brick), var(--blue));
  background-size: 220% 100%;
  animation: loading 1.2s linear infinite;
  margin-top: 12px;
}

@keyframes loading {
  from { background-position: 0 0; }
  to { background-position: 220% 0; }
}

.judge-dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  width: min(760px, calc(100vw - 30px));
  padding: 0;
  box-shadow: var(--shadow);
  background: #fffdf8;
}

.judge-dialog::backdrop {
  background: rgba(28, 29, 31, 0.42);
}

.judge-dialog form {
  padding: 18px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dialog-head {
  margin-bottom: 14px;
}

.dialog-actions {
  margin-top: 16px;
}

.dialog-actions > div {
  display: flex;
  gap: 10px;
}

@media (max-width: 1160px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "submission config"
      "judges judges"
      "results results";
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 12px;
  }

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

  .topbar-actions,
  .topbar-actions .primary-button {
    width: 100%;
  }

  .workspace,
  .split-fields,
  .scoreboard,
  .review-grid,
  .scores-grid {
    grid-template-columns: 1fr;
    grid-template-areas: none;
  }

  .submission-panel,
  .judges-panel,
  .config-panel,
  .results-panel {
    grid-area: auto;
  }

  .judge-card,
  .review-card {
    grid-template-columns: 1fr;
  }

  .review-head {
    flex-direction: column;
  }

  .score-pill {
    width: 100%;
  }
}
