:root {
  color-scheme: dark;
  --bg: #11151d;
  --side: #141923;
  --surface: #171d28;
  --raised: #1b2230;
  --line: #2b3342;
  --text: #edf0f6;
  --muted: #a5afc1;
  --faint: #8895aa;
  --gold: #f4bd65;
  --gold-soft: #302a25;
  --green: #8bd6ae;
  --green-soft: #1c302d;
  --red: #ffaaaa;
  --red-soft: #3a272c;
  --code: #10141c;
  --keyword: #d2a4f4;
  --number: #f4bd65;
  --type: #8cd2ef;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f9;
  --side: #f9fafc;
  --surface: #fff;
  --raised: #eef1f7;
  --line: #d7dde8;
  --text: #212837;
  --muted: #4c596e;
  --faint: #59667b;
  --gold: #83510e;
  --gold-soft: #f8ead3;
  --green: #246747;
  --green-soft: #e5f4eb;
  --red: #972f36;
  --red-soft: #fbe9eb;
  --code: #f4f6fa;
  --keyword: #713899;
  --number: #85500e;
  --type: #145d7a;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.55 var(--sans); }
button, select, input { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button, select { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
button:hover, select:hover { border-color: var(--faint); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only, .skip-link:not(:focus) { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: 12px; z-index: 3; background: var(--surface); padding: 8px 12px; }

.topbar { height: 70px; display: flex; align-items: center; gap: 23px; padding: 0 34px; background: var(--side); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; text-decoration: none; font-size: 1.3rem; font-weight: 750; letter-spacing: -.045em; line-height: 1; }
.brand-mark { display: grid; place-items: center; width: 33px; height: 33px; margin-right: 11px; color: #241a10; background: #f4bd65; border-radius: 8px; font: bold 1.9rem/1 var(--mono); }
.brand-accent { color: var(--gold); }
.header-location { border-left: 1px solid var(--line); padding-left: 23px; font-size: .875rem; color: var(--muted); }
.theme-button { margin-left: auto; padding: 6px 12px; display: inline-flex; align-items: center; gap: 8px; font-size: .875rem; white-space: nowrap; }
#theme-icon { font-size: 1.18rem; line-height: 1; color: var(--gold); }

.workspace { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: calc(100vh - 70px); }
.sidebar { padding: 30px 17px 26px; background: var(--side); border-right: 1px solid var(--line); }
.eyebrow { margin: 0; font: 600 .77rem/1.5 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.sidebar-title { margin: 0 13px 11px; color: var(--faint); }
.category-list { display: flex; flex-direction: column; gap: 2px; }
.category { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 11px; min-height: 34px; text-align: left; background: transparent; border-color: transparent; color: var(--muted); font-size: .875rem; white-space: nowrap; }
.category:hover { background: var(--raised); border-color: transparent; }
.category[aria-selected="true"] { color: var(--gold); background: var(--gold-soft); border-color: var(--line); }
.category-icon { width: 18px; flex: none; text-align: center; font: 1rem/1 var(--mono); color: var(--faint); }
.category[aria-selected="true"] .category-icon { color: currentColor; }
.category-count { margin-left: auto; font: .75rem/1 var(--mono); }
.progress { margin: 20px 2px 0; padding: 13px 12px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.progress-heading { display: flex; justify-content: space-between; align-items: center; gap: 5px; }
.progress-heading h2 { margin: 0; font-size: .875rem; }
#progress-value { color: var(--gold); font: .78rem var(--mono); }
progress { display: block; width: 100%; height: 6px; margin-top: 11px; appearance: none; border: 0; border-radius: 8px; background: var(--line); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--gold); }
progress::-moz-progress-bar { background: var(--gold); }
.progress p { margin: 8px 0 0; color: var(--faint); font-size: .75rem; }

main { width: 100%; max-width: 1310px; margin: 0 auto; padding: 34px clamp(26px, 4vw, 62px) 0; min-width: 0; }
.hero { position: relative; isolation: isolate; display: grid; grid-template-columns: 1.25fr 1fr; align-items: center; min-height: 238px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(113deg, var(--surface) 41%, var(--raised)); }
.hero-content { padding: 30px 0 32px clamp(24px, 3vw, 44px); }
.hero-label { color: var(--gold); display: flex; align-items: center; gap: 9px; }
.hero-label span, .diagram-label span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.hero h1 { margin: 8px 0 10px; font-size: clamp(2.45rem, 4.3vw, 4.45rem); letter-spacing: -.075em; line-height: 1.06; font-weight: 750; }
.hero h1 em { color: var(--gold); font-style: normal; }
.hero-description { margin: 0; max-width: 34ch; color: var(--muted); }
.hero-graphic { position: relative; justify-self: end; width: 100%; height: 100%; min-height: 180px; display: grid; align-content: center; justify-items: center; padding: 16px 24px; font-family: var(--mono); }
.hero-graphic::before { content: ""; position: absolute; z-index: -1; inset: 0; background: radial-gradient(circle, var(--faint) 1px, transparent 1.5px) 0 0 / 17px 17px; opacity: .21; mask-image: linear-gradient(90deg, transparent, #000 40%, #000); }
.diagram-label { color: var(--gold); display: flex; align-items: center; gap: 7px; font-size: .71rem; letter-spacing: .11em; margin-bottom: 10px; }
.diagram-array { --cell: clamp(29px, 3.7vw, 53px); display: flex; gap: 5px; }
.diagram-array span { display: grid; place-items: center; width: var(--cell); height: var(--cell); border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--faint); font-size: 1rem; }
.diagram-array .in-window { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); border-left-color: transparent; border-right-color: transparent; border-radius: 0; position: relative; }
.diagram-array .in-window::after { content: ""; position: absolute; right: -6px; top: -1px; bottom: -1px; width: 5px; background: var(--gold-soft); border-block: 1px solid var(--gold); }
.diagram-array .first { border-left-color: var(--gold); border-radius: 6px 0 0 6px; }
.diagram-array .last { border-right-color: var(--gold); border-radius: 0 6px 6px 0; }
.diagram-array .last::after { display: none; }
.diagram-bracket { width: calc(clamp(29px, 3.7vw, 53px) * 3 + 10px); height: 8px; margin-top: 8px; border: 1px solid var(--gold); border-top: 0; border-radius: 0 0 5px 5px; opacity: .6; }
.diagram-sum { margin-top: 6px; color: var(--muted); font-size: .76rem; }
.diagram-sum b { color: var(--gold); }

#library { margin-top: 26px; border-radius: 10px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2 { font-size: clamp(1.5rem, 2.2vw, 1.95rem); line-height: 1.2; letter-spacing: -.045em; margin: 0; }
.section-heading p { margin: 0; color: var(--muted); white-space: nowrap; font-size: .875rem; }
.filters { display: flex; gap: 10px; margin-bottom: 16px; }
.search { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; padding: 0 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.search:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
.search input { width: 100%; min-width: 0; padding: 10px 0; border: 0; background: transparent; font-size: 1rem; outline: none; }
.search input::placeholder { color: var(--faint); }
.search-icon { position: relative; flex: none; width: 12px; height: 12px; border: 1.5px solid var(--faint); border-radius: 50%; margin-right: 2px; }
.search-icon::after { content: ""; position: absolute; width: 6px; height: 1.5px; background: var(--faint); transform: rotate(45deg); top: 9px; left: 8px; }
kbd { font: .78rem var(--mono); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; color: var(--faint); }
.difficulty-select { position: relative; display: flex; }
.difficulty-select::after { content: ""; position: absolute; right: 14px; top: 17px; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); pointer-events: none; }
select { appearance: none; padding: 8px 32px 8px 12px; min-height: 44px; font-size: .875rem; }

#problems { display: grid; gap: 8px; }
.problem { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.problem:hover { border-color: var(--faint); }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
.problem-summary { display: grid; grid-template-columns: 35px minmax(0, 1fr) auto 12px; gap: 13px; align-items: center; padding: 10px 16px; border-radius: 10px; min-height: 64px; }
.problem-marker { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 6px; background: var(--raised); color: var(--muted); font: .79rem var(--mono); }
.problem-marker.is-complete { color: var(--green); background: var(--green-soft); }
.problem-name { display: block; font-size: 1rem; font-weight: 650; line-height: 1.35; }
.problem-category { display: block; color: var(--faint); font-size: .81rem; margin-top: 2px; }
.badge { padding: 3px 9px; border-radius: 5px; font: 600 .75rem/1.5 var(--mono); background: var(--green-soft); color: var(--green); }
.badge.medium { background: var(--gold-soft); color: var(--gold); }
.badge.hard { background: var(--red-soft); color: var(--red); }
.chevron { width: 8px; height: 8px; border-right: 1.5px solid var(--faint); border-bottom: 1.5px solid var(--faint); transform: translateY(-2px) rotate(45deg); }
details[open] > summary .chevron { transform: translateY(2px) rotate(225deg); }
.empty { margin: 0; padding: 28px 22px; background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); }

.problem-body { border-top: 1px solid var(--line); padding: 20px clamp(14px, 3vw, 30px) 24px; }
.problem-body p, .problem-body ul { margin: 0 0 12px; }
.problem-body h3 { margin: 18px 0 7px; font-size: 1rem; }
.problem-body ul { padding-left: 1.35em; }
.examples { display: grid; gap: 8px; }
.example { background: var(--code); border: 1px solid var(--line); border-radius: 8px; padding: 10px 13px; overflow-wrap: anywhere; }
.example p { margin: 5px 0 0; color: var(--muted); font-size: .875rem; }
.example code { display: block; font: .86rem/1.65 var(--mono); }
.example strong { color: var(--gold); }
.disclosure { margin-top: 13px; border: 1px solid var(--line); border-radius: 8px; }
.disclosure > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 13px; font-weight: 600; font-size: .9rem; border-radius: 8px; }
.disclosure > div { border-top: 1px solid var(--line); padding: 12px 13px 0; }
.disclosure .disclosure { margin-bottom: 12px; }
.code-box { margin: 3px 0 14px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.code-toolbar, .language-tabs { display: flex; align-items: center; gap: 8px; }
.code-toolbar { padding: 6px 8px; justify-content: space-between; background: var(--raised); }
.code-toolbar button, .complete-button { padding: 5px 10px; font-size: .875rem; }
.language-tabs button[aria-selected="true"] { color: var(--gold); background: var(--gold-soft); }
.copy-status { font-size: .8rem; color: var(--muted); margin-left: auto; }
pre { margin: 0; padding: 15px; background: var(--code); overflow: auto; font: .85rem/1.6 var(--mono); tab-size: 4; }
pre code { font: inherit; }
.token-keyword { color: var(--keyword); }
.token-number { color: var(--number); }
.token-type { color: var(--type); }
.complexity { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.complexity div { display: flex; align-items: baseline; gap: 7px; background: var(--raised); padding: 5px 9px; border-radius: 6px; }
.complexity dt { font-weight: 650; }
.complexity dd { margin: 0; color: var(--gold); font: .83rem var(--mono); }
.complete-button { margin-top: 14px; min-height: 38px; }
.footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 25px; padding: 14px 0 19px; border-top: 1px solid var(--line); color: var(--faint); font-size: .79rem; }
.footer span:first-child { color: var(--muted); font-weight: 650; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 222px minmax(0, 1fr); }
  .sidebar { padding-inline: 13px; }
  .hero { grid-template-columns: 1.35fr 1fr; }
}
@media (max-width: 790px) {
  .topbar { height: 60px; padding-inline: 20px; }
  .workspace { display: block; min-height: calc(100vh - 60px); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 0; position: relative; }
  .sidebar-title { margin: 0 156px 6px 20px; }
  .category-list { flex-direction: row; overflow-x: auto; padding: 4px 20px; scrollbar-width: thin; gap: 5px; }
  .category { width: auto; flex: none; padding-inline: 10px; }
  .progress { position: absolute; right: 20px; top: 8px; margin: 0; padding: 0; background: transparent; border: 0; width: 120px; }
  .progress-heading h2 { font-size: .79rem; }
  .progress p { display: none; }
  progress { height: 3px; margin-top: 2px; }
  main { padding: 22px 20px 0; }
  .hero { min-height: 185px; }
}
@media (max-width: 540px) {
  .header-location { display: none; }
  .topbar, main { padding-inline: 15px; }
  .hero { grid-template-columns: 1fr; }
  .hero-content { padding: 21px 19px 8px; }
  .hero h1 { font-size: clamp(2.15rem, 9.8vw, 3.2rem); }
  .hero-description { max-width: 36ch; }
  .hero-graphic { min-height: 0; padding: 11px 16px 14px; }
  .hero-graphic::before { mask-image: linear-gradient(0deg, #000, transparent); }
  .diagram-label { margin-bottom: 6px; }
  .diagram-array { --cell: 29px; }
  .diagram-bracket { margin-top: 5px; height: 5px; }
  .diagram-sum { margin-top: 3px; }
  .filters { gap: 7px; }
  .search { padding-inline: 9px; gap: 7px; }
  .search input { text-overflow: ellipsis; }
  kbd { display: none; }
  select { padding-left: 8px; padding-right: 26px; }
  .difficulty-select::after { right: 11px; }
  .problem-summary { padding: 9px; gap: 8px; grid-template-columns: 28px minmax(0, 1fr) auto 9px; }
  .problem-marker { width: 28px; height: 29px; }
  .badge { padding-inline: 5px; }
}
