:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #18202a;
  --muted: #667085;
  --border: #dfe3e8;
  --accent: #a90032;
  --accent-dark: #7d0026;
  --soft-accent: #fff0f4;
  --radius: 16px;
  --shadow: 0 12px 34px rgba(20, 27, 38, 0.07);
  --header-bg-1: #ffffff;
  --header-bg-2: #f8edf1;
  --header-glow: rgba(169,0,50,.14);
  --input-bg: #ffffff;
  --table-head: #fafbfc;
  --row-hover: #fcfcfd;
  --footer-bg: #ffffff;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111318;
  --surface: #191c23;
  --ink: #f2f4f7;
  --muted: #a8b0bd;
  --border: #313743;
  --accent: #ff5f8f;
  --accent-dark: #ff8eaf;
  --soft-accent: #351924;
  --shadow: 0 12px 34px rgba(0,0,0,.24);
  --header-bg-1: #171a20;
  --header-bg-2: #24171d;
  --header-glow: rgba(255,95,143,.12);
  --input-bg: #14171d;
  --table-head: #171a20;
  --row-hover: #20242c;
  --footer-bg: #15181e;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}

a { color: var(--accent-dark); }
button, input, select { font: inherit; }
button, select, input { color: inherit; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.site-header {
  background:
    radial-gradient(circle at 80% 20%, var(--header-glow), transparent 32%),
    linear-gradient(135deg, var(--header-bg-1) 0%, var(--header-bg-2) 100%);
  border-bottom: 1px solid var(--border);
}
.hero {
  min-height: 300px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, .7fr);
  gap: 40px;
  align-items: center;
  padding: 56px 0;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
h1, h2, h3 { line-height: 1.15; }
h1 { margin: 0; font-size: clamp(38px, 6vw, 64px); letter-spacing: -.04em; }
h2 { margin: 0; font-size: 24px; }
h3 { margin: 0 0 6px; }
.hero-copy { max-width: 760px; color: var(--muted); font-size: 18px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(20,27,38,.08); }
.hero-card {
  display: grid;
  gap: 1px;
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-card > div { padding: 20px; background: var(--surface); }
.hero-card strong { display: block; font-size: 28px; }
.hero-card span { color: var(--muted); font-size: 13px; }

.main-grid {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 24px;
  padding: 28px 0 56px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.sticky-panel { position: sticky; top: 18px; padding: 18px; }
.panel-heading, .toolbar, .footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.text-button {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 700;
  padding: 6px;
}
.field { display: grid; gap: 7px; margin-top: 18px; }
.field > span, legend, .sort-control > span { font-size: 12px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
input, select {
  width: 100%;
  border: 1px solid #cfd5dd;
  background: var(--input-bg);
  border-radius: 10px;
  padding: 9px 10px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(169,0,50,.10); }
fieldset { margin: 20px 0 0; padding: 0; border: 0; }
legend { margin-bottom: 9px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice-list { display: grid; gap: 7px; }
.filter-choice {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: var(--input-bg);
}
.filter-choice:hover { border-color: #b9c0ca; }
.filter-choice input { width: auto; accent-color: var(--accent); margin: 0; }
.filter-choice small { color: var(--muted); margin-left: auto; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.results { min-width: 0; }
.toolbar { padding: 16px 18px; }
.sort-control { display: flex; align-items: center; gap: 10px; }
.sort-control select { min-width: 190px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; min-height: 16px; margin: 12px 2px; }
.filter-pill {
  border: 1px solid #e7b8c6;
  background: var(--soft-accent);
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}
.table-wrap { overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid #edf0f3; vertical-align: middle; }
th { position: sticky; top: 0; background: var(--table-head); color: #505967; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; z-index: 1; }
tbody tr:hover { background: var(--row-hover); }
.problem-name { font-weight: 800; letter-spacing: -.01em; }
.problem-meta { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.topic-badge, .hardness-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  border: 1px solid transparent;
}
.topic-A { background: #f3efff; color: #5b3da8; border-color: #ded4ff; }
.topic-C { background: #eaf8ff; color: #006f99; border-color: #cdeeff; }
.topic-G { background: #ecf8ee; color: #27763c; border-color: #d3edd9; }
.topic-N { background: #fff5df; color: #8a5c00; border-color: #f4dfae; }
.hardness-badge { background: #f1f3f5; color: #333b45; }
.hardness-badge[data-level="hard"] { background: #fff0ec; color: #9a3412; border-color: #fed6c7; }
.hardness-badge[data-level="brutal"] { background: #feecee; color: #9f1239; border-color: #fecdd3; }
.rating-label { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.links { display: flex; gap: 7px; flex-wrap: wrap; }
.mini-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  font-weight: 750;
  font-size: 12px;
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--input-bg);
}
.mini-link:hover { border-color: var(--accent); color: var(--accent-dark); }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.notes { margin-top: 20px; padding: 22px; }
.notes p:not(.eyebrow) { color: var(--muted); max-width: 830px; }
.reference-links { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.reference-links a { font-weight: 700; }
footer { border-top: 1px solid var(--border); background: var(--footer-bg); }
.footer-inner { padding: 22px 0; color: var(--muted); font-size: 13px; }
.footer-inner a { white-space: nowrap; }

.theme-toggle { cursor: pointer; }
.theme-toggle span:first-child { font-size: 17px; line-height: 1; }

.progress-summary { display: grid; gap: 9px; }
.progress-summary-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.progress-summary-head strong { font-size: 16px; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--border); }
.progress-track > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .25s ease; }

.secondary-action {
  width: 100%;
  margin-top: 18px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}
.secondary-action:hover { border-color: var(--accent); color: var(--accent-dark); }

.progress-select {
  min-width: 112px;
  width: auto;
  padding: 6px 28px 6px 9px;
  font-size: 12px;
  font-weight: 750;
  border-radius: 999px;
}
.progress-select[data-status="solved"] { border-color: #86d39a; background: #eefaf1; color: #17612b; }
.progress-select[data-status="attempted"] { border-color: #f0cf79; background: #fff8e5; color: #765100; }
html[data-theme="dark"] .progress-select[data-status="solved"] { border-color: #356b43; background: #183321; color: #9de2ae; }
html[data-theme="dark"] .progress-select[data-status="attempted"] { border-color: #725d27; background: #332b17; color: #f5d982; }

html[data-theme="dark"] .topic-A { background: #2b2340; color: #c9b8ff; border-color: #493c6a; }
html[data-theme="dark"] .topic-C { background: #132f3d; color: #8edcff; border-color: #255268; }
html[data-theme="dark"] .topic-G { background: #183322; color: #9fe2ae; border-color: #2d5b39; }
html[data-theme="dark"] .topic-N { background: #392e14; color: #f3d37d; border-color: #695526; }
html[data-theme="dark"] .hardness-badge { background: #282d36; color: #e1e5eb; }
html[data-theme="dark"] .hardness-badge[data-level="hard"] { background: #3a231c; color: #ffb495; border-color: #674033; }
html[data-theme="dark"] .hardness-badge[data-level="brutal"] { background: #3b1d26; color: #ff9db2; border-color: #6b3342; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 24px; }
  .hero-card { grid-template-columns: repeat(2, 1fr); }
  .main-grid { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
  .choice-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .choice-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 650px) {
  .shell { width: min(100% - 20px, 1180px); }
  .hero { padding: 38px 0; }
  .hero-card { grid-template-columns: 1fr; }
  .choice-grid, .choice-list { grid-template-columns: 1fr 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .sort-control { justify-content: space-between; }
  .sort-control select { min-width: 0; max-width: 65%; }
  th:nth-child(2), td:nth-child(2) { display: none; }
  th, td { padding: 12px 10px; }
  .links { flex-direction: column; align-items: flex-start; }
  .footer-inner { align-items: flex-start; flex-direction: column; }
}
