:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #16203a;
  --muted: #5b6786;
  --border: #e3e7f0;
  --accent: #1f3a8a;
  --accent-2: #2f6fed;
  --accent-ink: #ffffff;
  --ring: #2f6fed;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1020;
    --surface: #141a2e;
    --text: #e7ebf5;
    --muted: #9aa6c4;
    --border: #232c47;
    --accent: #6d9bff;
    --accent-2: #6d9bff;
    --accent-ink: #0c1020;
    --ring: #6d9bff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

a { color: var(--accent-2); }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; text-decoration: none; color: var(--text); }
.brand span { color: var(--accent-2); }
.nav a { margin-left: 18px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .95rem; }
.nav a:hover { color: var(--text); }

/* Hero */
.hero { padding: 56px 0 28px; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 3rem); line-height: 1.1; letter-spacing: -.03em; margin: 0 0 .4em; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 60ch; margin: 0 0 1em; }
.meta-note { font-size: .85rem; color: var(--muted); margin: 0; }

/* Sections */
section { padding: 22px 0; }
.section-head { margin-bottom: 18px; }
.section-head h2 { font-size: 1.5rem; letter-spacing: -.02em; margin: 0 0 .2em; }
.hint { color: var(--muted); margin: 0; font-size: .95rem; }
.arrow-inline { color: var(--accent-2); font-weight: 700; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.chip:hover { color: var(--text); border-color: var(--accent-2); }
.chip.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* App grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent-2) 40%, var(--border)); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { font-size: 1.12rem; margin: 0; letter-spacing: -.01em; }
.card-title .title-link { color: inherit; text-decoration: none; }
.card-title .title-link:hover { text-decoration: underline; }
.card-sub { display: block; font-size: .82rem; font-weight: 500; color: var(--muted); }
.card-desc { color: var(--muted); font-size: .95rem; margin: 10px 0 14px; flex: 1; }

/* Upvote */
.upvote {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  line-height: 1;
  transition: all .15s ease;
  flex-shrink: 0;
}
.upvote:hover { border-color: var(--accent-2); color: var(--accent-2); }
.upvote.is-voted { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.upvote-arrow { font-size: .8rem; }

/* Tags */
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 14px; }
.tag {
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 999px;
}
.tag-cat { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 35%, var(--border)); }

.visit { font-weight: 700; text-decoration: none; font-size: .95rem; align-self: flex-start; }
.visit:hover { text-decoration: underline; }

/* Global search results (homepage only) – shown instead of the category grid
   while a search query is active; spans every language, not just English. */
.search-results { display: flex; flex-direction: column; gap: 10px; margin-bottom: 28px; }
.search-result {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.search-result-name { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1rem; }
.search-result-name:hover { text-decoration: underline; }
.search-result-lang {
  font-size: .75rem;
  font-weight: 600;
  color: var(--accent-2);
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--accent-2) 35%, var(--border));
  border-radius: 999px;
  padding: 2px 10px;
  text-decoration: none;
}
.search-result-lang:hover { background: color-mix(in srgb, var(--accent-2) 12%, var(--bg)); }
.search-result-desc { flex-basis: 100%; margin: 0; color: var(--muted); font-size: .9rem; }

/* Resource links */
.links { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.links a {
  display: block;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
  transition: border-color .15s ease, transform .15s ease;
}
.links a:hover { border-color: var(--accent-2); transform: translateY(-1px); }
.links strong { display: block; font-size: 1rem; }
.links span { color: var(--muted); font-size: .9rem; }

/* Nominate form */
.nominate { max-width: 520px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.optional { color: var(--muted); font-weight: 400; }
.field input, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent); }
.btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: filter .15s ease;
}
.btn:hover { filter: brightness(1.08); }
.form-msg { color: var(--accent-2); font-weight: 600; font-size: .9rem; margin: 12px 0 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 28px 0; color: var(--muted); font-size: .88rem; }
.site-footer p { margin: 0 0 6px; max-width: 70ch; }
.fine { font-size: .82rem; }

/* Focus visibility for keyboard users */
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }

@media (max-width: 560px) {
  .hero { padding: 36px 0 18px; }
  .nav a { margin-left: 14px; }
}

/* Search + category toolbar */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.toolbar { position: sticky; top: 59px; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(160%) blur(8px); padding: 12px 0; margin-bottom: 6px; }
.search { width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; margin-bottom: 12px; }
.search:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent); }

/* Category sections */
.cat[hidden] { display: none; }
.count-badge { display: inline-block; font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; vertical-align: middle; margin-left: 4px; }
.no-results { color: var(--muted); text-align: center; padding: 24px; font-size: 1.05rem; }

/* Vote button states */
.upvote[disabled] { opacity: .55; cursor: default; }
.upvote .count { min-width: 1ch; text-align: right; }

.form-msg.is-error { color: #d9544a; }

/* Language switcher – two fixed rows so every language stays visible (no hidden horizontal scroll) */
.langbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.langbar .wrap { padding: 8px 20px; }
.langbar-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.langbar-row + .langbar-row { margin-top: 4px; }
.langbar a { flex: 0 0 auto; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .85rem; padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
.langbar a:hover { color: var(--text); background: var(--bg); }
.langbar a.is-current { background: var(--accent); color: var(--accent-ink); }
.hero-endonym { font-size: .95rem; font-weight: 500; color: var(--muted); }
