:root {
  color-scheme: light;
  --bg: #f7f8fc;
  --bg-soft: #eef3ff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --surface-muted: rgba(241, 245, 249, 0.84);
  --border: rgba(30, 41, 59, 0.12);
  --border-strong: rgba(79, 70, 229, 0.24);
  --text: #111827;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --brand: #4f46e5;
  --brand-2: #0891b2;
  --accent: #e11d48;
  --success: #059669;
  --warning: #d97706;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 16px 40px rgba(15, 23, 42, 0.08);
  --code-bg: #101624;
  --code-text: #e5e7eb;
  --radius: 8px;
  --radius-lg: 12px;
  --container: 1180px;

  /* HSL equivalents or additions for premium gradients & glows */
  --brand-hsl: 243, 75%, 59%;
  --brand-2-hsl: 188, 91%, 36%;
  --accent-hsl: 346, 84%, 49%;
  --success-hsl: 161, 94%, 30%;
  --warning-hsl: 36, 96%, 44%;

  /* Codeforces ratings HSL color tokens - Light mode */
  --cf-newbie: 0, 0%, 50%;
  --cf-pupil: 120, 50%, 35%;
  --cf-specialist: 180, 60%, 35%;
  --cf-expert: 220, 85%, 50%;
  --cf-candidate-master: 300, 75%, 40%;
  --cf-master: 35, 95%, 45%;
  --cf-grandmaster: 0, 90%, 50%;

  /* Heatmap levels - Light mode */
  --heatmap-level-0: rgba(148, 163, 184, 0.12);
  --heatmap-level-1: hsla(var(--brand-hsl), 0.2);
  --heatmap-level-2: hsla(var(--brand-hsl), 0.45);
  --heatmap-level-3: hsla(var(--brand-hsl), 0.7);
  --heatmap-level-4: hsla(var(--brand-hsl), 0.95);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080d1a;
  --bg-soft: #101a2f;
  --surface: rgba(15, 23, 42, 0.72);
  --surface-strong: rgba(15, 23, 42, 0.9);
  --surface-muted: rgba(30, 41, 59, 0.72);
  --border: rgba(226, 232, 240, 0.11);
  --border-strong: rgba(129, 140, 248, 0.32);
  --text: #f8fafc;
  --text-muted: #b6c2d2;
  --text-soft: #7f8da3;
  --brand: #8b5cf6;
  --brand-2: #22d3ee;
  --accent: #fb7185;
  --success: #34d399;
  --warning: #fbbf24;
  --shadow: 0 26px 90px rgba(0, 0, 0, 0.36);
  --shadow-soft: 0 16px 45px rgba(0, 0, 0, 0.24);
  --code-bg: #0b1020;
  --code-text: #e5e7eb;

  /* HSL equivalents or additions for premium gradients & glows */
  --brand-hsl: 260, 94%, 71%;
  --brand-2-hsl: 189, 87%, 54%;
  --accent-hsl: 351, 95%, 71%;
  --success-hsl: 158, 64%, 52%;
  --warning-hsl: 43, 96%, 56%;

  /* Codeforces ratings HSL color tokens - Dark mode */
  --cf-newbie: 0, 0%, 70%;
  --cf-pupil: 120, 55%, 50%;
  --cf-specialist: 180, 70%, 48%;
  --cf-expert: 215, 95%, 65%;
  --cf-candidate-master: 300, 85%, 65%;
  --cf-master: 35, 95%, 60%;
  --cf-grandmaster: 0, 95%, 60%;

  /* Heatmap levels - Dark mode */
  --heatmap-level-0: rgba(30, 41, 59, 0.5);
  --heatmap-level-1: hsla(var(--brand-hsl), 0.25);
  --heatmap-level-2: hsla(var(--brand-hsl), 0.5);
  --heatmap-level-3: hsla(var(--brand-hsl), 0.75);
  --heatmap-level-4: hsla(var(--brand-hsl), 1.0);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(34, 211, 238, 0.22), transparent 32rem),
    radial-gradient(circle at 88% 4%, rgba(225, 29, 72, 0.18), transparent 30rem),
    radial-gradient(circle at 54% 42%, rgba(79, 70, 229, 0.16), transparent 34rem),
    linear-gradient(135deg, var(--bg), var(--bg-soft));
  background-attachment: fixed;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

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

