/* Comfortaa (SIL Open Font License), self-hosted: the latin and cyrillic subsets of the variable font. */
@font-face {
  font-family: 'Comfortaa';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(/comfortaa-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Comfortaa';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(/comfortaa-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Science Hub's palette: sciencehub.site */
:root {
  --bg: #f8f8f9;
  --surface: #ffffff;
  --text: #303136;
  --heading: #101828;
  --subtle: #4b5060;
  --muted: #7c7f8a;
  --border: #f0f1f2;
  --line: #e1e2e5;
  --segment: #efeff2;
  --primary: #7d2cb0;
  --primary-hover: #6a2496;
  --primary-text: #7d2cb0;
  --primary-soft: #f5e9fa;
  --primary-ring: #b57bdb;
  --pattern: #7d2cb0;
  --pattern-opacity: .11;
  --overlay: rgba(16, 24, 40, .62);
  --shadow: 0 10px 15px -3px rgba(16, 24, 40, .08), 0 4px 6px -4px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101014;
    --surface: #18181d;
    --text: #e4e4e9;
    --heading: #f5f5f7;
    --subtle: #b9bbc4;
    --muted: #8d909b;
    --border: #25252c;
    --line: #34343c;
    --segment: #222228;
    --primary-text: #c79bea;
    --primary-soft: rgba(125, 44, 176, .24);
    --primary-ring: #8f45c4;
    --pattern: #b57bdb;
    --pattern-opacity: .07;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--text); font-family: 'Comfortaa', system-ui, sans-serif; font-size: 15px; line-height: 1.45; }
/* Faint line icons across the page, as on sciencehub.site; tinted through a mask so dark mode can recolour them. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--pattern);
  opacity: var(--pattern-opacity);
  -webkit-mask: url(/background.svg) 0 0 / 1400px 1000px repeat;
  mask: url(/background.svg) 0 0 / 1400px 1000px repeat;
}
a { color: var(--primary-text); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.i { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.button { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 10px 18px; background: var(--primary); color: #fff; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color .15s; }
.button:hover { background: var(--primary-hover); }
.button:disabled { opacity: .5; cursor: default; }
.button.soft { background: var(--primary-soft); color: var(--primary-text); }
.button.soft:hover { background: var(--primary-soft); filter: brightness(.97); }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.icon-button:hover { color: var(--text); }

.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--surface) 95%, transparent); backdrop-filter: blur(8px); box-shadow: 0 1px 3px rgba(16, 24, 40, .08); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar .button { border-radius: 8px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--heading); text-decoration: none; font-weight: 600; }
.brand img { display: block; height: 32px; width: auto; }

.page { max-width: 1280px; margin: 0 auto; padding: 0 24px 48px; }
.hero { text-align: center; padding: 52px 0 32px; }
.hero h1 { margin: 0; color: var(--heading); font-size: 48px; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; }
.hero p { margin: 10px 0 0; color: var(--subtle); font-size: 19px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.segmented { display: inline-flex; gap: 2px; padding: 4px; border-radius: 10px; background: var(--segment); }
.segmented button { border: 0; border-radius: 8px; padding: 8px 16px; background: transparent; color: var(--subtle); font: inherit; font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--primary-text); box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }
.n { margin-left: 5px; font-size: 11px; opacity: .65; }

.search { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: text; }
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 15px; }
.search input::placeholder { color: var(--muted); }
.search kbd { min-width: 22px; padding: 1px 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font: inherit; font-size: 12px; text-align: center; }
/* The shortcut hint only helps with a keyboard and an unfocused box. */
.search:focus-within kbd { display: none; }
@media (hover: none) { .search kbd { display: none; } }

.groups { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px 40px; margin-top: 18px; }
.group .label { margin-bottom: 7px; color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: border-color .15s; }
.chip:hover { border-color: var(--primary-ring); }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.none:not([aria-pressed="true"]) { opacity: .45; }

.summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 30px 0 14px; color: var(--muted); font-size: 14px; }
.sort { display: inline-flex; align-items: center; gap: 8px; }
.sort select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px; }
.card { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); transition: box-shadow .2s, border-color .2s; }
.card:hover { border-color: var(--primary-ring); box-shadow: var(--shadow); }
.card.dim { opacity: .5; }

