:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-strong: #f0f0f0;
  --ink: #111111;
  --muted: #666666;
  --line: #dddddd;
  --accent: #111111;
  --shadow: 0 8px 24px rgba(17, 17, 17, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--ink);
}

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

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

img {
  display: block;
  width: 100%;
}

.page-shell {
  min-height: 100vh;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar__inner {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.topbar__home {
  display: inline-block;
  font-size: 1.5rem;
  font-weight: 700;
}

.main-content {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.overview {
  display: block;
  margin-bottom: 8px;
}

.overview__item {
  width: 100%;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.overview__label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

.overview__item strong {
  display: block;
  font-size: 1.6rem;
  line-height: 1.15;
}

.section-head {
  padding: 0 0 20px;
}

.section-head h2,
.placeholder h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
}

.contest-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.contest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.contest-row:hover {
  background: rgba(17, 17, 17, 0.02);
}

.contest-row__body {
  flex: 1 1 auto;
  min-width: 0;
}

.contest-row__title {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
}

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

.contest-row__meta-box {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.contest-row__meta-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.3;
}

.contest-row__meta-value {
  display: block;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.45;
}

.contest-row__arrow {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

.detail-page {
  padding-top: 8px;
}

.detail-header {
  padding-bottom: 28px;
}

.back-link {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.detail-header h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
}

.detail-description {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.detail-meta-box {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detail-meta-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.3;
}

.detail-meta-value {
  display: block;
  font-size: 1rem;
  line-height: 1.45;
}

.detail-section {
  padding-top: 36px;
}

.detail-section__header {
  padding-bottom: 16px;
}

.detail-section__header h3 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

.problem-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.problem-row {
  border-bottom: 1px solid var(--line);
}

.problem-row__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0;
}

.problem-row__link:hover {
  background: rgba(17, 17, 17, 0.02);
}

.problem-row__body {
  min-width: 0;
}

.problem-row__title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
}

.problem-row__subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.problem-row__credit {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.problem-row__arrow {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

.problem-list-placeholder,
.problem-list-empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.attachment-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.attachment-list__item {
  border-bottom: 1px solid var(--line);
}

.attachment-link {
  display: inline-block;
  width: 100%;
  padding: 16px 0;
  color: var(--ink);
  line-height: 1.5;
}

.attachment-link:hover {
  color: var(--muted);
}

.problem-page {
  padding-top: 8px;
}

.problem-header {
  padding-bottom: 24px;
}

.problem-header__id {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
  font-weight: 600;
}

.problem-header h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
}

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

.problem-limit-box {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.problem-limit-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.problem-limit-value {
  display: block;
  font-size: 1rem;
  line-height: 1.45;
}

.problem-section {
  padding-top: 36px;
}

.problem-section h3 {
  margin: 0 0 16px;
  font-size: 1.35rem;
  line-height: 1.2;
}

.problem-section__content {
  color: var(--ink);
  line-height: 1.75;
}

.problem-section__content p {
  margin: 0 0 14px;
}

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

.problem-section__content ol {
  margin: 0;
  padding-left: 24px;
}

.problem-section__content li + li {
  margin-top: 8px;
}

.problem-section__content code,
.problem-tex-block code,
.problem-list-label code {
  font-family: ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
}

.problem-list-label {
  font-weight: 600;
}

.problem-tex-block {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 0.98rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.problem-centered-block {
  margin: 0 0 14px;
  text-align: center;
}

.problem-centered-block > * + * {
  margin-top: 10px;
}

.problem-image {
  display: inline-block;
  max-width: min(100%, 720px);
  height: auto;
  vertical-align: middle;
}

.problem-inline-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.problem-text-small {
  display: inline-block;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--muted);
}

.problem-table-wrap {
  overflow-x: auto;
  margin: 0 0 14px;
}

.problem-table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
  background: var(--surface);
}

.problem-table td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  vertical-align: top;
  white-space: normal;
}

.problem-table .problem-image {
  max-width: min(100%, 360px);
}

.problem-centered-block .problem-table-wrap {
  margin-bottom: 10px;
}

.problem-centered-block .problem-table {
  width: auto;
  margin: 0 auto;
  background: transparent;
}

.problem-centered-block .problem-table td {
  border: none;
  padding: 0 12px;
  text-align: center;
}

.problem-figure-grid {
  display: grid;
  justify-content: center;
  align-items: end;
  gap: 20px;
  margin: 0 auto 10px;
}

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

.problem-figure-grid--2 {
  grid-template-columns: repeat(2, minmax(220px, auto));
}

.problem-figure-grid__cell {
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.problem-figure-grid__cell .problem-image {
  max-width: min(100%, 420px);
}

.sample-list {
  display: grid;
  gap: 16px;
}

.sample-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sample-card h4 {
  margin: 0 0 10px;
  font-size: 1rem;
  line-height: 1.3;
}

.sample-card__code {
  overflow-x: auto;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  font-family: "SFMono-Regular", SFMono-Regular, Consolas, "Liberation Mono",
    Menlo, monospace;
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.sample-card__code:last-child {
  margin-bottom: 0;
}

.placeholder {
  padding: 0;
}

.placeholder p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 920px) {
  .contest-row__meta-group {
    grid-template-columns: 1fr;
  }

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

  .problem-limit-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main-content {
    width: min(100% - 20px, 960px);
    padding-top: 24px;
  }

  .contest-row {
    align-items: start;
  }

  .contest-row__meta-group {
    grid-template-columns: 1fr;
  }

  .contest-row__arrow {
    padding-top: 2px;
  }
}