button,
input,
select {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: min(var(--container), calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
  backdrop-filter: blur(18px);
}

.header-inner {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-weight: 800;
}

.brand-button {
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: var(--radius);
  color: white;
  background:
    linear-gradient(135deg, rgba(34, 211, 238, 0.95), rgba(79, 70, 229, 0.92) 48%, rgba(225, 29, 72, 0.9)),
    #4f46e5;
  box-shadow: 0 14px 36px rgba(79, 70, 229, 0.32);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-size: 1rem;
  letter-spacing: 0;
}

.brand-subtitle {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.text-button,
.chip-button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button {
  width: 42px;
  display: inline-grid;
  place-items: center;
}

.text-button,
.chip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.icon-button:hover,
.text-button:hover,
.chip-button:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: var(--surface-strong);
}

.icon-button svg,
.text-button svg,
.chip-button svg {
  width: 18px;
  height: 18px;
}

.theme-toggle {
  position: relative;
  overflow: hidden;
}

.theme-toggle .moon-icon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .sun-icon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .moon-icon {
  display: block;
}

.theme-toggle svg {
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle:hover svg {
  transform: rotate(45deg);
}

@keyframes spin-in {
  0% { transform: rotate(-180deg) scale(0.2); opacity: 0; }
  100% { transform: rotate(0) scale(1); opacity: 1; }
}

.theme-toggle .sun-icon,
.theme-toggle .moon-icon {
  animation: spin-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.hero {
  position: relative;
  padding: clamp(16px, 3vw, 32px) 0 clamp(16px, 3vw, 32px);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
  gap: clamp(28px, 5vw, 68px);
  align-items: center;
}

.hero-content {
  min-width: 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow svg {
  width: 18px;
  height: 18px;
}

.hero h1,
.page-title {
  margin: 0;
  max-width: 760px;
  color: var(--text);
  font-size: clamp(2.85rem, 6.1vw, 5.9rem);
  line-height: 0.96;
  font-weight: 950;
  letter-spacing: 0;
  text-wrap: balance;
}

.gradient-text {
  color: transparent;
  background: linear-gradient(120deg, var(--brand-2), var(--brand) 52%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
}

.hero-copy {
  max-width: 680px;
  margin: 22px 0 0;
  color: var(--text-muted);
  font-size: clamp(1rem, 1.8vw, 1.13rem);
  line-height: 1.75;
}

.hero-copy strong {
  color: var(--success);
  font-weight: 900;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.primary-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius);
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 18px 34px rgba(79, 70, 229, 0.28);
  font-weight: 900;
}

.primary-button svg {
  width: 18px;
  height: 18px;
}

.stats-panel {
  display: grid;
  gap: 14px;
  align-self: center;
}

.metric-card,
.panel,
.problem-card,
.solution-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
}

.metric-card {
  padding: clamp(20px, 3vw, 28px);
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-label svg {
  width: 17px;
  height: 17px;
  color: var(--brand);
}

.metric-value {
  margin-top: 10px;
  color: var(--text);
  font-size: clamp(2.8rem, 5vw, 4.2rem);
  line-height: 1;
  font-weight: 950;
}

.metric-note {
  margin-top: 8px;
  color: var(--text-muted);
  line-height: 1.5;
}

.architecture-section {
  padding: clamp(28px, 5vw, 56px) 0 8px;
}

.pipeline-card,
.pipeline-phase {
  position: relative;
  overflow: hidden;
}

.pipeline-card::before,
.pipeline-phase::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.16), transparent 42%, rgba(225, 29, 72, 0.12));
}

.pipeline-card > *,
.pipeline-phase > * {
  position: relative;
}

.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.pipeline-phase,
.architecture-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
}

.pipeline-phase {
  min-height: 310px;
  padding: 22px;
}

.phase-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: white;
  background: linear-gradient(135deg, var(--brand-2), var(--brand) 58%, var(--accent));
  box-shadow: 0 14px 28px rgba(79, 70, 229, 0.24);
}

.phase-icon svg {
  width: 21px;
  height: 21px;
}

.phase-label {
  margin: 18px 0 8px;
  color: var(--brand);
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pipeline-phase h3,
.architecture-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1.25;
  font-weight: 950;
}

