:root {
  --ink: #191919;
  --muted: #6b6b6b;
  --faint: #9a9a9a;
  --line: #ebebeb;
  --chip: #f3f3f3;
  --chip-hover: #e9e9e9;
  --bg: #ffffff;
  --accent: #191919;       /* focus rings */
  --key: #e8f27a;          /* brand lime: logo, Free badge, main button */
  --placeholder: #f4f4f2;
  --radius: 12px;
  --gap: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
/* Three columns: logo | search (centered) | Saved. The side columns share the leftover space equally. */
.topbar-inner { display: grid; grid-template-columns: 1fr minmax(0, 560px) 1fr; align-items: center; gap: 20px; height: 64px; }
.topbar-inner .brand { justify-self: start; }
.topbar-inner .saved-btn { justify-self: end; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.25rem; letter-spacing: -.5px; text-decoration: none; white-space: nowrap; color: var(--ink); }
.brand img { width: 34px; height: 34px; flex: none; }
.wordmark span { font-weight: 500; }
.wordmark b { font-weight: 800; }
.search { width: 100%; display: flex; align-items: center; gap: 8px;
  background: var(--chip); border-radius: 999px; padding: 0 16px; height: 42px; color: var(--muted); }
.search input { flex: 1; border: 0; background: transparent; font: inherit; color: var(--ink); outline: none; min-width: 0; height: 100%; }
.search:focus-within { box-shadow: 0 0 0 2px var(--ink) inset; }
.saved-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--chip); border-radius: 999px; height: 42px; padding: 0 16px; font-weight: 600; cursor: pointer; }
.saved-btn:hover { background: var(--chip-hover); }
.saved-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.saved-btn .count { font-size: .8rem; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--key); color: var(--ink); text-align: center; }

/* Category rail */
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 20px 0 8px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 84px; padding: 4px 0;
  border: 0; background: none; cursor: pointer; font-size: .8rem; font-weight: 500; color: var(--ink); white-space: nowrap; }
.cat .ico { width: 64px; height: 64px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; color: var(--ink); transition: transform .15s, background .15s; }
.cat .ico svg { width: 24px; height: 24px; }
.cat:hover .ico { transform: translateY(-2px); background: var(--chip-hover); }
.cat[aria-pressed="true"] .ico { background: var(--ink); color: #fff; }
.cat[aria-pressed="true"] { font-weight: 700; }

/* Filter pills */
.pills { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 0 8px; }
.pill { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 999px; border: 0;
  background: var(--chip); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; font-size: .88rem; cursor: pointer; }
.pill:hover { background: var(--chip-hover); }
.pill[aria-pressed="true"], .pill.on { background: var(--ink); color: #fff; box-shadow: none; }
.pill.select { position: relative; padding: 0; }
.pill.select select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; font: inherit; color: inherit;
  height: 100%; padding: 0 32px 0 14px; cursor: pointer; outline: none; }
.pill.select::after { content: ""; position: absolute; right: 13px; top: 50%; width: 6px; height: 6px; margin-top: -5px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); pointer-events: none; }
.pill.select:has(select:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Carousel rows */
.row { margin: 28px 0 8px; }
.row-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.row-head h2 { font-size: 1.4rem; font-weight: 800; letter-spacing: -.4px; margin: 0; }
.row-head .sub { color: var(--muted); font-size: .9rem; }
.row-head .actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.link { border: 0; background: none; font-weight: 700; font-size: .9rem; cursor: pointer; padding: 6px 4px; white-space: nowrap; }
.link:hover { text-decoration: underline; }
.arrow { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--chip); display: grid; place-items: center; cursor: pointer; }
.arrow:hover { background: var(--chip-hover); }
.arrow:disabled { opacity: .35; cursor: default; }
.arrow svg { width: 16px; height: 16px; }
.track { display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 2 * var(--gap)) / 3); gap: var(--gap);
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none; padding-bottom: 4px; }
.track::-webkit-scrollbar { display: none; }
.track > .card { scroll-snap-align: start; }

