.contest-shell {
  display: grid;
  gap: 18px;
}

.contest-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 249, 239, 0.82);
  box-shadow: var(--shadow);
  padding: 24px;
}

.contest-header h1 {
  margin: 0 0 10px;
  font-family: "Instrument Serif", serif;
  font-size: 3rem;
  font-weight: 400;
  line-height: 1;
}

.contest-header p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.contest-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.contest-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 18px;
}

.contest-layout > * {
  min-width: 0;
  max-width: 100%;
}

.contest-app {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.contest-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 249, 239, 0.78);
  padding: 12px;
}

.contest-toolbar span {
  color: var(--ink-soft);
  font-weight: 700;
}

.contest-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

.contest-table th,
.contest-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.contest-table th {
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.contest-table tr:last-child td {
  border-bottom: 0;
}

.contest-table a {
  color: var(--leaf);
  font-weight: 700;
  text-decoration: none;
}

.contest-table a:hover,
.contest-table a:focus-visible {
  text-decoration: underline;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid rgba(47, 90, 68, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(47, 90, 68, 0.1);
  color: var(--leaf);
  font-weight: 700;
}

.problem-card {
  display: grid;
  gap: 18px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.important-note ul {
  margin: 0;
  padding-left: 20px;
}

.important-note li {
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.6;
}

.problem-domain {
  display: grid;
  gap: 18px;
}

.problem-domain__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.problem-domain__header h2 {
  margin: 0;
}

.problem-domain__header .btn {
  flex: 0 0 auto;
}

.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.68;
}

.problem-family {
  display: grid;
  gap: 12px;
}

.problem-family__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.problem-family__header h3 {
  margin: 0 0 6px;
  font-size: 1.24rem;
}

.problem-family__header p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.problem-id {
  display: none;
}

.problem-table th,
.problem-table td {
  padding: 7px 12px;
  vertical-align: middle;
}

.problem-table .btn {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 0.9rem;
  line-height: 1.1;
}

.problem-statement {
  display: grid;
  gap: 14px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.problem-statement > * {
  min-width: 0;
  max-width: 100%;
}

.problem-statement h2,
.problem-statement h3 {
  margin-bottom: 0;
}

.problem-statement p,
.problem-statement li {
  color: var(--ink-soft);
  line-height: 1.65;
}

.problem-statement ul {
  margin: 0;
  padding-left: 20px;
}

.copyable-text-block {
  display: grid;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  overflow: hidden;
}

.copyable-text-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 700;
}

.copy-text-button {
  min-height: 28px;
  border: 1px solid rgba(47, 90, 68, 0.28);
  border-radius: var(--radius-sm);
  background: rgba(255, 249, 239, 0.72);
  color: var(--leaf);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 9px;
}

.copy-text-button:hover {
  border-color: rgba(47, 90, 68, 0.48);
  background: rgba(47, 90, 68, 0.1);
}

.system-message-block {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  border: 1px solid rgba(47, 90, 68, 0.24);
  border-radius: var(--radius-md);
  background: rgba(47, 90, 68, 0.08);
  padding: 12px;
}

.system-message-block__header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  color: var(--leaf);
  font-size: 0.88rem;
  font-weight: 700;
}

.system-message-block__header .copy-text-button {
  margin-left: auto;
}

.system-message-block__header strong {
  border: 1px solid rgba(47, 90, 68, 0.22);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  background: rgba(255, 249, 239, 0.7);
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.system-message-text {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-inline-size: 0;
  max-inline-size: 100%;
  max-height: 34vh;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--ink);
  font: 0.94rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.example-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  padding: 16px;
}

.answer-form {
  display: grid;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.answer-form label {
  display: grid;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
}

.mcqa-options {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.mcqa-options legend {
  margin-bottom: 4px;
  font-weight: 700;
}

.mcqa-option {
  display: grid;
  grid-template-columns: auto 36px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
}

.mcqa-option input {
  margin: 0;
}

.mcqa-option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(47, 90, 68, 0.12);
  color: var(--leaf);
}

.mcqa-option strong {
  font-weight: 600;
  line-height: 1.45;
}

.answer-form textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  padding: 12px;
  resize: vertical;
}

.answer-form .text-input,
.text-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
}