.pipeline-phase p:not(.phase-label),
.architecture-card p {
  margin: 12px 0 0;
  color: var(--text-muted);
  line-height: 1.65;
}

.pipeline-phase code,
.architecture-card code {
  padding: 0.12rem 0.32rem;
  border-radius: 6px;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  font-size: 0.86em;
}

.architecture-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.architecture-card {
  padding: 22px;
}

.architecture-card strong {
  color: var(--text);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.tag-list span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.pipeline-steps {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.pipeline-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
}

.step-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--accent));
}

.step-icon svg {
  width: 18px;
  height: 18px;
}

.step-title {
  margin: 0;
  font-weight: 900;
}

.step-copy {
  margin: 3px 0 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 38px 0 18px;
}

.section-kicker {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.1;
  font-weight: 950;
}

.section-title svg {
  width: 30px;
  height: 30px;
  color: var(--brand);
}

.section-copy {
  max-width: 620px;
  margin: 10px 0 0;
  color: var(--text-muted);
  line-height: 1.7;
}

.rating-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.rating-card {
  position: relative;
  overflow: hidden;
  min-height: 158px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.rating-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.rating-card::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0.16;
  background: linear-gradient(135deg, var(--rating-a), var(--rating-b));
}

.rating-card > * {
  position: relative;
}

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

.rating-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rating-value {
  margin: 6px 0 0;
  font-size: 2rem;
  line-height: 1;
  font-weight: 950;
}

.rating-badge {
  min-width: 54px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: white;
  background: linear-gradient(135deg, var(--rating-a), var(--rating-b));
  font-weight: 950;
}

.rating-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.rating-footer svg {
  width: 17px;
  height: 17px;
  transition: transform 180ms ease;
}

.rating-card:hover .rating-footer svg {
  transform: translateX(3px);
}

.progress-track {
  width: 100%;
  height: 8px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-soft) 22%, transparent);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rating-a), var(--rating-b));
}

.page-main {
  flex: 1;
  padding: 44px 0 64px;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.compact-title {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.98;
  font-weight: 950;
}

.muted {
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.search-box {
  min-height: 42px;
  width: min(360px, 100%);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface-strong);
  outline: none;
}

.search-box:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent);
}

.problem-table {
  overflow: hidden;
}

.table-head,
.problem-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 128px;
  gap: 16px;
  align-items: center;
}

.table-head {
  padding: 15px 18px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.problem-list {
  max-height: 70vh;
  overflow: auto;
}

.problem-row {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 160ms ease;
}

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

.problem-row:hover {
  background: color-mix(in srgb, var(--brand) 8%, transparent);
}

.contest-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  font-weight: 900;
}

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

.problem-name strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.problem-name span {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.empty-state,
.error-state,
.loading-state {
  padding: 34px 20px;
  color: var(--text-muted);
  text-align: center;
}

.error-state {
  color: var(--accent);
}

.skeleton {
  min-height: 140px;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text-soft) 16%, transparent), transparent);
  background-size: 220% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

.solution-layout {
  display: flex;
  gap: 18px;
  transition: gap 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  align-items: stretch;
}

.notes-panel,
.solution-layout > .solution-card:first-child {
  width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.35s ease,
              transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              margin 0.35s ease;
  min-width: 0;
}

.code-panel,
.solution-layout > .solution-card.code-window {
  flex-grow: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.solution-layout.sidebar-collapsed .notes-panel,
.solution-layout.sidebar-collapsed > .solution-card:first-child {
  width: 0 !important;
  opacity: 0;
  transform: translateX(-30px);
  margin: 0;
  pointer-events: none;
}

.solution-layout.sidebar-collapsed {
  gap: 0;
}

.toggle-sidebar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  min-height: 40px;
  white-space: nowrap;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-sidebar-btn:hover {
  color: var(--brand);
  border-color: var(--border-strong);
  background: var(--surface-strong);
  transform: scale(1.05);
}

.toggle-sidebar-btn svg {
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease;
}

.solution-layout.sidebar-collapsed .toggle-sidebar-btn svg {
  transform: rotate(180deg);
}

.solution-card {
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  margin: 0;
  font-size: 0.98rem;
  font-weight: 950;
}

.card-title svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  color: var(--brand);
}

