.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 clamp(14px, 3vw, 28px);
  background: rgba(11, 11, 18, 0.72);
  backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, transparent, rgba(139,92,246,0.35), rgba(236,72,153,0.3), transparent) 1;
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  color: #fff; background: var(--accent-grad); border-radius: 12px;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.45);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-4deg) scale(1.04); }
.brand-mark svg { width: 22px; height: 22px; }
.brand-name {
  font-size: 20px; font-weight: 750; letter-spacing: -0.02em;
  color: #db2777;
}

.search {
  position: relative;
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  min-width: 120px;
}
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--faint); pointer-events: none;
}
#search-input {
  width: 100%;
  height: 42px;
  padding: 0 40px 0 42px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, transform 0.2s var(--ease);
}
#search-input::-webkit-search-decoration,
#search-input::-webkit-search-cancel-button,
#search-input::-webkit-search-results-button,
#search-input::-webkit-search-results-decoration { display: none; }
#search-input::placeholder { color: var(--faint); }
#search-input:focus {
  border-color: var(--accent);
  background: var(--bg-elev);
  box-shadow: 0 0 0 4px var(--accent-soft);
  transform: translateY(-1px);
}
#search-input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--muted); line-height: 1;
  transition: background 0.18s, color 0.18s, transform 0.18s var(--ease);
}
.search-clear svg { width: 15px; height: 15px; }
.search-clear:hover { background: var(--accent); color: #fff; transform: translateY(-50%) rotate(90deg); }

.quick-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  overflow: hidden auto; max-height: min(68vh, 460px); z-index: 60; padding: 6px;
  animation: qDrop 0.18s var(--ease);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top center;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}
.quick-results.open { opacity: 1; transform: translateY(0) scale(1); }
.quick-results[hidden] { display: none; }
.quick-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius-sm); transition: background 0.15s, transform 0.15s var(--ease); }
.quick-item:hover, .quick-item.active { background: var(--surface-2); transform: translateX(2px); }
.quick-item img { width: 38px; height: 54px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: var(--surface-3); }
.quick-item .qi-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.quick-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 14px; }
/* Genre shortcuts inside the search dropdown (replaces the home "browse by genre") */
.quick-head { padding: 8px 8px 7px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); }
.quick-genres { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 8px 8px; }
.quick-genres .chip { padding: 6px 12px; font-size: 12.5px; }
/* No pointless lift here — just a colour change on hover. */
.quick-genres .chip:hover { transform: none; box-shadow: none; }

/* Clean nav (Crunchyroll-style): no container, active tab is an animated pill. */
.top-nav {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.top-nav a {
  position: relative; z-index: 0;
  padding: 8px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--muted);
  text-align: center; transition: color 0.25s var(--ease);
}
/* The gradient pill scales + fades in when a tab becomes active. */
.top-nav a::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 999px;
  background: linear-gradient(100deg, #7c3aed, #db2777);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
  opacity: 0; transform: scale(0.75);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.top-nav a:hover { color: var(--text); }
.top-nav a.active { color: #fff; }
.top-nav a.active:hover { color: #fff; }
.top-nav a.active::before { opacity: 1; transform: scale(1); }
.top-nav #auth-slot { margin-left: 8px; display: inline-flex; }
/* read2gether feature pill — stands out from the plain nav links */
.nav-r2g {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: 999px; font-weight: 650; font-size: 14px;
  color: #eadcff; background: var(--accent-soft); border: 1px solid var(--accent); cursor: pointer;
  transition: background 0.2s var(--ease);
}
.nav-r2g svg { width: 17px; height: 17px; }
.nav-r2g:hover { background: rgba(139, 92, 246, 0.24); }