/* Cards */
.card { min-width: 0; position: relative; }
.media { display: block; position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: var(--placeholder); }
.media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.card:hover .media img { transform: scale(1.03); }
.media .ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; }
.media img + .ph { display: none; }
.media::after { content: ""; position: absolute; inset: 0; border: 1px solid var(--line); border-radius: inherit; pointer-events: none; }
.badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.badge { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #fff; color: var(--ink); }
.badge.free { background: var(--key); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.badge.new { background: var(--ink); color: #fff; }
.info { padding: 10px 2px 0; }
.title-row { display: flex; align-items: flex-start; gap: 4px; }
.title-row h3 { margin-right: 4px; }
.card h3 { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.3; flex: 1; min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card h3 a { text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.icon-btn { flex: none; width: 26px; height: 26px; margin: -2px -4px 0 0; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: var(--chip); }
.icon-btn[aria-pressed="true"] svg { fill: var(--ink); }
.meta { margin: 3px 0 0; color: var(--muted); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta.when { font-weight: 600; }

/* List view */
.list-head { display: flex; align-items: baseline; gap: 14px; margin-top: 28px; }
.list-head h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -.5px; margin: 0; line-height: 1.2; }
.summary { color: var(--muted); margin: 4px 0 0; }
#results { margin-top: 20px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px var(--gap); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .ico { font-size: 40px; }
.empty .ico.heart, .empty .ico.line { display: flex; justify-content: center; color: var(--ink); }
.empty .ico.heart svg { width: 48px; height: 48px; fill: currentColor; }
.empty .ico.line svg { width: 48px; height: 48px; stroke-width: 1.5; }
.more { text-align: center; margin: 32px 0; }
.more button, .empty button { height: 44px; padding: 0 24px; border-radius: 999px; border: 0; background: var(--key); color: var(--ink); font-weight: 700; font-size: .88rem; cursor: pointer; }
.more button:hover, .empty button:hover { filter: brightness(.96); }

.foot { color: var(--muted); font-size: 13px; line-height: 1.45; padding-top: 24px; padding-bottom: 48px; border-top: 1px solid var(--line); margin-top: 48px; }
.foot-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
.foot h2 { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0 0 10px; }
.foot p { margin: 0; }
.foot-meta { margin-top: 24px; display: grid; gap: 4px; }
#updated { font-style: italic; }
.foot a { color: var(--ink); }

@media (max-width: 900px) {
  .track { grid-auto-columns: calc((100% - var(--gap)) / 2); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.region, .tabbar { display: none; }
@media (max-width: 900px) { .foot-cols { grid-template-columns: 1fr; gap: 20px; } }

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  :root { --gap: 12px; --pad: 16px; }
  body { font-size: 15px; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .wrap { padding: 0 var(--pad); }

  /* Header: logo row scrolls away, search stays pinned */
  .topbar { top: -40px; border-bottom: 0; box-shadow: 0 1px 0 var(--line); }
  .topbar-inner { display: flex; flex-wrap: wrap; height: auto; gap: 0; padding-top: 6px; padding-bottom: 10px; }
  .brand { height: 42px; gap: 7px; font-size: 1.15rem; }
  .brand img { width: 30px; height: 30px; }
  .search { order: 3; flex-basis: 100%; height: 44px; font-size: 16px; }
  .search input { font-size: 16px; } /* 16px stops iOS from zooming in on focus */
  .saved-btn { display: none; }

  /* Edge-to-edge horizontal scrollers */
  .cats, .pills, .track { margin-left: calc(-1 * var(--pad)); margin-right: calc(-1 * var(--pad));
    padding-left: var(--pad); padding-right: var(--pad); scroll-padding-left: var(--pad); }
  .cats { gap: 2px; padding-top: 14px; padding-bottom: 4px; }
  .cat { width: 66px; font-size: .74rem; gap: 5px; }
  .cat .ico { width: 52px; height: 52px; }
  .cat .ico svg { width: 20px; height: 20px; }
  .pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-top: 10px; padding-bottom: 6px; gap: 6px; }
  .pills::-webkit-scrollbar { display: none; }
  .pill { flex: none; height: 34px; font-size: .84rem; }

  /* Home rows */
  .row { margin: 22px 0 4px; }
  .row-head { margin-bottom: 10px; }
  .row-head h2 { font-size: 1.15rem; letter-spacing: -.3px; }
  .row-head .sub, .row-head .arrow { display: none; }
  .link { font-size: .85rem; color: var(--muted); }
  .track { grid-auto-columns: 78%; }
  .card h3 { font-size: .98rem; }
  .icon-btn { width: 34px; height: 34px; margin: -6px -6px 0 -4px; }
  .meta { font-size: .84rem; }

  /* List view: compact rows with a thumbnail */
  .list-head { margin-top: 18px; flex-wrap: wrap; row-gap: 0; }
  .list-head h1 { font-size: 1.35rem; }
  .list-head .link { margin-left: auto; }
  #results { margin-top: 12px; }
  .grid { grid-template-columns: 1fr; gap: 0; }
  .grid .card { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px; align-items: start;
    padding: 12px 0; border-bottom: 1px solid var(--line); }
  .grid .media { aspect-ratio: 1; border-radius: 10px; }
  .grid .media .ph { font-size: 32px; }
  .grid .badges { top: 6px; left: 6px; }
  .grid .badge { font-size: .65rem; padding: 2px 7px; }
  .grid .info { padding: 0; }
  .grid .card h3 { font-size: .95rem; }
  .more { margin: 20px 0; }
  .more button { width: 100%; }

  .foot { margin-top: 28px; padding-top: 16px; }

  /* Bottom tab bar */
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255,255,255,.97);
    backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar button { flex: 1; height: 58px; border: 0; background: none; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; font-size: .7rem; font-weight: 600; color: var(--faint); cursor: pointer; position: relative; }
  .tabbar button svg { width: 22px; height: 22px; }
  .tabbar button[aria-current="page"] { color: var(--ink); }
  .tabbar button[aria-current="page"][data-tab="saved"] svg { fill: var(--ink); }
  .tabbar .dot { position: absolute; top: 7px; left: 50%; margin-left: 6px; min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px; background: var(--ink); color: #fff; font-size: .62rem; line-height: 16px; text-align: center; }
}
