:root {
  color-scheme: light;
  --bg: #fcfbf8;
  --surface: #ffffff;
  --surface-soft: #faf8f3;
  --border: #e8e0d3;
  --border-strong: #d9cfbe;
  --text: #242c3c;
  --muted: #8a92a5;
  --primary: #4368e4;
  --primary-soft: #f1f4fe;
  --gold: #b88920;
  --silver: #8791a3;
  --bronze: #b06d42;
  --editor-selection: rgba(67, 104, 228, 0.18);
  --syntax-comment: #7d8798;
  --syntax-keyword: #3557d6;
  --syntax-string: #9f5b00;
  --syntax-number: #8e3bb8;
  --syntax-function: #0f6f82;
  --syntax-operator: #59657c;
  --syntax-punctuation: #59657c;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141821;
  --surface: #1b212d;
  --surface-soft: #202735;
  --border: #313849;
  --border-strong: #45506a;
  --text: #eef2f8;
  --muted: #a6b0c3;
  --primary: #7ea6ff;
  --primary-soft: rgba(126, 166, 255, 0.1);
  --gold: #d8b04b;
  --silver: #b2bccd;
  --bronze: #d58a5d;
  --editor-selection: rgba(126, 166, 255, 0.22);
  --syntax-comment: #7d8aa3;
  --syntax-keyword: #8db0ff;
  --syntax-string: #f1c26b;
  --syntax-number: #d29cff;
  --syntax-function: #83d8e7;
  --syntax-operator: #aeb9cd;
  --syntax-punctuation: #aeb9cd;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

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

button,
input,
select {
  font: inherit;
}

.site-shell,
.page-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
}

.page-shell--wide {
  width: min(1480px, calc(100% - 32px));
}

.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 64px;
}

.brand {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand--static {
  cursor: default;
}

.site-nav {
  display: flex;
  gap: 22px;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-nav a,
.text-link {
  transition: color 140ms ease;
}

.site-nav__link--active,
.site-nav a[aria-current="page"] {
  color: var(--text);
}

.site-nav a:hover,
.text-link:hover {
  color: var(--text);
}

.account-link,
.primary-button,
.secondary-button,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.account-link:hover,
.primary-button:hover,
.secondary-button:hover,
.theme-toggle:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}

.site-header .account-link {
  margin-left: auto;
}

.hero {
  padding: 54px 0 0;
}

.hero__inner {
  background: transparent;
}

.hero__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 56px;
  align-items: start;
}

.hero__eyebrow,
.section__eyebrow,
.form-title__eyebrow,
.panel-title__eyebrow,
.subject-line,
.place-cell,
.score-cell,
.info-grid dt,
.section-note,
.theme-toggle,
.tournament-item__meta,
.tournament-item__aside,
.leaderboard-meta,
.history-item__meta,
.history-item__date,
.history-item__result {
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
}