.problem-info {
  max-height: 74vh;
  overflow: auto;
  padding: 20px;
}

.code-window {
  min-height: 72vh;
}

.window-dots {
  display: flex;
  gap: 7px;
}

.window-dots span {
  width: 11px;
  height: 11px;
  border-radius: 999px;
}

.window-dots span:nth-child(1) { background: #fb7185; }
.window-dots span:nth-child(2) { background: #fbbf24; }
.window-dots span:nth-child(3) { background: #34d399; }

.filename {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  font-size: 0.86rem;
  font-weight: 800;
}

.code-body {
  max-height: 74vh;
  overflow: auto;
  background: var(--code-bg);
}

.code-body pre {
  margin: 0;
  padding: 20px;
  background: transparent !important;
}

.code-body code {
  color: var(--code-text);
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  font-size: 0.88rem;
  line-height: 1.7;
  text-shadow: none !important;
}

.markdown-body {
  color: var(--text-muted);
  line-height: 1.72;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 1.2rem 0 0.65rem;
  color: var(--text);
  line-height: 1.15;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body h1 { font-size: 1.55rem; }
.markdown-body h2 { font-size: 1.25rem; }
.markdown-body h3 { font-size: 1.05rem; }

.markdown-body p,
.markdown-body ul,
.markdown-body ol {
  margin: 0 0 1rem;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.25rem;
}

.markdown-body a {
  color: var(--brand);
  font-weight: 800;
}

.markdown-body code {
  padding: 0.12rem 0.35rem;
  border-radius: 6px;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
}

.markdown-body pre {
  overflow: auto;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--code-bg);
}

.markdown-body pre code {
  padding: 0;
  color: var(--code-text);
  background: transparent;
}

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 54%, transparent);
}

.footer-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.footer-inner strong {
  color: var(--text);
}

.custom-scrollbar,
.problem-list,
.problem-info,
.code-body {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--brand) 42%, var(--text-soft)) transparent;
}

.custom-scrollbar::-webkit-scrollbar,
.problem-list::-webkit-scrollbar,
.problem-info::-webkit-scrollbar,
.code-body::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb,
.problem-list::-webkit-scrollbar-thumb,
.problem-info::-webkit-scrollbar-thumb,
.code-body::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 48%, var(--text-soft));
  background-clip: content-box;
}

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

@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
  .solution-layout {
    flex-direction: column;
  }
  .notes-panel,
  .solution-layout > .solution-card:first-child {
    width: 100% !important;
  }

  .stats-panel {
    width: 100%;
  }

  .metric-card {
    max-width: none;
  }

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

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

  .page-heading,
  .section-header {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(100% - 28px, var(--container));
  }

  .header-inner {
    height: auto;
    min-height: 68px;
    padding: 10px 0;
  }

  .brand-subtitle,
  .hide-mobile {
    display: none;
  }

  .hero {
    padding: 36px 0 34px;
  }

  .hero h1,
  .page-title {
    font-size: clamp(2.35rem, 13vw, 3.9rem);
    line-height: 1;
  }

  .hero-copy {
    margin-top: 18px;
    line-height: 1.65;
  }

  .hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .hero-actions .chip-button {
    width: 100%;
  }

  .pipeline-grid,
  .architecture-grid {
    grid-template-columns: 1fr;
  }

  .pipeline-phase {
    min-height: auto;
  }

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

  .table-head {
    display: none;
  }

  .problem-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .problem-row .text-button {
    width: 100%;
  }

  .footer-inner {
    align-items: start;
    flex-direction: column;
    padding: 18px 0;
  }
}

/* ==========================================================================
   UI/UX ENHANCEMENTS & PREMIUM DESIGN SYSTEM
   ========================================================================== */

