body {
  font-family: monospace;
  font-size: 13px;
  /* iOS Safari ignores user-scalable=no for double-tap zoom (e.g. rapid taps
     on the a-/a+ buttons); "manipulation" drops that gesture but keeps panning. */
  touch-action: manipulation;
}
#controls {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 24px 32px 12px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid #ddd;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}
#bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
#sample-input,
#single-input {
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
  border-bottom: 1px dotted currentColor;
  padding: 2px 0;
  flex: 1;
  max-width: 480px;
}
#filters-toggle {
  font: inherit;
  font-size: 20px;
  line-height: 1;
  color: #888;
  background: transparent;
  border: none;
  /* Generous tap target; negative margins cancel it out of the layout so the
     bar stays input-height and the glyph hugs the content's right edge. */
  padding: 8px 10px;
  margin: -8px -10px;
  cursor: pointer;
  transition: color 0.2s ease;
}
#filters-toggle:hover,
#filters-toggle.active {
  color: #000;
}
#sample-input::placeholder,
#single-input::placeholder {
  color: #888;
}
#filters {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  color: #888;
  letter-spacing: 0.05em;
}
#filters .group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
#filters button {
  font: inherit;
  letter-spacing: inherit;
  color: #888;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s ease;
}
#filters button:hover,
#filters button.active {
  color: #000;
}
#filters .sep,
#filters .dot {
  user-select: none;
}
/* Collapsed filters vanish entirely; the toggle lives on the input line so
   the header shrinks to a single row, with the trailing space tightened up. */
#filters.collapsed {
  display: none;
}
#controls.collapsed {
  padding-bottom: 6px;
}
#controls.collapsed #bar {
  margin-bottom: 0;
}
#list {
  padding: 8px 32px 16px;
  --sample-size: 34px;
}
.card {
  padding: 18px 0 14px;
  border-bottom: 1px solid #eee;
  transition: border-color 0.2s ease;
}
.card .sample {
  /* Shrink-wrap the text so only the word itself is a click target — a plain
     block div would catch clicks across the whole row. */
  width: fit-content;
  max-width: 100%;
  font-size: var(--sample-size);
  line-height: 1.3;
  overflow-wrap: break-word;
  opacity: 0.15;
  transition: opacity 0.25s ease;
  cursor: pointer;
}
.card.loaded .sample {
  opacity: 1;
}
.card .info {
  margin-top: 6px;
  color: #888;
  letter-spacing: 0.05em;
}
.info a {
  color: inherit;
  text-decoration: none;
}
.info a:hover {
  color: #000;
  text-decoration: underline;
}
/* Minimal mode: metadata hidden, samples tiled side by side to compare. */
#list.minimal {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 28px;
}
#list.minimal .card {
  border-bottom: none;
  padding: 0;
  /* Flex items default to min-width auto, so a long font name would push a
     tile past the viewport — which makes iOS Safari zoom the page out. Cap
     tiles at the row width so the sample's break-word can kick in instead. */
  min-width: 0;
  max-width: 100%;
}
#list.minimal .card .info {
  display: none;
}
#sentinel {
  height: 1px;
}
/* Single font view: a fixed overlay, so the list underneath keeps its exact
   scroll position and state for when it's dismissed. */
#single {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}
#single[hidden] {
  display: none;
}
#single-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 32px 12px;
  border-bottom: 1px solid #ddd;
  color: #888;
  letter-spacing: 0.05em;
}
#single-info {
  flex: 1;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
#single-input {
  /* Shares #sample-input's look; uncap the width so it fills the bar and the
     close button stays pinned right. The bar's #888 is placeholder-only —
     typed text gets the body color back. */
  max-width: none;
  color: #000;
}
#single-info::-webkit-scrollbar {
  display: none;
}
#single-close {
  font: inherit;
  font-size: 20px;
  line-height: 1;
  color: #888;
  background: transparent;
  border: none;
  padding: 8px 10px;
  margin: -8px -10px;
  cursor: pointer;
  transition: color 0.2s ease;
}
#single-close:hover {
  color: #000;
}
#single-tiles {
  flex: 1;
  overflow-y: auto;
  padding: 16px 32px;
  line-height: 1.3;
  overflow-wrap: break-word;
}
body.dark #controls {
  background: rgba(17, 17, 17, 0.95);
  border-bottom-color: #333;
}
body.dark #filters button:hover,
body.dark #filters button.active,
body.dark #filters-toggle:hover,
body.dark #filters-toggle.active {
  color: #fff;
}
body.dark .card {
  border-bottom-color: #2a2a2a;
}
body.dark .info a:hover {
  color: #fff;
}
body.dark #single {
  background: #111111;
}
body.dark #single-top {
  border-bottom-color: #333;
}
body.dark #single-close:hover {
  color: #fff;
}
body.dark #single-input {
  color: #fff;
}
@media (prefers-color-scheme: dark) {
  body:not(.light) #controls {
    background: rgba(17, 17, 17, 0.95);
    border-bottom-color: #333;
  }
  body:not(.light) #filters button:hover,
  body:not(.light) #filters button.active,
  body:not(.light) #filters-toggle:hover,
  body:not(.light) #filters-toggle.active {
    color: #fff;
  }
  body:not(.light) .card {
    border-bottom-color: #2a2a2a;
  }
  body:not(.light) .info a:hover {
    color: #fff;
  }
  body:not(.light) #single {
    background: #111111;
  }
  body:not(.light) #single-top {
    border-bottom-color: #333;
  }
  body:not(.light) #single-close:hover {
    color: #fff;
  }
  body:not(.light) #single-input {
    color: #fff;
  }
}
@media (max-width: 640px) {
  #controls {
    padding: 20px 20px 10px;
  }
  /* One horizontally scrollable line, bleeding to the viewport edges so
     entries aren't clipped mid-padding while scrolling. */
  #filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -20px;
    padding: 0 20px;
  }
  #filters::-webkit-scrollbar {
    display: none;
  }
  #filters .group {
    flex-wrap: nowrap;
  }
  #filters button,
  #filters .sep,
  #filters .dot,
  #count {
    white-space: nowrap;
    flex-shrink: 0;
  }
  #list {
    padding: 4px 20px 12px;
  }
  #list {
    --sample-size: 26px;
  }
  /* Keep each card's metadata on one line, scrollable if it overflows. */
  .card .info {
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .card .info::-webkit-scrollbar {
    display: none;
  }
  #single-top {
    padding: 16px 20px 10px;
  }
  #single-tiles {
    padding: 12px 20px;
  }
}