.hero__eyebrow,
.section__eyebrow,
.form-title__eyebrow,
.panel-title__eyebrow {
  margin-bottom: 12px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1,
.page-hero h1,
.section h2,
.sheet-card h3,
.sheet-panel h3,
.page-card h2,
.page-section h3,
.profile-header h2 {
  letter-spacing: -0.04em;
}

.hero h1 {
  font-size: clamp(3.9rem, 7vw, 5.2rem);
  line-height: 0.98;
  font-weight: 800;
}

.hero__lead,
.page-hero p,
.page-card__lead,
.muted,
.hero-note p,
.empty-state,
.profile-note {
  color: var(--muted);
}

.hero__lead {
  max-width: 57ch;
  margin-top: 12px;
  font-size: 0.95rem;
}

.hero-note {
  margin-top: 18px;
  padding: 14px 15px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.hero-note strong {
  display: inline-block;
  margin-bottom: 10px;
  font-size: 0.92rem;
}

.hero-note p {
  font-size: 0.92rem;
}

.hero-fade {
  display: none;
}

.section {
  padding-top: 36px;
}

.section-stage,
.page-stage {
  padding: 0;
  background: transparent;
}

.section__head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.section h2,
.page-card h2,
.page-section h3 {
  font-size: 1.15rem;
  font-weight: 800;
}

.section-note {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.latest-grid,
.login-layout,
.account-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.44fr) minmax(0, 0.56fr);
  gap: 18px;
  align-items: start;
}

.sheet-card,
.sheet-panel,
.page-card,
.page-section,
.leaderboard-table-wrap,
.empty-state {
  border: 1px solid var(--border);
  background: var(--surface);
}

.sheet-card,
.sheet-panel,
.page-card,
.page-section,
.empty-state {
  padding: 14px 15px;
}

.sheet-card,
.sheet-panel {
  min-height: 640px;
}

.sheet-card h3,
.sheet-panel h3,
.page-card h2,
.page-section h3 {
  font-size: 0.96rem;
  font-weight: 800;
}

.subject-line {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.info-grid div {
  padding: 11px 13px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.info-grid dt {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.info-grid dd {
  margin-top: 6px;
  font-size: 0.9rem;
  font-weight: 700;
}

.leaderboard-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
}

.leaderboard-table-wrap {
  overflow: hidden;
  margin-top: 10px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.leaderboard-table thead th {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
}

.leaderboard-table thead th:last-child,
.leaderboard-table tbody td:last-child {
  text-align: right;
}

.leaderboard-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid var(--border);
}

.leaderboard-table td {
  padding: 10px 12px;
  vertical-align: top;
}

.place-cell {
  width: 42px;
  color: var(--primary);
  font-size: 0.84rem;
  font-weight: 700;
}

.rank-1 .place-cell {
  color: var(--primary);
}

.rank-2 .place-cell,
.rank-3 .place-cell {
  color: var(--primary);
}

.participant-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.participant-cell strong {
  font-size: 0.93rem;
  font-weight: 800;
}

.school-cell {
  color: var(--muted);
  font-size: 0.78rem;
}

.score-cell {
  font-size: 0.88rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

.tournament-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  background: var(--surface);
}

.tournament-item {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(170px, 0.75fr) minmax(110px, 0.55fr);
  gap: 18px;
  align-items: center;
  padding: 14px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tournament-item--link,
.history-item--link {
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.tournament-item--link:hover,
.history-item--link:hover {
  background: var(--surface-soft);
}

.tournament-item:last-child {
  border-bottom: none;
}

.tournament-item__title {
  display: block;
  margin-bottom: 4px;
  font-size: 0.97rem;
  font-weight: 800;
}

.tournament-item__sub,
.tournament-item__meta,
.tournament-item__aside {
  color: var(--muted);
  font-size: 0.82rem;
}

.tournament-item__meta,
.tournament-item__aside {
  font-size: 0.78rem;
}

.tournament-item__aside {
  text-align: right;
}

.page-shell {
  padding: 30px 0 0;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.38fr) minmax(0, 0.62fr);
  gap: 18px;
  align-items: start;
}

.detail-main {
  display: grid;
  gap: 18px;
}

.detail-sidebar {
  display: grid;
  gap: 16px;
}

.section__head--compact {
  margin-bottom: 10px;
}

.task-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.task-card {
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.task-card--link {
  display: block;
  color: inherit;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.task-card--link:hover,
.task-card--link:focus-visible {
  border-color: var(--border-strong);
  background: var(--surface);
  transform: translateY(-1px);
}

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

.task-pill,
.task-card__difficulty {
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.76rem;
  font-weight: 700;
}

.task-pill {
  color: var(--primary);
}

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

.task-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.94rem;
}

.page-hero {
  margin-bottom: 20px;
}

.contest-facts-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.contest-fact-card {
  padding: 11px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.contest-fact-card span {
  display: block;
  color: var(--muted);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.contest-fact-card strong {
  display: block;
  margin-top: 6px;
  font-size: 0.94rem;
  font-weight: 800;
}

.page-hero h1 {
  margin-bottom: 8px;
  font-size: 2.1rem;
  font-weight: 800;
}

.page-card__lead {
  margin-top: 8px;
}

.account-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.account-summary-card {
  padding: 11px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.account-summary-card span {
  display: block;
  color: var(--muted);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.account-summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 0.94rem;
  font-weight: 800;
}

.page-section--wide {
  grid-column: 1 / -1;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.login-form input,
.login-form select {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.login-form input:focus,
.login-form select:focus {
  outline: none;
  border-color: var(--primary);
}

.login-form__actions,
.page-card__actions,
.account-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.text-link {
  font-size: 0.9rem;
  font-weight: 700;
}

.profile-block {
  display: grid;
  gap: 16px;
}

.profile-header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.profile-header h2 {
  margin-bottom: 6px;
  font-size: 1.55rem;
  font-weight: 800;
}

.profile-grid {
  display: grid;
  gap: 10px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.profile-row:last-child {
  border-bottom: none;
}

.profile-row span {
  color: var(--muted);
}

.profile-row strong {
  text-align: right;
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.82rem;
}

.profile-note {
  font-size: 0.84rem;
}

.history-list {
  display: grid;
  gap: 0;
  margin-top: 14px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(140px, 0.8fr) minmax(130px, 0.8fr);
  gap: 16px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child {
  border-bottom: none;
}

.history-item__title {
  font-weight: 800;
}

.history-item__main {
  display: grid;
  gap: 5px;
}

.history-item__meta,
.history-item__date {
  color: var(--muted);
  font-size: 0.78rem;
}

.history-item__date--stacked {
  display: grid;
  gap: 5px;
}

.history-item__result {
  justify-self: end;
  color: var(--muted);
  font-size: 0.76rem;
}

.history-item__result--stacked {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.history-stat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.73rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.history-stat--active {
  border-color: var(--primary);
}

.history-list--results {
  gap: 10px;
  margin-top: 12px;
}

.history-list--results .history-item {
  padding: 14px 15px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.history-list--results .history-item:last-child {
  border-bottom: 1px solid var(--border);
}

.attempts-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: start;
  margin-top: 14px;
}

.attempt-item {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(140px, 0.8fr) minmax(130px, 0.8fr);
  gap: 16px;
  align-items: center;
  width: 100%;
  padding: 16px 0;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.attempt-item:first-child {
  padding-top: 0;
}

.attempt-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.attempt-item:hover,
.attempt-item--active {
  color: var(--primary);
}

.code-viewer-empty,
.code-viewer {
  min-height: 320px;
  padding: 14px 15px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.code-viewer-empty {
  color: var(--muted);
}

.code-viewer__header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.code-viewer__header h4 {
  font-size: 1rem;
  font-weight: 800;
}

.code-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.code-meta-grid div {
  padding: 11px 13px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.code-meta-grid span {
  display: block;
  color: var(--muted);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.code-meta-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 0.86rem;
}

.code-block {
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  white-space: pre;
}

.code-block code {
  display: block;
  min-width: max-content;
}

.contest-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.admin-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.contest-main,
.admin-main {
  display: grid;
  gap: 14px;
}

.contest-sidebar,
.admin-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
}

.contest-sidebar__actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.contest-sidebar__group {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.contest-sidebar__group--tasks {
  padding-top: 0;
  border-top: none;
}

.contest-sidebar__actions .secondary-button,
.contest-sidebar__actions .primary-button {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  justify-content: flex-start;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.contest-section-links {
  display: grid;
  gap: 6px;
}

.contest-section-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 0.84rem;
  font-weight: 700;
  transition: border-color 140ms ease, background 140ms ease;
}

.contest-section-link::after {
  content: "↘";
  color: var(--muted);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.76rem;
}

.contest-section-link:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

.task-tab-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.contest-overview-grid {
  display: grid;
  gap: 14px;
}

.contest-overview-copy {
  display: grid;
  gap: 12px;
}

.contest-overview-summary {
  line-height: 1.7;
}

.contest-overview-notes {
  display: grid;
  gap: 8px;
}

.contest-overview-note {
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
}

.contest-overview-stats {
  margin-top: 0;
}

.task-tab {
  display: grid;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.task-tab span {
  color: var(--muted);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.74rem;
}

.task-tab strong {
  min-width: 0;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.task-tab:hover,
.task-tab--active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.problem-sheet {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.problem-sheet__section--full {
  grid-column: 1 / -1;
}

.problem-sheet__section {
  padding: 12px 13px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.problem-sheet__section h4 {
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 800;
}

.problem-sheet__section h5 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 800;
}

.problem-sheet__section > * + * {
  margin-top: 8px;
}

.problem-sheet__section > h4 + * {
  margin-top: 0;
}

.problem-sheet__section--facts {
  background: var(--surface);
}

.problem-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.problem-fact {
  padding: 10px 11px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.problem-fact span {
  display: block;
  color: var(--muted);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.problem-fact strong {
  display: block;
  margin-top: 6px;
  font-size: 0.9rem;
}

.problem-text {
  margin: 0;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.problem-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.problem-list li {
  line-height: 1.7;
}


.problem-pre {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.problem-examples {
  display: grid;
  gap: 10px;
}

.problem-example {
  display: grid;
  gap: 8px;
}

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

.empty-state--compact {
  padding: 0;
  border: none;
  background: transparent;
}

.workspace-form {
  display: grid;
  gap: 16px;
}

.workspace-form--two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.workspace-form__wide {
  grid-column: 1 / -1;
}

.workspace-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.workspace-form input,
.workspace-form select,
.workspace-form textarea {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.workspace-form textarea {
  resize: vertical;
}

.code-editor {
  display: block;
  min-height: 360px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.code-editor__pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 360px;
}

.code-editor__label {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.code-editor__surface {
  margin: 0;
  min-height: 0;
  padding: 12px 14px;
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.83rem;
  line-height: 1.7;
  tab-size: 4;
  white-space: pre-wrap;
  overflow: auto;
  color: var(--text);
  background: var(--surface);
  outline: none;
  word-break: break-word;
}

.code-editor__surface:empty::before {
  content: "";
  display: inline-block;
}

.code-editor__input {
  display: none;
}

.code-editor:focus-within {
  border-color: var(--primary);
}

.code-editor .token.comment,
.code-block--syntax .token.comment,
.code-editor .token.prolog,
.code-block--syntax .token.prolog,
.code-editor .token.doctype,
.code-block--syntax .token.doctype,
.code-editor .token.cdata,
.code-block--syntax .token.cdata {
  color: var(--syntax-comment);
}

.code-editor .token.keyword,
.code-block--syntax .token.keyword,
.code-editor .token.boolean,
.code-block--syntax .token.boolean,
.code-editor .token.class-name,
.code-block--syntax .token.class-name,
.code-editor .token.builtin,
.code-block--syntax .token.builtin {
  color: var(--syntax-keyword);
}

.code-editor .token.string,
.code-block--syntax .token.string,
.code-editor .token.char,
.code-block--syntax .token.char,
.code-editor .token.attr-value,
.code-block--syntax .token.attr-value {
  color: var(--syntax-string);
}

.code-editor .token.number,
.code-block--syntax .token.number,
.code-editor .token.constant,
.code-block--syntax .token.constant {
  color: var(--syntax-number);
}

.code-editor .token.function,
.code-block--syntax .token.function,
.code-editor .token.method,
.code-block--syntax .token.method {
  color: var(--syntax-function);
}

.code-editor .token.operator,
.code-block--syntax .token.operator,
.code-editor .token.entity,
.code-block--syntax .token.entity,
.code-editor .token.url,
.code-block--syntax .token.url {
  color: var(--syntax-operator);
}

.code-editor .token.punctuation,
.code-block--syntax .token.punctuation {
  color: var(--syntax-punctuation);
}

.workspace-form input:focus,
.workspace-form select:focus,
.workspace-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.attempts-layout--stacked {
  grid-template-columns: 1fr;
}

.history-list--expanded {
  gap: 6px;
  margin-top: 0;
}

.contest-leaderboard-wrap {
  margin-top: 0;
}

.attempt-entry {
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 140ms ease, background 140ms ease;
}

.attempt-entry--active {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}

.attempt-entry .attempt-item {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 10px 12px;
  border-bottom: none;
}

.attempt-item__main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.attempt-item__title-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.attempt-item__task-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.74rem;
  font-weight: 700;
}

.attempt-item__meta {
  color: var(--muted);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.69rem;
  line-height: 1.35;
}

.attempt-item__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attempt-item__aside {
  display: grid;
  gap: 7px;
  justify-items: end;
  min-width: 168px;
}

.attempt-item__summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

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

.attempt-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.attempt-toggle-label__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.72rem;
  line-height: 1;
}

.attempt-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.68rem;
  font-weight: 700;
}

.attempt-badge--score {
  color: var(--text);
}

.attempt-entry--active .attempt-item {
  color: inherit;
}

.attempt-entry:hover {
  border-color: var(--border-strong);
}

.attempt-entry:hover .attempt-item {
  color: inherit;
}

.attempt-entry + .attempt-entry {
  margin-top: 0;
}

.code-viewer--inline,
.attempt-inline-state {
  margin: 0 12px 12px;
}

.code-viewer--inline {
  border-top: 1px solid var(--border);
  padding: 12px 0 0;
  background: transparent;
}

.attempt-inline-state {
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.admin-task-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.35fr) minmax(0, 0.65fr);
  gap: 18px;
  margin-top: 14px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding: 20px 0 28px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
}

@media (min-width: 1100px) {
  .contest-sidebar {
    position: sticky;
    top: 16px;
  }

  .contest-main {
    grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr);
    gap: 16px;
    align-items: start;
  }

  .contest-panel--overview,
  .contest-panel--statement {
    grid-column: 1 / -1;
  }

  .contest-panel--leaderboard,
  .contest-panel--submission,
  .contest-panel--attempts {
    grid-column: 1 / -1;
  }

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

  .problem-facts {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .hero__layout,
  .latest-grid,
  .login-layout,
  .account-layout,
  .detail-layout,
  .contest-layout,
  .admin-layout,
  .admin-task-layout,
  .attempts-layout,
  .task-list,
  .tournament-item,
  .attempt-item,
  .history-item {
    grid-template-columns: 1fr;
  }

  .site-nav {
    display: none;
  }

  .hero {
    padding-top: 32px;
  }

  .hero-note {
    margin-top: 0;
  }

  .sheet-card,
  .sheet-panel {
    min-height: auto;
  }

  .tournament-item__aside,
  .history-item__result {
    text-align: left;
    justify-self: start;
  }

  .code-meta-grid {
    grid-template-columns: 1fr;
  }

  .workspace-form--two-column {
    grid-template-columns: 1fr;
  }

  .contest-sidebar__actions .secondary-button,
  .contest-sidebar__actions .primary-button {
    justify-content: center;
    white-space: normal;
  }

  .account-summary-strip,
  .contest-facts-strip,
  .problem-example__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .attempt-item__aside,
  .attempt-item__foot {
    justify-items: start;
  }

  .attempt-item__foot {
    justify-content: flex-start;
  }

  .attempt-item__summary {
    justify-content: flex-start;
  }

}

@media (max-width: 640px) {
  .site-shell,
  .page-shell {
    width: calc(100% - 24px);
  }

  .site-header__inner {
    gap: 12px;
    min-height: 58px;
  }

  .brand {
    font-size: 0.92rem;
  }

  .account-link,
  .primary-button,
  .secondary-button,
  .theme-toggle {
    min-height: 36px;
    padding: 0 12px;
  }

  .hero__layout {
    gap: 24px;
  }

  .hero h1 {
    font-size: clamp(2.8rem, 14vw, 3.8rem);
  }

  .account-summary-strip,
  .contest-facts-strip,
  .problem-example__grid {
    grid-template-columns: 1fr;
  }

  .section__head,
  .site-footer,
  .login-form__actions,
  .page-card__actions,
  .account-actions,
  .profile-row,
  .code-viewer__header {
    flex-direction: column;
    align-items: start;
  }

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

  .profile-row strong {
    text-align: left;
  }
}