/* 1. Codeforces Ratings & Glow Helpers */
.difficulty-newbie {
  --difficulty-color: hsl(var(--cf-newbie));
  --difficulty-glow: hsla(var(--cf-newbie), 0.18);
}
.difficulty-pupil {
  --difficulty-color: hsl(var(--cf-pupil));
  --difficulty-glow: hsla(var(--cf-pupil), 0.18);
}
.difficulty-specialist {
  --difficulty-color: hsl(var(--cf-specialist));
  --difficulty-glow: hsla(var(--cf-specialist), 0.18);
}
.difficulty-expert {
  --difficulty-color: hsl(var(--cf-expert));
  --difficulty-glow: hsla(var(--cf-expert), 0.18);
}
.difficulty-candidate-master {
  --difficulty-color: hsl(var(--cf-candidate-master));
  --difficulty-glow: hsla(var(--cf-candidate-master), 0.18);
}
.difficulty-master {
  --difficulty-color: hsl(var(--cf-master));
  --difficulty-glow: hsla(var(--cf-master), 0.18);
}
.difficulty-grandmaster {
  --difficulty-color: hsl(var(--cf-grandmaster));
  --difficulty-glow: hsla(var(--cf-grandmaster), 0.18);
}

/* 2. Global Contribution Heatmap */
#heatmap-container {
  padding: 24px;
  margin: 28px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

.heatmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.heatmap-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 950;
  color: var(--text);
}

.heatmap-title svg {
  width: 20px;
  height: 20px;
  color: var(--brand);
}

.heatmap-grid-wrapper {
  position: relative;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 10px);
  grid-auto-flow: column;
  grid-auto-columns: 10px;
  gap: 3px;
  width: max-content;
}

.heatmap-cell {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background-color: var(--heatmap-level-0);
  transition: transform 120ms ease, background-color 150ms ease, box-shadow 120ms ease;
  cursor: pointer;
  position: relative;
}

.heatmap-cell:hover {
  transform: scale(1.3);
  z-index: 5;
  box-shadow: 0 0 5px var(--brand);
}

.heatmap-cell[data-level="0"] { background-color: var(--heatmap-level-0); }
.heatmap-cell[data-level="1"] { background-color: var(--heatmap-level-1); }
.heatmap-cell[data-level="2"] { background-color: var(--heatmap-level-2); }
.heatmap-cell[data-level="3"] { background-color: var(--heatmap-level-3); }
.heatmap-cell[data-level="4"] { background-color: var(--heatmap-level-4); }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  justify-content: flex-end;
}

.heatmap-legend-cells {
  display: flex;
  gap: 3px;
}

.heatmap-tooltip {
  position: absolute;
  z-index: 50;
  background: var(--surface-strong);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  box-shadow: var(--shadow);
  pointer-events: none;
  transform: translate(-50%, -100%) translateY(-8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
  opacity: 0;
}

.heatmap-tooltip.visible {
  opacity: 1;
  transform: translate(-50%, -100%) translateY(-12px);
}

/* 3. Recent Activity Feed */
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.2s ease,
              box-shadow 0.2s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.recent-item:hover {
  transform: translateY(-2px) scale(1.005);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.recent-item-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.recent-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  color: var(--brand);
}

.recent-item-icon.success {
  background: color-mix(in srgb, var(--success) 10%, transparent);
  color: var(--success);
}

.recent-item-info {
  min-width: 0;
}

.recent-item-title {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-item-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.recent-item-time {
  font-size: 0.78rem;
  color: var(--text-soft);
  flex-shrink: 0;
  font-weight: 700;
}

/* 4. Homepage Global Search */
#global-search-container {
  margin: 28px 0;
  position: relative;
}

#global-search-container .search-box-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#global-search-container .search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-soft);
  pointer-events: none;
  width: 20px;
  height: 20px;
}

#global-search-container .search-box {
  width: 100%;
  padding-left: 44px;
  height: 48px;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.search-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.search-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.2s ease,
              box-shadow 0.2s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.search-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.search-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.search-card-title {
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--text);
}

.search-card-path {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 5. Stats Panel Visualizer */
.stats-card {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stat-progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-soft) 18%, transparent);
  overflow: hidden;
  position: relative;
}

.stat-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--progress-start, var(--brand)), var(--progress-end, var(--brand-2)));
  position: relative;
  overflow: hidden;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.22) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: stat-shimmer 2.2s infinite linear;
}

@keyframes stat-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* 6. Codeforces Profile Widget */
.profile-widget {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-widget::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}

.profile-widget[class*="difficulty-"]::before {
  background: var(--difficulty-color);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-avatar-wrapper {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.profile-avatar-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  font-size: 1.2rem;
  border: 2px solid var(--surface-strong);
  box-shadow: var(--shadow-soft);
}

.profile-status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--success);
  border: 2px solid var(--surface-strong);
}