.cover { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: var(--primary-soft); }
.cover .backdrop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(18px) saturate(1.2); transform: scale(1.25); opacity: .85; }
.cover .box { position: absolute; inset: 14px 14px 16px; width: calc(100% - 28px); height: calc(100% - 30px); object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .35)); }
.cover .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--primary-text); }
.cover .placeholder .i { width: 64px; height: 64px; stroke-width: 1.25; opacity: .5; }
.cover-top, .cover-bottom { position: absolute; left: 10px; right: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cover-top { top: 10px; justify-content: space-between; }
.cover-bottom { bottom: 10px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 6px; background: var(--overlay); color: #fff; font-size: 12px; font-weight: 500; backdrop-filter: blur(4px); }
.pill .i { width: 13px; height: 13px; }
.pill.rating { margin-left: auto; }
.owner { padding: 3px 10px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }

.card-body { display: flex; flex-direction: column; flex: 1; gap: 7px; padding: 16px 16px 14px; }
.title { margin: 0; color: var(--heading); font-size: 17px; line-height: 1.3; font-weight: 600; }
.sub { margin-top: -4px; color: var(--muted); font-size: 12.5px; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.meta .i { width: 14px; height: 14px; }
.badge { align-self: flex-start; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.best { background: var(--primary-soft); color: var(--primary-text); }
.badge.rec { background: var(--segment); color: var(--subtle); }
.badge.meh { border: 1px solid var(--line); color: var(--muted); }
.tags { overflow: hidden; color: var(--muted); font-size: 12.5px; white-space: nowrap; text-overflow: ellipsis; }
.desc { margin: 0; color: var(--subtle); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.desc.open { -webkit-line-clamp: unset; }
.expansions { display: none; margin: 0; padding-left: 18px; color: var(--subtle); font-size: 13px; }
.card.show-expansions .expansions { display: block; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; padding-top: 8px; font-size: 14px; }
.link { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link .i { width: 15px; height: 15px; }
.toggle-expansions { display: inline-flex; align-items: center; gap: 5px; border: 0; padding: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.toggle-expansions:hover, .card.show-expansions .toggle-expansions { color: var(--primary-text); }

.pick { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; overflow: hidden; margin-top: 28px; border: 2px solid var(--primary); border-radius: 16px; background: var(--surface); box-shadow: 0 20px 25px -5px rgba(125, 44, 176, .15); }
.pick .cover { aspect-ratio: auto; min-height: 230px; }
.pick .card-body { padding: 20px 24px; }
.pick .title { font-size: 26px; }
.pick-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--primary-text); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.pick-actions { display: flex; gap: 8px; }
.pick .desc { -webkit-line-clamp: 4; }

.empty { grid-column: 1 / -1; padding: 48px 16px; border: 1px dashed var(--line); border-radius: 16px; background: var(--surface); color: var(--muted); text-align: center; }

.footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 28px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px; color: var(--muted); font-size: 13px; }
.footer p { margin: 0; }
.footer .brand img { height: 28px; }

@media (max-width: 900px) {
  .groups { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar-inner, .page, .footer-inner { padding-left: 14px; padding-right: 14px; }
  .topbar .wide { display: none; }
  .topbar .button { padding: 10px; }
  .hero { padding: 32px 0 22px; }
  .hero h1 { font-size: 34px; }
  .hero p { font-size: 16px; }
  .toolbar .segmented, .toolbar #roll { width: 100%; }
  /* One swipeable row per filter group instead of several wrapped lines. */
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 0 14px 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .groups { gap: 12px; }
  .segmented button { flex: auto; padding: 8px 10px; font-size: 13px; }
  #roll { justify-content: center; }
  .pick { grid-template-columns: 1fr; }
  .pick .cover { min-height: 0; aspect-ratio: 3 / 2; }
  .pick .card-body { padding: 16px; }
  .pick .title { font-size: 21px; }
}
