:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f8fafc;
  --surface-strong: #f1f5f9;
  --text: #202124;
  --muted: #5f6b7a;
  --border: #dde5ec;
  --accent: #20a8d8;
  --accent-dark: #0077a3;
  --accent-soft: #e8f7fc;
  --danger: #b42318;
  --success: #087443;
  --shadow: 0 14px 34px rgba(31, 42, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 56px;
  padding: 0 max(32px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.98);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-size: 1.02rem;
  font-weight: 800;
}

.competition-hero {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.competition-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 32px 0;
}

.competition-copy {
  max-width: 780px;
}

.competition-copy h1 {
  font-size: 2rem;
  line-height: 1.15;
}

.competition-copy p {
  margin-top: 8px;
  color: #4e5d70;
  font-size: 1.02rem;
  line-height: 1.6;
}

.competition-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 680px;
  gap: 0;
  margin: 22px 0 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}

.competition-meta div {
  padding: 14px 16px;
  border-right: 1px solid var(--border);
}

.competition-meta div:last-child {
  border-right: 0;
}

.competition-meta dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.competition-meta dd {
  margin: 4px 0 0;
  color: var(--text);
  font-weight: 800;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 24px;
  overflow-x: auto;
  color: var(--muted);
  font-size: 0.93rem;
  font-weight: 750;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  margin-right: 28px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.nav-links a.active {
  border-bottom-color: var(--accent);
  color: var(--accent-dark);
}

.account-control {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 120px;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.account-control > span {
  color: var(--text);
  font-weight: 800;
}

.account-control > a {
  color: var(--accent-dark);
  font-weight: 800;
}

.nav-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-form span {
  color: var(--text);
  font-weight: 800;
}

.nav-form button {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 0.82rem;
  background: white;
  color: var(--accent-dark);
}

.nav-links a:hover,
.icon-link:hover,
.download-strip a:hover,
.file-row:hover {
  color: var(--accent);
}

main {
  padding: 34px 32px 56px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  align-items: start;
}

.main-column,
.side-panel,
.page-section,
.submit-panel,
.history-panel {
  min-width: 0;
}

.section-heading,
.page-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.page-title {
  display: grid;
  gap: 10px;
  max-width: 760px;
  margin-bottom: 24px;
}

.page-title p {
  font-size: 1rem;
  line-height: 1.6;
}

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

h1 {
  font-size: 1.55rem;
  line-height: 1.2;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.2;
}

p {
  margin: 0;
  color: var(--muted);
}

code {
  color: var(--accent-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

pre {
  overflow-x: auto;
  margin: 10px 0 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  padding: 10px 12px;
}

pre code {
  color: var(--text);
  font-size: 0.84rem;
}

.icon-link {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.table-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.table-header div {
  display: grid;
  gap: 8px;
  max-width: 720px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  box-shadow: 0 12px 32px rgba(31, 42, 55, 0.06);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
  background: white;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  font-size: 0.9rem;
}

th {
  background: var(--surface);
  color: #475467;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.user-name {
  font-weight: 800;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.message-cell {
  white-space: normal;
  min-width: 220px;
  color: var(--muted);
}

.side-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.page-section,
.submission-layout {
  margin: 0 auto;
}

.content-page {
  max-width: 920px;
}

.leaderboard-page {
  max-width: 1040px;
}

.content-stack,
.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.info-panel,
.submit-panel,
.history-panel,
.login-callout {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(26, 48, 64, 0.06);
  padding: 18px;
}

.content-page .content-stack {
  border-top: 1px solid var(--border);
}

.content-page .info-panel {
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 24px 0;
}

.content-page .info-panel:last-child {
  border-bottom: 0;
}

.info-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.file-list.compact {
  max-width: none;
}

.submission-layout {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 980px;
  gap: 18px;
  align-items: start;
}

.submit-panel form {
  margin-top: 14px;
}

.history-panel .section-heading {
  align-items: center;
}

.login-callout {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.submit-panel .login-callout {
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 16px 0 0;
}

.login-callout .button-link {
  justify-self: start;
  min-width: 180px;
}

.side-panel h2 + form,
.side-panel .status + form {
  margin-top: 14px;
}

.side-panel h2:not(:first-child) {
  margin-top: 26px;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
}

input[type="file"] {
  padding: 7px 10px;
}

button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  padding: 8px 12px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  padding: 8px 12px;
}

.button-link.secondary {
  background: white;
  color: var(--accent-dark);
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

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

.download-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.download-strip a,
.file-row,
.status {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
}

.download-strip a {
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.file-list {
  display: grid;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  max-width: 760px;
}

.file-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 15px;
  border-width: 0 0 1px;
  color: var(--text);
}

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

.file-row span:last-child {
  color: var(--muted);
}

.flash-stack {
  display: grid;
  gap: 10px;
  padding: 18px 32px 0;
}

.flash {
  border-radius: 6px;
  padding: 10px 12px;
  font-weight: 700;
}

.flash.success {
  background: #ecfdf3;
  color: var(--success);
}

.flash.error {
  background: #fef3f2;
  color: var(--danger);
}

.status {
  display: inline-flex;
  width: max-content;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  font-size: 0.82rem;
  font-weight: 800;
}

.status.locked {
  background: #fff4ed;
  color: #b54708;
}

.status.open {
  background: #ecfdf3;
  color: var(--success);
}

.inline-auth {
  grid-template-columns: minmax(160px, 220px) minmax(160px, 220px) auto;
  align-items: end;
  margin-bottom: 18px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.admin-actions button {
  width: auto;
}

.auth-page {
  display: grid;
  place-items: start center;
  padding-top: 28px;
}

.auth-panel {
  width: min(100%, 420px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.auth-panel h1 {
  margin-bottom: 18px;
}

@media (max-width: 940px) {
  .workspace,
  .submission-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    order: -1;
  }
}

@media (max-width: 700px) {
  .app-header {
    align-items: center;
    flex-direction: row;
    gap: 16px;
    padding: 16px 18px;
  }

  .competition-inner {
    padding: 24px 18px 0;
  }

  .competition-copy h1 {
    font-size: 1.55rem;
  }

  .competition-copy p {
    font-size: 0.95rem;
  }

  .competition-meta {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .competition-meta div {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .competition-meta div:last-child {
    border-bottom: 0;
  }

  .nav-links {
    flex-wrap: nowrap;
    font-size: 0.86rem;
    margin-top: 18px;
  }

  .nav-links a {
    min-height: 44px;
    margin-right: 15px;
  }

  .account-control {
    justify-content: flex-start;
    min-width: 0;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  main,
  .flash-stack {
    padding-left: 18px;
    padding-right: 18px;
  }

  h1 {
    font-size: 1.35rem;
  }

  .inline-auth {
    grid-template-columns: 1fr;
  }

  .login-callout .button-link {
    justify-self: stretch;
  }

  .table-header,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