.profile-status-dot.active {
  animation: status-pulse 1.8s infinite;
}

@keyframes status-pulse {
  0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.6); }
  70% { box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
  100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

.profile-meta {
  display: flex;
  flex-direction: column;
}

.profile-handle {
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--text);
}

.profile-rank {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--brand);
}

.profile-widget[class*="difficulty-"] .profile-rank {
  color: var(--difficulty-color);
}

.profile-stats-summary {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.profile-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.profile-stat-val {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text);
}

.profile-stat-lbl {
  font-size: 0.7rem;
  color: var(--text-soft);
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 2px;
}

/* 7. Category Cards */
.problem-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.2s ease,
              box-shadow 0.2s ease;
  gap: 14px;
}

.problem-card:hover {
  transform: translateY(-3px);
  border-color: var(--difficulty-color, var(--border-strong));
  box-shadow: 0 12px 30px -5px var(--difficulty-glow, rgba(0, 0, 0, 0.15)), var(--shadow-soft);
}

.lang-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  transition: all 0.16s ease;
}

.lang-badge.lang-cpp {
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 20%, transparent);
}

.lang-badge.lang-python {
  background: color-mix(in srgb, var(--brand-2) 8%, transparent);
  color: var(--brand-2);
  border-color: color-mix(in srgb, var(--brand-2) 20%, transparent);
}

/* 8. Additional Micro-Animations & Utility classes */
.card-hover-scale {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}
.card-hover-scale:hover {
  transform: scale(1.02) translateY(-2px);
  box-shadow: var(--shadow);
}

.btn-hover-translate {
  transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.16s ease;
}
.btn-hover-translate:hover {
  transform: translateY(-2px);
}

/* CP Dashboard Portal Layout */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  align-items: start;
  margin-top: 32px;
  margin-bottom: 60px;
}
.dashboard-main {
  min-width: 0;
}
.dashboard-sidebar {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
@media (max-width: 960px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .dashboard-sidebar {
    position: static;
  }
}

/* Custom Sort Dropdown styling */
select.sort-dropdown {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='%2364748b' height='20' viewBox='0 0 24 24' width='20' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 36px !important;
  cursor: pointer;
  font-weight: 700;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background-color: var(--surface-strong);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
select.sort-dropdown:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent);
}
:root[data-theme="dark"] select.sort-dropdown {
  background-image: url("data:image/svg+xml;utf8,<svg fill='%23f8fafc' height='20' viewBox='0 0 24 24' width='20' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  color: var(--text);
}

/* Fix Prism.js operator highlight background box styling */
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  background: transparent !important;
}

/* Center items in page-heading toolbar */
.page-heading {
  align-items: center !important;
}

/* Profile Banner Component Styles */
.profile-banner {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(8, 145, 178, 0.08));
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  border: 1px solid var(--border-strong);
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  font-size: 1.3rem;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.25);
  flex-shrink: 0;
}

.profile-info {
  flex: 1;
  min-width: 200px;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-name-row h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 950;
  letter-spacing: -0.02em;
  word-break: break-all;
  color: var(--text);
}

.profile-badge {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--success);
  color: white;
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.profile-stats {
  display: flex;
  gap: 16px;
  align-items: center;
}

.profile-stat {
  text-align: center;
}

.profile-stat-val {
  font-size: 1.5rem;
  font-weight: 950;
  color: var(--brand);
  line-height: 1.1;
}

.profile-stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.profile-divider {
  width: 1px;
  background: var(--border);
  height: 28px;
  align-self: center;
}

/* Heatmap scroll container on mobile */
.heatmap-scroll-wrapper {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--brand) 20%, var(--text-soft)) transparent;
}
.heatmap-scroll-wrapper::-webkit-scrollbar {
  height: 6px;
}
.heatmap-scroll-wrapper::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: color-mix(in srgb, var(--brand) 30%, var(--text-soft));
}

@media (max-width: 640px) {
  .profile-banner {
    flex-direction: column;
    text-align: center;
    align-items: center;
    padding: 24px 16px;
  }
  .profile-name-row {
    justify-content: center;
    flex-direction: column;
    gap: 6px;
  }
  .profile-stats {
    justify-content: center;
    margin-top: 8px;
  }
}

