:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-soft: #eff6ff;
  --item: #f5f7fa;
  --shadow: 0 2px 12px rgba(0,0,0,.05);
  --shadow-hover: 0 8px 24px rgba(0,0,0,.08);
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --panel: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --line: #1f2937;
  --brand: #60a5fa;
  --brand-soft: #1e293b;
  --item: #1f2937;
  --shadow: 0 2px 12px rgba(0,0,0,.35);
  --shadow-hover: 0 8px 24px rgba(0,0,0,.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--brand); }

.top-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 0;
}
.top-bar button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  height: 34px;
  padding: 0 12px;
  cursor: pointer;
  font-size: 13px;
}

.site-hero {
  text-align: center;
  padding: 48px 20px 24px;
}
.site-hero h1 {
  font-weight: 700;
  letter-spacing: .02em;
}

.search-wrap {
  max-width: 520px;
  margin: 0 auto 28px;
  padding: 0 20px;
}
.search-wrap input {
  width: 100%;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 0 18px;
  font-size: 15px;
  outline: none;
}
.search-wrap input:focus { border-color: var(--brand); }

.gate-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 24px 18vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% 38%, rgba(37, 99, 235, 0.07), transparent 70%),
    var(--bg);
}
html[data-theme="dark"] .gate-page {
  background:
    radial-gradient(ellipse 80% 50% at 50% 38%, rgba(96, 165, 250, 0.12), transparent 70%),
    var(--bg);
}
.gate-form {
  width: 100%;
  max-width: 480px;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
}
.gate-form input[type="search"] {
  width: 100%;
  height: 54px;
  border-radius: 999px;
  border: 2px solid #93c5fd;
  background: #fff;
  color: var(--text);
  padding: 0 22px;
  font-size: 17px;
  outline: none;
  box-shadow: 0 8px 28px rgba(37, 99, 235, 0.12);
  transition: border-color .15s ease, box-shadow .15s ease;
}
html[data-theme="dark"] .gate-form input[type="search"] {
  background: var(--panel);
  border-color: #3b82f6;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.gate-form input[type="search"]::placeholder {
  color: #94a3b8;
}
.gate-form input[type="search"]:focus {
  border-color: var(--brand);
  box-shadow: 0 10px 32px rgba(37, 99, 235, 0.22);
}
.gate-submit {
  display: block;
  width: 140px;
  height: 44px;
  margin: 0 auto;
  border: none;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28);
  transition: background .15s ease, transform .15s ease;
}
.gate-submit:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}
.gate-submit:active { transform: translateY(0); }
.gate-error {
  margin: 0;
  text-align: center;
  color: #dc2626;
  font-size: 13px;
}
html[data-theme="dark"] .gate-error { color: #f87171; }

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

.category-wrap { margin-bottom: 28px; }
.category-wrap > h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 14px;
}

.block-card {
  position: relative;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 22px;
  margin-bottom: 18px;
  overflow: visible;
  transition: box-shadow .25s ease;
}
.block-card:hover {
  box-shadow: var(--shadow-hover);
}
/* keep open submenu above the next columns/cards */
.block-card:has(.nav-item.open),
.block-card:has(.nav-item:hover) {
  z-index: 30;
}

.block-title {
  font-size: 15px;
  font-weight: 600;
  border-left: 4px solid var(--brand);
  padding-left: 10px;
  margin-bottom: 16px;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  overflow: visible;
}

.nav-item {
  position: relative;
  z-index: 1;
  background: var(--item);
  border-radius: 8px;
  text-align: center;
  padding: 12px 8px;
  cursor: pointer;
  transition: background .2s ease;
  border: 1px solid transparent;
}
.nav-item:hover, .nav-item.open {
  z-index: 40;
  background: var(--brand-soft);
  border-color: rgba(37,99,235,.15);
}
.nav-item .label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  min-height: 22px;
}
.badge {
  display: inline-block;
  font-size: 10px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  color: #fff;
  vertical-align: middle;
}
/* colors also set inline from badge_catalog(); keep fallbacks */
.badge-hot { background: #ef4444; }
.badge-new { background: #10b981; }
.badge-rec { background: #f59e0b; }

.sub-nav {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: auto;
  z-index: 50;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-hover);
  border-radius: 8px;
  padding: 6px;
  display: none;
  text-align: left;
  min-width: 160px;
  max-width: min(280px, 80vw);
  max-height: min(70vh, 420px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-item:hover .sub-nav,
.nav-item.open .sub-nav { display: block; }
.sub-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.sub-nav a:hover { background: var(--brand-soft); color: var(--brand); }

.empty-state, .no-result {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
}
.hidden-by-search { display: none !important; }

@media (max-width: 992px) {
  .nav-grid { grid-template-columns: repeat(4, 1fr); }
  .site-hero { padding-top: 32px; }
}
@media (max-width: 768px) {
  .nav-grid { grid-template-columns: repeat(2, 1fr); }
  .block-card { padding: 16px; }
  .nav-item:hover .sub-nav { display: none; }
  .nav-item.open .sub-nav { display: block; }
}
