:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #dde1e7;
  --text: #16202c;
  --text-muted: #5b6676;
  --accent: #c2410c;
  --accent-strong: #9a3412;
  --accent-soft: #fdeee6;
  --header-bg: #16202c;
  --header-text: #f5f6f8;
  --header-muted: #a7b0bd;
  --shadow: 0 1px 2px rgba(22, 32, 44, 0.06), 0 4px 12px rgba(22, 32, 44, 0.05);
  --shadow-hover: 0 2px 4px rgba(22, 32, 44, 0.08), 0 10px 24px rgba(22, 32, 44, 0.1);
  --radius: 10px;
  --max: 1200px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151c;
    --surface: #18212b;
    --surface-2: #212c38;
    --border: #2b3744;
    --text: #e8ecf1;
    --text-muted: #98a3b1;
    --accent: #f97316;
    --accent-strong: #fb923c;
    --accent-soft: #2e1d12;
    --header-bg: #0a0f14;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

/* ---------- Header ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  color: var(--header-text);
}

.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 19px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 12px;
  color: var(--header-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.search {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 520px;
  margin-left: auto;
}

.search input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 40px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: var(--header-text);
  font: inherit;
  outline: none;
  transition: background 0.15s, border-color 0.15s;
}

.search input::placeholder {
  color: var(--header-muted);
}

.search input:focus {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--accent);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--header-muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.search-hint {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font: 12px/1 inherit;
  padding: 3px 7px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--header-muted);
}

.catnav {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.catnav-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.catnav-inner::-webkit-scrollbar {
  display: none;
}

.catnav button {
  flex-shrink: 0;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--header-muted);
  font: inherit;
  font-size: 14px;
  padding: 11px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.catnav button:hover {
  color: var(--header-text);
}

.catnav button[aria-current="true"] {
  color: var(--header-text);
  border-bottom-color: var(--accent);
}

/* ---------- Layout ---------- */

.main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px 48px;
}

.hero {
  padding: 40px 0 8px;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 30px;
  letter-spacing: -0.01em;
}

.hero p {
  margin: 0;
  color: var(--text-muted);
  font-size: 16px;
}

.section {
  margin-top: 36px;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
}

.count {
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Category tiles ---------- */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.cat-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  text-align: left;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}

.cat-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.cat-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
}

.cat-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cat-name {
  display: block;
  margin: 0 0 3px;
  font-weight: 600;
  font-size: 16px;
}

.cat-desc {
  display: block;
  color: var(--text-muted);
  font-size: 13.5px;
}

.cat-card .cat-count {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-strong);
}

/* ---------- App tiles ---------- */

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.app-card-wrap {
  position: relative;
  display: flex;
}

.app-card {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}

.app-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.app-card:focus-visible,
.cat-card:focus-visible,
.catnav button:focus-visible,
.fav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding-right: 28px;
}

.app-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.app-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.app-card p {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 13.5px;
  flex: 1;
}

.app-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.app-meta .open {
  margin-left: auto;
  color: var(--accent-strong);
  font-weight: 600;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
}

.fav-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-muted);
}

.fav-btn:hover {
  background: var(--surface-2);
}

.fav-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.fav-btn[aria-pressed="true"] {
  color: var(--accent);
}

.fav-btn[aria-pressed="true"] svg {
  fill: currentColor;
}

.empty {
  color: var(--text-muted);
  padding: 24px 0;
}

.footer {
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 16px 28px;
}

.footer p {
  margin: 0;
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  .topbar-inner {
    padding: 12px 16px;
    gap: 12px;
  }
  .brand-text {
    display: none;
  }
  .search-hint {
    display: none;
  }
  .catnav-inner,
  .main {
    padding-left: 16px;
    padding-right: 16px;
  }
  .hero {
    padding-top: 28px;
  }
  .hero h1 {
    font-size: 24px;
  }
  .cat-grid,
  .app-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
