:root {
  --bg: #f4efe7;
  --bg-accent: #efe2cf;
  --card: #fffaf3;
  --text: #1e1a17;
  --muted: #6b625b;
  --line: #d8c7b3;
  --primary: #b2532d;
  --primary-dark: #7d381e;
  --success: #2f7d4a;
  --danger: #a33434;
  --warning: #a56d00;
  --shadow: 0 18px 40px rgba(85, 52, 32, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(178, 83, 45, 0.16), transparent 28%),
    linear-gradient(180deg, var(--bg-accent), var(--bg));
  min-height: 100vh;
}

.container {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.site-brand {
  color: var(--text);
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 800;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-user {
  color: var(--muted);
  font-weight: 700;
}

.hero,
.card {
  background: rgba(255, 250, 243, 0.92);
  border: 1px solid rgba(216, 199, 179, 0.85);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 32px;
  margin-bottom: 24px;
}

.card {
  padding: 28px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
}

.difficulty,
.back-link,
th {
  color: var(--muted);
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  text-decoration: none;
}

.back-link:hover,
a:hover {
  color: var(--primary-dark);
}

a {
  color: var(--primary);
}

.problem-table {
  width: 100%;
  border-collapse: collapse;
}

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

.problem-table tr:last-child td {
  border-bottom: none;
}

.problem-solved-row td {
  background: rgba(47, 125, 74, 0.12);
}

.problem-solved-row:hover td {
  background: rgba(47, 125, 74, 0.18);
}

.solved-mark {
  display: inline-flex;
  align-items: center;
  margin-left: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(47, 125, 74, 0.16);
  color: var(--success);
  font-size: 0.8rem;
  font-weight: 700;
  vertical-align: middle;
}

.sample-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

pre,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
  overflow-x: auto;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.95rem;
  line-height: 1.55;
}

textarea {
  min-height: 280px;
  resize: vertical;
}

button {
  margin-top: 14px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.secondary-button {
  margin-top: 0;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 10px 18px;
}

button:hover {
  filter: brightness(1.05);
}

.secondary-button:hover {
  background: rgba(178, 83, 45, 0.08);
}

.error {
  color: var(--danger);
  font-weight: 700;
}

.success {
  color: var(--success);
  font-weight: 700;
}

.notice {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(239, 226, 207, 0.45);
}

.auth-card {
  max-width: 560px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.collapsible summary {
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 800;
  list-style: none;
}

.collapsible summary::-webkit-details-marker {
  display: none;
}

.collapsible summary::after {
  content: "▼";
  float: right;
  color: var(--muted);
  font-size: 0.9rem;
}

.collapsible[open] summary::after {
  content: "▲";
}

.collapsible > :not(summary) {
  margin-top: 18px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
}

.mini-stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
}

.mini-stat strong {
  display: block;
  margin-top: 6px;
  font-size: 1.6rem;
}

.mini-stat-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.entity-list {
  display: grid;
  gap: 18px;
}

.compact-list {
  gap: 12px;
}

.entity-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.entity-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.entity-head h3 {
  margin-bottom: 6px;
}

.entity-meta {
  margin: 4px 0;
  color: var(--muted);
}

.sample-block {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(244, 239, 231, 0.5);
}

.hidden-case-block {
  border-style: dashed;
  background: rgba(178, 83, 45, 0.06);
}

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

.danger-form {
  margin-top: 10px;
}

.danger-button {
  background: linear-gradient(135deg, #b44040, #7d2222);
}

.danger-zone {
  max-width: 520px;
}

.problem-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.problem-row {
  padding: 14px 16px;
}

.problem-row-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.problem-main h3 {
  margin-bottom: 4px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(178, 83, 45, 0.1);
  color: var(--primary-dark);
  font-size: 0.9rem;
  font-weight: 700;
}

.status-pill.status-ac {
  background: rgba(47, 125, 74, 0.16);
  color: var(--success);
}

.status-pill.status-wa,
.status-pill.status-re {
  background: rgba(163, 52, 52, 0.14);
  color: var(--danger);
}

.status-pill.status-tle {
  background: rgba(165, 109, 0, 0.18);
  color: var(--warning);
}

.secondary-link {
  font-weight: 700;
  text-decoration: none;
}

.nested-editor {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.nested-editor summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--primary);
  list-style: none;
}

.nested-editor summary::-webkit-details-marker {
  display: none;
}

.nested-editor summary::before {
  content: "+ ";
}

.nested-editor[open] summary::before {
  content: "- ";
}

.nested-editor > :not(summary) {
  margin-top: 14px;
}

label {
  display: block;
  margin: 14px 0 8px;
  font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px 14px;
  font-size: 1rem;
}

.upload-panel {
  margin-bottom: 18px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.result-badge {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
}

.status-ac {
  background: var(--success);
}

.status-wa,
.status-re {
  background: var(--danger);
}

.status-tle {
  background: var(--warning);
}

.result-detail + .result-detail {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 20px;
}

@media (max-width: 640px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .entity-head {
    flex-direction: column;
  }

  .problem-row-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .problem-stats {
    justify-content: flex-start;
  }

  .container {
    width: min(100% - 20px, 980px);
    padding-top: 20px;
  }

  .hero,
  .card {
    padding: 20px;
    border-radius: 16px;
  }
}
