:root {
  color-scheme: light;
  --bg: #f7efe2;
  --surface: rgba(255, 251, 245, 0.82);
  --surface-strong: rgba(255, 250, 242, 0.96);
  --surface-deep: #fff7ec;
  --surface-soft: rgba(255, 247, 236, 0.74);
  --text: #1f2933;
  --muted: #5a6774;
  --accent: #c2410c;
  --accent-dark: #7c2d12;
  --accent-soft: rgba(194, 65, 12, 0.08);
  --line: rgba(31, 41, 51, 0.08);
  --shadow: 0 20px 60px rgba(72, 55, 32, 0.14);
  --radius: 24px;
  --code-bg: #171a21;
  --code-text: #edf2f7;
  --code-panel: #232938;
  --code-muted: #94a3b8;
  --code-keyword: #f59e0b;
  --code-string: #86efac;
  --code-number: #7dd3fc;
  --code-comment: #64748b;
  --code-type: #f472b6;
  --preview-bg: rgba(255, 248, 239, 0.98);
  --preview-panel: rgba(255, 252, 247, 0.92);
  --preview-line: rgba(194, 65, 12, 0.1);
  --preview-text: rgba(31, 41, 51, 0.98);
  --preview-fade-top: rgba(255, 248, 239, 0);
  --preview-fade-bottom: rgba(255, 248, 239, 0.1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: rgba(15, 23, 42, 0.86);
  --surface-strong: rgba(17, 24, 39, 0.96);
  --surface-deep: #111827;
  --surface-soft: rgba(17, 24, 39, 0.78);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #fb923c;
  --accent-dark: #fed7aa;
  --accent-soft: rgba(251, 146, 60, 0.14);
  --line: rgba(148, 163, 184, 0.12);
  --shadow: 0 24px 70px rgba(2, 6, 23, 0.55);
  --code-bg: #020617;
  --code-text: #e2e8f0;
  --code-panel: #0f172a;
  --code-muted: #94a3b8;
  --code-keyword: #fb923c;
  --code-string: #86efac;
  --code-number: #7dd3fc;
  --code-comment: #64748b;
  --code-type: #f9a8d4;
  --preview-bg: rgba(255, 248, 239, 0.98);
  --preview-panel: rgba(255, 252, 247, 0.92);
  --preview-line: rgba(194, 65, 12, 0.1);
  --preview-text: rgba(31, 41, 51, 0.98);
  --preview-fade-top: rgba(255, 248, 239, 0);
  --preview-fade-bottom: rgba(255, 248, 239, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 8%, rgba(251, 146, 60, 0.2), transparent 24%),
    radial-gradient(circle at 85% 12%, rgba(56, 189, 248, 0.16), transparent 22%),
    radial-gradient(circle at 84% 86%, rgba(251, 191, 36, 0.14), transparent 26%),
    linear-gradient(135deg, color-mix(in srgb, var(--bg) 68%, white 32%) 0%, color-mix(in srgb, var(--bg) 86%, #ffe8d2 14%) 42%, var(--bg) 100%);
  transition: background 180ms ease, color 180ms ease;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background-image: linear-gradient(rgba(148, 163, 184, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.24), transparent 85%);
}

body::after {
  inset: auto -60px -40px auto;
  width: 460px;
  height: 460px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 180'%3E%3Cpath d='M110 20h30l20 20v30h-20V48h-22v84h22v-22h20v30l-20 20h-30l-20-20V40z' fill='none' stroke='%23f97316' stroke-width='12' stroke-linecap='round' stroke-linejoin='round' opacity='0.85'/%3E%3Cpath d='M72 56 42 86l30 30' fill='none' stroke='%23fb923c' stroke-width='12' stroke-linecap='round' stroke-linejoin='round' opacity='0.8'/%3E%3Ccircle cx='96' cy='90' r='8' fill='%23f97316' opacity='0.9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: blur(28px);
  opacity: 0.14;
  transform: rotate(-10deg);
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1320px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

.site-bar,
.hero,
.section-block,
.stat-card {
  backdrop-filter: blur(18px);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.site-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border-radius: 20px;
  margin-bottom: 18px;
}

.brand-mark {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.site-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-note {
  color: var(--muted);
  font-size: 0.92rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.95fr);
  gap: 24px;
  padding: 32px;
  border-radius: calc(var(--radius) + 6px);
}

.eyebrow {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.74rem;
  color: var(--accent-dark);
}

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

h1 {
  margin-bottom: 16px;
  font-size: clamp(2.4rem, 4vw, 4.6rem);
  line-height: 0.96;
  max-width: 11ch;
}

.hero-text,
.modal-meta,
.selected-date-summary,
.panel-label,
.results-count,
.file-name,
.created-at,
.solution-meta,
.toolbar label span,
.stat-card span,
.fallback-note,
.section-copy,
.site-note,
.summary-note {
  color: var(--muted);
}

.hero-text,
.section-copy,
.summary-note {
  line-height: 1.7;
}

.hero-points,
.hero-actions,
.code-actions,
.modal-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-points {
  margin: 22px 0 0;
}

.hero-point,
.today-badge,
.status-badge,
.problem-number,
.language-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.hero-point,
.today-badge,
.problem-number {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.status-badge,
.language-pill {
  background: linear-gradient(135deg, rgba(12, 74, 110, 0.12), rgba(56, 189, 248, 0.2));
  color: #0c4a6e;
  border: 1px solid rgba(14, 116, 144, 0.18);
}

:root[data-theme="dark"] .status-badge,
:root[data-theme="dark"] .language-pill {
  color: #cbeeff;
}

.hero-actions {
  margin-top: 24px;
}

.primary-button,
.secondary-button,
.source-link,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, color 160ms ease;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  padding: 0 20px;
  font-weight: 700;
}

.compact-button {
  min-height: 40px;
  padding: 0 16px;
}

.primary-button {
  color: #fff9f2;
  background: linear-gradient(135deg, #c2410c 0%, #ea580c 100%);
  box-shadow: 0 14px 30px rgba(194, 65, 12, 0.26);
}

.secondary-button,
.icon-button,
.source-link {
  color: var(--text);
  background: color-mix(in srgb, var(--surface-strong) 90%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
}

.hero-panel,
.latest-card,
.solution-card,
.toolbar,
.selected-date-summary,
.archive-results-head {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.hero-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.preview-shell {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: linear-gradient(180deg, var(--preview-panel), var(--preview-bg));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hero-preview {
  min-height: 320px;
}

.preview-grid {
  position: relative;
  height: 100%;
  overflow: hidden;
}

.preview-code {
  position: relative;
  display: grid;
  align-content: start;
  gap: 10px;
  height: 100%;
  padding: 22px;
  overflow: hidden;
  color: var(--preview-text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  filter: blur(0.2px);
}

.preview-line {
  display: block;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--preview-line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.preview-fade {
  position: absolute;
  inset: auto 0 0;
  height: 8%;
  background: linear-gradient(180deg, var(--preview-fade-top), var(--preview-fade-bottom));
}

.latest-highlight {
  display: grid;
  gap: 10px;
}

.latest-highlight strong {
  font-size: 1.45rem;
  line-height: 1.1;
}

.problem-number {
  font-family: "IBM Plex Mono", monospace;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin: 22px 0;
}

.stat-card {
  padding: 22px 24px;
  border-radius: 22px;
}

.accent-stat {
  background: linear-gradient(135deg, rgba(194, 65, 12, 0.1), rgba(234, 88, 12, 0.14));
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.5rem, 3vw, 2.4rem);
}

.section-block {
  margin-top: 28px;
  padding: 28px;
  border-radius: calc(var(--radius) + 4px);
}

.section-heading {
  margin-bottom: 20px;
}

.section-heading h2 {
  margin-bottom: 10px;
  font-size: clamp(1.5rem, 2vw, 2.2rem);
}

.latest-grid,
.solutions-grid {
  display: grid;
  gap: 18px;
  grid-auto-rows: 1fr;
}

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

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

.latest-card,
.solution-card {
  display: grid;
  grid-template-rows: 162px minmax(0, 1fr) auto;
  gap: 14px;
  padding: 18px;
  min-height: 100%;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(72, 55, 32, 0.08);
}

.latest-card {
  grid-template-rows: 154px minmax(0, 1fr) auto;
}

.solution-card {
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.solution-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(72, 55, 32, 0.12);
}

.card-preview,
.card-preview .preview-grid {
  height: 100%;
}

.card-preview {
  min-height: 154px;
  overflow: hidden;
  border-radius: 18px;
}

.card-preview .preview-code {
  padding: 18px;
  gap: 12px;
  font-size: 0.86rem;
  line-height: 1.7;
}

.card-preview .preview-line {
  padding: 8px 14px;
  border-radius: 12px;
}

.card-content {
  display: grid;
  align-content: start;
  gap: 12px;
  padding-top: 2px;
  min-height: 0;
}

.solution-meta,
.card-footer,
.code-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.problem-title {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.18;
}

.file-name,
.created-at,
.modal-meta {
  font-size: 0.92rem;
}

.card-footer {
  align-items: end;
  margin-top: 6px;
}

.source-link {
  min-height: 38px;
  padding: 0 14px;
  color: var(--accent-dark);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-strong));
  font-weight: 700;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(220px, 0.6fr);
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.calendar-toolbar {
  grid-template-columns: minmax(240px, 0.75fr) minmax(0, 1.25fr);
}

.toolbar label {
  display: grid;
  gap: 8px;
}

.selected-date-summary,
.archive-results-head {
  padding: 16px 18px;
}

.selected-date-summary {
  display: grid;
  gap: 4px;
  min-height: 82px;
}

.archive-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.archive-results-head h3 {
  margin-bottom: 0;
  font-size: 1.2rem;
}

.search-box input,
.filter-box select,
.filter-box input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--muted) 24%, transparent);
  background: color-mix(in srgb, var(--surface-strong) 95%, transparent);
  color: var(--text);
}

.search-box input:focus,
.filter-box select:focus,
.filter-box input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border-radius: var(--radius);
  border: 1px dashed rgba(90, 103, 116, 0.28);
  background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
}

.code-modal {
  width: min(1100px, calc(100% - 20px));
  border: 0;
  padding: 0;
  background: transparent;
}

.code-modal::backdrop {
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(6px);
}

.code-modal-card {
  background: var(--surface-deep);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 22px;
}

#modal-title {
  color: var(--text);
  line-height: 1.15;
}

.modal-problem-id {
  color: var(--accent);
}

.icon-button {
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
}

.code-actions {
  justify-content: space-between;
  margin: 20px 0 14px;
}

.code-shell {
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.code-shell-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  background: var(--code-panel);
  color: var(--code-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.83rem;
}

.code-shell-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
}

.code-shell-file {
  margin-left: 8px;
}

.code-block {
  margin-bottom: 0;
  padding: 0;
  background: var(--code-bg);
  color: var(--code-text);
  overflow: auto;
  max-height: 70vh;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.92rem;
  line-height: 1.65;
}

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

.code-line {
  display: grid;
  grid-template-columns: 56px auto;
  min-width: max-content;
}

.line-number {
  user-select: none;
  color: rgba(148, 163, 184, 0.7);
  text-align: right;
  padding: 0 14px 0 0;
  border-right: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255, 255, 255, 0.02);
}

.line-content {
  display: block;
  padding: 0 18px;
  white-space: pre;
}

.token-comment {
  color: var(--code-comment);
}

.token-string {
  color: var(--code-string);
}

.token-number {
  color: var(--code-number);
}

.token-keyword {
  color: var(--code-keyword);
}

.token-type {
  color: var(--code-type);
}

.token-strong {
  font-weight: 600;
}

.primary-button:hover,
.secondary-button:hover,
.source-link:hover,
.icon-button:hover {
  transform: translateY(-2px);
}

@media (max-width: 1200px) {
  .latest-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 900px) {
  .site-bar,
  .archive-results-head,
  .solution-meta,
  .card-footer,
  .code-modal-header,
  .code-actions {
    display: grid;
    align-items: stretch;
  }

  .hero,
  .stats-grid,
  .toolbar,
  .calendar-toolbar,
  .latest-grid,
  .solutions-grid {
    grid-template-columns: 1fr;
  }

  .page-shell {
    width: min(100% - 20px, 1320px);
    padding-top: 20px;
  }

  .hero,
  .section-block,
  .code-modal-card {
    padding: 22px;
  }

  .site-bar-actions {
    flex-wrap: wrap;
  }
}
