:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #69727d;
  --line: #dfe3e8;
  --surface: #ffffff;
  --canvas: #f4f6f8;
  --blue: #165dff;
  --blue-dark: #0f45c7;
  --green: #147d64;
  --red: #c33c45;
  --amber: #9a6500;
  --shadow: 0 12px 32px rgba(23, 32, 42, 0.09);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
}

button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.topbar {
  height: 64px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--ink);
  border-radius: 5px;
  font-size: 12px;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-label { color: var(--muted); font-size: 14px; }

.auth-layout {
  width: min(1040px, calc(100% - 40px));
  min-height: calc(100vh - 64px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 390px;
  align-items: center;
  gap: 100px;
}

.auth-context h1, .workspace-header h1 {
  margin: 8px 0 22px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.06;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}


.auth-panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px;
  background: transparent;
  color: var(--muted);
}
.tab.active { color: var(--ink); border-color: var(--blue); font-weight: 700; }

.auth-form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #454d57; font-size: 13px; font-weight: 650; }
input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #cbd1d8;
  border-radius: 5px;
  outline: none;
  background: #fff;
  color: var(--ink);
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.12); }

.button, .icon-button {
  border: 1px solid transparent;
  border-radius: 5px;
  min-height: 40px;
  padding: 0 16px;
  font-weight: 700;
}
.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.button.primary { background: var(--blue); color: #fff; }
.button.primary:hover { background: var(--blue-dark); }
.button.quiet { border-color: var(--line); background: #fff; color: var(--ink); }
.button:disabled { cursor: not-allowed; opacity: 0.55; }
.button.full { width: 100%; margin-top: 4px; }
.icon-button { width: 40px; padding: 0; border-color: var(--line); background: #fff; font-size: 18px; }

.form-error { min-height: 19px; margin: 10px 0 0; color: var(--red); font-size: 13px; }

.workspace { width: min(1180px, calc(100% - 40px)); margin: 0 auto 80px; }
.workspace-header {
  min-height: 190px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.workspace-header h1 { margin-bottom: 0; font-size: 42px; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
  align-items: start;
  gap: 24px;
}
.upload-section, .status-section {
  min-width: 0;
  padding: 28px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.status-section { background: #fafbfc; }

.section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.section-heading > div:first-child { display: flex; align-items: center; gap: 10px; }
.section-heading h2 { margin: 0; font-size: 19px; }
.section-actions { display: flex; align-items: center; gap: 8px; }
.compact-button { min-height: 34px; padding: 0 11px; font-size: 12px; }
.section-index { color: var(--blue); font-size: 11px; font-weight: 800; }
.cooldown { padding: 4px 8px; border-radius: 4px; background: #e8f5f0; color: var(--green); font-size: 12px; font-weight: 700; }
.cooldown.waiting { background: #fff3dc; color: var(--amber); }

.segmented { width: 100%; display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: #f2f4f6; }
.segment { min-height: 36px; border: 0; border-radius: 3px; background: transparent; color: var(--muted); font-weight: 650; }
.segment.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(23, 32, 42, 0.12); }
.segmented.compact { width: 250px; }
.control-label {
  display: block;
  margin: 18px 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.dropzone {
  min-height: 190px;
  margin: 18px 0;
  padding: 28px;
  place-items: center;
  align-content: center;
  border: 1px dashed #aab2bc;
  border-radius: 6px;
  background: #fafbfc;
  text-align: center;
  cursor: pointer;
}
.dropzone.dragover { border-color: var(--blue); background: #f2f6ff; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone strong { max-width: 100%; overflow-wrap: anywhere; color: var(--ink); font-size: 15px; }
.dropzone span:last-child { color: var(--muted); font-size: 12px; font-weight: 500; }
.upload-symbol { color: var(--blue); font-size: 30px; line-height: 1; }

.form-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; }
.form-row .form-error { flex: 1; margin: 0; }
.upload-progress { height: 5px; margin-top: 16px; overflow: hidden; border-radius: 2px; background: #e8ebef; }
.upload-progress div { width: 0; height: 100%; background: var(--blue); transition: width 160ms ease; }

.submission-list { display: grid; max-height: 520px; overflow-y: auto; }
.submission-item { padding: 16px 0; border-bottom: 1px solid var(--line); }
.submission-item:last-child { border-bottom: 0; }
.submission-summary { display: grid; grid-template-columns: minmax(0, 1fr) 112px; gap: 18px; align-items: center; }
.submission-main { min-width: 0; }
.submission-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.submission-identity { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.submission-kind { font-weight: 750; }
.status-pill { font-size: 11px; font-weight: 800; text-transform: uppercase; }
.status-succeeded { color: var(--green); }
.status-failed, .status-rejected { color: var(--red); }
.status-queued, .status-running { color: var(--amber); }
.submission-file { margin: 8px 0; overflow-wrap: anywhere; color: var(--muted); font-size: 12px; }
.submission-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 12px; }
.submission-score { display: grid; gap: 5px; padding-left: 14px; border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.submission-metric { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.submission-score span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.submission-score strong { max-width: 100%; color: var(--ink); font-size: 13px; line-height: 1.1; }
.submission-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 14px; }
.submission-actions .button { min-height: 36px; padding: 0 10px; font-size: 11px; }
.submission-download { width: auto; margin: 0; }
.scene-metrics-toggle { gap: 7px; }
.scene-metrics-toggle::after {
  content: "";
  box-sizing: border-box;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transform-origin: 50% 50%;
  transition: transform 160ms ease;
}
.scene-metrics-toggle[aria-expanded="true"]::after { transform: rotate(225deg); }
.scene-metrics-panel { margin-top: 10px; overflow-x: auto; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.scene-metrics-table { min-width: 330px; table-layout: fixed; font-size: 11px; font-variant-numeric: tabular-nums; }
.scene-metrics-table th, .scene-metrics-table td { height: auto; padding: 9px 7px; text-align: right; }
.scene-metrics-table thead th { padding-top: 8px; padding-bottom: 8px; font-size: 9px; }
.scene-metrics-table th:first-child { width: 45%; text-align: left; }
.scene-metrics-table tbody th { overflow-wrap: anywhere; font-weight: 500; text-transform: none; }
.scene-metrics-table tbody th strong { display: block; color: var(--ink); font-size: 10px; }
.scene-metrics-table tbody th span { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 500; }
.scene-metrics-table tbody th .scene-warning { color: var(--red); font-size: 9px; font-weight: 700; line-height: 1.35; }
.scene-metrics-table tbody td { color: #303943; }
.empty-state { padding: 50px 0; text-align: center; color: var(--muted); }

.leaderboard-section { margin-top: 34px; padding-top: 28px; border-top: 1px solid var(--line); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { height: 52px; padding: 0 18px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #fafbfc; font-size: 11px; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.rank { font-weight: 800; color: var(--blue); }
.empty-cell { text-align: center; color: var(--muted); }

dialog { width: min(540px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(23, 32, 42, 0.45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.dialog-head h2 { margin: 0; font-size: 20px; }
.credential-block { display: grid; gap: 6px; margin: 13px 0; }
.credential-block span { color: var(--muted); font-size: 12px; }
.credential-block code { padding: 10px; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 4px; background: #f6f7f9; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 12px 16px; border-radius: 5px; background: var(--ink); color: #fff; opacity: 0; transform: translateY(8px); pointer-events: none; transition: 180ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

[hidden] { display: none !important; }

@media (max-width: 820px) {
  .topbar { padding: 0 16px; }
  .user-label { display: none; }
  .auth-layout { grid-template-columns: 1fr; align-content: center; gap: 34px; padding: 50px 0; }
  .auth-context h1 { font-size: 38px; }
  .workspace { width: min(100% - 24px, 1180px); }
  .workspace-header { min-height: 150px; }
  .workspace-header h1 { font-size: 32px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .status-section { border: 1px solid var(--line); }
}

@media (max-width: 520px) {
  .auth-layout { width: calc(100% - 24px); }
  .auth-panel, .upload-section, .status-section { padding: 20px; }
  .workspace-header { align-items: flex-end; padding: 32px 0 24px; }
  .leaderboard-heading { align-items: flex-start; gap: 14px; }
  .leaderboard-heading { flex-direction: column; }
  .status-section .section-heading { align-items: flex-start; gap: 12px; }
  .status-section .section-actions { flex-shrink: 0; }
  .submission-summary { grid-template-columns: minmax(0, 1fr) 116px; gap: 8px; }
  .submission-score { padding-left: 10px; }
  .submission-score strong { font-size: 12px; }
  .segmented.compact { width: 100%; }
  .form-row { align-items: stretch; flex-direction: column; }
  .form-row .button { width: 100%; }
  .topbar-actions { gap: 6px; }
  .topbar .button { padding: 0 9px; font-size: 12px; white-space: nowrap; }
  .brand { font-size: 14px; }
}
