@font-face {
    font-family: 'Montserrat';
    src: url('/fonts/Montserrat-Variable.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/fonts/JetBrainsMono-Variable.woff2') format('woff2');
    font-weight: 100 800;
    font-display: swap;
}
:root {
  color-scheme: dark;

  /* --- Catppuccin Mocha --- */
  --bg: #1e1e2e;
  --bg-soft: #181825;
  --bg-card: #313244;
  --bg-hover: #313244;
  --line: #45475a;
  --line-soft: #313244;
  --text: #cdd6f4;
  --text-dim: #a6adc8;
  --text-faint: #9399b2;
  --accent: #89b4fa;
  --tier-ink: #11111b;

  --radius: 10px;
  --wrap: 980px;

  --tier-s: #f38ba8;
  --tier-a: #fab387;
  --tier-b: #f9e2af;
  --tier-c: #a6e3a1;
  --tier-d: #74c7ec;
  --tier-e: #cba6f7;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;

    /* --- Catppuccin Latte --- */
    --bg: #eff1f5;
    --bg-soft: #e6e9ef;
    --bg-card: #ffffff;
    --bg-hover: #e6e9ef;
    --line: #ccd0da;
    --line-soft: #dce0e8;
    --text: #4c4f69;
    --text-dim: #5c5f77;
    --text-faint: #676a80;
    --accent: #1a5fe0;
    --tier-ink: #ffffff;

    --tier-s: #c11238;
    --tier-a: #b25000;
    --tier-b: #856400;
    --tier-c: #2b7d1d;
    --tier-d: #0b7488;
    --tier-e: #7b2fd6;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  --nav-top: 66px;
  --scroll-offset: 128px;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .toolbar,
  .tier-nav {
    transition: none;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 'Montserrat', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  text-rendering: optimizeLegibility;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-head {
  padding: 34px 0 18px;
}

.crumbs {
  font-size: 13px;
  color: var(--text-faint);
  margin: 0 0 14px;
}

.crumbs a {
  color: var(--text-dim);
}

.site-head h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 4vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0;
  max-width: 62ch;
  color: var(--text-dim);
}

.rule {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-dim);
  font-size: 14px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 22px 0 14px;
  padding: 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 0.3s ease;
}

.toolbar.is-hidden {
  transform: translateY(-100%);
}

.field {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}

.field input {
  width: 100%;
  padding: 10px 34px 10px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.field input::placeholder {
  color: var(--text-faint);
}

.field .clear {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  color: var(--text-dim);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.field.has-value .clear {
  display: flex;
}

.field .clear:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.sorter {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  color: var(--text-dim);
}

.sorter select {
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sorter select:focus {
  outline: none;
  border-color: var(--accent);
}

.counter {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tier-nav {
  position: sticky;
  top: var(--nav-top, 66px);
  z-index: 25;
  display: flex;
  gap: 8px;
  margin: 0 0 22px;
  padding: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: top 0.3s ease;
}

.tier-nav::-webkit-scrollbar {
  display: none;
}

.tier-nav a {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex: 1 1 0;
  justify-content: center;
  padding: 8px 10px;
  color: var(--text-dim);
  border: 1px solid transparent;
  border-radius: 8px;
  white-space: nowrap;
  transition: color .12s ease, background .12s ease, border-color .12s ease;
}

.tier-nav a:hover {
  text-decoration: none;
  color: var(--text);
  background: var(--bg-hover);
}

.tier-nav a .key {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tier-nav a .label {
  font-size: 12px;
  color: var(--text-faint);
}

.tier-nav a .count {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.tier-nav a[data-tier="S"] .key { color: var(--tier-s); }
.tier-nav a[data-tier="A"] .key { color: var(--tier-a); }
.tier-nav a[data-tier="B"] .key { color: var(--tier-b); }
.tier-nav a[data-tier="C"] .key { color: var(--tier-c); }
.tier-nav a[data-tier="D"] .key { color: var(--tier-d); }
.tier-nav a[data-tier="E"] .key { color: var(--tier-e); }

.tier-nav a.is-active {
  color: var(--text);
  background: var(--bg-hover);
  border-color: var(--line);
}

.tier-nav a.is-hidden {
  display: none;
}

.tier-nav a.is-empty {
  opacity: .4;
}

.tier {
  margin: 0 0 34px;
  scroll-margin-top: var(--scroll-offset, 128px);
}

.tier-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.tier-head .key {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--tier-ink);
  border-radius: 8px;
}

.tier[data-tier="S"] .key { background: var(--tier-s); }
.tier[data-tier="A"] .key { background: var(--tier-a); }
.tier[data-tier="B"] .key { background: var(--tier-b); }
.tier[data-tier="C"] .key { background: var(--tier-c); }
.tier[data-tier="D"] .key { background: var(--tier-d); }
.tier[data-tier="E"] .key { background: var(--tier-e); }

.tier-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tier-head .count {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  padding: 11px 12px;
  border-radius: var(--radius);
  transition: background .12s ease;
}

.item + .item {
  border-top: 1px solid var(--line-soft);
}

.item:hover {
  background: var(--bg-hover);
}

.item h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.item .year {
  margin-left: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.item .meta {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

.item .note {
  margin: 5px 0 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-dim);
}

.links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  align-self: start;
  margin-top: 2px;
}

.links a {
  display: inline-block;
  padding: 3px 9px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

.links a:hover {
  color: var(--text);
  border-color: var(--text-faint);
  text-decoration: none;
}

.empty {
  display: none;
  margin: 30px 0;
  padding: 26px 20px;
  text-align: center;
  color: var(--text-dim);
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

body.is-empty .empty {
  display: block;
}

body.is-empty .tier {
  display: none;
}

.is-filtered {
  display: none !important;
}

.site-foot {
  margin: 40px 0 0;
  padding: 20px 0 40px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-faint);
}

.site-foot a {
  color: var(--text-dim);
}

noscript .noscript {
  display: block;
  margin: 30px 0;
  padding: 18px;
  color: var(--text-dim);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.hub {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 26px 0;
}

.hub a {
  display: block;
  padding: 20px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .14s ease, transform .14s ease;
}

.hub a:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
}

.hub strong {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}

.hub span {
  font-size: 14px;
  color: var(--text-dim);
}

@media (max-width: 640px) {
  .wrap {
    padding: 0 14px;
  }

  .toolbar {
    top: 0;
  }

  .tier-nav {
    gap: 4px;
  }

  .tier-nav a {
    flex: 0 0 auto;
    padding: 7px 9px;
  }

  .tier-nav a .label {
    display: none;
  }

  .counter {
    margin-left: 0;
    flex-basis: 100%;
  }

  .item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .links {
    margin-top: 0;
  }
}

@media print {
  .toolbar,
  .tier-nav,
  .links,
  .crumbs {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }

  .item + .item {
    border-top: 1px solid #ddd;
  }

  .tier {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