.answer-form .text-input:focus,
.text-input:focus {
  border-color: rgba(47, 90, 68, 0.44);
  outline: none;
}

.answer-form textarea:focus {
  border-color: rgba(47, 90, 68, 0.44);
  outline: none;
}

.submission-result {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(47, 90, 68, 0.28);
  border-radius: var(--radius-md);
  background: rgba(47, 90, 68, 0.08);
  padding: 16px;
}

.submission-result p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

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

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

.sidebar-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

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

.sidebar-row span {
  color: var(--ink-soft);
}

.submission-empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--ink-soft);
  background: rgba(255, 249, 239, 0.5);
}

.submission-answer {
  max-width: 420px;
  color: var(--ink-soft);
}

.prompt-text {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-inline-size: 0;
  max-inline-size: 100%;
  max-height: 62vh;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  border: 0;
  border-radius: 0;
  background: var(--panel);
  color: var(--ink);
  font: 0.96rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 16px;
}

.prompt-image {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  overflow: hidden;
}

.prompt-image img {
  display: block;
  width: 100%;
  height: auto;
}

.prompt-image figcaption {
  padding: 10px 12px;
  color: var(--ink-soft);
}

.status-error {
  border-color: rgba(182, 90, 48, 0.44);
  color: #7b2f18;
}

.status-message {
  border-color: rgba(47, 90, 68, 0.28);
}

.stats-shell {
  width: min(1280px, calc(100vw - 32px));
}

.stats-hero {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
  gap: 18px;
}

.stats-metric-grid,
.stats-grid {
  display: grid;
  gap: 14px;
}

.stats-metric-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
}

.stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-metric {
  display: grid;
  align-content: start;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 249, 239, 0.82);
  box-shadow: var(--shadow);
  padding: 18px;
}

.stats-metric span {
  color: var(--rust);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.stats-metric strong {
  margin-top: 10px;
  font-family: "Instrument Serif", serif;
  font-size: 3.2rem;
  font-weight: 400;
  line-height: 0.94;
}

.stats-metric p {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-weight: 700;
}

.stats-graphic {
  display: grid;
  gap: 14px;
}

.stats-graphic__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.stats-graphic__header h2,
.stats-graphic__empty h2 {
  margin: 0;
  font-size: 1.8rem;
}

.stats-graphic__header strong {
  color: var(--leaf);
  font-size: 1.1rem;
}

.stats-graphic__empty p:last-child {
  color: var(--ink-soft);
}

.stats-chart {
  display: block;
  width: 100%;
  height: auto;
}

.stats-chart-bg {
  fill: rgba(47, 90, 68, 0.08);
}

.stats-chart-track {
  fill: rgba(32, 49, 38, 0.1);
}

.stats-chart-bar {
  fill: var(--leaf);
}

.stats-chart-label,
.stats-chart-value {
  fill: var(--ink);
  font: 700 13px "Familjen Grotesk", sans-serif;
}

.stats-chart-value {
  fill: white;
}

.stats-bar-list {
  display: grid;
  gap: 12px;
}

.stats-bar-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(120px, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.stats-bar-row strong,
.stats-bar-row span {
  display: block;
}

.stats-bar-row strong {
  overflow-wrap: anywhere;
}

.stats-bar-row span {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.stats-bar-row__track {
  height: 14px;
  border-radius: var(--radius-sm);
  background: rgba(32, 49, 38, 0.1);
  overflow: hidden;
}

.stats-bar-row__track span {
  display: block;
  height: 100%;
  border-radius: var(--radius-sm);
  background: var(--leaf);
}

.stats-bar-row b {
  color: var(--leaf);
}

@media (max-width: 820px) {
  .contest-header,
  .contest-layout,
  .stats-hero,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .contest-header {
    display: grid;
  }

  .contest-nav {
    justify-content: flex-start;
  }

  .contest-table {
    display: block;
    overflow-x: auto;
  }

  .stats-shell {
    width: min(100vw - 20px, 100%);
  }

  .stats-metric-grid {
    grid-template-columns: 1fr;
  }

  .stats-bar-row {
    grid-template-columns: 1fr auto;
  }

  .stats-bar-row__track {
    grid-column: 1 / -1;
  }
}
